12LiquidSFZPlugin::RTMutex::try_lock()
14 return !locked_flag.test_and_set();
19LiquidSFZPlugin::RTMutex::wait_for_lock()
26 constexpr int fps = 240;
32LiquidSFZPlugin::RTMutex::unlock()
37LiquidSFZPlugin::LiquidSFZPlugin (tracktion::PluginCreationInfo info) : Plugin (info)
43LiquidSFZPlugin::load (
const String& filename)
45 rt_mutex_.wait_for_lock();
48 if (synth_.is_bank (filename))
49 result = synth_.load_bank (filename) && synth_.select_program (0);
51 result = synth_.load (filename);
68LiquidSFZPlugin::initialise (
const tracktion::PluginInitialisationInfo& info)
70 rt_mutex_.wait_for_lock();
71 synth_.set_sample_rate (info.sampleRate);
72 synth_.all_sound_off();
77LiquidSFZPlugin::deinitialise()
79 rt_mutex_.wait_for_lock();
80 synth_.all_sound_off();
85LiquidSFZPlugin::applyToBuffer (
const tracktion::PluginRenderContext& fc)
87 if (fc.destBuffer !=
nullptr)
94 if (!rt_mutex_.try_lock())
96 tracktion::clearChannels (*fc.destBuffer, 0, -1, fc.bufferStartSample, fc.bufferNumSamples);
100 tracktion::clearChannels (*fc.destBuffer, 2, -1, fc.bufferStartSample, fc.bufferNumSamples);
101 if (fc.bufferForMidiMessages !=
nullptr)
103 for (
auto& m : *fc.bufferForMidiMessages)
105 int channel = m.getChannel();
112 const int note = m.getNoteNumber();
115 synth_.add_event_note_on (noteTimeSample, channel, note, m.getVelocity());
117 else if (m.isNoteOff())
119 const int note = m.getNoteNumber();
122 synth_.add_event_note_off (noteTimeSample, channel, note);
124 else if (m.isAllNotesOff() || m.isAllSoundOff())
126 synth_.all_sound_off();
149 float *
left = fc.destBuffer->getWritePointer (0, fc.bufferStartSample);
150 float *
right = fc.destBuffer->getWritePointer (1, fc.bufferStartSample);
153 synth_.process (output, fc.bufferNumSamples);
159const char* LiquidSFZPlugin::xmlTypeName =
"liquidsfz";
The Anklang C++ API namespace.
int roundToInt(const FloatType value) noexcept