... saving current state...

pull/1/head
Holger Wirtz 8 years ago
parent aa4f31bf3d
commit 0f99ea3c00
  1. 4
      src/Dexed.h
  2. 4
      src/EngineMkI.cpp
  3. 2
      src/Makefile
  4. 124
      src/dexed.cpp
  5. 14
      src/dexed.h
  6. 17
      src/msfa/synth.h

@ -27,11 +27,7 @@ void dexed_trace(const char *source, const char *fmt, ...);
#ifdef DEBUG #ifdef DEBUG
#define DEXED_VERSION DEXED_ID " DEBUG" #define DEXED_VERSION DEXED_ID " DEBUG"
#ifdef _MSC_VER
#define TRACE(fmt, ...) dexed_trace(__FUNCTION__,fmt,##__VA_ARGS__)
#else
#define TRACE(fmt, ...) dexed_trace(__PRETTY_FUNCTION__,fmt,##__VA_ARGS__) #define TRACE(fmt, ...) dexed_trace(__PRETTY_FUNCTION__,fmt,##__VA_ARGS__)
#endif
#else #else
#define DEXED_VERSION DEXED_ID #define DEXED_VERSION DEXED_ID
#define TRACE(fmt, ...) #define TRACE(fmt, ...)

@ -121,7 +121,9 @@ EngineMkI::EngineMkI() {
inline int32_t mkiSin(int32_t phase, uint16_t env) { inline int32_t mkiSin(int32_t phase, uint16_t env) {
uint16_t expVal = sinLog(phase >> (22 - SINLOG_BITDEPTH)) + (env); uint16_t expVal = sinLog(phase >> (22 - SINLOG_BITDEPTH)) + (env);
//int16_t expValShow = expVal; #ifdef MKIDEBUG
int16_t expValShow = expVal;
#endif
const bool isSigned = expVal & NEGATIVE_BIT; const bool isSigned = expVal & NEGATIVE_BIT;
expVal &= ~NEGATIVE_BIT; expVal &= ~NEGATIVE_BIT;

@ -1,6 +1,6 @@
BUNDLE = dexed.lv2 BUNDLE = dexed.lv2
INSTALL_DIR = /home/pi/zynthian/zynthian-plugins/mod-lv2 INSTALL_DIR = /home/pi/zynthian/zynthian-plugins/mod-lv2
CFLAGS := -fPIC -DPIC -DDEBUG=0 -std=c++11 -I. -I/usr/local/include/lvtk-2 -L/usr/local/lib -llvtk_plugin2 CFLAGS := -fPIC -DPIC -DDEBUG=1 -std=c++11 -I. -I/usr/local/include/lvtk-2 -L/usr/local/lib -llvtk_plugin2
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 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 # SysexComm.o PluginFx.o

@ -1,6 +1,7 @@
// from: http://ll-plugins.nongnu.org/lv2pftci/#A_synth // from: http://ll-plugins.nongnu.org/lv2pftci/#A_synth
#include <lvtk/synth.hpp> #include <lvtk/synth.hpp>
#include <string.h>
#include "dexed.peg" #include "dexed.peg"
#include "dexed.h" #include "dexed.h"
#include "EngineMkI.h" #include "EngineMkI.h"
@ -10,25 +11,89 @@
#include "msfa/freqlut.h" #include "msfa/freqlut.h"
#include "msfa/controllers.h" #include "msfa/controllers.h"
Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_lv2_events_in)
{
TRACE("Hi");
Exp2::init();
Tanh::init();
Sin::init();
feedback_bitdepth=11;
for(uint i=0;i<sizeof(init_voice);i++) {
data[i] = init_voice[i];
}
controllers.values_[kControllerPitchRange] = 3;
controllers.values_[kControllerPitchStep] = 0;
controllers.masterTune = 0;
controllers.values_[kControllerPitch] = 0x2000;
controllers.modwheel_cc = 0;
controllers.foot_cc = 0;
controllers.breath_cc = 0;
controllers.aftertouch_cc = 0;
controllers.core=&engineMkI;
lfo.reset(data + 137);
Freqlut::init(rate);
Lfo::init(rate);
PitchEnv::init(rate);
Env::init_sr(rate);
//add_voices(new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate));
add_voices(new DexedVoice(rate));
add_audio_outputs(p_lv2_audio_out_1);
}
Dexed::~Dexed()
{
TRACE("Bye");
}
//==============================================================================
DexedVoice::DexedVoice(double rate) : m_key(lvtk::INVALID_KEY), m_rate(rate) DexedVoice::DexedVoice(double rate) : m_key(lvtk::INVALID_KEY), m_rate(rate)
{ {
voice_number=voice_counter++;
TRACE("Hi %d",voice_number);
voice.dx7_note=new Dx7Note; voice.dx7_note=new Dx7Note;
} }
DexedVoice::~DexedVoice()
{
TRACE("Bye");
}
void DexedVoice::on(unsigned char key, unsigned char velocity) void DexedVoice::on(unsigned char key, unsigned char velocity)
{ {
m_key = key; m_key = key;
voice.dx7_note->init(data, key, velocity, feedback_bitdepth); voice.midi_note=data[144] - 24;
voice.keydown=true; voice.keydown=true;
printf("Dexed: key-down: %d %d\n",key,velocity); voice.sustained=false;
lfo.keydown();
if(voice.live==false)
{
voice.dx7_note->init(data, key, velocity, feedback_bitdepth);
voice.live=true;
}
if(data[136])
voice.dx7_note->oscSync();
TRACE("%d key-down: %d %d",voice_number,key,velocity);
} }
void DexedVoice::off(unsigned char velocity) void DexedVoice::off(unsigned char velocity)
{ {
voice.dx7_note->keyup(); voice.dx7_note->keyup();
voice.keydown=false; voice.keydown=false;
voice.live=false;
m_key = lvtk::INVALID_KEY; m_key = lvtk::INVALID_KEY;
printf("Dexed: key-up: %d\n",velocity); TRACE("%d key-up: %d",voice_number,velocity);
} }
unsigned char DexedVoice::get_key(void) const unsigned char DexedVoice::get_key(void) const
@ -38,51 +103,46 @@ unsigned char DexedVoice::get_key(void) const
void DexedVoice::render(uint32_t from, uint32_t to) void DexedVoice::render(uint32_t from, uint32_t to)
{ {
if (m_key == lvtk::INVALID_KEY) int32_t s;
return;
TRACE("Hi");
TRACE("%d from: %d to: %d",voice_number,from,to);
if (m_key != lvtk::INVALID_KEY)
{
for (uint32_t i = from; i < to; ++i) for (uint32_t i = from; i < to; ++i)
{ {
int32_t s; if(voice.live==true)
//dx7_note->compute(&s, lfovalue, lfodelay, &controllers); {
voice.dx7_note->compute(&s, lfo.getsample(), lfo.getdelay(), &controllers); voice.dx7_note->compute(&s, lfo.getsample(), lfo.getdelay(), &controllers);
float fs=float(s)/(INT32_MAX); float fs=(float)s/INT32_MAX;
p(p_lv2_audio_out_1)[i]+=fs; p(p_lv2_audio_out_1)[i]+=fs;
TRACE("out: %2.5f",fs);
}
} }
} }
TRACE("Bye");
}
void DexedVoice::post_process(uint32_t from, uint32_t to) void DexedVoice::post_process(uint32_t from, uint32_t to)
{ {
TRACE("Hi");
for (uint32_t i = from; i < to; ++i) for (uint32_t i = from; i < to; ++i)
{ {
p(p_lv2_audio_out_1)[i] *= *p(p_output); p(p_lv2_audio_out_1)[i] *= *p(p_output);
} }
TRACE("Bye");
} }
//============================================================================== #ifdef DEBUG
void dexed_trace(const char *source, const char *fmt, ...) {
Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_lv2_events_in) char output[4096];
{ va_list argptr;
Exp2::init(); va_start(argptr, fmt);
Tanh::init(); vsnprintf(output, 4095, fmt, argptr);
Sin::init(); va_end(argptr);
Freqlut::init(rate); printf("%s: %s\n",source,output);
Lfo::init(rate);
PitchEnv::init(rate);
Env::init_sr(rate);
engineType=DEXED_ENGINE_MARKI;
feedback_bitdepth=11;
controllers.core=&engineMkI;
for(uint i=0;i<sizeof(init_voice);i++) {
data[i] = init_voice[i];
}
add_voices(new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate));
add_audio_outputs(p_lv2_audio_out_1);
} }
#endif
static int _ = Dexed::register_class(p_uri); static int _ = Dexed::register_class(p_uri);

@ -50,6 +50,7 @@ class DexedVoice : public lvtk::Voice
{ {
public: public:
DexedVoice(double rate); DexedVoice(double rate);
~DexedVoice();
void on(unsigned char key, unsigned char velocity); void on(unsigned char key, unsigned char velocity);
void off(unsigned char velocity); void off(unsigned char velocity);
unsigned char get_key(void) const; unsigned char get_key(void) const;
@ -60,6 +61,7 @@ class DexedVoice : public lvtk::Voice
unsigned char m_key; unsigned char m_key;
double m_rate; double m_rate;
ProcessorVoice voice; ProcessorVoice voice;
char voice_number;
}; };
//============================================================================== //==============================================================================
@ -68,24 +70,20 @@ class Dexed : public lvtk::Synth<DexedVoice, Dexed>
{ {
public: public:
Dexed(double rate); Dexed(double rate);
FmCore *core; ~Dexed();
protected: protected:
// dexed internal // dexed internal
}; };
// GLOBALS // GLOBALS
char voice_counter=0;
EngineMkI engineMkI; EngineMkI engineMkI;
//FmCore engineMsfa;
//EngineOpl engineOpl;
uint8_t feedback_bitdepth; uint8_t feedback_bitdepth;
uint32_t engineType;
Lfo lfo; Lfo lfo;
Controllers controllers; Controllers controllers;
const uint8_t init_voice[] =
const char init_voice[] =
{ 99, 99, 99, 99, 99, 99, 99, 00, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 7, { 99, 99, 99, 99, 99, 99, 99, 00, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 7,
99, 99, 99, 99, 99, 99, 99, 00, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 7, 99, 99, 99, 99, 99, 99, 99, 00, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 7,
99, 99, 99, 99, 99, 99, 99, 00, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 7, 99, 99, 99, 99, 99, 99, 99, 00, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 7,
@ -95,6 +93,6 @@ const char init_voice[] =
99, 99, 99, 99, 50, 50, 50, 50, 0, 0, 1, 35, 0, 0, 0, 1, 0, 3, 24, 99, 99, 99, 99, 50, 50, 50, 50, 0, 0, 1, 35, 0, 0, 0, 1, 0, 3, 24,
73, 78, 73, 84, 32, 86, 79, 73, 67, 69 }; 73, 78, 73, 84, 32, 86, 79, 73, 67, 69 };
uint8_t data[161]; // program data uint8_t data[156]; // program data
#endif // PLUGINPROCESSOR_H_INCLUDED #endif // PLUGINPROCESSOR_H_INCLUDED

@ -17,6 +17,16 @@
#ifndef __SYNTH_H #ifndef __SYNTH_H
#define __SYNTH_H #define __SYNTH_H
#define DEXED_ID "0.9.2"
#ifdef DEBUG
#define DEXED_VERSION DEXED_ID " DEBUG"
#define TRACE(fmt, ...) dexed_trace(__PRETTY_FUNCTION__,fmt,##__VA_ARGS__)
#else
#define DEXED_VERSION DEXED_ID
#define TRACE(fmt, ...)
#endif
// This IS not be present on MSVC. // This IS not be present on MSVC.
// See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio // See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio
#include <stdint.h> #include <stdint.h>
@ -62,11 +72,4 @@ void dexed_trace(const char *source, const char *fmt, ...);
#define QER(n,b) ( ((float)n)/(1<<b) ) #define QER(n,b) ( ((float)n)/(1<<b) )
#ifdef _MSC_VER
#define TRACE(fmt, ...) dexed_trace(__FUNCTION__,fmt,##__VA_ARGS__)
#else
#define TRACE(fmt, ...) dexed_trace(__PRETTY_FUNCTION__,fmt,##__VA_ARGS__)
#endif
#endif // __SYNTH_H #endif // __SYNTH_H

Loading…
Cancel
Save