diff options
-rw-r--r-- | src/mdaPiano.cpp | 46 | ||||
-rw-r--r-- | src/mdaPiano.h | 44 |
2 files changed, 45 insertions, 45 deletions
diff --git a/src/mdaPiano.cpp b/src/mdaPiano.cpp index 6b5dc43..11c6fa4 100644 --- a/src/mdaPiano.cpp +++ b/src/mdaPiano.cpp @@ -52,7 +52,7 @@ mdaPiano::mdaPiano(double rate) if(programs) { //fill patches... - VstInt32 i=0; + uint32_t i=0; //TODO: load initial values from default preset fillpatch(i++, "mda Piano", 0.500f, 0.500f, 0.500f, 0.5f, 0.803f, 0.251f, 0.376f, 0.500f, 0.330f, 0.500f, 0.246f, 0.500f); setProgram(0); @@ -62,7 +62,7 @@ mdaPiano::mdaPiano(double rate) load_kgrp(kgrp); //initialise... - for(VstInt32 v=0; v<NVOICES; v++) + for(uint32_t v=0; v<NVOICES; v++) { voice[v].env = 0.0f; voice[v].dec = 0.99f; //all notes off @@ -81,7 +81,7 @@ mdaPiano::mdaPiano(double rate) void mdaPiano::update() //parameter change { float * param = programs[curProgram].param; - size = (VstInt32)(12.0f * param[2] - 6.0f); + size = (uint32_t)(12.0f * param[2] - 6.0f); sizevel = 0.12f * param[3]; muffvel = param[5] * param[5] * 5.0f; @@ -96,7 +96,7 @@ void mdaPiano::update() //parameter change trim = 1.50f - 0.79f * cdep; width = 0.04f * param[7]; if(width > 0.03f) width = 0.03f; - poly = 8 + (VstInt32)(24.9f * param[8]); + poly = 8 + (uint32_t)(24.9f * param[8]); } @@ -116,20 +116,20 @@ mdaPiano::~mdaPiano () //destroy any buffers... } -void mdaPiano::setParameter(VstInt32 index, float value) +void mdaPiano::setParameter(uint32_t index, float value) { programs[curProgram].param[index] = value; update(); } -void mdaPiano::process(float **inputs, float **outputs, VstInt32 sampleFrames) +void mdaPiano::process(float **inputs, float **outputs, uint32_t sampleFrames) { float* out0 = outputs[0]; float* out1 = outputs[1]; - VstInt32 event=0, frame=0, frames, v; + uint32_t event=0, frame=0, frames, v; float x, l, r; - VstInt32 i; + uint32_t i; while(frame<sampleFrames) { @@ -172,8 +172,8 @@ void mdaPiano::process(float **inputs, float **outputs, VstInt32 sampleFrames) if(frame<sampleFrames) { - VstInt32 note = notes[event++]; - VstInt32 vel = notes[event++]; + uint32_t note = notes[event++]; + uint32_t vel = notes[event++]; noteOn(note, vel); } } @@ -182,13 +182,13 @@ void mdaPiano::process(float **inputs, float **outputs, VstInt32 sampleFrames) } -void mdaPiano::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) +void mdaPiano::processReplacing(float **inputs, float **outputs, uint32_t sampleFrames) { float* out0 = outputs[0]; float* out1 = outputs[1]; - VstInt32 event=0, frame=0, frames, v; + uint32_t event=0, frame=0, frames, v; float x, l, r; - VstInt32 i; + uint32_t i; while(frame<sampleFrames) { @@ -242,8 +242,8 @@ if(!(r > -2.0f) || !(r < 2.0f)) if(frame<sampleFrames) { - VstInt32 note = notes[event++]; - VstInt32 vel = notes[event++]; + uint32_t note = notes[event++]; + uint32_t vel = notes[event++]; noteOn(note, vel); } } @@ -252,11 +252,11 @@ if(!(r > -2.0f) || !(r < 2.0f)) } -void mdaPiano::noteOn(VstInt32 note, VstInt32 velocity) +void mdaPiano::noteOn(uint32_t note, uint32_t velocity) { float * param = programs[curProgram].param; float l=99.0f; - VstInt32 v, vl=0, k, s; + uint32_t v, vl=0, k, s; if(velocity>0) { @@ -278,14 +278,14 @@ void mdaPiano::noteOn(VstInt32 note, VstInt32 velocity) if(note > 60) l += stretch * (float)k; //stretch s = size; - if(velocity > 40) s += (VstInt32)(sizevel * (float)(velocity - 40)); + if(velocity > 40) s += (uint32_t)(sizevel * (float)(velocity - 40)); k = 0; while(note > (kgrp[k].high + s)) k++; //find keygroup l += (float)(note - kgrp[k].root); //pitch l = 22050.0f * iFs * (float)exp(0.05776226505 * l); - voice[vl].delta = (VstInt32)(65536.0f * l); + voice[vl].delta = (uint32_t)(65536.0f * l); voice[vl].frac = 0; voice[vl].pos = kgrp[k].pos; voice[vl].end = kgrp[k].end; @@ -326,11 +326,11 @@ void mdaPiano::noteOn(VstInt32 note, VstInt32 velocity) } -VstInt32 mdaPiano::processEvents(VstEvents* ev) +uint32_t mdaPiano::processEvents(VstEvents* ev) { - VstInt32 npos=0; + uint32_t npos=0; - for (VstInt32 i=0; i<ev->numEvents; i++) + for (uint32_t i=0; i<ev->numEvents; i++) { if((ev->events[i])->type != kVstMidiType) continue; VstMidiEvent* event = (VstMidiEvent*)ev->events[i]; @@ -376,7 +376,7 @@ VstInt32 mdaPiano::processEvents(VstEvents* ev) default: //all notes off if(midiData[1]>0x7A) { - for(VstInt32 v=0; v<NVOICES; v++) voice[v].dec=0.99f; + for(uint32_t v=0; v<NVOICES; v++) voice[v].dec=0.99f; sustain = 0; muff = 160.0f; } diff --git a/src/mdaPiano.h b/src/mdaPiano.h index 750fd6c..c8a02a3 100644 --- a/src/mdaPiano.h +++ b/src/mdaPiano.h @@ -3,9 +3,9 @@ #ifndef __mdaPiano__ #define __mdaPiano__ -#include <string.h> - +#pragma GCC system_header #include <lv2synth.hpp> +#include <string.h> #define NPARAMS 12 //number of parameters #define NPROGS 8 //number of programs @@ -30,11 +30,11 @@ private: struct VOICE //voice state { - VstInt32 delta; //sample playback - VstInt32 frac; - VstInt32 pos; - VstInt32 end; - VstInt32 loop; + uint32_t delta; //sample playback + uint32_t frac; + uint32_t pos; + uint32_t end; + uint32_t loop; float env; //envelope float dec; @@ -45,17 +45,17 @@ struct VOICE //voice state float outl; float outr; - VstInt32 note; //remember what note triggered this + uint32_t note; //remember what note triggered this }; struct KGRP //keygroup { - VstInt32 root; //MIDI root note - VstInt32 high; //highest note - VstInt32 pos; - VstInt32 end; - VstInt32 loop; + uint32_t root; //MIDI root note + uint32_t high; //highest note + uint32_t pos; + uint32_t end; + uint32_t loop; }; class mdaPiano : public LV2::Synth<mdaPianoVoice, mdaPiano> { @@ -63,33 +63,33 @@ public: mdaPiano(double rate); ~mdaPiano(); - virtual void process(float **inputs, float **outputs, VstInt32 sampleframes); - virtual void processReplacing(float **inputs, float **outputs, VstInt32 sampleframes); - virtual VstInt32 processEvents(VstEvents* events); + virtual void process(float **inputs, float **outputs, uint32_t sampleframes); + virtual void processReplacing(float **inputs, float **outputs, uint32_t sampleframes); + virtual uint32_t processEvents(VstEvents* events); - virtual void setParameter(VstInt32 index, float value); + virtual void setParameter(uint32_t index, float value); virtual void resume(); private: void update(); //my parameter update - void noteOn(VstInt32 note, VstInt32 velocity); + void noteOn(uint32_t note, uint32_t velocity); float param[NPARAMS]; float Fs, iFs; #define EVENTBUFFER 120 #define EVENTS_DONE 99999999 - VstInt32 notes[EVENTBUFFER + 8]; //list of delta|note|velocity for current block + uint32_t notes[EVENTBUFFER + 8]; //list of delta|note|velocity for current block ///global internal variables KGRP kgrp[16]; VOICE voice[NVOICES]; - VstInt32 activevoices, poly, cpos; + uint32_t activevoices, poly, cpos; short *waves; - VstInt32 cmax; + uint32_t cmax; float *comb, cdep, width, trim; - VstInt32 size, sustain; + uint32_t size, sustain; float tune, fine, random, stretch; float muff, muffvel, sizevel, velsens, volume; }; |