23 |
#ifndef __LS_GIG_SYNTHESIZER_H__ |
#ifndef __LS_GIG_SYNTHESIZER_H__ |
24 |
#define __LS_GIG_SYNTHESIZER_H__ |
#define __LS_GIG_SYNTHESIZER_H__ |
25 |
|
|
26 |
|
#include "../../common/global.h" |
27 |
#include "../../common/RTMath.h" |
#include "../../common/RTMath.h" |
28 |
#include "../common/Resampler.h" |
#include "../common/Resampler.h" |
29 |
#include "../common/BiquadFilter.h" |
#include "../common/BiquadFilter.h" |
30 |
#include "Filter.h" |
#include "Filter.h" |
31 |
#include "Voice.h" |
#include "Voice.h" |
32 |
|
|
33 |
#define SYNTHESIS_MODE_SET_CONSTPITCH(iMode,bVal) if (bVal) iMode |= 0x01; else iMode &= 0xfe /* (un)set mode bit 0 */ |
#define SYNTHESIS_MODE_SET_CONSTPITCH(iMode,bVal) if (bVal) iMode |= 0x01; else iMode &= ~0x01 /* (un)set mode bit 0 */ |
34 |
#define SYNTHESIS_MODE_SET_LOOP(iMode,bVal) if (bVal) iMode |= 0x02; else iMode &= 0xfd /* (un)set mode bit 1 */ |
#define SYNTHESIS_MODE_SET_LOOP(iMode,bVal) if (bVal) iMode |= 0x02; else iMode &= ~0x02 /* (un)set mode bit 1 */ |
35 |
#define SYNTHESIS_MODE_SET_INTERPOLATE(iMode,bVal) if (bVal) iMode |= 0x04; else iMode &= 0xfb /* (un)set mode bit 2 */ |
#define SYNTHESIS_MODE_SET_INTERPOLATE(iMode,bVal) if (bVal) iMode |= 0x04; else iMode &= ~0x04 /* (un)set mode bit 2 */ |
36 |
#define SYNTHESIS_MODE_SET_FILTER(iMode,bVal) if (bVal) iMode |= 0x08; else iMode &= 0xf7 /* (un)set mode bit 3 */ |
#define SYNTHESIS_MODE_SET_FILTER(iMode,bVal) if (bVal) iMode |= 0x08; else iMode &= ~0x08 /* (un)set mode bit 3 */ |
37 |
#define SYNTHESIS_MODE_SET_CHANNELS(iMode,bVal) if (bVal) iMode |= 0x10; else iMode &= 0xef /* (un)set mode bit 4 */ |
#define SYNTHESIS_MODE_SET_CHANNELS(iMode,bVal) if (bVal) iMode |= 0x10; else iMode &= ~0x10 /* (un)set mode bit 4 */ |
38 |
#define SYNTHESIS_MODE_SET_IMPLEMENTATION(iMode,bVal) if (bVal) iMode |= 0x20; else iMode &= 0xdf /* (un)set mode bit 5 */ |
#define SYNTHESIS_MODE_SET_IMPLEMENTATION(iMode,bVal) if (bVal) iMode |= 0x20; else iMode &= ~0x20 /* (un)set mode bit 5 */ |
39 |
#define SYNTHESIS_MODE_SET_PROFILING(iMode,bVal) if (bVal) iMode |= 0x40; else iMode &= ~0x40 /* (un)set mode bit 6 */ |
#define SYNTHESIS_MODE_SET_PROFILING(iMode,bVal) if (bVal) iMode |= 0x40; else iMode &= ~0x40 /* (un)set mode bit 6 */ |
40 |
|
|
41 |
#define SYNTHESIS_MODE_GET_CONSTPITCH(iMode) iMode & 0x01 |
#define SYNTHESIS_MODE_GET_CONSTPITCH(iMode) iMode & 0x01 |
153 |
case CPP: { |
case CPP: { |
154 |
return uint((LoopEnd - *((double *)Pos)) / Pitch); |
return uint((LoopEnd - *((double *)Pos)) / Pitch); |
155 |
} |
} |
156 |
|
#if ARCH_X86 |
157 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
158 |
int result; |
int result; |
159 |
__asm__ __volatile__ ( |
__asm__ __volatile__ ( |
168 |
); |
); |
169 |
return result; |
return result; |
170 |
} |
} |
171 |
|
#endif // ARCH_X86 |
172 |
} |
} |
173 |
} |
} |
174 |
|
|
181 |
*Pos = fmod(*Pos - LoopEnd, LoopSize) + LoopStart; |
*Pos = fmod(*Pos - LoopEnd, LoopSize) + LoopStart; |
182 |
return 1; |
return 1; |
183 |
} |
} |
184 |
|
#if ARCH_X86 |
185 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
186 |
int result; |
int result = 0; |
187 |
__asm__ __volatile__ ( |
__asm__ __volatile__ ( |
188 |
"movss (%2), %%xmm0 # load LoopEnd\n\t" |
"movss (%2), %%xmm0 # load LoopEnd\n\t" |
189 |
"movss (%1), %%xmm1 # load Pos\n\t" |
"movss (%1), %%xmm1 # load Pos\n\t" |
190 |
"comiss %%xmm0, %%xmm1 # LoopEnd <> Pos\n\t" |
"comiss %%xmm0, %%xmm1 # LoopEnd <> Pos\n\t" |
|
"movl $0,%%eax # result = 0\n\t" |
|
191 |
"jb 1f # jump if no work needs to be done\n\t" |
"jb 1f # jump if no work needs to be done\n\t" |
192 |
"movss (%3), %%xmm2 # load LoopSize\n\t" |
"movss (%3), %%xmm2 # load LoopSize\n\t" |
193 |
"subss %%xmm0, %%xmm1 # Pos - LoopEnd\n\t" |
"subss %%xmm0, %%xmm1 # Pos - LoopEnd\n\t" |
202 |
//done with fmodf |
//done with fmodf |
203 |
"addss %%xmm0, %%xmm3 # add LoopStart\n\t" |
"addss %%xmm0, %%xmm3 # add LoopStart\n\t" |
204 |
"movss %%xmm3, (%1) # update Pos\n\t" |
"movss %%xmm3, (%1) # update Pos\n\t" |
205 |
"movl $1,%%eax # result = 1\n\t" |
"movl $1, (%0) # result = 1\n\t" |
206 |
".balign 16 \n\t" |
".balign 16 \n\t" |
207 |
"1:\n\t" |
"1:\n\t" |
208 |
: "=a" (result) /* %0 */ |
:: "r" (&result), /* %0 */ |
209 |
: "r" (vPos), /* %1 */ |
"r" (vPos), /* %1 */ |
210 |
"r" (&LoopEnd), /* %2 */ |
"r" (&LoopEnd), /* %2 */ |
211 |
"r" (&LoopSize), /* %3 */ |
"r" (&LoopSize), /* %3 */ |
212 |
"r" (&LoopStart) /* %4 */ |
"r" (&LoopStart) /* %4 */ |
213 |
); |
); |
214 |
return result; |
return result; |
215 |
} |
} |
216 |
|
#endif // ARCH_X86 |
217 |
} |
} |
218 |
} |
} |
219 |
|
|
244 |
} |
} |
245 |
break; |
break; |
246 |
} |
} |
247 |
|
#if ARCH_X86 |
248 |
// Assembly optimization using the MMX & SSE(1) instruction set (thus only for x86) |
// Assembly optimization using the MMX & SSE(1) instruction set (thus only for x86) |
249 |
case ASM_X86_MMX_SSE: { |
case ASM_X86_MMX_SSE: { |
250 |
const int ii = i & 0xfffffffc; |
const int ii = i & 0xfffffffc; |
330 |
"r" (&pOutR[ii]) /* %1 - must be 16 byte aligned ! */ |
"r" (&pOutR[ii]) /* %1 - must be 16 byte aligned ! */ |
331 |
); |
); |
332 |
} |
} |
333 |
|
#endif // ARCH_X86 |
334 |
} |
} |
335 |
} |
} |
336 |
}; |
}; |