/[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 1038 by persson, Sat Feb 3 15:33:00 2007 UTC revision 1248 by persson, Fri Jun 22 10:10:06 2007 UTC
# Line 51  namespace LinuxSampler { namespace gig { Line 51  namespace LinuxSampler { namespace gig {
51          if (engines.count(pDevice)) {          if (engines.count(pDevice)) {
52              dmsg(4,("Using existing gig::Engine.\n"));              dmsg(4,("Using existing gig::Engine.\n"));
53              pEngine = engines[pDevice];              pEngine = engines[pDevice];
54    
55                // Disable the engine while the new engine channel is
56                // added and initialized. The engine will be enabled again
57                // in EngineChannel::Connect.
58                pEngine->DisableAndLock();
59          } else { // create a new engine (and disk thread) instance for the given audio output device          } else { // create a new engine (and disk thread) instance for the given audio output device
60              dmsg(4,("Creating new gig::Engine.\n"));              dmsg(4,("Creating new gig::Engine.\n"));
61              pEngine = (Engine*) EngineFactory::Create("gig");              pEngine = (Engine*) EngineFactory::Create("gig");
62              pEngine->Connect(pDevice);              pEngine->Connect(pDevice);
63              engines[pDevice] = pEngine;              engines[pDevice] = pEngine;
64          }          }
   
65          // register engine channel to the engine instance          // register engine channel to the engine instance
   
         // Disable the engine while the new engine channel is added  
         // and initialized. The engine will be enabled again in  
         // EngineChannel::Connect.  
         pEngine->DisableAndLock();  
   
66          pEngine->engineChannels.add(pChannel);          pEngine->engineChannels.add(pChannel);
67          // remember index in the ArrayList          // remember index in the ArrayList
68          pChannel->iEngineIndexSelf = pEngine->engineChannels.size() - 1;          pChannel->iEngineIndexSelf = pEngine->engineChannels.size() - 1;
# Line 143  namespace LinuxSampler { namespace gig { Line 141  namespace LinuxSampler { namespace gig {
141          if (pEventGenerator) delete pEventGenerator;          if (pEventGenerator) delete pEventGenerator;
142          if (pVoiceStealingQueue) delete pVoiceStealingQueue;          if (pVoiceStealingQueue) delete pVoiceStealingQueue;
143          if (pSysexBuffer) delete pSysexBuffer;          if (pSysexBuffer) delete pSysexBuffer;
144            if (pGlobalEvents) delete pGlobalEvents;
145            if (InstrumentChangeQueue) delete InstrumentChangeQueue;
146            if (InstrumentChangeReplyQueue) delete InstrumentChangeReplyQueue;
147            if (pDimRegionsInUse) delete[] pDimRegionsInUse;
148          Unregister();          Unregister();
149      }      }
150    
# Line 711  namespace LinuxSampler { namespace gig { Line 713  namespace LinuxSampler { namespace gig {
713    
714          if (!pEngineChannel->pInstrument) return; // ignore if no instrument loaded          if (!pEngineChannel->pInstrument) return; // ignore if no instrument loaded
715    
716            //HACK: we should better add the transpose value only to the most mandatory places (like for retrieving the region and calculating the tuning), because otherwise voices will unintendedly survive when changing transpose while playing
717            itNoteOnEvent->Param.Note.Key += pEngineChannel->GlobalTranspose;
718    
719          const int key = itNoteOnEvent->Param.Note.Key;          const int key = itNoteOnEvent->Param.Note.Key;
720          midi_key_info_t* pKey = &pEngineChannel->pMIDIKeyInfo[key];          midi_key_info_t* pKey = &pEngineChannel->pMIDIKeyInfo[key];
721    
# Line 798  namespace LinuxSampler { namespace gig { Line 803  namespace LinuxSampler { namespace gig {
803          if (pEngineChannel->GetMute()) return; // skip if sampler channel is muted          if (pEngineChannel->GetMute()) return; // skip if sampler channel is muted
804          #endif          #endif
805    
806            //HACK: we should better add the transpose value only to the most mandatory places (like for retrieving the region and calculating the tuning), because otherwise voices will unintendedly survive when changing transpose while playing
807            itNoteOffEvent->Param.Note.Key += pEngineChannel->GlobalTranspose;
808    
809          const int iKey = itNoteOffEvent->Param.Note.Key;          const int iKey = itNoteOffEvent->Param.Note.Key;
810          midi_key_info_t* pKey = &pEngineChannel->pMIDIKeyInfo[iKey];          midi_key_info_t* pKey = &pEngineChannel->pMIDIKeyInfo[iKey];
811          pKey->KeyPressed = false; // the MIDI key was now released          pKey->KeyPressed = false; // the MIDI key was now released
# Line 1358  namespace LinuxSampler { namespace gig { Line 1366  namespace LinuxSampler { namespace gig {
1366                  pEngineChannel->PortamentoTime = (float) itControlChangeEvent->Param.CC.Value / 127.0f * (float) CONFIG_PORTAMENTO_TIME_MAX + (float) CONFIG_PORTAMENTO_TIME_MIN;                  pEngineChannel->PortamentoTime = (float) itControlChangeEvent->Param.CC.Value / 127.0f * (float) CONFIG_PORTAMENTO_TIME_MAX + (float) CONFIG_PORTAMENTO_TIME_MIN;
1367                  break;                  break;
1368              }              }
1369                case 6: { // data entry (currently only used for RPN controllers)
1370                    if (pEngineChannel->GetMidiRpnController() == 2) { // coarse tuning in half tones
1371                        int transpose = (int) itControlChangeEvent->Param.CC.Value - 64;
1372                        // limit to +- two octaves for now
1373                        transpose = RTMath::Min(transpose,  24);
1374                        transpose = RTMath::Max(transpose, -24);
1375                        pEngineChannel->GlobalTranspose = transpose;
1376                        // workaround, so we won't have hanging notes
1377                        ReleaseAllVoices(pEngineChannel, itControlChangeEvent);
1378                    }
1379                    // to avoid other MIDI CC #6 messages to be misenterpreted as RPN controller data
1380                    pEngineChannel->ResetMidiRpnController();
1381                    break;
1382                }
1383              case 7: { // volume              case 7: { // volume
1384                  //TODO: not sample accurate yet                  //TODO: not sample accurate yet
1385                  pEngineChannel->MidiVolume = VolumeCurve[itControlChangeEvent->Param.CC.Value];                  pEngineChannel->MidiVolume = VolumeCurve[itControlChangeEvent->Param.CC.Value];
# Line 1462  namespace LinuxSampler { namespace gig { Line 1484  namespace LinuxSampler { namespace gig {
1484                  }                  }
1485                  break;                  break;
1486              }              }
1487                case 100: { // RPN controller LSB
1488                    pEngineChannel->SetMidiRpnControllerLsb(itControlChangeEvent->Param.CC.Value);
1489                    break;
1490                }
1491                case 101: { // RPN controller MSB
1492                    pEngineChannel->SetMidiRpnControllerMsb(itControlChangeEvent->Param.CC.Value);
1493                    break;
1494                }
1495    
1496    
1497              // Channel Mode Messages              // Channel Mode Messages
# Line 1498  namespace LinuxSampler { namespace gig { Line 1528  namespace LinuxSampler { namespace gig {
1528                  FxSend* pFxSend = pEngineChannel->GetFxSend(iFxSend);                  FxSend* pFxSend = pEngineChannel->GetFxSend(iFxSend);
1529                  if (pFxSend->MidiController() == itControlChangeEvent->Param.CC.Controller)                  if (pFxSend->MidiController() == itControlChangeEvent->Param.CC.Controller)
1530                      pFxSend->SetLevel(itControlChangeEvent->Param.CC.Value);                      pFxSend->SetLevel(itControlChangeEvent->Param.CC.Value);
1531                        pFxSend->SetInfoChanged(true);
1532              }              }
1533          }          }
1534      }      }
# Line 1694  namespace LinuxSampler { namespace gig { Line 1725  namespace LinuxSampler { namespace gig {
1725      }      }
1726    
1727      String Engine::Version() {      String Engine::Version() {
1728          String s = "$Revision: 1.71 $";          String s = "$Revision: 1.77 $";
1729          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
1730      }      }
1731    

Legend:
Removed from v.1038  
changed lines
  Added in v.1248

  ViewVC Help
Powered by ViewVC