diff --git a/source/backend/CarlaNative.h b/source/backend/CarlaNative.h index 5de22fea2..c3e210586 100644 --- a/source/backend/CarlaNative.h +++ b/source/backend/CarlaNative.h @@ -193,37 +193,32 @@ typedef struct _PluginDescriptor { // ----------------------------------------------------------------------- -// Register single plugin (plugin-side) +// Register plugin void carla_register_native_plugin(const PluginDescriptor* desc); -// Register all plugins (host-side) -static inline -void carla_register_all_plugins() -{ - // Simple plugins - void carla_register_native_plugin_bypass(); - void carla_register_native_plugin_midiSequencer(); - void carla_register_native_plugin_midiSplit(); - void carla_register_native_plugin_midiThrough(); - void carla_register_native_plugin_midiTranspose(); - void carla_register_native_plugin_nekofilter(); - - // DISTRHO plugins - void carla_register_native_plugin_3BandEQ(); - void carla_register_native_plugin_3BandSplitter(); - void carla_register_native_plugin_PingPongPan(); - void carla_register_native_plugin_Notes(); +// Simple plugins +void carla_register_native_plugin_bypass(); +void carla_register_native_plugin_midiSequencer(); +void carla_register_native_plugin_midiSplit(); +void carla_register_native_plugin_midiThrough(); +void carla_register_native_plugin_midiTranspose(); +void carla_register_native_plugin_nekofilter(); + +// DISTRHO plugins +void carla_register_native_plugin_3BandEQ(); +void carla_register_native_plugin_3BandSplitter(); +void carla_register_native_plugin_PingPongPan(); +void carla_register_native_plugin_Notes(); #ifdef WANT_AUDIOFILE - // AudioFile - void carla_register_native_plugin_audiofile(); +// AudioFile +void carla_register_native_plugin_audiofile(); #endif #ifdef WANT_ZYNADDSUBFX - // ZynAddSubFX - void carla_register_native_plugin_zynaddsubfx(); +// ZynAddSubFX +void carla_register_native_plugin_zynaddsubfx(); #endif -} // ----------------------------------------------------------------------- diff --git a/source/backend/Makefile.mk b/source/backend/Makefile.mk index daaa25b5f..ee8db431f 100644 --- a/source/backend/Makefile.mk +++ b/source/backend/Makefile.mk @@ -8,11 +8,11 @@ include ../../Makefile.mk # -------------------------------------------------------------- -BASE_FLAGS = -pthread -fvisibility=hidden -fPIC -I. -I.. -I../../includes -BASE_FLAGS += $(shell pkg-config --cflags gl) +BACKEND_FLAGS = -pthread -fvisibility=hidden -fPIC -I. -I.. -I../../includes +BACKEND_FLAGS += $(shell pkg-config --cflags gl) -BUILD_C_FLAGS += $(BASE_FLAGS) -BUILD_CXX_FLAGS += $(BASE_FLAGS) -I../../libs -I../../libs/distrho -I../../utils +BUILD_C_FLAGS += $(BACKEND_FLAGS) +BUILD_CXX_FLAGS += $(BACKEND_FLAGS) -I../../libs -I../../libs/distrho -I../../utils LINK_FLAGS += $(shell pkg-config --libs gl) -lpthread # -------------------------------------------------------------- diff --git a/source/backend/native/zynaddsubfx.cpp b/source/backend/native/zynaddsubfx.cpp index 09788cac9..2cd47316d 100644 --- a/source/backend/native/zynaddsubfx.cpp +++ b/source/backend/native/zynaddsubfx.cpp @@ -50,40 +50,41 @@ public: ZynAddSubFxPlugin(const HostDescriptor* const host) : PluginDescriptorClass(host), - m_master(new Master) + kMaster(new Master()), + kSampleRate(getSampleRate()) { // refresh banks - m_master->bank.rescanforbanks(); + kMaster->bank.rescanforbanks(); - for (uint32_t i=0, size = m_master->bank.banks.size(); i < size; i++) + for (uint32_t i=0, size = kMaster->bank.banks.size(); i < size; i++) { - if (m_master->bank.banks[i].dir.empty()) + if (kMaster->bank.banks[i].dir.empty()) continue; - m_master->bank.loadbank(m_master->bank.banks[i].dir); + kMaster->bank.loadbank(kMaster->bank.banks[i].dir); for (unsigned int instrument = 0; instrument < BANK_SIZE; instrument++) { - const std::string insName(m_master->bank.getname(instrument)); + const std::string insName(kMaster->bank.getname(instrument)); if (insName.empty() || insName[0] == '\0' || insName[0] == ' ') continue; ProgramInfo pInfo(i, instrument, insName.c_str()); - m_programs.push_back(pInfo); + fPrograms.push_back(pInfo); } } } ~ZynAddSubFxPlugin() { - //ensure that everything has stopped with the mutex wait - pthread_mutex_lock(&m_master->mutex); - pthread_mutex_unlock(&m_master->mutex); + //ensure that everything has stopped + pthread_mutex_lock(&kMaster->mutex); + pthread_mutex_unlock(&kMaster->mutex); - m_programs.clear(); + fPrograms.clear(); - delete m_master; + delete kMaster; } protected: @@ -135,7 +136,7 @@ protected: { #if 0 case PARAMETER_MASTER: - return m_master->Pvolume; + return kMaster->Pvolume; #endif default: return 0.0f; @@ -147,17 +148,17 @@ protected: uint32_t getMidiProgramCount() { - return m_programs.size(); + return fPrograms.size(); } const MidiProgram* getMidiProgramInfo(const uint32_t index) { CARLA_ASSERT(index < getMidiProgramCount()); - if (index >= m_programs.size()) + if (index >= fPrograms.size()) return nullptr; - const ProgramInfo& pInfo(m_programs[index]); + const ProgramInfo& pInfo(fPrograms[index]); static MidiProgram midiProgram; midiProgram.bank = pInfo.bank; @@ -186,21 +187,21 @@ protected: void setMidiProgram(const uint32_t bank, const uint32_t program) { - if (bank >= m_master->bank.banks.size()) + if (bank >= kMaster->bank.banks.size()) return; if (program >= BANK_SIZE) return; - const std::string bankdir(m_master->bank.banks[bank].dir); + const std::string bankdir(kMaster->bank.banks[bank].dir); if (! bankdir.empty()) { - pthread_mutex_lock(&m_master->mutex); + pthread_mutex_lock(&kMaster->mutex); - m_master->bank.loadbank(bankdir); - m_master->bank.loadfromslot(program, m_master->part[0]); + kMaster->bank.loadbank(bankdir); + kMaster->bank.loadfromslot(program, kMaster->part[0]); - pthread_mutex_unlock(&m_master->mutex); + pthread_mutex_unlock(&kMaster->mutex); } } @@ -209,81 +210,50 @@ protected: void activate() { - m_master->setController(0, MIDI_CONTROL_ALL_SOUND_OFF, 0); + kMaster->setController(0, MIDI_CONTROL_ALL_SOUND_OFF, 0); } void process(float**, float** const outBuffer, const uint32_t frames, const uint32_t midiEventCount, const MidiEvent* const midiEvents) { - if (pthread_mutex_trylock(&m_master->mutex) != 0) + if (pthread_mutex_trylock(&kMaster->mutex) != 0) { carla_zeroFloat(outBuffer[0], frames); carla_zeroFloat(outBuffer[1], frames); return; } - uint32_t fromFrame = 0; - uint32_t eventIndex = 0; - uint32_t nextEventFrame = 0; - uint32_t toFrame = 0; - - do { - // Find the time of the next event, if any - if (eventIndex >= midiEventCount) - nextEventFrame = UINT32_MAX; - else - nextEventFrame = midiEvents[eventIndex].time; - - // find the end of the sub-sample to be processed this time round... - // if the next event falls within the desired sample interval... - if ((nextEventFrame < frames) && (nextEventFrame >= toFrame)) - // set the end to be at that event - toFrame = nextEventFrame; - else - // ...else go for the whole remaining sample - toFrame = frames; - - if (fromFrame < toFrame) + for (uint32_t i=0; i < midiEventCount; i++) + { + const MidiEvent* const midiEvent = &midiEvents[i]; + + const uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent->data); + const uint8_t channel = MIDI_GET_CHANNEL_FROM_DATA(midiEvent->data); + + if (MIDI_IS_STATUS_NOTE_OFF(status)) { - // call master to fill from `fromFrame` to `toFrame`: - m_master->GetAudioOutSamples(toFrame - fromFrame, (unsigned)getSampleRate(), &outBuffer[0][fromFrame], &outBuffer[1][fromFrame]); - // next sub-sample please... - fromFrame = toFrame; + const uint8_t note = midiEvent->data[1]; + + kMaster->noteOff(channel, note); } + else if (MIDI_IS_STATUS_NOTE_ON(status)) + { + const uint8_t note = midiEvent->data[1]; + const uint8_t velo = midiEvent->data[2]; - // Now process any event(s) at the current timing point - while (eventIndex < midiEventCount && midiEvents[eventIndex].time == toFrame) + kMaster->noteOn(channel, note, velo); + } + else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status)) { - const uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvents[eventIndex].data); - const uint8_t channel = MIDI_GET_CHANNEL_FROM_DATA(midiEvents[eventIndex].data); - - if (MIDI_IS_STATUS_NOTE_OFF(status)) - { - const uint8_t note = midiEvents[eventIndex].data[1]; - - m_master->noteOff(channel, note); - } - else if (MIDI_IS_STATUS_NOTE_ON(status)) - { - const uint8_t note = midiEvents[eventIndex].data[1]; - const uint8_t velo = midiEvents[eventIndex].data[2]; - - m_master->noteOn(channel, note, velo); - } - else if (MIDI_IS_STATUS_POLYPHONIC_AFTERTOUCH(status)) - { - const uint8_t note = midiEvents[eventIndex].data[1]; - const uint8_t pressure = midiEvents[eventIndex].data[2]; - - m_master->polyphonicAftertouch(channel, note, pressure); - } - - eventIndex++; + const uint8_t note = midiEvent->data[1]; + const uint8_t pressure = midiEvent->data[2]; + + kMaster->polyphonicAftertouch(channel, note, pressure); } + } - // Keep going until we have the desired total length of sample... - } while (toFrame < frames); + kMaster->GetAudioOutSamples(frames, kSampleRate, outBuffer[0], outBuffer[1]); - pthread_mutex_unlock(&m_master->mutex); + pthread_mutex_unlock(&kMaster->mutex); } // ------------------------------------------------------------------- @@ -302,16 +272,17 @@ private: ProgramInfo() = delete; }; - std::vector m_programs; + std::vector fPrograms; - Master* const m_master; + Master* const kMaster; + const unsigned kSampleRate; public: - static int s_instanceCount; + static int sInstanceCount; static PluginHandle _instantiate(const PluginDescriptor*, HostDescriptor* host) { - if (s_instanceCount++ == 0) + if (sInstanceCount++ == 0) { synth = new SYNTH_T; synth->buffersize = host->get_buffer_size(host->handle); @@ -336,7 +307,7 @@ public: { delete (ZynAddSubFxPlugin*)handle; - if (--s_instanceCount == 0) + if (--sInstanceCount == 0) { delete[] denormalkillbuf; denormalkillbuf = nullptr; @@ -349,7 +320,7 @@ public: CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ZynAddSubFxPlugin) }; -int ZynAddSubFxPlugin::s_instanceCount = 0; +int ZynAddSubFxPlugin::sInstanceCount = 0; // ----------------------------------------------------------------------- diff --git a/source/backend/native/zynaddsubfx/Misc/Master.cpp b/source/backend/native/zynaddsubfx/Misc/Master.cpp index c3321b120..1f96672c2 100644 --- a/source/backend/native/zynaddsubfx/Misc/Master.cpp +++ b/source/backend/native/zynaddsubfx/Misc/Master.cpp @@ -490,6 +490,7 @@ void Master::GetAudioOutSamples(size_t nsamples, if(nsamples >= smps) { memcpy(outl + out_off, bufl + off, sizeof(float) * smps); memcpy(outr + out_off, bufr + off, sizeof(float) * smps); + nsamples -= smps; //generate samples AudioOut(bufl, bufr); @@ -497,7 +498,6 @@ void Master::GetAudioOutSamples(size_t nsamples, smps = synth->buffersize; out_off += smps; - nsamples -= smps; } else { //use some samples memcpy(outl + out_off, bufl + off, sizeof(float) * nsamples); diff --git a/source/backend/native/zynaddsubfx/Output/DSSIaudiooutput.cpp b/source/backend/native/zynaddsubfx/Output/DSSIaudiooutput.cpp index 1499792f3..e9cea86a6 100644 --- a/source/backend/native/zynaddsubfx/Output/DSSIaudiooutput.cpp +++ b/source/backend/native/zynaddsubfx/Output/DSSIaudiooutput.cpp @@ -629,6 +629,7 @@ DSSIaudiooutput::DSSIaudiooutput(unsigned long sampleRate) for(int i = 0; i < synth->buffersize; i++) denormalkillbuf[i] = (RND - 0.5f) * 1e-16; + synth->alias(); this->master = new Master(); } diff --git a/source/backend/plugin/NativePlugin.cpp b/source/backend/plugin/NativePlugin.cpp index cbc717f4a..d196c0975 100644 --- a/source/backend/plugin/NativePlugin.cpp +++ b/source/backend/plugin/NativePlugin.cpp @@ -23,6 +23,33 @@ #include +void carla_register_all_plugins() +{ + // Simple plugins + carla_register_native_plugin_bypass(); + carla_register_native_plugin_midiSequencer(); + carla_register_native_plugin_midiSplit(); + carla_register_native_plugin_midiThrough(); + carla_register_native_plugin_midiTranspose(); + carla_register_native_plugin_nekofilter(); + + // DISTRHO plugins + carla_register_native_plugin_3BandEQ(); + carla_register_native_plugin_3BandSplitter(); + carla_register_native_plugin_PingPongPan(); + carla_register_native_plugin_Notes(); + +#ifdef WANT_AUDIOFILE + // AudioFile + carla_register_native_plugin_audiofile(); +#endif + +#ifdef WANT_ZYNADDSUBFX + // ZynAddSubFX + carla_register_native_plugin_zynaddsubfx(); +#endif +} + CARLA_BACKEND_START_NAMESPACE struct NativePluginMidiData { @@ -224,16 +251,17 @@ public: if (fDescriptor->name != nullptr) { - if (std::strcmp(fDescriptor->name, "ZynAddSubFX") == 0) - { - // nothing - } - else - { - options |= PLUGIN_OPTION_FIXED_BUFFER; - } +// if (std::strcmp(fDescriptor->name, "ZynAddSubFX") == 0) +// { +// // nothing +// } +// else +// { + +// } } + options |= PLUGIN_OPTION_FIXED_BUFFER; options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES; //if ((kData->audioIns.count() == 1 || kData->audioOuts.count() == 0) || (kData->audioIns.count() == 0 || kData->audioOuts.count() == 1)) @@ -910,14 +938,6 @@ public: // plugin options fOptions = 0x0; - if (fDescriptor->name != nullptr) - { - if (std::strcmp(fDescriptor->name, "ZynAddSubFX") == 0) - { - fOptions |= PLUGIN_OPTION_FIXED_BUFFER; - } - } - fOptions |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES; if (forcedStereoIn || forcedStereoOut) diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index 745f2c66f..a5e947fab 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -91,6 +91,10 @@ const char* carla_get_extended_license_text() retText += "
  • VST plugin support, using official VST SDK 2.4 (trademark of Steinberg Media Technologies GmbH)
  • "; # endif #endif +#ifdef WANT_AUDIOFILE + // TODO + //retText += "
  • ZynAddSubFX plugin code, http://zynaddsubfx.sf.net/
  • "; +#endif #ifdef WANT_ZYNADDSUBFX retText += "
  • ZynAddSubFX plugin code, http://zynaddsubfx.sf.net/
  • "; #endif @@ -104,7 +108,7 @@ const char* carla_get_extended_license_text() #ifdef WANT_LV2 retText += "
  • serd, sord, sratom and lilv libraries for LV2 discovery, http://drobilla.net/software/lilv/
  • "; #endif -#ifdef CARLA_ENGINE_RTAUDIO +#ifdef WANT_RTAUDIO retText += "
  • RtAudio and RtMidi libraries for extra Audio and MIDI support, http://www.music.mcgill.ca/~gary/rtaudio/
  • "; #endif retText += ""; diff --git a/source/widgets/Makefile b/source/widgets/Makefile index 4907cadff..fdc633e47 100644 --- a/source/widgets/Makefile +++ b/source/widgets/Makefile @@ -13,6 +13,7 @@ BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore) LINK_FLAGS += $(shell pkg-config --libs QtCore) FILES = \ + moc_paramspinbox.cpp \ moc_pixmapkeyboard.cpp OBJS = \ @@ -21,6 +22,7 @@ OBJS = \ paramspinbox.cpp.o \ pixmapdial.cpp.o \ pixmapkeyboard.cpp.o \ + moc_paramspinbox.cpp.o \ moc_pixmapkeyboard.cpp.o TARGET = ../libs/widgets.a