2 |
* * |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
* Copyright (C) 2005-2007 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
57 |
pEngine->Connect(pDevice); |
pEngine->Connect(pDevice); |
58 |
engines[pDevice] = pEngine; |
engines[pDevice] = pEngine; |
59 |
} |
} |
60 |
|
|
61 |
// register engine channel to the engine instance |
// register engine channel to the engine instance |
62 |
|
|
63 |
|
// Disable the engine while the new engine channel is added |
64 |
|
// and initialized. The engine will be enabled again in |
65 |
|
// EngineChannel::Connect. |
66 |
|
pEngine->DisableAndLock(); |
67 |
|
|
68 |
pEngine->engineChannels.add(pChannel); |
pEngine->engineChannels.add(pChannel); |
69 |
// remember index in the ArrayList |
// remember index in the ArrayList |
70 |
pChannel->iEngineIndexSelf = pEngine->engineChannels.size() - 1; |
pChannel->iEngineIndexSelf = pEngine->engineChannels.size() - 1; |
104 |
pAudioOutputDevice = NULL; |
pAudioOutputDevice = NULL; |
105 |
pDiskThread = NULL; |
pDiskThread = NULL; |
106 |
pEventGenerator = NULL; |
pEventGenerator = NULL; |
107 |
pSysexBuffer = new RingBuffer<uint8_t>(CONFIG_SYSEX_BUFFER_SIZE, 0); |
pSysexBuffer = new RingBuffer<uint8_t,false>(CONFIG_SYSEX_BUFFER_SIZE, 0); |
108 |
pEventQueue = new RingBuffer<Event>(CONFIG_MAX_EVENTS_PER_FRAGMENT, 0); |
pEventQueue = new RingBuffer<Event,false>(CONFIG_MAX_EVENTS_PER_FRAGMENT, 0); |
109 |
pEventPool = new Pool<Event>(CONFIG_MAX_EVENTS_PER_FRAGMENT); |
pEventPool = new Pool<Event>(CONFIG_MAX_EVENTS_PER_FRAGMENT); |
110 |
pVoicePool = new Pool<Voice>(CONFIG_MAX_VOICES); |
pVoicePool = new Pool<Voice>(CONFIG_MAX_VOICES); |
111 |
|
pDimRegionsInUse = new ::gig::DimensionRegion*[CONFIG_MAX_VOICES + 1]; |
112 |
pVoiceStealingQueue = new RTList<Event>(pEventPool); |
pVoiceStealingQueue = new RTList<Event>(pEventPool); |
113 |
pGlobalEvents = new RTList<Event>(pEventPool); |
pGlobalEvents = new RTList<Event>(pEventPool); |
114 |
|
InstrumentChangeQueue = new RingBuffer<instrument_change_command_t,false>(1, 0); |
115 |
|
InstrumentChangeReplyQueue = new RingBuffer<instrument_change_reply_t,false>(1, 0); |
116 |
|
|
117 |
for (RTList<Voice>::Iterator iterVoice = pVoicePool->allocAppend(); iterVoice == pVoicePool->last(); iterVoice = pVoicePool->allocAppend()) { |
for (RTList<Voice>::Iterator iterVoice = pVoicePool->allocAppend(); iterVoice == pVoicePool->last(); iterVoice = pVoicePool->allocAppend()) { |
118 |
iterVoice->SetEngine(this); |
iterVoice->SetEngine(this); |
119 |
} |
} |
143 |
if (pEventGenerator) delete pEventGenerator; |
if (pEventGenerator) delete pEventGenerator; |
144 |
if (pVoiceStealingQueue) delete pVoiceStealingQueue; |
if (pVoiceStealingQueue) delete pVoiceStealingQueue; |
145 |
if (pSysexBuffer) delete pSysexBuffer; |
if (pSysexBuffer) delete pSysexBuffer; |
146 |
EngineFactory::Destroy(this); |
Unregister(); |
147 |
} |
} |
148 |
|
|
149 |
void Engine::Enable() { |
void Engine::Enable() { |
268 |
delete this->pDiskThread; |
delete this->pDiskThread; |
269 |
dmsg(1,("OK\n")); |
dmsg(1,("OK\n")); |
270 |
} |
} |
271 |
this->pDiskThread = new DiskThread(((pAudioOut->MaxSamplesPerCycle() << CONFIG_MAX_PITCH) << 1) + 6); //FIXME: assuming stereo |
this->pDiskThread = new DiskThread(((pAudioOut->MaxSamplesPerCycle() << CONFIG_MAX_PITCH) << 1) + 6, //FIXME: assuming stereo |
272 |
|
&instruments); |
273 |
if (!pDiskThread) { |
if (!pDiskThread) { |
274 |
dmsg(0,("gig::Engine new diskthread = NULL\n")); |
dmsg(0,("gig::Engine new diskthread = NULL\n")); |
275 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
318 |
* current audio cycle |
* current audio cycle |
319 |
*/ |
*/ |
320 |
void Engine::ImportEvents(uint Samples) { |
void Engine::ImportEvents(uint Samples) { |
321 |
RingBuffer<Event>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader(); |
RingBuffer<Event,false>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader(); |
322 |
Event* pEvent; |
Event* pEvent; |
323 |
while (true) { |
while (true) { |
324 |
// get next event from input event queue |
// get next event from input event queue |
341 |
} |
} |
342 |
|
|
343 |
/** |
/** |
344 |
* Let this engine proceed to render the given amount of sample points. The |
* Let this engine proceed to render the given amount of sample points. |
345 |
* calculated audio data of all voices of this engine will be placed into |
* The engine will iterate through all engine channels and render audio |
346 |
* the engine's audio sum buffer which has to be copied and eventually be |
* for each engine channel independently. The calculated audio data of |
347 |
* converted to the appropriate value range by the audio output class (e.g. |
* all voices of each engine channel will be placed into the audio sum |
348 |
* AlsaIO or JackIO) right after. |
* buffers of the respective audio output device, connected to the |
349 |
|
* respective engine channel. |
350 |
* |
* |
351 |
* @param Samples - number of sample points to be rendered |
* @param Samples - number of sample points to be rendered |
352 |
* @returns 0 on success |
* @returns 0 on success |
353 |
*/ |
*/ |
354 |
int Engine::RenderAudio(uint Samples) { |
int Engine::RenderAudio(uint Samples) { |
355 |
dmsg(5,("RenderAudio(Samples=%d)\n", Samples)); |
dmsg(7,("RenderAudio(Samples=%d)\n", Samples)); |
356 |
|
|
357 |
// return if engine disabled |
// return if engine disabled |
358 |
if (EngineDisabled.Pop()) { |
if (EngineDisabled.Pop()) { |
389 |
// reset internal voice counter (just for statistic of active voices) |
// reset internal voice counter (just for statistic of active voices) |
390 |
ActiveVoiceCountTemp = 0; |
ActiveVoiceCountTemp = 0; |
391 |
|
|
392 |
|
// handle instrument change commands |
393 |
|
instrument_change_command_t command; |
394 |
|
if (InstrumentChangeQueue->pop(&command) > 0) { |
395 |
|
EngineChannel* pEngineChannel = command.pEngineChannel; |
396 |
|
pEngineChannel->pInstrument = command.pInstrument; |
397 |
|
|
398 |
|
// iterate through all active voices and mark their |
399 |
|
// dimension regions as "in use". The instrument resource |
400 |
|
// manager may delete all of the instrument except the |
401 |
|
// dimension regions and samples that are in use. |
402 |
|
int i = 0; |
403 |
|
RTList<uint>::Iterator iuiKey = pEngineChannel->pActiveKeys->first(); |
404 |
|
RTList<uint>::Iterator end = pEngineChannel->pActiveKeys->end(); |
405 |
|
while (iuiKey != end) { // iterate through all active keys |
406 |
|
midi_key_info_t* pKey = &pEngineChannel->pMIDIKeyInfo[*iuiKey]; |
407 |
|
++iuiKey; |
408 |
|
|
409 |
|
RTList<Voice>::Iterator itVoice = pKey->pActiveVoices->first(); |
410 |
|
RTList<Voice>::Iterator itVoicesEnd = pKey->pActiveVoices->end(); |
411 |
|
for (; itVoice != itVoicesEnd; ++itVoice) { // iterate through all voices on this key |
412 |
|
if (!itVoice->Orphan) { |
413 |
|
itVoice->Orphan = true; |
414 |
|
pDimRegionsInUse[i++] = itVoice->pDimRgn; |
415 |
|
} |
416 |
|
} |
417 |
|
} |
418 |
|
pDimRegionsInUse[i] = 0; // end of list |
419 |
|
|
420 |
|
// send a reply to the calling thread, which is waiting |
421 |
|
instrument_change_reply_t reply; |
422 |
|
InstrumentChangeReplyQueue->push(&reply); |
423 |
|
} |
424 |
|
|
425 |
// handle events on all engine channels |
// handle events on all engine channels |
426 |
for (int i = 0; i < engineChannels.size(); i++) { |
for (int i = 0; i < engineChannels.size(); i++) { |
|
if (!engineChannels[i]->pInstrument) continue; // ignore if no instrument loaded |
|
427 |
ProcessEvents(engineChannels[i], Samples); |
ProcessEvents(engineChannels[i], Samples); |
428 |
} |
} |
429 |
|
|
430 |
// render all 'normal', active voices on all engine channels |
// render all 'normal', active voices on all engine channels |
431 |
for (int i = 0; i < engineChannels.size(); i++) { |
for (int i = 0; i < engineChannels.size(); i++) { |
|
if (!engineChannels[i]->pInstrument) continue; // ignore if no instrument loaded |
|
432 |
RenderActiveVoices(engineChannels[i], Samples); |
RenderActiveVoices(engineChannels[i], Samples); |
433 |
} |
} |
434 |
|
|
435 |
// now that all ordinary voices on ALL engine channels are rendered, render new stolen voices |
// now that all ordinary voices on ALL engine channels are rendered, render new stolen voices |
436 |
RenderStolenVoices(Samples); |
RenderStolenVoices(Samples); |
437 |
|
|
438 |
|
// handle audio routing for engine channels with FX sends |
439 |
|
for (int i = 0; i < engineChannels.size(); i++) { |
440 |
|
if (engineChannels[i]->fxSends.empty()) continue; // ignore if no FX sends |
441 |
|
RouteAudio(engineChannels[i], Samples); |
442 |
|
} |
443 |
|
|
444 |
// handle cleanup on all engine channels for the next audio fragment |
// handle cleanup on all engine channels for the next audio fragment |
445 |
for (int i = 0; i < engineChannels.size(); i++) { |
for (int i = 0; i < engineChannels.size(); i++) { |
|
if (!engineChannels[i]->pInstrument) continue; // ignore if no instrument loaded |
|
446 |
PostProcess(engineChannels[i]); |
PostProcess(engineChannels[i]); |
447 |
} |
} |
448 |
|
|
561 |
RTList<Event>::Iterator end = pVoiceStealingQueue->end(); |
RTList<Event>::Iterator end = pVoiceStealingQueue->end(); |
562 |
for (; itVoiceStealEvent != end; ++itVoiceStealEvent) { |
for (; itVoiceStealEvent != end; ++itVoiceStealEvent) { |
563 |
EngineChannel* pEngineChannel = (EngineChannel*) itVoiceStealEvent->pEngineChannel; |
EngineChannel* pEngineChannel = (EngineChannel*) itVoiceStealEvent->pEngineChannel; |
564 |
|
if (!pEngineChannel->pInstrument) continue; // ignore if no instrument loaded |
565 |
Pool<Voice>::Iterator itNewVoice = |
Pool<Voice>::Iterator itNewVoice = |
566 |
LaunchVoice(pEngineChannel, itVoiceStealEvent, itVoiceStealEvent->Param.Note.Layer, itVoiceStealEvent->Param.Note.ReleaseTrigger, false, false); |
LaunchVoice(pEngineChannel, itVoiceStealEvent, itVoiceStealEvent->Param.Note.Layer, itVoiceStealEvent->Param.Note.ReleaseTrigger, false, false); |
567 |
if (itNewVoice) { |
if (itNewVoice) { |
581 |
} |
} |
582 |
|
|
583 |
/** |
/** |
584 |
|
* Will be called in case the respective engine channel sports FX send |
585 |
|
* channels. In this particular case, engine channel local buffers are |
586 |
|
* used to render and mix all voices to. This method is responsible for |
587 |
|
* copying the audio data from those local buffers to the master audio |
588 |
|
* output channels as well as to the FX send audio output channels with |
589 |
|
* their respective FX send levels. |
590 |
|
* |
591 |
|
* @param pEngineChannel - engine channel from which audio should be |
592 |
|
* routed |
593 |
|
* @param Samples - amount of sample points to be routed in |
594 |
|
* this audio fragment cycle |
595 |
|
*/ |
596 |
|
void Engine::RouteAudio(EngineChannel* pEngineChannel, uint Samples) { |
597 |
|
// route master signal |
598 |
|
{ |
599 |
|
AudioChannel* pDstL = pAudioOutputDevice->Channel(pEngineChannel->AudioDeviceChannelLeft); |
600 |
|
AudioChannel* pDstR = pAudioOutputDevice->Channel(pEngineChannel->AudioDeviceChannelRight); |
601 |
|
pEngineChannel->pChannelLeft->MixTo(pDstL, Samples); |
602 |
|
pEngineChannel->pChannelRight->MixTo(pDstR, Samples); |
603 |
|
} |
604 |
|
// route FX send signal |
605 |
|
{ |
606 |
|
for (int iFxSend = 0; iFxSend < pEngineChannel->GetFxSendCount(); iFxSend++) { |
607 |
|
FxSend* pFxSend = pEngineChannel->GetFxSend(iFxSend); |
608 |
|
// left channel |
609 |
|
const int iDstL = pFxSend->DestinationChannel(0); |
610 |
|
if (iDstL < 0) { |
611 |
|
dmsg(1,("Engine::RouteAudio() Error: invalid FX send (L) destination channel")); |
612 |
|
} else { |
613 |
|
AudioChannel* pDstL = pAudioOutputDevice->Channel(iDstL); |
614 |
|
if (!pDstL) { |
615 |
|
dmsg(1,("Engine::RouteAudio() Error: invalid FX send (L) destination channel")); |
616 |
|
} else pEngineChannel->pChannelLeft->MixTo(pDstL, Samples, pFxSend->Level()); |
617 |
|
} |
618 |
|
// right channel |
619 |
|
const int iDstR = pFxSend->DestinationChannel(1); |
620 |
|
if (iDstR < 0) { |
621 |
|
dmsg(1,("Engine::RouteAudio() Error: invalid FX send (R) destination channel")); |
622 |
|
} else { |
623 |
|
AudioChannel* pDstR = pAudioOutputDevice->Channel(iDstR); |
624 |
|
if (!pDstR) { |
625 |
|
dmsg(1,("Engine::RouteAudio() Error: invalid FX send (R) destination channel")); |
626 |
|
} else pEngineChannel->pChannelRight->MixTo(pDstR, Samples, pFxSend->Level()); |
627 |
|
} |
628 |
|
} |
629 |
|
} |
630 |
|
// reset buffers with silence (zero out) for the next audio cycle |
631 |
|
pEngineChannel->pChannelLeft->Clear(); |
632 |
|
pEngineChannel->pChannelRight->Clear(); |
633 |
|
} |
634 |
|
|
635 |
|
/** |
636 |
* Free all keys which have turned inactive in this audio fragment, from |
* Free all keys which have turned inactive in this audio fragment, from |
637 |
* the list of active keys and clear all event lists on that engine |
* the list of active keys and clear all event lists on that engine |
638 |
* channel. |
* channel. |
709 |
if (pEngineChannel->GetMute()) return; // skip if sampler channel is muted |
if (pEngineChannel->GetMute()) return; // skip if sampler channel is muted |
710 |
#endif |
#endif |
711 |
|
|
712 |
|
if (!pEngineChannel->pInstrument) return; // ignore if no instrument loaded |
713 |
|
|
714 |
const int key = itNoteOnEvent->Param.Note.Key; |
const int key = itNoteOnEvent->Param.Note.Key; |
715 |
midi_key_info_t* pKey = &pEngineChannel->pMIDIKeyInfo[key]; |
midi_key_info_t* pKey = &pEngineChannel->pMIDIKeyInfo[key]; |
716 |
|
|
808 |
bool bShouldRelease = pKey->Active && ShouldReleaseVoice(pEngineChannel, itNoteOffEventOnKeyList->Param.Note.Key); |
bool bShouldRelease = pKey->Active && ShouldReleaseVoice(pEngineChannel, itNoteOffEventOnKeyList->Param.Note.Key); |
809 |
|
|
810 |
// in case Solo Mode is enabled, kill all voices on this key and respawn a voice on the highest pressed key (if any) |
// in case Solo Mode is enabled, kill all voices on this key and respawn a voice on the highest pressed key (if any) |
811 |
if (pEngineChannel->SoloMode) { //TODO: this feels like too much code just for handling solo mode :P |
if (pEngineChannel->SoloMode && pEngineChannel->pInstrument) { //TODO: this feels like too much code just for handling solo mode :P |
812 |
bool bOtherKeysPressed = false; |
bool bOtherKeysPressed = false; |
813 |
if (iKey == pEngineChannel->SoloKey) { |
if (iKey == pEngineChannel->SoloKey) { |
814 |
pEngineChannel->SoloKey = -1; |
pEngineChannel->SoloKey = -1; |
871 |
itNoteOffEventOnKeyList->Type = Event::type_release; // transform event type |
itNoteOffEventOnKeyList->Type = Event::type_release; // transform event type |
872 |
|
|
873 |
// spawn release triggered voice(s) if needed |
// spawn release triggered voice(s) if needed |
874 |
if (pKey->ReleaseTrigger) { |
if (pKey->ReleaseTrigger && pEngineChannel->pInstrument) { |
875 |
// first, get total amount of required voices (dependant on amount of layers) |
// first, get total amount of required voices (dependant on amount of layers) |
876 |
::gig::Region* pRegion = pEngineChannel->pInstrument->GetRegion(itNoteOffEventOnKeyList->Param.Note.Key); |
::gig::Region* pRegion = pEngineChannel->pInstrument->GetRegion(itNoteOffEventOnKeyList->Param.Note.Key); |
877 |
if (pRegion) { |
if (pRegion) { |
974 |
DimValues[i] = itNoteOnEvent->Param.Note.Velocity; |
DimValues[i] = itNoteOnEvent->Param.Note.Velocity; |
975 |
break; |
break; |
976 |
case ::gig::dimension_channelaftertouch: |
case ::gig::dimension_channelaftertouch: |
977 |
DimValues[i] = 0; //TODO: we currently ignore this dimension |
DimValues[i] = pEngineChannel->ControllerTable[128]; |
978 |
break; |
break; |
979 |
case ::gig::dimension_releasetrigger: |
case ::gig::dimension_releasetrigger: |
980 |
VoiceType = (ReleaseTriggerVoice) ? Voice::type_release_trigger : (!iLayer) ? Voice::type_release_trigger_required : Voice::type_normal; |
VoiceType = (ReleaseTriggerVoice) ? Voice::type_release_trigger : (!iLayer) ? Voice::type_release_trigger_required : Voice::type_normal; |
1066 |
std::cerr << "gig::Engine::LaunchVoice() Error: Unknown dimension\n" << std::flush; |
std::cerr << "gig::Engine::LaunchVoice() Error: Unknown dimension\n" << std::flush; |
1067 |
} |
} |
1068 |
} |
} |
1069 |
|
|
1070 |
|
// return if this is a release triggered voice and there is no |
1071 |
|
// releasetrigger dimension (could happen if an instrument |
1072 |
|
// change has occured between note on and off) |
1073 |
|
if (ReleaseTriggerVoice && VoiceType != Voice::type_release_trigger) return Pool<Voice>::Iterator(); |
1074 |
|
|
1075 |
::gig::DimensionRegion* pDimRgn = pRegion->GetDimensionRegionByValue(DimValues); |
::gig::DimensionRegion* pDimRgn = pRegion->GetDimensionRegionByValue(DimValues); |
1076 |
|
|
1077 |
// no need to continue if sample is silent |
// no need to continue if sample is silent |
1301 |
|
|
1302 |
uint keygroup = itVoice->KeyGroup; |
uint keygroup = itVoice->KeyGroup; |
1303 |
|
|
1304 |
|
// if the sample and dimension region belong to an |
1305 |
|
// instrument that is unloaded, tell the disk thread to |
1306 |
|
// release them |
1307 |
|
if (itVoice->Orphan) { |
1308 |
|
pDiskThread->OrderDeletionOfDimreg(itVoice->pDimRgn); |
1309 |
|
} |
1310 |
|
|
1311 |
// free the voice object |
// free the voice object |
1312 |
pVoicePool->free(itVoice); |
pVoicePool->free(itVoice); |
1313 |
|
|
1352 |
// update controller value in the engine channel's controller table |
// update controller value in the engine channel's controller table |
1353 |
pEngineChannel->ControllerTable[itControlChangeEvent->Param.CC.Controller] = itControlChangeEvent->Param.CC.Value; |
pEngineChannel->ControllerTable[itControlChangeEvent->Param.CC.Controller] = itControlChangeEvent->Param.CC.Value; |
1354 |
|
|
1355 |
|
// handle hard coded MIDI controllers |
1356 |
switch (itControlChangeEvent->Param.CC.Controller) { |
switch (itControlChangeEvent->Param.CC.Controller) { |
1357 |
case 5: { // portamento time |
case 5: { // portamento time |
1358 |
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; |
1360 |
} |
} |
1361 |
case 7: { // volume |
case 7: { // volume |
1362 |
//TODO: not sample accurate yet |
//TODO: not sample accurate yet |
1363 |
pEngineChannel->GlobalVolume = VolumeCurve[itControlChangeEvent->Param.CC.Value] * CONFIG_GLOBAL_ATTENUATION; |
pEngineChannel->MidiVolume = VolumeCurve[itControlChangeEvent->Param.CC.Value]; |
1364 |
pEngineChannel->bStatusChanged = true; // engine channel status has changed, so set notify flag |
pEngineChannel->bStatusChanged = true; // engine channel status has changed, so set notify flag |
1365 |
break; |
break; |
1366 |
} |
} |
1491 |
break; |
break; |
1492 |
} |
} |
1493 |
} |
} |
1494 |
|
|
1495 |
|
// handle FX send controllers |
1496 |
|
if (!pEngineChannel->fxSends.empty()) { |
1497 |
|
for (int iFxSend = 0; iFxSend < pEngineChannel->GetFxSendCount(); iFxSend++) { |
1498 |
|
FxSend* pFxSend = pEngineChannel->GetFxSend(iFxSend); |
1499 |
|
if (pFxSend->MidiController() == itControlChangeEvent->Param.CC.Controller) |
1500 |
|
pFxSend->SetLevel(itControlChangeEvent->Param.CC.Value); |
1501 |
|
} |
1502 |
|
} |
1503 |
} |
} |
1504 |
|
|
1505 |
/** |
/** |
1508 |
* @param itSysexEvent - sysex data size and time stamp of the sysex event |
* @param itSysexEvent - sysex data size and time stamp of the sysex event |
1509 |
*/ |
*/ |
1510 |
void Engine::ProcessSysex(Pool<Event>::Iterator& itSysexEvent) { |
void Engine::ProcessSysex(Pool<Event>::Iterator& itSysexEvent) { |
1511 |
RingBuffer<uint8_t>::NonVolatileReader reader = pSysexBuffer->get_non_volatile_reader(); |
RingBuffer<uint8_t,false>::NonVolatileReader reader = pSysexBuffer->get_non_volatile_reader(); |
1512 |
|
|
1513 |
uint8_t exclusive_status, id; |
uint8_t exclusive_status, id; |
1514 |
if (!reader.pop(&exclusive_status)) goto free_sysex_data; |
if (!reader.pop(&exclusive_status)) goto free_sysex_data; |
1527 |
|
|
1528 |
// command address |
// command address |
1529 |
uint8_t addr[3]; // 2 byte addr MSB, followed by 1 byte addr LSB) |
uint8_t addr[3]; // 2 byte addr MSB, followed by 1 byte addr LSB) |
1530 |
const RingBuffer<uint8_t>::NonVolatileReader checksum_reader = reader; // so we can calculate the check sum later |
const RingBuffer<uint8_t,false>::NonVolatileReader checksum_reader = reader; // so we can calculate the check sum later |
1531 |
if (reader.read(&addr[0], 3) != 3) goto free_sysex_data; |
if (reader.read(&addr[0], 3) != 3) goto free_sysex_data; |
1532 |
if (addr[0] == 0x40 && addr[1] == 0x00) { // System Parameters |
if (addr[0] == 0x40 && addr[1] == 0x00) { // System Parameters |
1533 |
dmsg(3,("\tSystem Parameter\n")); |
dmsg(3,("\tSystem Parameter\n")); |
1574 |
* question |
* question |
1575 |
* @param DataSize - size of the GS message data (in bytes) |
* @param DataSize - size of the GS message data (in bytes) |
1576 |
*/ |
*/ |
1577 |
uint8_t Engine::GSCheckSum(const RingBuffer<uint8_t>::NonVolatileReader AddrReader, uint DataSize) { |
uint8_t Engine::GSCheckSum(const RingBuffer<uint8_t,false>::NonVolatileReader AddrReader, uint DataSize) { |
1578 |
RingBuffer<uint8_t>::NonVolatileReader reader = AddrReader; |
RingBuffer<uint8_t,false>::NonVolatileReader reader = AddrReader; |
1579 |
uint bytes = 3 /*addr*/ + DataSize; |
uint bytes = 3 /*addr*/ + DataSize; |
1580 |
uint8_t addr_and_data[bytes]; |
uint8_t addr_and_data[bytes]; |
1581 |
reader.read(&addr_and_data[0], bytes); |
reader.read(&addr_and_data[0], bytes); |
1694 |
} |
} |
1695 |
|
|
1696 |
String Engine::Version() { |
String Engine::Version() { |
1697 |
String s = "$Revision: 1.63 $"; |
String s = "$Revision: 1.71 $"; |
1698 |
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 |
1699 |
} |
} |
1700 |
|
|
1701 |
|
InstrumentManager* Engine::GetInstrumentManager() { |
1702 |
|
return &instruments; |
1703 |
|
} |
1704 |
|
|
1705 |
// static constant initializers |
// static constant initializers |
1706 |
const float* Engine::VolumeCurve(InitVolumeCurve()); |
const float* Engine::VolumeCurve(InitVolumeCurve()); |
1707 |
const float* Engine::PanCurve(InitPanCurve()); |
const float* Engine::PanCurve(InitPanCurve()); |
1744 |
return y; |
return y; |
1745 |
} |
} |
1746 |
|
|
1747 |
|
/** |
1748 |
|
* Changes the instrument for an engine channel. |
1749 |
|
* |
1750 |
|
* @param pEngineChannel - engine channel on which the instrument |
1751 |
|
* should be changed |
1752 |
|
* @param pInstrument - new instrument |
1753 |
|
* @returns a list of dimension regions from the old instrument |
1754 |
|
* that are still in use |
1755 |
|
*/ |
1756 |
|
::gig::DimensionRegion** Engine::ChangeInstrument(EngineChannel* pEngineChannel, ::gig::Instrument* pInstrument) { |
1757 |
|
instrument_change_command_t command; |
1758 |
|
command.pEngineChannel = pEngineChannel; |
1759 |
|
command.pInstrument = pInstrument; |
1760 |
|
InstrumentChangeQueue->push(&command); |
1761 |
|
|
1762 |
|
// wait for the audio thread to confirm that the instrument |
1763 |
|
// change has been done |
1764 |
|
instrument_change_reply_t reply; |
1765 |
|
while (InstrumentChangeReplyQueue->pop(&reply) == 0) { |
1766 |
|
usleep(10000); |
1767 |
|
} |
1768 |
|
return pDimRegionsInUse; |
1769 |
|
} |
1770 |
|
|
1771 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |