From c4be7560071d9cf01bddbddadf3cada0264de0aa Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 6 Oct 2016 13:48:15 +0200 Subject: [PATCH] ... trying... --- src/Makefile | 4 +- src/dexed.cpp | 110 ++++++-------------------------------------------- src/dexed.h | 63 +++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 100 deletions(-) create mode 100644 src/dexed.h diff --git a/src/Makefile b/src/Makefile index 3831d62..e32b60f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,8 +1,8 @@ BUNDLE = dexed.lv2 INSTALL_DIR = /usr/local/lib/lv2 CFLAGS := -fPIC -DPIC -DDEBUG=0 -std=c++11 -I/usr/include/lv2-c++-tools -OBJ = dexed.o fm_core.o env.o lfo.o dx7note.o sin.o pitchenv.o fm_op_kernel.o freqlut.o exp2.o EngineMkI.o EngineOpl.o PluginFx.o PluginProcessor.o -# SysexComm.o +OBJ = dexed.o fm_core.o env.o lfo.o dx7note.o sin.o pitchenv.o fm_op_kernel.o freqlut.o exp2.o EngineMkI.o EngineOpl.o +# SysexComm.o PluginFx.o $(BUNDLE): manifest.ttl Dexed.ttl dexed.so rm -rf $(BUNDLE) diff --git a/src/dexed.cpp b/src/dexed.cpp index 15f08f3..026059f 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -2,109 +2,23 @@ #include #include "dexed.peg" +#include "dexed.h" #include "EngineMkI.h" #include "EngineOpl.h" - -class DexedVoice : public LV2::Voice { -public: - Controllers controllers; - StringArray programNames; - Cartridge currentCart; - uint8_t data[161]; - - SysexComm sysexComm; - VoiceStatus voiceStatus; - File activeFileCartridge; - int getEngineType(); - void setEngineType(int rs); - Array ctrl; - - OperatorCtrl opCtrl[6]; - ScopedPointer pitchEgRate[4]; - ScopedPointer pitchEgLevel[4]; - ScopedPointer pitchModSens; - ScopedPointer algo; - ScopedPointer oscSync; - ScopedPointer feedback; - ScopedPointer lfoRate; - ScopedPointer lfoDelay; - ScopedPointer lfoAmpDepth; - ScopedPointer lfoPitchDepth; - ScopedPointer lfoWaveform; - ScopedPointer lfoSync; - ScopedPointer transpose; - - ScopedPointer fxCutoff; - ScopedPointer fxReso; - ScopedPointer output; - ScopedPointer tune; - - DexedVoice(double rate) - : m_key(LV2::INVALID_KEY), m_rate(rate) { - - } - - void on(unsigned char key, unsigned char velocity) { - m_key = key; - } - - void off(unsigned char velocity) { - m_key = LV2::INVALID_KEY; - } - - unsigned char get_key() const { - return m_key; - } - - void render(uint32_t from, uint32_t to) { - int i=0; - - if (m_key == LV2::INVALID_KEY) - return; - float s=0.0; - p(p_lv2_audio_out_1)[i] += s; - } - -protected: - - unsigned char m_key; - double m_rate; - - PluginFx fx; - bool refreshVoice; - bool normalizeDxVelocity; - bool sendSysexChange; - static const int MAX_ACTIVE_NOTES = 16; - ProcessorVoice voices[MAX_ACTIVE_NOTES]; - int currentNote; - Lfo lfo; - - bool sustain; - bool monoMode; - float extra_buf[N]; - int extra_buf_size; - - int currentProgram; - long lastStateSave; - uint32_t engineType; - - FmCore engineMsfa; - EngineMkI engineMkI; - EngineOpl engineOpl; - int feedback_bitdepth; +#include "msfa/exp2.h" +#include "msfa/sin.h" + +DexedVoice::DexedVoice(double rate) +{ + Exp2::init(); + Tanh::init(); + Sin::init(); }; - -class Dexed : public LV2::Synth { -public: - - Dexed(double rate) - : LV2::Synth(p_n_ports, p_lv2_events_in) { +Dexed::Dexed(double rate) : LV2::Synth(p_n_ports, p_lv2_events_in) +{ add_voices(new DexedVoice(rate), new DexedVoice(rate), new DexedVoice(rate)); add_audio_outputs(p_lv2_audio_out_1); - } - -}; - +} static int _ = Dexed::register_class(p_uri); diff --git a/src/dexed.h b/src/dexed.h new file mode 100644 index 0000000..ea33ded --- /dev/null +++ b/src/dexed.h @@ -0,0 +1,63 @@ +/** + * + * Copyright (c) 2013-2015 Pascal Gauthier. + * + * 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 3 of the License, or + * (at your option) 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef DEXED_H_INCLUDED +#define DEXED_H_INCLUDED + +#include "msfa/controllers.h" +#include "msfa/dx7note.h" +#include "msfa/lfo.h" +#include "msfa/synth.h" +#include "msfa/fm_core.h" +#include "PluginFx.h" +#include "EngineMkI.h" +#include "EngineOpl.h" + +struct ProcessorVoice { + int midi_note; + bool keydown; + bool sustained; + bool live; + Dx7Note *dx7_note; +}; + +enum DexedEngineResolution { + DEXED_ENGINE_MODERN, + DEXED_ENGINE_MARKI, + DEXED_ENGINE_OPL +}; + +//============================================================================== + +class DexedVoice : public LV2::Voice +{ + public: + DexedVoice(double rate); +}; + +//============================================================================== + +class Dexed : public LV2::Synth +{ + public: + Dexed(double rate); +}; + +#endif // PLUGINPROCESSOR_H_INCLUDED