/[svn]/linuxsampler/trunk/src/engines/gig/Engine.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/gig/Engine.cpp

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

revision 829 by schoenebeck, Sat Jan 14 14:07:47 2006 UTC revision 846 by persson, Sun Mar 19 16:38:22 2006 UTC
# Line 116  namespace LinuxSampler { namespace gig { Line 116  namespace LinuxSampler { namespace gig {
116       * Destructor       * Destructor
117       */       */
118      Engine::~Engine() {      Engine::~Engine() {
119            MidiInputPort::RemoveSysexListener(this);
120          if (pDiskThread) {          if (pDiskThread) {
121              dmsg(1,("Stopping disk thread..."));              dmsg(1,("Stopping disk thread..."));
122              pDiskThread->StopThread();              pDiskThread->StopThread();
# Line 165  namespace LinuxSampler { namespace gig { Line 166  namespace LinuxSampler { namespace gig {
166    
167      /**      /**
168       *  Reset all voices and disk thread and clear input event queue and all       *  Reset all voices and disk thread and clear input event queue and all
169       *  control and status variables. This method is not thread safe!       *  control and status variables. This method is protected by a mutex.
170       */       */
171      void Engine::ResetInternal() {      void Engine::ResetInternal() {
172            ResetInternalMutex.Lock();
173    
174            // make sure that the engine does not get any sysex messages
175            // while it's reseting
176            bool sysexDisabled = MidiInputPort::RemoveSysexListener(this);
177          ActiveVoiceCount    = 0;          ActiveVoiceCount    = 0;
178          ActiveVoiceCountMax = 0;          ActiveVoiceCountMax = 0;
179    
# Line 191  namespace LinuxSampler { namespace gig { Line 197  namespace LinuxSampler { namespace gig {
197          // delete all input events          // delete all input events
198          pEventQueue->init();          pEventQueue->init();
199          pSysexBuffer->init();          pSysexBuffer->init();
200            if (sysexDisabled) MidiInputPort::AddSysexListener(this);
201            ResetInternalMutex.Unlock();
202      }      }
203    
204      /**      /**
# Line 1234  namespace LinuxSampler { namespace gig { Line 1242  namespace LinuxSampler { namespace gig {
1242              }              }
1243              case 7: { // volume              case 7: { // volume
1244                  //TODO: not sample accurate yet                  //TODO: not sample accurate yet
1245                  pEngineChannel->GlobalVolume = (float) itControlChangeEvent->Param.CC.Value / 127.0f *  CONFIG_GLOBAL_ATTENUATION;                  pEngineChannel->GlobalVolume = VolumeCurve[itControlChangeEvent->Param.CC.Value] *  CONFIG_GLOBAL_ATTENUATION;
1246                  pEngineChannel->bStatusChanged = true; // engine channel status has changed, so set notify flag                  pEngineChannel->bStatusChanged = true; // engine channel status has changed, so set notify flag
1247                  break;                  break;
1248              }              }
1249              case 10: { // panpot              case 10: { // panpot
1250                  //TODO: not sample accurate yet                  //TODO: not sample accurate yet
1251                  const int pan = (int) itControlChangeEvent->Param.CC.Value - 64;                  pEngineChannel->GlobalPanLeft  = PanCurve[128 - itControlChangeEvent->Param.CC.Value];
1252                  pEngineChannel->GlobalPanLeft  = 1.0f - float(RTMath::Max(pan, 0)) /  63.0f;                  pEngineChannel->GlobalPanRight = PanCurve[itControlChangeEvent->Param.CC.Value];
                 pEngineChannel->GlobalPanRight = 1.0f - float(RTMath::Min(pan, 0)) / -64.0f;  
1253                  break;                  break;
1254              }              }
1255              case 64: { // sustain              case 64: { // sustain
# Line 1558  namespace LinuxSampler { namespace gig { Line 1565  namespace LinuxSampler { namespace gig {
1565      }      }
1566    
1567      String Engine::Version() {      String Engine::Version() {
1568          String s = "$Revision: 1.57 $";          String s = "$Revision: 1.60 $";
1569          return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword          return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
1570      }      }
1571    
1572        // static constant initializers
1573        const float* Engine::VolumeCurve(InitVolumeCurve());
1574        const float* Engine::PanCurve(InitPanCurve());
1575        const float* Engine::CrossfadeCurve(InitCrossfadeCurve());
1576    
1577        float* Engine::InitVolumeCurve() {
1578            // line-segment approximation
1579            const float segments[] = {
1580                0, 0, 2, 0.0046, 16, 0.016, 31, 0.051, 45, 0.115, 54.5, 0.2,
1581                64.5, 0.39, 74, 0.74, 92, 1.03, 114, 1.94, 119.2, 2.2, 127, 2.2
1582            };
1583            return InitCurve(segments);
1584        }
1585    
1586        float* Engine::InitPanCurve() {
1587            // line-segment approximation
1588            const float segments[] = {
1589                0, 0, 1, 0,
1590                2, 0.05, 31.5, 0.7, 51, 0.851, 74.5, 1.12,
1591                127, 1.41, 128, 1.41
1592            };
1593            return InitCurve(segments, 129);
1594        }
1595    
1596        float* Engine::InitCrossfadeCurve() {
1597            // line-segment approximation
1598            const float segments[] = {
1599                0, 0, 1, 0.03, 10, 0.1, 51, 0.58, 127, 1
1600            };
1601            return InitCurve(segments);
1602        }
1603    
1604        float* Engine::InitCurve(const float* segments, int size) {
1605            float* y = new float[size];
1606            for (int x = 0 ; x < size ; x++) {
1607                if (x > segments[2]) segments += 2;
1608                y[x] = segments[1] + (x - segments[0]) *
1609                    (segments[3] - segments[1]) / (segments[2] - segments[0]);
1610            }
1611            return y;
1612        }
1613    
1614  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.829  
changed lines
  Added in v.846

  ViewVC Help
Powered by ViewVC