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 * |
22 |
***************************************************************************/ |
***************************************************************************/ |
23 |
|
|
24 |
#include "EngineChannel.h" |
#include "EngineChannel.h" |
25 |
|
#include "../../network/lscpserver.h" |
26 |
|
|
27 |
namespace LinuxSampler { namespace gig { |
namespace LinuxSampler { namespace gig { |
28 |
|
|
31 |
pEngine = NULL; |
pEngine = NULL; |
32 |
pInstrument = NULL; |
pInstrument = NULL; |
33 |
pEvents = NULL; // we allocate when we retrieve the right Engine object |
pEvents = NULL; // we allocate when we retrieve the right Engine object |
34 |
pEventQueue = new RingBuffer<Event>(CONFIG_MAX_EVENTS_PER_FRAGMENT, 0); |
pEventQueue = new RingBuffer<Event,false>(CONFIG_MAX_EVENTS_PER_FRAGMENT, 0); |
35 |
pActiveKeys = new Pool<uint>(128); |
pActiveKeys = new Pool<uint>(128); |
36 |
for (uint i = 0; i < 128; i++) { |
for (uint i = 0; i < 128; i++) { |
37 |
pMIDIKeyInfo[i].pActiveVoices = NULL; // we allocate when we retrieve the right Engine object |
pMIDIKeyInfo[i].pActiveVoices = NULL; // we allocate when we retrieve the right Engine object |
44 |
} |
} |
45 |
InstrumentIdx = -1; |
InstrumentIdx = -1; |
46 |
InstrumentStat = -1; |
InstrumentStat = -1; |
47 |
|
pChannelLeft = NULL; |
48 |
|
pChannelRight = NULL; |
49 |
AudioDeviceChannelLeft = -1; |
AudioDeviceChannelLeft = -1; |
50 |
AudioDeviceChannelRight = -1; |
AudioDeviceChannelRight = -1; |
51 |
pMidiInputPort = NULL; |
pMidiInputPort = NULL; |
62 |
if (pEventQueue) delete pEventQueue; |
if (pEventQueue) delete pEventQueue; |
63 |
if (pActiveKeys) delete pActiveKeys; |
if (pActiveKeys) delete pActiveKeys; |
64 |
if (pMIDIKeyInfo) delete[] pMIDIKeyInfo; |
if (pMIDIKeyInfo) delete[] pMIDIKeyInfo; |
65 |
|
RemoveAllFxSends(); |
66 |
} |
} |
67 |
|
|
68 |
/** |
/** |
164 |
* @see PrepareLoadInstrument() |
* @see PrepareLoadInstrument() |
165 |
*/ |
*/ |
166 |
void EngineChannel::LoadInstrument() { |
void EngineChannel::LoadInstrument() { |
167 |
|
::gig::Instrument* oldInstrument = pInstrument; |
|
if (pEngine) pEngine->DisableAndLock(); |
|
|
|
|
|
ResetInternal(); |
|
168 |
|
|
169 |
// free old instrument |
// free old instrument |
170 |
if (pInstrument) { |
if (oldInstrument) { |
171 |
// give old instrument back to instrument manager |
if (pEngine) { |
172 |
Engine::instruments.HandBack(pInstrument, this); |
// make sure we don't trigger any new notes with the |
173 |
|
// old instrument |
174 |
|
::gig::DimensionRegion** dimRegionsInUse = pEngine->ChangeInstrument(this, 0); |
175 |
|
|
176 |
|
// give old instrument back to instrument manager, but |
177 |
|
// keep the dimension regions and samples that are in |
178 |
|
// use |
179 |
|
Engine::instruments.HandBackInstrument(oldInstrument, this, dimRegionsInUse); |
180 |
|
} else { |
181 |
|
Engine::instruments.HandBack(oldInstrument, this); |
182 |
|
} |
183 |
} |
} |
184 |
|
|
185 |
// delete all key groups |
// delete all key groups |
186 |
ActiveKeyGroups.clear(); |
ActiveKeyGroups.clear(); |
187 |
|
|
188 |
// request gig instrument from instrument manager |
// request gig instrument from instrument manager |
189 |
|
::gig::Instrument* newInstrument; |
190 |
try { |
try { |
191 |
instrument_id_t instrid; |
InstrumentManager::instrument_id_t instrid; |
192 |
instrid.FileName = InstrumentFile; |
instrid.FileName = InstrumentFile; |
193 |
instrid.iInstrument = InstrumentIdx; |
instrid.Index = InstrumentIdx; |
194 |
pInstrument = Engine::instruments.Borrow(instrid, this); |
newInstrument = Engine::instruments.Borrow(instrid, this); |
195 |
if (!pInstrument) { |
if (!newInstrument) { |
196 |
InstrumentStat = -1; |
throw InstrumentResourceManagerException("resource was not created"); |
|
dmsg(1,("no instrument loaded!!!\n")); |
|
|
exit(EXIT_FAILURE); |
|
197 |
} |
} |
198 |
} |
} |
199 |
catch (RIFF::Exception e) { |
catch (RIFF::Exception e) { |
212 |
} |
} |
213 |
|
|
214 |
// rebuild ActiveKeyGroups map with key groups of current instrument |
// rebuild ActiveKeyGroups map with key groups of current instrument |
215 |
for (::gig::Region* pRegion = pInstrument->GetFirstRegion(); pRegion; pRegion = pInstrument->GetNextRegion()) |
for (::gig::Region* pRegion = newInstrument->GetFirstRegion(); pRegion; pRegion = newInstrument->GetNextRegion()) |
216 |
if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL; |
if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL; |
217 |
|
|
218 |
InstrumentIdxName = pInstrument->pInfo->Name; |
InstrumentIdxName = newInstrument->pInfo->Name; |
219 |
InstrumentStat = 100; |
InstrumentStat = 100; |
220 |
|
|
221 |
// inform audio driver for the need of two channels |
if (pEngine) pEngine->ChangeInstrument(this, newInstrument); |
222 |
try { |
else pInstrument = newInstrument; |
|
if (pEngine && pEngine->pAudioOutputDevice) |
|
|
pEngine->pAudioOutputDevice->AcquireChannels(2); // gig Engine only stereo |
|
|
} |
|
|
catch (AudioOutputException e) { |
|
|
String msg = "Audio output device unable to provide 2 audio channels, cause: " + e.Message(); |
|
|
throw Exception(msg); |
|
|
} |
|
|
|
|
|
if (pEngine) pEngine->Enable(); |
|
223 |
} |
} |
224 |
|
|
225 |
/** |
/** |
270 |
} |
} |
271 |
AudioDeviceChannelLeft = 0; |
AudioDeviceChannelLeft = 0; |
272 |
AudioDeviceChannelRight = 1; |
AudioDeviceChannelRight = 1; |
273 |
pOutputLeft = pAudioOut->Channel(0)->Buffer(); |
if (fxSends.empty()) { // render directly into the AudioDevice's output buffers |
274 |
pOutputRight = pAudioOut->Channel(1)->Buffer(); |
pChannelLeft = pAudioOut->Channel(AudioDeviceChannelLeft); |
275 |
|
pChannelRight = pAudioOut->Channel(AudioDeviceChannelRight); |
276 |
|
} else { // use local buffers for rendering and copy later |
277 |
|
// ensure the local buffers have the correct size |
278 |
|
if (pChannelLeft) delete pChannelLeft; |
279 |
|
if (pChannelRight) delete pChannelRight; |
280 |
|
pChannelLeft = new AudioChannel(0, pAudioOut->MaxSamplesPerCycle()); |
281 |
|
pChannelRight = new AudioChannel(1, pAudioOut->MaxSamplesPerCycle()); |
282 |
|
} |
283 |
|
if (pEngine->EngineDisabled.GetUnsafe()) pEngine->Enable(); |
284 |
MidiInputPort::AddSysexListener(pEngine); |
MidiInputPort::AddSysexListener(pEngine); |
285 |
} |
} |
286 |
|
|
307 |
Engine::FreeEngine(this, oldAudioDevice); |
Engine::FreeEngine(this, oldAudioDevice); |
308 |
AudioDeviceChannelLeft = -1; |
AudioDeviceChannelLeft = -1; |
309 |
AudioDeviceChannelRight = -1; |
AudioDeviceChannelRight = -1; |
310 |
|
if (!fxSends.empty()) { // free the local rendering buffers |
311 |
|
if (pChannelLeft) delete pChannelLeft; |
312 |
|
if (pChannelRight) delete pChannelRight; |
313 |
|
} |
314 |
|
pChannelLeft = NULL; |
315 |
|
pChannelRight = NULL; |
316 |
} |
} |
317 |
} |
} |
318 |
|
|
319 |
|
AudioOutputDevice* EngineChannel::GetAudioOutputDevice() { |
320 |
|
return (pEngine) ? pEngine->pAudioOutputDevice : NULL; |
321 |
|
} |
322 |
|
|
323 |
void EngineChannel::SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) { |
void EngineChannel::SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) { |
324 |
if (!pEngine || !pEngine->pAudioOutputDevice) throw AudioOutputException("No audio output device connected yet."); |
if (!pEngine || !pEngine->pAudioOutputDevice) throw AudioOutputException("No audio output device connected yet."); |
325 |
|
|
327 |
if (!pChannel) throw AudioOutputException("Invalid audio output device channel " + ToString(AudioDeviceChannel)); |
if (!pChannel) throw AudioOutputException("Invalid audio output device channel " + ToString(AudioDeviceChannel)); |
328 |
switch (EngineAudioChannel) { |
switch (EngineAudioChannel) { |
329 |
case 0: // left output channel |
case 0: // left output channel |
330 |
pOutputLeft = pChannel->Buffer(); |
if (fxSends.empty()) pChannelLeft = pChannel; |
331 |
AudioDeviceChannelLeft = AudioDeviceChannel; |
AudioDeviceChannelLeft = AudioDeviceChannel; |
332 |
break; |
break; |
333 |
case 1: // right output channel |
case 1: // right output channel |
334 |
pOutputRight = pChannel->Buffer(); |
if (fxSends.empty()) pChannelRight = pChannel; |
335 |
AudioDeviceChannelRight = AudioDeviceChannel; |
AudioDeviceChannelRight = AudioDeviceChannel; |
336 |
break; |
break; |
337 |
default: |
default: |
372 |
return midiChannel; |
return midiChannel; |
373 |
} |
} |
374 |
|
|
375 |
|
FxSend* EngineChannel::AddFxSend(uint8_t MidiCtrl, String Name) throw (Exception) { |
376 |
|
if (pEngine) pEngine->DisableAndLock(); |
377 |
|
FxSend* pFxSend = new FxSend(this, MidiCtrl, Name); |
378 |
|
if (fxSends.empty()) { |
379 |
|
if (pEngine && pEngine->pAudioOutputDevice) { |
380 |
|
AudioOutputDevice* pDevice = pEngine->pAudioOutputDevice; |
381 |
|
// create local render buffers |
382 |
|
pChannelLeft = new AudioChannel(0, pDevice->MaxSamplesPerCycle()); |
383 |
|
pChannelRight = new AudioChannel(1, pDevice->MaxSamplesPerCycle()); |
384 |
|
} else { |
385 |
|
// postpone local render buffer creation until audio device is assigned |
386 |
|
pChannelLeft = NULL; |
387 |
|
pChannelRight = NULL; |
388 |
|
} |
389 |
|
} |
390 |
|
fxSends.push_back(pFxSend); |
391 |
|
if (pEngine) pEngine->Enable(); |
392 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_count, iSamplerChannelIndex, GetFxSendCount())); |
393 |
|
return pFxSend; |
394 |
|
} |
395 |
|
|
396 |
|
FxSend* EngineChannel::GetFxSend(uint FxSendIndex) { |
397 |
|
return (FxSendIndex < fxSends.size()) ? fxSends[FxSendIndex] : NULL; |
398 |
|
} |
399 |
|
|
400 |
|
uint EngineChannel::GetFxSendCount() { |
401 |
|
return fxSends.size(); |
402 |
|
} |
403 |
|
|
404 |
|
void EngineChannel::RemoveFxSend(FxSend* pFxSend) { |
405 |
|
if (pEngine) pEngine->DisableAndLock(); |
406 |
|
for ( |
407 |
|
std::vector<FxSend*>::iterator iter = fxSends.begin(); |
408 |
|
iter != fxSends.end(); iter++ |
409 |
|
) { |
410 |
|
if (*iter == pFxSend) { |
411 |
|
delete pFxSend; |
412 |
|
fxSends.erase(iter); |
413 |
|
if (fxSends.empty()) { |
414 |
|
// destroy local render buffers |
415 |
|
if (pChannelLeft) delete pChannelLeft; |
416 |
|
if (pChannelRight) delete pChannelRight; |
417 |
|
// fallback to render directly into AudioOutputDevice's buffers |
418 |
|
if (pEngine && pEngine->pAudioOutputDevice) { |
419 |
|
pChannelLeft = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelLeft); |
420 |
|
pChannelRight = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelRight); |
421 |
|
} else { // we update the pointers later |
422 |
|
pChannelLeft = NULL; |
423 |
|
pChannelRight = NULL; |
424 |
|
} |
425 |
|
} |
426 |
|
break; |
427 |
|
} |
428 |
|
} |
429 |
|
if (pEngine) pEngine->Enable(); |
430 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_count, iSamplerChannelIndex, GetFxSendCount())); |
431 |
|
} |
432 |
|
|
433 |
/** |
/** |
434 |
* Will be called by the MIDIIn Thread to let the audio thread trigger a new |
* Will be called by the MIDIIn Thread to let the audio thread trigger a new |
435 |
* voice for the given key. |
* voice for the given key. This method is meant for real time rendering, |
436 |
|
* that is an event will immediately be created with the current system |
437 |
|
* time as time stamp. |
438 |
* |
* |
439 |
* @param Key - MIDI key number of the triggered key |
* @param Key - MIDI key number of the triggered key |
440 |
* @param Velocity - MIDI velocity value of the triggered key |
* @param Velocity - MIDI velocity value of the triggered key |
452 |
} |
} |
453 |
|
|
454 |
/** |
/** |
455 |
|
* Will be called by the MIDIIn Thread to let the audio thread trigger a new |
456 |
|
* voice for the given key. This method is meant for offline rendering |
457 |
|
* and / or for cases where the exact position of the event in the current |
458 |
|
* audio fragment is already known. |
459 |
|
* |
460 |
|
* @param Key - MIDI key number of the triggered key |
461 |
|
* @param Velocity - MIDI velocity value of the triggered key |
462 |
|
* @param FragmentPos - sample point position in the current audio |
463 |
|
* fragment to which this event belongs to |
464 |
|
*/ |
465 |
|
void EngineChannel::SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) { |
466 |
|
if (FragmentPos < 0) { |
467 |
|
dmsg(1,("EngineChannel::SendNoteOn(): negative FragmentPos! Seems MIDI driver is buggy!")); |
468 |
|
} |
469 |
|
else if (pEngine) { |
470 |
|
Event event = pEngine->pEventGenerator->CreateEvent(FragmentPos); |
471 |
|
event.Type = Event::type_note_on; |
472 |
|
event.Param.Note.Key = Key; |
473 |
|
event.Param.Note.Velocity = Velocity; |
474 |
|
event.pEngineChannel = this; |
475 |
|
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
476 |
|
else dmsg(1,("EngineChannel: Input event queue full!")); |
477 |
|
} |
478 |
|
} |
479 |
|
|
480 |
|
/** |
481 |
* Will be called by the MIDIIn Thread to signal the audio thread to release |
* Will be called by the MIDIIn Thread to signal the audio thread to release |
482 |
* voice(s) on the given key. |
* voice(s) on the given key. This method is meant for real time rendering, |
483 |
|
* that is an event will immediately be created with the current system |
484 |
|
* time as time stamp. |
485 |
* |
* |
486 |
* @param Key - MIDI key number of the released key |
* @param Key - MIDI key number of the released key |
487 |
* @param Velocity - MIDI release velocity value of the released key |
* @param Velocity - MIDI release velocity value of the released key |
499 |
} |
} |
500 |
|
|
501 |
/** |
/** |
502 |
|
* Will be called by the MIDIIn Thread to signal the audio thread to release |
503 |
|
* voice(s) on the given key. This method is meant for offline rendering |
504 |
|
* and / or for cases where the exact position of the event in the current |
505 |
|
* audio fragment is already known. |
506 |
|
* |
507 |
|
* @param Key - MIDI key number of the released key |
508 |
|
* @param Velocity - MIDI release velocity value of the released key |
509 |
|
* @param FragmentPos - sample point position in the current audio |
510 |
|
* fragment to which this event belongs to |
511 |
|
*/ |
512 |
|
void EngineChannel::SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) { |
513 |
|
if (FragmentPos < 0) { |
514 |
|
dmsg(1,("EngineChannel::SendNoteOff(): negative FragmentPos! Seems MIDI driver is buggy!")); |
515 |
|
} |
516 |
|
else if (pEngine) { |
517 |
|
Event event = pEngine->pEventGenerator->CreateEvent(FragmentPos); |
518 |
|
event.Type = Event::type_note_off; |
519 |
|
event.Param.Note.Key = Key; |
520 |
|
event.Param.Note.Velocity = Velocity; |
521 |
|
event.pEngineChannel = this; |
522 |
|
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
523 |
|
else dmsg(1,("EngineChannel: Input event queue full!")); |
524 |
|
} |
525 |
|
} |
526 |
|
|
527 |
|
/** |
528 |
* Will be called by the MIDIIn Thread to signal the audio thread to change |
* Will be called by the MIDIIn Thread to signal the audio thread to change |
529 |
* the pitch value for all voices. |
* the pitch value for all voices. This method is meant for real time |
530 |
|
* rendering, that is an event will immediately be created with the |
531 |
|
* current system time as time stamp. |
532 |
* |
* |
533 |
* @param Pitch - MIDI pitch value (-8192 ... +8191) |
* @param Pitch - MIDI pitch value (-8192 ... +8191) |
534 |
*/ |
*/ |
544 |
} |
} |
545 |
|
|
546 |
/** |
/** |
547 |
|
* Will be called by the MIDIIn Thread to signal the audio thread to change |
548 |
|
* the pitch value for all voices. This method is meant for offline |
549 |
|
* rendering and / or for cases where the exact position of the event in |
550 |
|
* the current audio fragment is already known. |
551 |
|
* |
552 |
|
* @param Pitch - MIDI pitch value (-8192 ... +8191) |
553 |
|
* @param FragmentPos - sample point position in the current audio |
554 |
|
* fragment to which this event belongs to |
555 |
|
*/ |
556 |
|
void EngineChannel::SendPitchbend(int Pitch, int32_t FragmentPos) { |
557 |
|
if (FragmentPos < 0) { |
558 |
|
dmsg(1,("EngineChannel::SendPitchBend(): negative FragmentPos! Seems MIDI driver is buggy!")); |
559 |
|
} |
560 |
|
else if (pEngine) { |
561 |
|
Event event = pEngine->pEventGenerator->CreateEvent(FragmentPos); |
562 |
|
event.Type = Event::type_pitchbend; |
563 |
|
event.Param.Pitch.Pitch = Pitch; |
564 |
|
event.pEngineChannel = this; |
565 |
|
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
566 |
|
else dmsg(1,("EngineChannel: Input event queue full!")); |
567 |
|
} |
568 |
|
} |
569 |
|
|
570 |
|
/** |
571 |
* Will be called by the MIDIIn Thread to signal the audio thread that a |
* Will be called by the MIDIIn Thread to signal the audio thread that a |
572 |
* continuous controller value has changed. |
* continuous controller value has changed. This method is meant for real |
573 |
|
* time rendering, that is an event will immediately be created with the |
574 |
|
* current system time as time stamp. |
575 |
* |
* |
576 |
* @param Controller - MIDI controller number of the occured control change |
* @param Controller - MIDI controller number of the occured control change |
577 |
* @param Value - value of the control change |
* @param Value - value of the control change |
588 |
} |
} |
589 |
} |
} |
590 |
|
|
591 |
|
/** |
592 |
|
* Will be called by the MIDIIn Thread to signal the audio thread that a |
593 |
|
* continuous controller value has changed. This method is meant for |
594 |
|
* offline rendering and / or for cases where the exact position of the |
595 |
|
* event in the current audio fragment is already known. |
596 |
|
* |
597 |
|
* @param Controller - MIDI controller number of the occured control change |
598 |
|
* @param Value - value of the control change |
599 |
|
* @param FragmentPos - sample point position in the current audio |
600 |
|
* fragment to which this event belongs to |
601 |
|
*/ |
602 |
|
void EngineChannel::SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos) { |
603 |
|
if (FragmentPos < 0) { |
604 |
|
dmsg(1,("EngineChannel::SendControlChange(): negative FragmentPos! Seems MIDI driver is buggy!")); |
605 |
|
} |
606 |
|
else if (pEngine) { |
607 |
|
Event event = pEngine->pEventGenerator->CreateEvent(FragmentPos); |
608 |
|
event.Type = Event::type_control_change; |
609 |
|
event.Param.CC.Controller = Controller; |
610 |
|
event.Param.CC.Value = Value; |
611 |
|
event.pEngineChannel = this; |
612 |
|
if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event); |
613 |
|
else dmsg(1,("EngineChannel: Input event queue full!")); |
614 |
|
} |
615 |
|
} |
616 |
|
|
617 |
void EngineChannel::ClearEventLists() { |
void EngineChannel::ClearEventLists() { |
618 |
pEvents->clear(); |
pEvents->clear(); |
619 |
// empty MIDI key specific event lists |
// empty MIDI key specific event lists |
630 |
Pitch = 0; |
Pitch = 0; |
631 |
SustainPedal = false; |
SustainPedal = false; |
632 |
SostenutoPedal = false; |
SostenutoPedal = false; |
633 |
GlobalVolume = CONFIG_GLOBAL_ATTENUATION; |
GlobalVolume = 1.0f; |
634 |
|
MidiVolume = 1.0; |
635 |
GlobalPanLeft = 1.0f; |
GlobalPanLeft = 1.0f; |
636 |
GlobalPanRight = 1.0f; |
GlobalPanRight = 1.0f; |
637 |
|
GlobalTranspose = 0; |
638 |
// set all MIDI controller values to zero |
// set all MIDI controller values to zero |
639 |
memset(ControllerTable, 0x00, 128); |
memset(ControllerTable, 0x00, 129); |
640 |
|
// reset all FX Send levels |
641 |
|
for ( |
642 |
|
std::vector<FxSend*>::iterator iter = fxSends.begin(); |
643 |
|
iter != fxSends.end(); iter++ |
644 |
|
) { |
645 |
|
(*iter)->Reset(); |
646 |
|
} |
647 |
} |
} |
648 |
|
|
649 |
/** |
/** |
660 |
* current audio cycle |
* current audio cycle |
661 |
*/ |
*/ |
662 |
void EngineChannel::ImportEvents(uint Samples) { |
void EngineChannel::ImportEvents(uint Samples) { |
663 |
RingBuffer<Event>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader(); |
RingBuffer<Event,false>::NonVolatileReader eventQueueReader = pEventQueue->get_non_volatile_reader(); |
664 |
Event* pEvent; |
Event* pEvent; |
665 |
while (true) { |
while (true) { |
666 |
// get next event from input event queue |
// get next event from input event queue |
682 |
eventQueueReader.free(); // free all copied events from input queue |
eventQueueReader.free(); // free all copied events from input queue |
683 |
} |
} |
684 |
|
|
685 |
|
void EngineChannel::RemoveAllFxSends() { |
686 |
|
if (pEngine) pEngine->DisableAndLock(); |
687 |
|
if (!fxSends.empty()) { // free local render buffers |
688 |
|
if (pChannelLeft) { |
689 |
|
delete pChannelLeft; |
690 |
|
if (pEngine && pEngine->pAudioOutputDevice) { |
691 |
|
// fallback to render directly to the AudioOutputDevice's buffer |
692 |
|
pChannelLeft = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelLeft); |
693 |
|
} else pChannelLeft = NULL; |
694 |
|
} |
695 |
|
if (pChannelRight) { |
696 |
|
delete pChannelRight; |
697 |
|
if (pEngine && pEngine->pAudioOutputDevice) { |
698 |
|
// fallback to render directly to the AudioOutputDevice's buffer |
699 |
|
pChannelRight = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannelRight); |
700 |
|
} else pChannelRight = NULL; |
701 |
|
} |
702 |
|
} |
703 |
|
for (int i = 0; i < fxSends.size(); i++) delete fxSends[i]; |
704 |
|
fxSends.clear(); |
705 |
|
if (pEngine) pEngine->Enable(); |
706 |
|
} |
707 |
|
|
708 |
float EngineChannel::Volume() { |
float EngineChannel::Volume() { |
709 |
return GlobalVolume; |
return GlobalVolume; |
710 |
} |
} |