Saving current state.

pull/1/head
Holger Wirtz 8 years ago
parent 1087ad7c24
commit fe88998c12
  1. 58
      src/Makefile
  2. 333
      src/dexed-ttl.h
  3. 114
      src/dexed.cpp
  4. 58
      src/dexed.h
  5. 76
      src/msfa/ringbuffer.cc
  6. 44
      src/msfa/ringbuffer.h
  7. 0
      src/trash/DXComponents.h
  8. 0
      src/trash/ParamDialog.h
  9. 0
      src/trash/SysexComm.cpp

@ -1,35 +1,45 @@
BUNDLE = dexed.lv2 #DEBUG=-DDEBUG=1 -DMSFADEBUG=1
INSTALL_DIR = /home/pi/zynthian/zynthian-plugins/mod-lv2 #DEBUG=-DMSFADEBUG=1
CFLAGS := -fPIC -DPIC -DDEBUG=1 -std=c++11 -I. -I/usr/local/include/lvtk-2 BUNDLE=dexed.lv2
LDFLAGS := -L/usr/local/lib -llvtk_plugin2 INSTALL_DIR=/home/pi/zynthian/zynthian-plugins/mod-lv2
OBJ = 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 TARGET=dexed.so
# SysexComm.o PluginFx.o OBJ=ringbuffer.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
CFLAGS=-fPIC -DPIC $(DEBUG) -std=c++11 -I. -I/usr/local/include/lvtk-2
LDFLAGS=-L/usr/local/lib -llvtk_plugin2
$(BUNDLE): manifest.ttl Dexed.ttl dexed.so all: $(BUNDLE) Makefile
rm -rf $(BUNDLE)
mkdir $(BUNDLE)
cp $^ $(BUNDLE)
clean: clean:
rm -f *.o *~ *.bak *.gch *.peg dexed-test rm -f *.o *~ *.bak *.gch dexed-ttl.h *.so
rm -rf $(BUNDLE)
install: $(BUNDLE) install: $(BUNDLE)
mkdir -p $(INSTALL_DIR) mkdir -p $(INSTALL_DIR)
rm -rf $(INSTALL_DIR)/$(BUNDLE) rm -rf $(INSTALL_DIR)/$(BUNDLE)
rm -rf ${HOME}/.lv2/$(BUNDLE)
cp -R $(BUNDLE) $(INSTALL_DIR) cp -R $(BUNDLE) $(INSTALL_DIR)
dexed-test: $(OBJ) dexed-test.o $(BUNDLE): manifest.ttl Dexed.ttl dexed.so
g++ -fPIC -DPIC dexed-test.o $(OBJ) $(LDFLAGS) -o dexed-test rm -rf $(BUNDLE)
mkdir $(BUNDLE)
cp $^ $(BUNDLE)
# cp -R modgui $(BUNDLE)
dexed.so: $(OBJ) dexed.o dexed.so: $(OBJ) dexed.o
g++ -shared dexed.o $(OBJ) $(LDFLAGS) -o dexed.so g++ -shared dexed.o $(OBJ) $(LDFLAGS) -o dexed.so
dexed-test.o: dexed-test.cpp #dexed-test: $(OBJ) dexed-test.o
$(CXX) $(CFLAGS) -Wall -c dexed-test.cpp # g++ -fPIC -DPIC dexed-test.o $(OBJ) $(LDFLAGS) -o dexed-test
#
#dexed-test.o: dexed-test.cpp
# $(CXX) $(CFLAGS) -Wall -c dexed-test.cpp
dexed.o: dexed.cpp dexed.peg dexed.o: dexed.cpp dexed-ttl.h
$(CXX) $(CFLAGS) -Wall -c dexed.cpp $(CXX) $(CFLAGS) -Wall -c dexed.cpp
ringbuffer.o: msfa/ringbuffer.cc
$(CXX) $(CFLAGS) -Wall -c msfa/ringbuffer.cc
fm_core.o: msfa/fm_core.cc fm_core.o: msfa/fm_core.cc
$(CXX) $(CFLAGS) -Wall -c msfa/fm_core.cc $(CXX) $(CFLAGS) -Wall -c msfa/fm_core.cc
@ -66,18 +76,6 @@ EngineOpl.o: EngineOpl.cpp
PluginFx.o: PluginFx.cpp PluginFx.o: PluginFx.cpp
$(CXX) $(CFLAGS) -Wall -c PluginFx.cpp $(CXX) $(CFLAGS) -Wall -c PluginFx.cpp
PluginProcessor.o: PluginProcessor.cpp dexed-ttl.h: Dexed.ttl
$(CXX) $(CFLAGS) -Wall -c PluginProcessor.cpp ttl2c Dexed.ttl dexed-ttl.h
SysexComm.o: SysexComm.cpp
$(CXX) $(CFLAGS) -Wall -c SysexComm.cpp
#msfa/%.o: msfa/%.cc
# $(CXX) $(CFLAGS) -Wall -c $<
#
#%.o: %.cpp
# $(CXX) $(CFLAGS) -Wall -c $<
dexed.peg: Dexed.ttl
lv2peg Dexed.ttl dexed.peg

@ -0,0 +1,333 @@
#ifndef dexed_ttl_h
#define dexed_ttl_h
#ifndef PEG_STRUCT
#define PEG_STRUCT
typedef struct {
float min;
float max;
float default_value;
char toggled;
char integer;
char logarithmic;
} peg_data_t;
#endif
/* <https://github.com/dcoredump/dexed> */
static const char p_uri[] = "https://github.com/dcoredump/dexed";
enum p_port_enum {
p_lv2_events_in,
p_lv2_freewheel,
p_lv2_latency,
p_lv2_audio_out_1,
p_cutoff,
p_resonance,
p_output,
p_algorithm,
p_feedback,
p_osc_key_sync,
p_lfo_speed,
p_lfo_delay,
p_lfo_pm_depth,
p_lfo_am_depth,
p_lfo_key_sync,
p_lfo_wave,
p_middle_c,
p_p_mode_sens_,
p_pitch_eg_rate_1,
p_pitch_eg_rate_2,
p_pitch_eg_rate_3,
p_pitch_eg_rate_4,
p_pitch_eg_level_1,
p_pitch_eg_level_2,
p_pitch_eg_level_3,
p_pitch_eg_level_4,
p_op1_eg_rate_1,
p_op1_eg_rate_2,
p_op1_eg_rate_3,
p_op1_eg_rate_4,
p_op1_eg_level_1,
p_op1_eg_level_2,
p_op1_eg_level_3,
p_op1_eg_level_4,
p_op1_output_level,
p_op1_mode,
p_op1_f_coarse,
p_op1_f_fine,
p_op1_osc_detune,
p_op1_break_point,
p_op1_l_scale_depth,
p_op1_r_scale_depth,
p_op1_l_key_scale,
p_op1_r_key_scale,
p_op1_rate_scaling,
p_op1_a_mod_sens_,
p_op1_key_velocity,
p_op2_eg_rate_1,
p_op2_eg_rate_2,
p_op2_eg_rate_3,
p_op2_eg_rate_4,
p_op2_eg_level_1,
p_op2_eg_level_2,
p_op2_eg_level_3,
p_op2_eg_level_4,
p_op2_output_level,
p_op2_mode,
p_op2_f_coarse,
p_op2_f_fine,
p_op2_osc_detune,
p_op2_break_point,
p_op2_l_scale_depth,
p_op2_r_scale_depth,
p_op2_l_key_scale,
p_op2_r_key_scale,
p_op2_rate_scaling,
p_op2_a_mod_sens_,
p_op2_key_velocity,
p_op3_eg_rate_1,
p_op3_eg_rate_2,
p_op3_eg_rate_3,
p_op3_eg_rate_4,
p_op3_eg_level_1,
p_op3_eg_level_2,
p_op3_eg_level_3,
p_op3_eg_level_4,
p_op3_output_level,
p_op3_mode,
p_op3_f_coarse,
p_op3_f_fine,
p_op3_osc_detune,
p_op3_break_point,
p_op3_l_scale_depth,
p_op3_r_scale_depth,
p_op3_l_key_scale,
p_op3_r_key_scale,
p_op3_rate_scaling,
p_op3_a_mod_sens_,
p_op3_key_velocity,
p_op4_eg_rate_1,
p_op4_eg_rate_2,
p_op4_eg_rate_3,
p_op4_eg_rate_4,
p_op4_eg_level_1,
p_op4_eg_level_2,
p_op4_eg_level_3,
p_op4_eg_level_4,
p_op4_output_level,
p_op4_mode,
p_op4_f_coarse,
p_op4_f_fine,
p_op4_osc_detune,
p_op4_break_point,
p_op4_l_scale_depth,
p_op4_r_scale_depth,
p_op4_l_key_scale,
p_op4_r_key_scale,
p_op4_rate_scaling,
p_op4_a_mod_sens_,
p_op4_key_velocity,
p_op5_eg_rate_1,
p_op5_eg_rate_2,
p_op5_eg_rate_3,
p_op5_eg_rate_4,
p_op5_eg_level_1,
p_op5_eg_level_2,
p_op5_eg_level_3,
p_op5_eg_level_4,
p_op5_output_level,
p_op5_mode,
p_op5_f_coarse,
p_op5_f_fine,
p_op5_osc_detune,
p_op5_break_point,
p_op5_l_scale_depth,
p_op5_r_scale_depth,
p_op5_l_key_scale,
p_op5_r_key_scale,
p_op5_rate_scaling,
p_op5_a_mod_sens_,
p_op5_key_velocity,
p_op6_eg_rate_1,
p_op6_eg_rate_2,
p_op6_eg_rate_3,
p_op6_eg_rate_4,
p_op6_eg_level_1,
p_op6_eg_level_2,
p_op6_eg_level_3,
p_op6_eg_level_4,
p_op6_output_level,
p_op6_mode,
p_op6_f_coarse,
p_op6_f_fine,
p_op6_osc_detune,
p_op6_break_point,
p_op6_l_scale_depth,
p_op6_r_scale_depth,
p_op6_l_key_scale,
p_op6_r_key_scale,
p_op6_rate_scaling,
p_op6_a_mod_sens_,
p_op6_key_velocity,
p_n_ports
};
static const peg_data_t p_ports[] = {
{ -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 0, 0 },
{ 0, 1, 0, 1, 0, 0 },
{ -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 1, 0 },
{ -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 0, 0 },
{ 0, 1, 1, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 2, 1, 0, 0, 0 },
{ 1, 32, 1, 0, 1, 0 },
{ 1, 8, 1, 0, 1, 0 },
{ 1, 1, 0, 1, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 1, 0, 1, 1, 0 },
{ 1, 6, 1, 0, 1, 0 },
{ 0, 48, 24, 0, 1, 0 },
{ 1, 8, 1, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 1, 0, 1, 1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0 },
{ 0, 3, 0, 0, 1, 0 },
{ 0, 7, 0, 0, 1, 0 },
{ 0, 99, 99, 0, 1, 0 },
{ 0, 99, 99, 0, 1, 0 },
{ 0, 99, 99, 0, 1, 0 },
{ 0, 99, 99, 0, 1, 0 },
{ 0, 99, 99, 0, 1, 0 },
{ 0, 99, 99, 0, 1, 0 },
{ 0, 99, 99, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 1, 0, 1, 1, 0 },
{ 0, 31, 1, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ -7, 7, 7, 0, 1, 0 },
{ 0, 99, 39, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 99, 0, 0, 1, 0 },
{ 0, 3, 0, 0, 1, 0 },
{ 0, 3, 0, 0, 1, 0 },
{ 0, 7, 0, 0, 1, 0 },
{ 0, 3, 0, 0, 1, 0 },
{ 0, 7, 0, 0, 1, 0 },
};
#endif /* dexed_ttl_h */

@ -2,7 +2,7 @@
#include <lvtk/synth.hpp> #include <lvtk/synth.hpp>
#include <string.h> #include <string.h>
#include "dexed.peg" #include "dexed-ttl.h"
#include "dexed.h" #include "dexed.h"
#include "EngineMkI.h" #include "EngineMkI.h"
#include "EngineOpl.h" #include "EngineOpl.h"
@ -10,41 +10,52 @@
#include "msfa/sin.h" #include "msfa/sin.h"
#include "msfa/freqlut.h" #include "msfa/freqlut.h"
#include "msfa/controllers.h" #include "msfa/controllers.h"
#include "msfa/ringbuffer.h"
Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_lv2_events_in) Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_lv2_events_in)
{ {
TRACE("Hi"); TRACE("Hi");
bufsize_=256;
outbuf16_=new int16_t[bufsize_];
Exp2::init(); Exp2::init();
Tanh::init(); Tanh::init();
Sin::init(); Sin::init();
feedback_bitdepth=11; lastStateSave = 0;
currentNote = -1;
engineType = -1;
monoMode = 0;
normalizeDxVelocity = false;
memset(&voiceStatus, 0, sizeof(VoiceStatus));
setEngineType(DEXED_ENGINE_MARKI);
for(uint i=0;i<sizeof(init_voice);i++) { Freqlut::init(rate);
data[i] = init_voice[i]; Lfo::init(rate);
PitchEnv::init(rate);
Env::init_sr(rate);
fx.init(rate);
for (int note = 0; note < MAX_ACTIVE_NOTES; ++note) {
voices[note].dx7_note = new Dx7Note;
voices[note].keydown = false;
voices[note].sustained = false;
voices[note].live = false;
} }
controllers.values_[kControllerPitchRange] = 3; currentNote = 0;
controllers.values_[kControllerPitchStep] = 0;
controllers.masterTune = 0;
controllers.values_[kControllerPitch] = 0x2000; controllers.values_[kControllerPitch] = 0x2000;
controllers.modwheel_cc = 0; controllers.modwheel_cc = 0;
controllers.foot_cc = 0; controllers.foot_cc = 0;
controllers.breath_cc = 0; controllers.breath_cc = 0;
controllers.aftertouch_cc = 0; controllers.aftertouch_cc = 0;
controllers.core=&engineMkI; sustain = false;
lfo.reset(data + 137); 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_voices(new DexedVoice(rate));
add_audio_outputs(p_lv2_audio_out_1); add_audio_outputs(p_lv2_audio_out_1);
@ -52,6 +63,10 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_lv2_even
Dexed::~Dexed() Dexed::~Dexed()
{ {
TRACE("Hi");
delete [] outbuf16_;
TRACE("Bye"); TRACE("Bye");
} }
@ -59,86 +74,45 @@ Dexed::~Dexed()
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");
TRACE("Hi %d",voice_number);
voice.dx7_note=new Dx7Note; TRACE("Bye");
} }
DexedVoice::~DexedVoice() DexedVoice::~DexedVoice()
{ {
TRACE("Hi");
TRACE("Bye"); TRACE("Bye");
} }
void DexedVoice::on(unsigned char key, unsigned char velocity) void DexedVoice::on(unsigned char key, unsigned char velocity)
{ {
TRACE("Hi");
m_key = key; m_key = key;
voice.midi_note=data[144] - 24;
voice.keydown=true;
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); TRACE("Bye");
} }
void DexedVoice::off(unsigned char velocity) void DexedVoice::off(unsigned char velocity)
{ {
voice.dx7_note->keyup(); TRACE("Hi");
voice.keydown=false;
voice.live=false;
m_key = lvtk::INVALID_KEY; m_key = lvtk::INVALID_KEY;
TRACE("%d key-up: %d",voice_number,velocity);
TRACE("Bye");
} }
unsigned char DexedVoice::get_key(void) const unsigned char DexedVoice::get_key(void) const
{ {
return m_key; TRACE("Hi");
}
void DexedVoice::render(uint32_t from, uint32_t to) return m_key;
{
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 (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)[render_loop_counter]+=fs;
TRACE("out: %2.5f",fs);
}
}
}
TRACE("Bye"); 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");
} */
#ifdef DEBUG #ifdef DEBUG
void dexed_trace(const char *source, const char *fmt, ...) { void dexed_trace(const char *source, const char *fmt, ...) {
char output[4096]; char output[4096];

@ -26,6 +26,7 @@
#include "msfa/lfo.h" #include "msfa/lfo.h"
#include "msfa/synth.h" #include "msfa/synth.h"
#include "msfa/fm_core.h" #include "msfa/fm_core.h"
#include "msfa/ringbuffer.h"
#include "PluginFx.h" #include "PluginFx.h"
#include "EngineMkI.h" #include "EngineMkI.h"
#include "EngineOpl.h" #include "EngineOpl.h"
@ -44,6 +45,12 @@ enum DexedEngineResolution {
DEXED_ENGINE_OPL DEXED_ENGINE_OPL
}; };
#ifdef DEBUG
#define TRACE(fmt, ...) _trace(__PRETTY_FUNCTION__,fmt,##__VA_ARGS__)
#else
#define TRACE(fmt, ...)
#endif
//============================================================================== //==============================================================================
class DexedVoice : public lvtk::Voice class DexedVoice : public lvtk::Voice
@ -54,14 +61,10 @@ class DexedVoice : public lvtk::Voice
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;
void render(uint32_t from, uint32_t to);
void post_process(uint32_t from, uint32_t to);
protected: protected:
unsigned char m_key; unsigned char m_key;
double m_rate; double m_rate;
ProcessorVoice voice;
char voice_number;
}; };
//============================================================================== //==============================================================================
@ -71,28 +74,39 @@ class Dexed : public lvtk::Synth<DexedVoice, Dexed>
public: public:
Dexed(double rate); Dexed(double rate);
~Dexed(); ~Dexed();
int getEngineType();
void setEngineType(int rs);
bool isMonoMode();
void setMonoMode(bool mode);
void setParameter (int index, int newValue);
uint8_t data[161];
Controllers controllers;
VoiceStatus voiceStatus;
protected: protected:
// dexed internal static const int MAX_ACTIVE_NOTES = 16;
ProcessorVoice voices[MAX_ACTIVE_NOTES];
int currentNote;
bool sustain;
bool monoMode;
bool refreshVoice;
bool normalizeDxVelocity;
uint32_t engineType;
int feedback_bitdepth;
long lastStateSave;
PluginFx fx;
Lfo lfo;
FmCore engineMsfa;
EngineMkI engineMkI;
EngineOpl engineOpl;
int16_t* outbuf16_;
uint32_t bufsize_;
}; };
// GLOBALS // GLOBALS
char voice_counter=0; RingBuffer ring_buffer_;
EngineMkI engineMkI; //static const float scaler = 0.00003051757813;
uint8_t feedback_bitdepth; static const float scaler = 0.00003;
Lfo lfo;
Controllers controllers;
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
#endif // PLUGINPROCESSOR_H_INCLUDED #endif // PLUGINPROCESSOR_H_INCLUDED

@ -0,0 +1,76 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <time.h>
#include <string.h>
#include "synth.h"
#include "ringbuffer.h"
RingBuffer::RingBuffer() {
rd_ix_ = 0;
wr_ix_ = 0;
}
int RingBuffer::BytesAvailable() {
return (wr_ix_ - rd_ix_) & (kBufSize - 1);
}
int RingBuffer::WriteBytesAvailable() {
return (rd_ix_ - wr_ix_ - 1) & (kBufSize - 1);
}
int RingBuffer::Read(int size, uint8_t *bytes) {
int rd_ix = rd_ix_;
SynthMemoryBarrier(); // read barrier, make sure data is committed before ix
int fragment_size = min(size, kBufSize - rd_ix);
memcpy(bytes, buf_ + rd_ix, fragment_size);
if (size > fragment_size) {
memcpy(bytes + fragment_size, buf_, size - fragment_size);
}
SynthMemoryBarrier(); // full barrier, make sure read commits before updating
rd_ix_ = (rd_ix + size) & (kBufSize - 1);
return size;
}
int RingBuffer::Write(const uint8_t *bytes, int size) {
int remaining = size;
while (remaining > 0) {
int rd_ix = rd_ix_;
int wr_ix = wr_ix_;
int space_available = (rd_ix - wr_ix - 1) & (kBufSize - 1);
if (space_available == 0) {
struct timespec sleepTime;
sleepTime.tv_sec = 0;
sleepTime.tv_nsec = 1000000;
nanosleep(&sleepTime, NULL);
} else {
int wr_size = min(remaining, space_available);
int fragment_size = min(wr_size, kBufSize - wr_ix);
memcpy(buf_ + wr_ix, bytes, fragment_size);
if (wr_size > fragment_size) {
memcpy(buf_, bytes + fragment_size, wr_size - fragment_size);
}
SynthMemoryBarrier(); // write barrier, make sure data commits
wr_ix_ = (wr_ix + wr_size) & (kBufSize - 1);
remaining -= wr_size;
bytes += wr_size;
}
}
// JJK : defined as returning int
return 0;
}

@ -0,0 +1,44 @@
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SYNTH_RINGBUFFER_H_
#define SYNTH_RINGBUFFER_H_
class RingBuffer {
public:
RingBuffer();
// Returns number of bytes available for reading.
int BytesAvailable();
// Returns number of bytes that can be written without blocking.
int WriteBytesAvailable();
// Reads bytes. It is the caller's responsibility to make sure that
// size <= a previous value of BytesAvailable().
int Read(int size, uint8_t *bytes);
// Writes bytes into the buffer. If the buffer is full, the method will
// block until space is available.
int Write(const uint8_t *bytes, int size);
private:
static const int kBufSize = 8192;
uint8_t buf_[kBufSize];
volatile unsigned int rd_ix_;
volatile unsigned int wr_ix_;
};
#endif // SYNTH_RINGBUFFER_H_
Loading…
Cancel
Save