Simple tests... SEGV is still present.

pull/1/head
Holger Wirtz 8 years ago
parent 0f99ea3c00
commit 57aa7c472b
  1. 108
      src/dexed-test.cpp
  2. 6
      src/dexed-test.sh
  3. 13
      src/dexed.cpp

@ -0,0 +1,108 @@
#include "EngineMkI.h"
#include "EngineOpl.h"
#include "msfa/exp2.h"
#include "msfa/sin.h"
#include "msfa/freqlut.h"
#include "msfa/controllers.h"
#include "msfa/dx7note.h"
#include "msfa/lfo.h"
#include "msfa/synth.h"
#include "msfa/fm_core.h"
#include <cstdint>
#include <limits>
template<class T> float normalize(const T x) {
const float valMin = std::numeric_limits<T>::min();
const float valMax = std::numeric_limits<T>::max();
return 2 * (x - valMin) / (valMax - valMin) - 1; // note: 0 does not become 0.
}
struct ProcessorVoice {
int midi_note;
bool keydown;
bool sustained;
bool live;
Dx7Note *dx7_note;
};
// GLOBALS
FmCore engineMsfa;
EngineMkI engineMkI;
EngineOpl engineOpl;
Lfo lfo;
Controllers controllers;
const int rate=44100;
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,
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, 99, 0, 1, 0, 7,
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[156]; // program data
ProcessorVoice voice;
uint8_t feedback_bitdepth=11;
int main(int argc, char **argv)
{
Exp2::init();
Tanh::init();
Sin::init();
Freqlut::init(rate);
Lfo::init(rate);
PitchEnv::init(rate);
Env::init_sr(rate);
uint32_t i;
for(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=&engineMsfa;
lfo.reset(data + 137);
voice.dx7_note=new Dx7Note;
unsigned char key=64;
unsigned char velocity=100;
voice.midi_note=key+data[144] - 24;
voice.keydown=true;
voice.live=false;
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();
int32_t s;
for(i=0;i<256;++i)
{
if(voice.live==true)
{
voice.dx7_note->compute(&s, lfo.getsample(), lfo.getdelay(), &controllers);
float fs=normalize(s);
printf("%f %d %d\n",fs, lfo.getsample(), lfo.getdelay());
}
}
}

@ -0,0 +1,6 @@
set -x
make
g++ -std=c++11 -c dexed-test.cpp
g++ -std=c++11 dexed-test.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 -lm -o dexed-test
./dexed-test

@ -104,19 +104,24 @@ unsigned char DexedVoice::get_key(void) const
void DexedVoice::render(uint32_t from, uint32_t to)
{
int32_t s;
uint32_t render_loop_counter=from;
TRACE("Hi");
TRACE("%d from: %d to: %d",voice_number,from,to);
TRACE("1:%d",render_loop_counter);
if (m_key != lvtk::INVALID_KEY)
{
for (uint32_t i = from; i < to; ++i)
for (render_loop_counter = from; render_loop_counter < to; ++render_loop_counter)
{
TRACE("2:%d",render_loop_counter);
if(voice.live==true)
{
TRACE("3:%d",render_loop_counter);
voice.dx7_note->compute(&s, lfo.getsample(), lfo.getdelay(), &controllers);
TRACE("4:%d",render_loop_counter);
float fs=(float)s/INT32_MAX;
p(p_lv2_audio_out_1)[i]+=fs;
p(p_lv2_audio_out_1)[render_loop_counter]+=fs;
TRACE("out: %2.5f",fs);
}
}
@ -124,7 +129,7 @@ void DexedVoice::render(uint32_t from, uint32_t to)
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)
@ -132,7 +137,7 @@ void DexedVoice::post_process(uint32_t from, uint32_t to)
p(p_lv2_audio_out_1)[i] *= *p(p_output);
}
TRACE("Bye");
}
} */
#ifdef DEBUG
void dexed_trace(const char *source, const char *fmt, ...) {

Loading…
Cancel
Save