revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / AHI / Device / devsupp.c
blob6b098fd87e4497895549a1a103cdced2eb51831a
1 /*
2 AHI - Hardware independent audio subsystem
3 Copyright (C) 1996-2005 Martin Blom <martin@blom.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge,
18 MA 02139, USA.
21 // Not the best routines (fraction does not get saved between calls,
22 // loads of byte writes, no interpolation etc), but who cares?
24 #include <config.h>
26 #include "ahi_def.h"
27 #include "devsupp.h"
30 * size Number of SAMPLES to fill. (Max 131071)
31 * add Add interger.fraction in samples (2×16 bit)
32 * src Source (AHIST_S16S)
33 * offset Pointer to Source Offset in bytes (will be updated)
34 * dest Pointer to Destination (will be updated)
37 struct sample
39 WORD left;
40 WORD right;
43 void
44 RecM8S( ULONG size,
45 ULONG add,
46 APTR src,
47 ULONG* offset,
48 void** dest )
50 Fixed64 offs = 0;
51 Fixed64 step = ((Fixed64) add) << 16;
52 struct sample* from = (struct sample*) (src + *offset);
53 BYTE* to = *dest;
54 ULONG i;
56 for( i = 0; i < size; ++i )
58 *to++ = from[ offs >> 32 ].left >> 8;
60 offs += step;
63 *offset += ( offs >> 32 ) * sizeof( struct sample* );
64 *dest = to;
67 void
68 RecS8S( ULONG size,
69 ULONG add,
70 APTR src,
71 ULONG* offset,
72 void** dest )
74 Fixed64 offs = 0;
75 Fixed64 step = ((Fixed64) add) << 16;
76 struct sample* from = (struct sample*) (src + *offset);
77 BYTE* to = *dest;
78 ULONG i;
80 for( i = 0; i < size; ++i )
82 *to++ = from[ offs >> 32 ].left >> 8;
83 *to++ = from[ offs >> 32 ].right >> 8;
85 offs += step;
88 *offset += ( offs >> 32 ) * sizeof( struct sample* );
89 *dest = to;
92 void
93 RecM16S( ULONG size,
94 ULONG add,
95 APTR src,
96 ULONG* offset,
97 void** dest )
99 Fixed64 offs = 0;
100 Fixed64 step = ((Fixed64) add) << 16;
101 struct sample* from = (struct sample*) (src + *offset);
102 WORD* to = *dest;
103 ULONG i;
105 for( i = 0; i < size; ++i )
107 *to++ = from[ offs >> 32 ].left;
109 offs += step;
112 *offset += ( offs >> 32 ) * sizeof( struct sample* );
113 *dest = to;
116 void
117 RecS16S( ULONG size,
118 ULONG add,
119 APTR src,
120 ULONG* offset,
121 void** dest )
123 Fixed64 offs = 0;
124 Fixed64 step = ((Fixed64) add) << 16;
125 struct sample* from = (struct sample*) (src + *offset);
126 WORD* to = *dest;
127 ULONG i;
129 for( i = 0; i < size; ++i )
131 *to++ = from[ offs >> 32 ].left;
132 *to++ = from[ offs >> 32 ].right;
134 offs += step;
137 *offset += ( offs >> 32 ) * sizeof( struct sample* );
138 *dest = to;
141 void
142 RecM32S( ULONG size,
143 ULONG add,
144 APTR src,
145 ULONG* offset,
146 void** dest )
148 Fixed64 offs = 0;
149 Fixed64 step = ((Fixed64) add) << 16;
150 struct sample* from = (struct sample*) (src + *offset);
151 LONG* to = *dest;
152 ULONG i;
154 for( i = 0; i < size; ++i )
156 *to++ = from[ offs >> 32 ].left << 16;
158 offs += step;
161 *offset += ( offs >> 32 ) * sizeof( struct sample* );
162 *dest = to;
165 void
166 RecS32S( ULONG size,
167 ULONG add,
168 APTR src,
169 ULONG* offset,
170 void** dest )
172 Fixed64 offs = 0;
173 Fixed64 step = ((Fixed64) add) << 16;
174 struct sample* from = (struct sample*) (src + *offset);
175 LONG* to = *dest;
176 ULONG i;
178 for( i = 0; i < size; ++i )
180 *to++ = from[ offs >> 32 ].left << 16;
181 *to++ = from[ offs >> 32 ].right << 16;
183 offs += step;
186 *offset += ( offs >> 32 ) * sizeof( struct sample* );
187 *dest = to;