/[svn]/linuxsampler/trunk/src/engines/gig/Synthesizer.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/Synthesizer.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 320 by schoenebeck, Mon Dec 13 00:53:16 2004 UTC revision 325 by senkov, Tue Dec 21 04:54:37 2004 UTC
# Line 35  Line 35 
35  #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 &= 0xf7   /* (un)set mode bit 3 */
36  #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 &= 0xef   /* (un)set mode bit 4 */
37  #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 &= 0xdf   /* (un)set mode bit 5 */
38    #define SYNTHESIS_MODE_SET_PROFILING(iMode,bVal)        if (bVal) iMode |= 0x40; else iMode &= ~0x40   /* (un)set mode bit 6 */
39    
40  #define SYNTHESIS_MODE_GET_CONSTPITCH(iMode)            iMode & 0x01  #define SYNTHESIS_MODE_GET_CONSTPITCH(iMode)            iMode & 0x01
41  #define SYNTHESIS_MODE_GET_LOOP(iMode)                  iMode & 0x02  #define SYNTHESIS_MODE_GET_LOOP(iMode)                  iMode & 0x02
# Line 52  Line 53 
53    
54  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
55    
56      typedef void SynthesizeFragment_Fn(VOICE&, uint, sample_t*, int);      typedef void SynthesizeFragment_Fn(VOICE&, uint, sample_t*, uint);
57    
58      void* GetSynthesisFunction(const int SynthesisMode);      void* GetSynthesisFunction(const int SynthesisMode);
59        void RunSynthesisFunction(const int SynthesisMode, VOICE& voice, uint Samples, sample_t* pSrc, uint Skip);
60    
61      enum channels_t {      enum channels_t {
62          MONO,          MONO,
# Line 65  namespace LinuxSampler { namespace gig { Line 67  namespace LinuxSampler { namespace gig {
67      class Synthesizer : public __RTMath<IMPLEMENTATION>, public LinuxSampler::Resampler<INTERPOLATE> {      class Synthesizer : public __RTMath<IMPLEMENTATION>, public LinuxSampler::Resampler<INTERPOLATE> {
68          public:          public:
69              template<typename VOICE_T>              template<typename VOICE_T>
70              inline static void SynthesizeFragment(VOICE_T& Voice, uint Samples, sample_t* pSrc, int& i) {              inline static void SynthesizeFragment(VOICE_T& Voice, uint Samples, sample_t* pSrc, uint i) {
71                  if (IMPLEMENTATION == ASM_X86_MMX_SSE) {                  if (IMPLEMENTATION == ASM_X86_MMX_SSE) {
72                      float fPos = (float) Voice.Pos;                      float fPos = (float) Voice.Pos;
73                      SynthesizeFragment(Voice, Samples, pSrc, i, Voice.pSample->LoopPlayCount,                      SynthesizeFragment(Voice, Samples, pSrc, i, Voice.pSample->LoopPlayCount,
# Line 93  namespace LinuxSampler { namespace gig { Line 95  namespace LinuxSampler { namespace gig {
95          //protected:          //protected:
96    
97              template<typename VOICE_T>              template<typename VOICE_T>
98              inline static void SynthesizeFragment(VOICE_T& Voice, uint Samples, sample_t* pSrc, int& i, uint& LoopPlayCount, uint LoopStart, uint LoopEnd, uint LoopSize, uint& LoopCyclesLeft, void* Pos, float& PitchBase, float& PitchBend) {              inline static void SynthesizeFragment(VOICE_T& Voice, uint Samples, sample_t* pSrc, uint& i, uint& LoopPlayCount, uint LoopStart, uint LoopEnd, uint LoopSize, uint& LoopCyclesLeft, void* Pos, float& PitchBase, float& PitchBend) {
99                  const float loopEnd = Float(LoopEnd);                  const float loopEnd = Float(LoopEnd);
100                  const float PBbyPB = Mul(PitchBase, PitchBend);                  const float PBbyPB = Mul(PitchBase, PitchBend);
101                  const float f_LoopStart = Float(LoopStart);                  const float f_LoopStart = Float(LoopStart);
# Line 103  namespace LinuxSampler { namespace gig { Line 105  namespace LinuxSampler { namespace gig {
105                          // render loop (loop count limited)                          // render loop (loop count limited)
106                          while (i < Samples && LoopCyclesLeft) {                          while (i < Samples && LoopCyclesLeft) {
107                              if (CONSTPITCH) {                              if (CONSTPITCH) {
108                                  const int processEnd = Min(Samples, i + DiffToLoopEnd(loopEnd,Pos, PBbyPB) + 1); //TODO: instead of +1 we could also round up                                  const uint processEnd = Min(Samples, i + DiffToLoopEnd(loopEnd,Pos, PBbyPB) + 1); //TODO: instead of +1 we could also round up
109                                  while (i < processEnd) Synthesize(Voice, Pos, pSrc, i);                                  while (i < processEnd) Synthesize(Voice, Pos, pSrc, i);
110                              }                              }
111                              else Synthesize(Voice, Pos, pSrc, i);                              else Synthesize(Voice, Pos, pSrc, i);
# Line 115  namespace LinuxSampler { namespace gig { Line 117  namespace LinuxSampler { namespace gig {
117                      else { // render loop (endless loop)                      else { // render loop (endless loop)
118                          while (i < Samples) {                          while (i < Samples) {
119                              if (CONSTPITCH) {                              if (CONSTPITCH) {
120                                  const int processEnd = Min(Samples, i + DiffToLoopEnd(loopEnd, Pos, PBbyPB) + 1); //TODO: instead of +1 we could also round up                                  const uint processEnd = Min(Samples, i + DiffToLoopEnd(loopEnd, Pos, PBbyPB) + 1); //TODO: instead of +1 we could also round up
121                                  while (i < processEnd) Synthesize(Voice, Pos, pSrc, i);                                  while (i < processEnd) Synthesize(Voice, Pos, pSrc, i);
122                              }                              }
123                              else Synthesize(Voice, Pos, pSrc, i);                              else Synthesize(Voice, Pos, pSrc, i);
# Line 129  namespace LinuxSampler { namespace gig { Line 131  namespace LinuxSampler { namespace gig {
131              }              }
132    
133              template<typename VOICE_T>              template<typename VOICE_T>
134              inline static void Synthesize(VOICE_T& Voice, void* Pos, sample_t* pSrc, int& i) {              inline static void Synthesize(VOICE_T& Voice, void* Pos, sample_t* pSrc, uint& i) {
135                  Synthesize(pSrc, Pos,                  Synthesize(pSrc, Pos,
136                             Voice.pEngine->pSynthesisParameters[Event::destination_vco][i],                             Voice.pEngine->pSynthesisParameters[Event::destination_vco][i],
137                             Voice.pEngine->pOutputLeft,                             Voice.pEngine->pOutputLeft,
# Line 148  namespace LinuxSampler { namespace gig { Line 150  namespace LinuxSampler { namespace gig {
150                  switch (IMPLEMENTATION) {                  switch (IMPLEMENTATION) {
151                      // pure C++ implementation (thus platform independent)                      // pure C++ implementation (thus platform independent)
152                      case CPP: {                      case CPP: {
153                          return int((LoopEnd - *((double *)Pos)) / Pitch);                          return uint((LoopEnd - *((double *)Pos)) / Pitch);
154                      }                      }
155                      case ASM_X86_MMX_SSE: {                      case ASM_X86_MMX_SSE: {
156                          int result;                          int result;
# Line 211  namespace LinuxSampler { namespace gig { Line 213  namespace LinuxSampler { namespace gig {
213                  }                  }
214              }              }
215    
216              inline static void Synthesize(sample_t* pSrc, void* Pos, float& Pitch, float* pOutL, float* pOutR, int& i, float* Volume, float* PanL, float* PanR, Filter& FilterL, Filter& FilterR, biquad_param_t& bqBase, biquad_param_t& bqMain) {              inline static void Synthesize(sample_t* pSrc, void* Pos, float& Pitch, float* pOutL, float* pOutR, uint& i, float* Volume, float* PanL, float* PanR, Filter& FilterL, Filter& FilterR, biquad_param_t& bqBase, biquad_param_t& bqMain) {
217                  switch (IMPLEMENTATION) {                  switch (IMPLEMENTATION) {
218                      // pure C++ implementation (thus platform independent)                      // pure C++ implementation (thus platform independent)
219                      case CPP: {                      case CPP: {

Legend:
Removed from v.320  
changed lines
  Added in v.325

  ViewVC Help
Powered by ViewVC