| @@ -98,6 +98,7 @@ OBJS += \ | |||
| OBJS += \ | |||
| $(OBJDIR)/distrho-3bandeq.cpp.o \ | |||
| $(OBJDIR)/distrho-3bandsplitter.cpp.o \ | |||
| $(OBJDIR)/distrho-kars.cpp.o \ | |||
| $(OBJDIR)/distrho-mverb.cpp.o \ | |||
| $(OBJDIR)/distrho-nekobi.cpp.o \ | |||
| $(OBJDIR)/distrho-pingpongpan.cpp.o | |||
| @@ -281,6 +282,11 @@ $(OBJDIR)/distrho-3bandsplitter.cpp.o: distrho-3bandsplitter.cpp | |||
| @echo "Compiling $<" | |||
| @$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_NAMESPACE=DISTRHO_3BandSplitter -Idistrho-3bandsplitter -I$(CWD)/modules/dgl -Wno-effc++ -c -o $@ | |||
| $(OBJDIR)/distrho-kars.cpp.o: distrho-kars.cpp | |||
| -@mkdir -p $(OBJDIR) | |||
| @echo "Compiling $<" | |||
| @$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_NAMESPACE=DISTRHO_Kars -Idistrho-kars -I$(CWD)/modules/dgl -Wno-effc++ -c -o $@ | |||
| $(OBJDIR)/distrho-mverb.cpp.o: distrho-mverb.cpp | |||
| -@mkdir -p $(OBJDIR) | |||
| # FIXME - fix mverb strict warnings | |||
| @@ -43,6 +43,7 @@ extern void carla_register_native_plugin_carla(void); | |||
| // DISTRHO plugins | |||
| extern void carla_register_native_plugin_distrho_3bandeq(void); | |||
| extern void carla_register_native_plugin_distrho_3bandsplitter(void); | |||
| extern void carla_register_native_plugin_distrho_kars(void); | |||
| extern void carla_register_native_plugin_distrho_mverb(void); | |||
| extern void carla_register_native_plugin_distrho_nekobi(void); | |||
| extern void carla_register_native_plugin_distrho_pingpongpan(void); | |||
| @@ -96,6 +97,7 @@ void carla_register_all_native_plugins(void) | |||
| // DISTRHO Plugins | |||
| carla_register_native_plugin_distrho_3bandeq(); | |||
| carla_register_native_plugin_distrho_3bandsplitter(); | |||
| carla_register_native_plugin_distrho_kars(); | |||
| carla_register_native_plugin_distrho_mverb(); | |||
| carla_register_native_plugin_distrho_nekobi(); | |||
| carla_register_native_plugin_distrho_pingpongpan(); | |||
| @@ -387,6 +387,31 @@ static const NativePluginDescriptor sNativePluginDescriptors[] = { | |||
| /* copyright */ "LGPL", | |||
| DESCFUNCS | |||
| }, | |||
| { | |||
| /* category */ NATIVE_PLUGIN_CATEGORY_SYNTH, | |||
| #ifdef HAVE_DGL | |||
| /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | |||
| |NATIVE_PLUGIN_IS_SYNTH | |||
| |NATIVE_PLUGIN_HAS_UI | |||
| |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |||
| |NATIVE_PLUGIN_USES_PARENT_ID), | |||
| #else | |||
| /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | |||
| |NATIVE_PLUGIN_IS_SYNTH), | |||
| #endif | |||
| /* supports */ NATIVE_PLUGIN_SUPPORTS_NOTHING, | |||
| /* audioIns */ 0, | |||
| /* audioOuts */ 1, | |||
| /* midiIns */ 1, | |||
| /* midiOuts */ 0, | |||
| /* paramIns */ 1, | |||
| /* paramOuts */ 0, | |||
| /* name */ "Kars", | |||
| /* label */ "kars", | |||
| /* maker */ "falkTX, Chris Cannam", | |||
| /* copyright */ "ISC", | |||
| DESCFUNCS | |||
| }, | |||
| { | |||
| /* category */ NATIVE_PLUGIN_CATEGORY_DELAY, | |||
| #ifdef HAVE_DGL | |||
| @@ -0,0 +1,84 @@ | |||
| /* | |||
| * Carla Native Plugins | |||
| * Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * This program is free software; you can redistribute it and/or | |||
| * modify it under the terms of the GNU General Public License as | |||
| * published by the Free Software Foundation; either version 2 of | |||
| * the License, or any later version. | |||
| * | |||
| * This program is distributed in the hope that it will be useful, | |||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| * GNU General Public License for more details. | |||
| * | |||
| * For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
| */ | |||
| // config fix | |||
| #include "distrho-kars/DistrhoPluginInfo.h" | |||
| #if DISTRHO_PLUGIN_HAS_UI && ! defined(HAVE_DGL) | |||
| # undef DISTRHO_PLUGIN_HAS_UI | |||
| # define DISTRHO_PLUGIN_HAS_UI 0 | |||
| #endif | |||
| // Plugin Code | |||
| #include "distrho-kars/DistrhoArtworkKars.cpp" | |||
| #include "distrho-kars/DistrhoPluginKars.cpp" | |||
| #ifdef HAVE_DGL | |||
| #include "distrho-kars/DistrhoUIKars.cpp" | |||
| #endif | |||
| // DISTRHO Code | |||
| #define DISTRHO_PLUGIN_TARGET_CARLA | |||
| #include "DistrhoPluginMain.cpp" | |||
| #ifdef HAVE_DGL | |||
| #include "DistrhoUIMain.cpp" | |||
| #endif | |||
| START_NAMESPACE_DISTRHO | |||
| // ----------------------------------------------------------------------- | |||
| static const NativePluginDescriptor karsDesc = { | |||
| /* category */ NATIVE_PLUGIN_CATEGORY_SYNTH, | |||
| #ifdef HAVE_DGL | |||
| /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | |||
| |NATIVE_PLUGIN_IS_SYNTH | |||
| |NATIVE_PLUGIN_HAS_UI | |||
| |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |||
| |NATIVE_PLUGIN_USES_PARENT_ID), | |||
| #else | |||
| /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | |||
| |NATIVE_PLUGIN_IS_SYNTH), | |||
| #endif | |||
| /* supports */ NATIVE_PLUGIN_SUPPORTS_NOTHING, | |||
| /* audioIns */ DISTRHO_PLUGIN_NUM_INPUTS, | |||
| /* audioOuts */ DISTRHO_PLUGIN_NUM_OUTPUTS, | |||
| /* midiIns */ 1, | |||
| /* midiOuts */ 0, | |||
| /* paramIns */ DistrhoPluginKars::paramCount, | |||
| /* paramOuts */ 0, | |||
| /* name */ DISTRHO_PLUGIN_NAME, | |||
| /* label */ "kars", | |||
| /* maker */ "falkTX, Chris Cannam", | |||
| /* copyright */ "ISC", | |||
| PluginDescriptorFILL(PluginCarla) | |||
| }; | |||
| END_NAMESPACE_DISTRHO | |||
| // ----------------------------------------------------------------------- | |||
| CARLA_EXPORT | |||
| void carla_register_native_plugin_distrho_kars(); | |||
| CARLA_EXPORT | |||
| void carla_register_native_plugin_distrho_kars() | |||
| { | |||
| USE_NAMESPACE_DISTRHO | |||
| carla_register_native_plugin(&karsDesc); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| @@ -0,0 +1,20 @@ | |||
| /* (Auto-generated binary data file). */ | |||
| #ifndef BINARY_DISTRHOARTWORKKARS_HPP | |||
| #define BINARY_DISTRHOARTWORKKARS_HPP | |||
| namespace DistrhoArtworkKars | |||
| { | |||
| extern const char* backgroundData; | |||
| const unsigned int backgroundDataSize = 379260; | |||
| const unsigned int backgroundWidth = 301; | |||
| const unsigned int backgroundHeight = 315; | |||
| extern const char* switchData; | |||
| const unsigned int switchDataSize = 61952; | |||
| const unsigned int switchWidth = 88; | |||
| const unsigned int switchHeight = 176; | |||
| } | |||
| #endif // BINARY_DISTRHOARTWORKKARS_HPP | |||
| @@ -0,0 +1,31 @@ | |||
| /* | |||
| * DISTRHO Kars Plugin, based on karplong by Chris Cannam. | |||
| * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
| * or without fee is hereby granted, provided that the above copyright notice and this | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
| #define DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
| #define DISTRHO_PLUGIN_BRAND "DISTRHO" | |||
| #define DISTRHO_PLUGIN_NAME "Kars" | |||
| #define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/Kars" | |||
| #define DISTRHO_PLUGIN_HAS_UI 1 | |||
| #define DISTRHO_PLUGIN_IS_RT_SAFE 1 | |||
| #define DISTRHO_PLUGIN_IS_SYNTH 1 | |||
| #define DISTRHO_PLUGIN_NUM_INPUTS 0 | |||
| #define DISTRHO_PLUGIN_NUM_OUTPUTS 1 | |||
| #define DISTRHO_PLUGIN_USES_MODGUI 1 | |||
| #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
| @@ -0,0 +1,214 @@ | |||
| /* | |||
| * DISTRHO Kars Plugin, based on karplong by Chris Cannam. | |||
| * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
| * or without fee is hereby granted, provided that the above copyright notice and this | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #include "DistrhoPluginKars.hpp" | |||
| START_NAMESPACE_DISTRHO | |||
| // ----------------------------------------------------------------------- | |||
| DistrhoPluginKars::DistrhoPluginKars() | |||
| : Plugin(paramCount, 0, 0), // 0 programs, 0 states | |||
| fSustain(false), | |||
| fSampleRate(getSampleRate()), | |||
| fBlockStart(0) | |||
| { | |||
| for (int i=kMaxNotes; --i >= 0;) | |||
| { | |||
| fNotes[i].index = i; | |||
| fNotes[i].setSampleRate(fSampleRate); | |||
| } | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // Init | |||
| void DistrhoPluginKars::initParameter(uint32_t index, Parameter& parameter) | |||
| { | |||
| if (index != 0) | |||
| return; | |||
| parameter.hints = kParameterIsAutomable|kParameterIsBoolean; | |||
| parameter.name = "Sustain"; | |||
| parameter.symbol = "sustain"; | |||
| parameter.ranges.def = 0.0f; | |||
| parameter.ranges.min = 0.0f; | |||
| parameter.ranges.max = 1.0f; | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // Internal data | |||
| float DistrhoPluginKars::getParameterValue(uint32_t index) const | |||
| { | |||
| if (index != 0) | |||
| return 0.0f; | |||
| return fSustain ? 1.0f : 0.0f; | |||
| } | |||
| void DistrhoPluginKars::setParameterValue(uint32_t index, float value) | |||
| { | |||
| if (index != 0) | |||
| return; | |||
| fSustain = value > 0.5f; | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // Process | |||
| void DistrhoPluginKars::activate() | |||
| { | |||
| fBlockStart = 0; | |||
| for (int i=kMaxNotes; --i >= 0;) | |||
| { | |||
| fNotes[i].on = kNoteNull; | |||
| fNotes[i].off = kNoteNull; | |||
| fNotes[i].velocity = 0; | |||
| } | |||
| } | |||
| void DistrhoPluginKars::run(const float**, float** outputs, uint32_t frames, const MidiEvent* midiEvents, uint32_t midiEventCount) | |||
| { | |||
| uint8_t note, velo; | |||
| float* out = outputs[0]; | |||
| for (uint32_t count, pos=0, curEventIndex=0; pos<frames;) | |||
| { | |||
| for (;curEventIndex < midiEventCount && pos >= midiEvents[curEventIndex].frame; ++curEventIndex) | |||
| { | |||
| if (midiEvents[curEventIndex].size > MidiEvent::kDataSize) | |||
| continue; | |||
| const uint8_t* data = midiEvents[curEventIndex].data; | |||
| const uint8_t status = data[0] & 0xF0; | |||
| switch (status) | |||
| { | |||
| case 0x90: | |||
| note = data[1]; | |||
| velo = data[2]; | |||
| DISTRHO_SAFE_ASSERT_BREAK(note < 128); // kMaxNotes | |||
| if (velo > 0) | |||
| { | |||
| fNotes[note].on = fBlockStart + midiEvents[curEventIndex].frame; | |||
| fNotes[note].off = kNoteNull; | |||
| fNotes[note].velocity = velo; | |||
| break; | |||
| } | |||
| // nobreak | |||
| case 0x80: | |||
| note = data[1]; | |||
| DISTRHO_SAFE_ASSERT_BREAK(note < 128); // kMaxNotes | |||
| fNotes[note].off = fBlockStart + midiEvents[curEventIndex].frame; | |||
| break; | |||
| } | |||
| } | |||
| if (curEventIndex < midiEventCount && midiEvents[curEventIndex].frame < frames) | |||
| count = midiEvents[curEventIndex].frame - pos; | |||
| else | |||
| count = frames - pos; | |||
| std::memset(out+pos, 0, sizeof(float)*count); | |||
| //for (uint32_t i=0; i<count; ++i) | |||
| // out[pos + i] = 0.0f; | |||
| for (int i=kMaxNotes; --i >= 0;) | |||
| { | |||
| if (fNotes[i].on != kNoteNull) | |||
| addSamples(out, i, pos, count); | |||
| } | |||
| pos += count; | |||
| } | |||
| fBlockStart += frames; | |||
| } | |||
| void DistrhoPluginKars::addSamples(float* out, int voice, uint32_t offset, uint32_t count) | |||
| { | |||
| const uint32_t start = fBlockStart + offset; | |||
| Note& note(fNotes[voice]); | |||
| if (start < note.on) | |||
| return; | |||
| if (start == note.on) | |||
| { | |||
| for (int i=note.sizei; --i >= 0;) | |||
| note.wavetable[i] = (float(rand()) / float(RAND_MAX)) * 2.0f - 1.0f; | |||
| } | |||
| const float vgain = float(note.velocity) / 127.0f; | |||
| bool decay; | |||
| float gain, sample; | |||
| uint32_t index, size; | |||
| for (uint32_t i=0, s=start-note.on; i<count; ++i, ++s) | |||
| { | |||
| gain = vgain; | |||
| if ((! fSustain) && note.off != kNoteNull && note.off < i+start) | |||
| { | |||
| // reuse index and size to save some performance. | |||
| // actual values are release and dist | |||
| index = 1 + uint32_t(0.01 * fSampleRate); // release, not index | |||
| size = i + start - note.off; // dist, not size | |||
| if (size > index) | |||
| { | |||
| note.on = kNoteNull; | |||
| break; | |||
| } | |||
| gain = gain * float(index - size) / float(index); | |||
| } | |||
| size = uint32_t(note.sizei); | |||
| decay = s > size; | |||
| index = s % size; | |||
| sample = note.wavetable[index]; | |||
| if (decay) | |||
| { | |||
| if (index == 0) | |||
| sample += note.wavetable[size-1]; | |||
| else | |||
| sample += note.wavetable[index-1]; | |||
| note.wavetable[index] = sample/2; | |||
| } | |||
| out[offset+i] += gain * sample; | |||
| } | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| Plugin* createPlugin() | |||
| { | |||
| return new DistrhoPluginKars(); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| END_NAMESPACE_DISTRHO | |||
| @@ -0,0 +1,152 @@ | |||
| /* | |||
| * DISTRHO Kars Plugin, based on karplong by Chris Cannam. | |||
| * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
| * or without fee is hereby granted, provided that the above copyright notice and this | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #ifndef DISTRHO_PLUGIN_KARS_HPP_INCLUDED | |||
| #define DISTRHO_PLUGIN_KARS_HPP_INCLUDED | |||
| #include "DistrhoPlugin.hpp" | |||
| START_NAMESPACE_DISTRHO | |||
| // ----------------------------------------------------------------------- | |||
| class DistrhoPluginKars : public Plugin | |||
| { | |||
| public: | |||
| static const int kMaxNotes = 128; | |||
| static const uint32_t kNoteNull = (uint32_t)-1; | |||
| enum Parameters | |||
| { | |||
| paramSustain = 0, | |||
| paramCount | |||
| }; | |||
| DistrhoPluginKars(); | |||
| protected: | |||
| // ------------------------------------------------------------------- | |||
| // Information | |||
| const char* getLabel() const noexcept override | |||
| { | |||
| return "Kars"; | |||
| } | |||
| const char* getDescription() const override | |||
| { | |||
| return "Simple karplus-strong plucked string synth."; | |||
| } | |||
| const char* getMaker() const noexcept override | |||
| { | |||
| return "falkTX"; | |||
| } | |||
| const char* getHomePage() const override | |||
| { | |||
| return "https://github.com/DISTRHO/Kars"; | |||
| } | |||
| const char* getLicense() const noexcept override | |||
| { | |||
| return "ISC"; | |||
| } | |||
| uint32_t getVersion() const noexcept override | |||
| { | |||
| return d_version(1, 0, 0); | |||
| } | |||
| int64_t getUniqueId() const noexcept override | |||
| { | |||
| return d_cconst('D', 'K', 'r', 's'); | |||
| } | |||
| // ------------------------------------------------------------------- | |||
| // Init | |||
| void initParameter(uint32_t index, Parameter& parameter) override; | |||
| // ------------------------------------------------------------------- | |||
| // Internal data | |||
| float getParameterValue(uint32_t index) const override; | |||
| void setParameterValue(uint32_t index, float value) override; | |||
| // ------------------------------------------------------------------- | |||
| // Process | |||
| void activate() override; | |||
| void run(const float**, float** outputs, uint32_t frames, const MidiEvent* midiEvents, uint32_t midiEventCount) override; | |||
| // ------------------------------------------------------------------- | |||
| private: | |||
| bool fSustain; | |||
| double fSampleRate; | |||
| uint32_t fBlockStart; | |||
| struct Note { | |||
| uint32_t on; | |||
| uint32_t off; | |||
| uint8_t velocity; | |||
| float index; | |||
| float size; | |||
| int sizei; | |||
| float* wavetable; | |||
| Note() noexcept | |||
| : on(kNoteNull), | |||
| off(kNoteNull), | |||
| velocity(0), | |||
| index(0.0f), | |||
| size(0.0f), | |||
| wavetable(nullptr) {} | |||
| ~Note() noexcept | |||
| { | |||
| if (wavetable != nullptr) | |||
| { | |||
| delete[] wavetable; | |||
| wavetable = nullptr; | |||
| } | |||
| } | |||
| void setSampleRate(const double sampleRate) | |||
| { | |||
| if (wavetable != nullptr) | |||
| delete[] wavetable; | |||
| const float frequency = 440.0f * std::pow(2.0f, (index - 69.0f) / 12.0f); | |||
| size = sampleRate / frequency; | |||
| sizei = int(size)+1; | |||
| wavetable = new float[sizei]; | |||
| std::memset(wavetable, 0, sizeof(float)*static_cast<size_t>(sizei)); | |||
| } | |||
| } fNotes[kMaxNotes]; | |||
| void addSamples(float* out, int voice, uint32_t offset, uint32_t count); | |||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoPluginKars) | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| END_NAMESPACE_DISTRHO | |||
| #endif // DISTRHO_PLUGIN_KARS_HPP_INCLUDED | |||
| @@ -0,0 +1,77 @@ | |||
| /* | |||
| * DISTRHO Kars Plugin, based on karplong by Chris Cannam. | |||
| * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
| * or without fee is hereby granted, provided that the above copyright notice and this | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #include "DistrhoPluginKars.hpp" | |||
| #include "DistrhoUIKars.hpp" | |||
| START_NAMESPACE_DISTRHO | |||
| namespace Art = DistrhoArtworkKars; | |||
| // ----------------------------------------------------------------------- | |||
| DistrhoUIKars::DistrhoUIKars() | |||
| : UI(Art::backgroundWidth, Art::backgroundHeight), | |||
| fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight) | |||
| { | |||
| // sustain switch | |||
| Image switchImageNormal(Art::switchData, Art::switchWidth, Art::switchHeight/2); | |||
| Image switchImageDown(Art::switchData+(Art::switchWidth*Art::switchHeight/2*4), Art::switchWidth, Art::switchHeight/2); | |||
| fSwitchSustain = new ImageSwitch(this, switchImageNormal, switchImageDown); | |||
| fSwitchSustain->setAbsolutePos(Art::backgroundWidth/2-Art::switchWidth/2, Art::backgroundHeight/2-Art::switchHeight/4); | |||
| fSwitchSustain->setId(DistrhoPluginKars::paramSustain); | |||
| fSwitchSustain->setCallback(this); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // DSP Callbacks | |||
| void DistrhoUIKars::parameterChanged(uint32_t index, float value) | |||
| { | |||
| if (index != 0) | |||
| return; | |||
| fSwitchSustain->setDown(value > 0.5f); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| // Widget Callbacks | |||
| void DistrhoUIKars::imageSwitchClicked(ImageSwitch* imageSwitch, bool down) | |||
| { | |||
| if (imageSwitch != fSwitchSustain) | |||
| return; | |||
| editParameter(DistrhoPluginKars::paramSustain, true); | |||
| setParameterValue(DistrhoPluginKars::paramSustain, down ? 1.0f : 0.0f); | |||
| editParameter(DistrhoPluginKars::paramSustain, false); | |||
| } | |||
| void DistrhoUIKars::onDisplay() | |||
| { | |||
| fImgBackground.draw(); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| UI* createUI() | |||
| { | |||
| return new DistrhoUIKars(); | |||
| } | |||
| // ----------------------------------------------------------------------- | |||
| END_NAMESPACE_DISTRHO | |||
| @@ -0,0 +1,60 @@ | |||
| /* | |||
| * DISTRHO Kars Plugin, based on karplong by Chris Cannam. | |||
| * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | |||
| * or without fee is hereby granted, provided that the above copyright notice and this | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #ifndef DISTRHO_UI_KARS_HPP_INCLUDED | |||
| #define DISTRHO_UI_KARS_HPP_INCLUDED | |||
| #include "DistrhoUI.hpp" | |||
| #include "ImageWidgets.hpp" | |||
| #include "DistrhoArtworkKars.hpp" | |||
| START_NAMESPACE_DISTRHO | |||
| // ----------------------------------------------------------------------- | |||
| class DistrhoUIKars : public UI, | |||
| public ImageSwitch::Callback | |||
| { | |||
| public: | |||
| DistrhoUIKars(); | |||
| protected: | |||
| // ------------------------------------------------------------------- | |||
| // DSP Callbacks | |||
| void parameterChanged(uint32_t index, float value) override; | |||
| // ------------------------------------------------------------------- | |||
| // Widget Callbacks | |||
| void imageSwitchClicked(ImageSwitch* imageSwitch, bool down) override; | |||
| void onDisplay() override; | |||
| private: | |||
| Image fImgBackground; | |||
| ScopedPointer<ImageSwitch> fSwitchSustain; | |||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUIKars) | |||
| }; | |||
| // ----------------------------------------------------------------------- | |||
| END_NAMESPACE_DISTRHO | |||
| #endif // DISTRHO_UI_KARS_HPP_INCLUDED | |||
| @@ -29,7 +29,6 @@ | |||
| #include "distrho-mverb/DistrhoPluginMVerb.cpp" | |||
| #if DISTRHO_PLUGIN_HAS_UI | |||
| #include "distrho-mverb/DistrhoUIMVerb.cpp" | |||
| #include "distrho-mverb/font/Kh-Kangrey.cpp" | |||
| #endif | |||
| // DISTRHO Code | |||