... saving current state...

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

@ -27,11 +27,7 @@ void dexed_trace(const char *source, const char *fmt, ...);
#ifdef 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__)
#endif
#define TRACE(fmt, ...) dexed_trace(__PRETTY_FUNCTION__,fmt,##__VA_ARGS__)
#else
#define DEXED_VERSION DEXED_ID
#define TRACE(fmt, ...)

@ -121,8 +121,10 @@ EngineMkI::EngineMkI() {
inline int32_t mkiSin(int32_t phase, uint16_t 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;
expVal &= ~NEGATIVE_BIT;

@ -1,6 +1,6 @@
BUNDLE = dexed.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
# SysexComm.o PluginFx.o

@ -1,6 +1,7 @@
// from: http://ll-plugins.nongnu.org/lv2pftci/#A_synth
#include <lvtk/synth.hpp>
#include <string.h>
#include "dexed.peg"
#include "dexed.h"
#include "EngineMkI.h"
@ -10,25 +11,89 @@
#include "msfa/freqlut.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)
{
voice_number=voice_counter++;
TRACE("Hi %d",voice_number);
voice.dx7_note=new Dx7Note;
}
DexedVoice::~DexedVoice()
{
TRACE("Bye");
}
void DexedVoice::on(unsigned char key, unsigned char velocity)
{
m_key = key;
voice.dx7_note->init(data, key, velocity, feedback_bitdepth);
voice.midi_note=data[144] - 24;
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)
{
voice.dx7_note->keyup();
voice.keydown=false;
voice.live=false;
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
@ -38,51 +103,46 @@ unsigned char DexedVoice::get_key(void) const
void DexedVoice::render(uint32_t from, uint32_t to)
{
if (m_key == lvtk::INVALID_KEY)
return;
int32_t s;
for (uint32_t i = from; i < to; ++i)
TRACE("Hi");
TRACE("%d from: %d to: %d",voice_number,from,to);
if (m_key != lvtk::INVALID_KEY)
{
int32_t s;
//dx7_note->compute(&s, lfovalue, lfodelay, &controllers);
voice.dx7_note->compute(&s, lfo.getsample(), lfo.getdelay(), &controllers);
float fs=float(s)/(INT32_MAX);
p(p_lv2_audio_out_1)[i]+=fs;
}
for (uint32_t i = from; i < to; ++i)
{
if(voice.live==true)
{
voice.dx7_note->compute(&s, lfo.getsample(), lfo.getdelay(), &controllers);
float fs=(float)s/INT32_MAX;
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)
{
TRACE("Hi");
for (uint32_t i = from; i < to; ++i)
{
p(p_lv2_audio_out_1)[i] *= *p(p_output);
}
TRACE("Bye");
}
//==============================================================================
Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_lv2_events_in)
{
Exp2::init();
Tanh::init();
Sin::init();
Freqlut::init(rate);
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);
#ifdef DEBUG
void dexed_trace(const char *source, const char *fmt, ...) {
char output[4096];
va_list argptr;
va_start(argptr, fmt);
vsnprintf(output, 4095, fmt, argptr);
va_end(argptr);
printf("%s: %s\n",source,output);
}
#endif
static int _ = Dexed::register_class(p_uri);

@ -50,6 +50,7 @@ class DexedVoice : public lvtk::Voice
{
public:
DexedVoice(double rate);
~DexedVoice();
void on(unsigned char key, unsigned char velocity);
void off(unsigned char velocity);
unsigned char get_key(void) const;
@ -60,6 +61,7 @@ class DexedVoice : public lvtk::Voice
unsigned char m_key;
double m_rate;
ProcessorVoice voice;
char voice_number;
};
//==============================================================================
@ -68,24 +70,20 @@ class Dexed : public lvtk::Synth<DexedVoice, Dexed>
{
public:
Dexed(double rate);
FmCore *core;
~Dexed();
protected:
// dexed internal
};
// GLOBALS
char voice_counter=0;
EngineMkI engineMkI;
uint8_t feedback_bitdepth;
Lfo lfo;
Controllers controllers;
EngineMkI engineMkI;
//FmCore engineMsfa;
//EngineOpl engineOpl;
uint8_t feedback_bitdepth;
uint32_t engineType;
Lfo lfo;
Controllers controllers;
const char init_voice[] =
const uint8_t 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,
@ -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,
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

@ -17,6 +17,16 @@
#ifndef __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.
// See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio
#include <stdint.h>
@ -62,11 +72,4 @@ void dexed_trace(const char *source, const char *fmt, ...);
#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

Loading…
Cancel
Save