Lines 21-26
Link Here
|
21 |
#ifndef __CSound_defs_H__ |
21 |
#ifndef __CSound_defs_H__ |
22 |
#define __CSound_defs_H__ |
22 |
#define __CSound_defs_H__ |
23 |
|
23 |
|
|
|
24 |
#ifndef GCC_VERSION |
25 |
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) |
26 |
#endif |
27 |
|
28 |
#if GCC_VERSION >= 403 |
29 |
# define STATIC |
30 |
#else |
31 |
# define STATIC static |
32 |
#endif |
33 |
|
24 |
#include "../../config/common.h" |
34 |
#include "../../config/common.h" |
25 |
|
35 |
|
26 |
class CSound; |
36 |
class CSound; |
Lines 161-170
Link Here
|
161 |
|
171 |
|
162 |
// int8_t -> ... |
172 |
// int8_t -> ... |
163 |
// int8_t -> int8_t |
173 |
// int8_t -> int8_t |
164 |
template<> static inline const int8_t convert_sample<int8_t,int8_t>(const register int8_t sample) { return sample; } |
174 |
template<> STATIC inline const int8_t convert_sample<int8_t,int8_t>(const register int8_t sample) { return sample; } |
165 |
|
175 |
|
166 |
// int8_t -> int16_t |
176 |
// int8_t -> int16_t |
167 |
template<> static inline const int16_t convert_sample<int8_t,int16_t>(const register int8_t sample) { return sample*256; } |
177 |
template<> STATIC inline const int16_t convert_sample<int8_t,int16_t>(const register int8_t sample) { return sample*256; } |
168 |
|
178 |
|
169 |
// int8_t -> int24_t |
179 |
// int8_t -> int24_t |
170 |
//template<> static inline const int24_t convert_sample<int8_t,int24_t>(const register int8_t sample) { } |
180 |
//template<> static inline const int24_t convert_sample<int8_t,int24_t>(const register int8_t sample) { } |
Lines 173-179
Link Here
|
173 |
//template<> static inline const int32_t convert_sample<int8_t,int32_t>(const register int8_t sample) { } |
183 |
//template<> static inline const int32_t convert_sample<int8_t,int32_t>(const register int8_t sample) { } |
174 |
|
184 |
|
175 |
// int8_t -> float |
185 |
// int8_t -> float |
176 |
template<> static inline const float convert_sample<int8_t,float>(const register int8_t sample) { return ((float)sample)/127.0f; } |
186 |
template<> STATIC inline const float convert_sample<int8_t,float>(const register int8_t sample) { return ((float)sample)/127.0f; } |
177 |
|
187 |
|
178 |
// int8_t -> double |
188 |
// int8_t -> double |
179 |
//template<> static inline const double convert_sample<int8_t,double>(const register int8_t sample) { } |
189 |
//template<> static inline const double convert_sample<int8_t,double>(const register int8_t sample) { } |
Lines 181-202
Link Here
|
181 |
|
191 |
|
182 |
// int16_t -> ... |
192 |
// int16_t -> ... |
183 |
// int16_t -> int8_t |
193 |
// int16_t -> int8_t |
184 |
template<> static inline const int8_t convert_sample<int16_t,int8_t>(const register int16_t sample) { return sample/256; } |
194 |
template<> STATIC inline const int8_t convert_sample<int16_t,int8_t>(const register int16_t sample) { return sample/256; } |
185 |
|
195 |
|
186 |
// int16_t -> int16_t |
196 |
// int16_t -> int16_t |
187 |
template<> static inline const int16_t convert_sample<int16_t,int16_t>(const register int16_t sample) { return sample; } |
197 |
template<> STATIC inline const int16_t convert_sample<int16_t,int16_t>(const register int16_t sample) { return sample; } |
188 |
|
198 |
|
189 |
// int16_t -> int24_t |
199 |
// int16_t -> int24_t |
190 |
template<> static inline const int24_t convert_sample<int16_t,int24_t>(const register int16_t sample) { int24_t r; r.set(sample*256); return r; } |
200 |
template<> STATIC inline const int24_t convert_sample<int16_t,int24_t>(const register int16_t sample) { int24_t r; r.set(sample*256); return r; } |
191 |
|
201 |
|
192 |
// int16_t -> int32_t |
202 |
// int16_t -> int32_t |
193 |
template<> static inline const int32_t convert_sample<int16_t,int32_t>(const register int16_t sample) { return sample*65536; } |
203 |
template<> STATIC inline const int32_t convert_sample<int16_t,int32_t>(const register int16_t sample) { return sample*65536; } |
194 |
|
204 |
|
195 |
// int16_t -> float |
205 |
// int16_t -> float |
196 |
template<> static inline const float convert_sample<int16_t,float>(const register int16_t sample) { return (float)sample/32767.0f; } |
206 |
template<> STATIC inline const float convert_sample<int16_t,float>(const register int16_t sample) { return (float)sample/32767.0f; } |
197 |
|
207 |
|
198 |
// int16_t -> double |
208 |
// int16_t -> double |
199 |
template<> static inline const double convert_sample<int16_t,double>(const register int16_t sample) { return (double)sample/32767.0; } |
209 |
template<> STATIC inline const double convert_sample<int16_t,double>(const register int16_t sample) { return (double)sample/32767.0; } |
200 |
|
210 |
|
201 |
|
211 |
|
202 |
// int24_t -> ... |
212 |
// int24_t -> ... |
Lines 204-219
Link Here
|
204 |
//template<> static inline const int8_t convert_sample<int24_t,int8_t>(const int24_t sample) { } |
214 |
//template<> static inline const int8_t convert_sample<int24_t,int8_t>(const int24_t sample) { } |
205 |
|
215 |
|
206 |
// int24_t -> int16_t |
216 |
// int24_t -> int16_t |
207 |
template<> static inline const int16_t convert_sample<int24_t,int16_t>(const int24_t sample) { return sample.get()>>8; } |
217 |
template<> STATIC inline const int16_t convert_sample<int24_t,int16_t>(const int24_t sample) { return sample.get()>>8; } |
208 |
|
218 |
|
209 |
// int24_t -> int24_t |
219 |
// int24_t -> int24_t |
210 |
template<> static inline const int24_t convert_sample<int24_t,int24_t>(const int24_t sample) { return sample; } |
220 |
template<> STATIC inline const int24_t convert_sample<int24_t,int24_t>(const int24_t sample) { return sample; } |
211 |
|
221 |
|
212 |
// int24_t -> int32_t |
222 |
// int24_t -> int32_t |
213 |
//template<> static inline const int32_t convert_sample<int24_t,int32_t>(const int24_t sample) { } |
223 |
//template<> static inline const int32_t convert_sample<int24_t,int32_t>(const int24_t sample) { } |
214 |
|
224 |
|
215 |
// int24_t -> float |
225 |
// int24_t -> float |
216 |
template<> static inline const float convert_sample<int24_t,float>(const int24_t sample) { return sample.get()/8388607.0f; } |
226 |
template<> STATIC inline const float convert_sample<int24_t,float>(const int24_t sample) { return sample.get()/8388607.0f; } |
217 |
|
227 |
|
218 |
// int24_t -> double |
228 |
// int24_t -> double |
219 |
//template<> static inline const double convert_sample<int24_t,double>(const int24_t sample) { } |
229 |
//template<> static inline const double convert_sample<int24_t,double>(const int24_t sample) { } |
Lines 224-239
Link Here
|
224 |
//template<> static inline const int8_t convert_sample<int32_t,int8_t>(const register int32_t sample) { } |
234 |
//template<> static inline const int8_t convert_sample<int32_t,int8_t>(const register int32_t sample) { } |
225 |
|
235 |
|
226 |
// int32_t -> int16_t |
236 |
// int32_t -> int16_t |
227 |
template<> static inline const int16_t convert_sample<int32_t,int16_t>(const register int32_t sample) { return sample/65536; } |
237 |
template<> STATIC inline const int16_t convert_sample<int32_t,int16_t>(const register int32_t sample) { return sample/65536; } |
228 |
|
238 |
|
229 |
// int32_t -> int24_t |
239 |
// int32_t -> int24_t |
230 |
//template<> static inline const int24_t convert_sample<int32_t,int24_t>(const register int32_t sample) { } |
240 |
//template<> static inline const int24_t convert_sample<int32_t,int24_t>(const register int32_t sample) { } |
231 |
|
241 |
|
232 |
// int32_t -> int32_t |
242 |
// int32_t -> int32_t |
233 |
template<> static inline const int32_t convert_sample<int32_t,int32_t>(const register int32_t sample) { return sample; } |
243 |
template<> STATIC inline const int32_t convert_sample<int32_t,int32_t>(const register int32_t sample) { return sample; } |
234 |
|
244 |
|
235 |
// int32_t -> float |
245 |
// int32_t -> float |
236 |
template<> static inline const float convert_sample<int32_t,float>(const register int32_t sample) { return ((double)sample)/2147483647.0; } |
246 |
template<> STATIC inline const float convert_sample<int32_t,float>(const register int32_t sample) { return ((double)sample)/2147483647.0; } |
237 |
|
247 |
|
238 |
// int32_t -> double |
248 |
// int32_t -> double |
239 |
//template<> static inline const double convert_sample<int32_t,double >(const register int32_t sample) { } |
249 |
//template<> static inline const double convert_sample<int32_t,double >(const register int32_t sample) { } |
Lines 241-262
Link Here
|
241 |
|
251 |
|
242 |
// float -> ... |
252 |
// float -> ... |
243 |
// float -> int8_t |
253 |
// float -> int8_t |
244 |
template<> static inline const int8_t convert_sample<float,int8_t>(const register float sample) { return (int8_t)floorf((sample>1.0f ? 1.0f : (sample<-1.0f ? -1.0f : sample))*127.0f); } |
254 |
template<> STATIC inline const int8_t convert_sample<float,int8_t>(const register float sample) { return (int8_t)floorf((sample>1.0f ? 1.0f : (sample<-1.0f ? -1.0f : sample))*127.0f); } |
245 |
|
255 |
|
246 |
// float -> int16_t |
256 |
// float -> int16_t |
247 |
template<> static inline const int16_t convert_sample<float,int16_t>(const register float sample) { return (int16_t)floorf((sample>1.0f ? 1.0f : (sample<-1.0f ? -1.0f : sample))*32767.0f); } |
257 |
template<> STATIC inline const int16_t convert_sample<float,int16_t>(const register float sample) { return (int16_t)floorf((sample>1.0f ? 1.0f : (sample<-1.0f ? -1.0f : sample))*32767.0f); } |
248 |
|
258 |
|
249 |
// float -> int24_t |
259 |
// float -> int24_t |
250 |
template<> static inline const int24_t convert_sample<float,int24_t>(const register float sample) { int24_t r; r.set((int_fast32_t)floorf((sample>1.0f ? 1.0f : (sample<-1.0f ? -1.0f : sample))*8388607.0f)); return r; } |
260 |
template<> STATIC inline const int24_t convert_sample<float,int24_t>(const register float sample) { int24_t r; r.set((int_fast32_t)floorf((sample>1.0f ? 1.0f : (sample<-1.0f ? -1.0f : sample))*8388607.0f)); return r; } |
251 |
|
261 |
|
252 |
// float -> int32_t |
262 |
// float -> int32_t |
253 |
template<> static inline const int32_t convert_sample<float,int32_t>(const register float sample) { return (int32_t) floor((double)(sample>1.0f ? 1.0f : (sample<-1.0f ? -1.0f : sample)) * 2147483647.0); } |
263 |
template<> STATIC inline const int32_t convert_sample<float,int32_t>(const register float sample) { return (int32_t) floor((double)(sample>1.0f ? 1.0f : (sample<-1.0f ? -1.0f : sample)) * 2147483647.0); } |
254 |
|
264 |
|
255 |
// float -> float |
265 |
// float -> float |
256 |
template<> static inline const float convert_sample<float,float>(const register float sample) { return sample; } |
266 |
template<> STATIC inline const float convert_sample<float,float>(const register float sample) { return sample; } |
257 |
|
267 |
|
258 |
// float -> double |
268 |
// float -> double |
259 |
template<> static inline const double convert_sample<float,double>(const register float sample) { return (double)sample; } |
269 |
template<> STATIC inline const double convert_sample<float,double>(const register float sample) { return (double)sample; } |
260 |
|
270 |
|
261 |
|
271 |
|
262 |
// double -> ... |
272 |
// double -> ... |
Lines 264-270
Link Here
|
264 |
//template<> static inline const int8_t convert_sample<double,int8_t>(const register double sample) { } |
274 |
//template<> static inline const int8_t convert_sample<double,int8_t>(const register double sample) { } |
265 |
|
275 |
|
266 |
// double -> int16_t |
276 |
// double -> int16_t |
267 |
template<> static inline const int16_t convert_sample<double,int16_t>(const register double sample) { return (int16_t)floor((sample>1.0 ? 1.0 : (sample<-1.0 ? -1.0 : sample))*32767.0); } |
277 |
template<> STATIC inline const int16_t convert_sample<double,int16_t>(const register double sample) { return (int16_t)floor((sample>1.0 ? 1.0 : (sample<-1.0 ? -1.0 : sample))*32767.0); } |
268 |
|
278 |
|
269 |
// double -> int24_t |
279 |
// double -> int24_t |
270 |
//template<> static inline const int24_t convert_sample<double,int24_t>(const register double sample) { } |
280 |
//template<> static inline const int24_t convert_sample<double,int24_t>(const register double sample) { } |
Lines 273-282
Link Here
|
273 |
//template<> static inline const int32_t convert_sample<double,int32_t>(const register double sample) { } |
283 |
//template<> static inline const int32_t convert_sample<double,int32_t>(const register double sample) { } |
274 |
|
284 |
|
275 |
// double -> float |
285 |
// double -> float |
276 |
template<> static inline const float convert_sample<double,float>(const register double sample) { return (float)sample; } |
286 |
template<> STATIC inline const float convert_sample<double,float>(const register double sample) { return (float)sample; } |
277 |
|
287 |
|
278 |
// double -> double |
288 |
// double -> double |
279 |
template<> static inline const double convert_sample<double,double>(const register double sample) { return sample; } |
289 |
template<> STATIC inline const double convert_sample<double,double>(const register double sample) { return sample; } |
280 |
|
290 |
|
281 |
|
291 |
|
282 |
|
292 |
|