summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2013-01-14 17:37:35 +0800
committerrekado <rekado@elephly.net>2013-01-14 17:46:52 +0800
commit3f626394f1a2c974986abd8298c57c6bf1bec44c (patch)
treed5895047c1e22990ca968343fc227ad2251261d3 /src
parent8952fd3bd059645228d2a096775261fca05bc60d (diff)
move shared definitions into mdaPianoCommon
Diffstat (limited to 'src')
-rw-r--r--src/mdaPiano.cpp1
-rw-r--r--src/mdaPiano.h55
-rw-r--r--src/mdaPianoCommon.h30
3 files changed, 33 insertions, 53 deletions
diff --git a/src/mdaPiano.cpp b/src/mdaPiano.cpp
index f88e062..71a8189 100644
--- a/src/mdaPiano.cpp
+++ b/src/mdaPiano.cpp
@@ -13,6 +13,7 @@
* ==================================================
*/
+#include "mdaPianoCommon.h"
#include "mdaPiano.h"
#include <stdio.h>
diff --git a/src/mdaPiano.h b/src/mdaPiano.h
index d8449c7..f902efc 100644
--- a/src/mdaPiano.h
+++ b/src/mdaPiano.h
@@ -1,64 +1,13 @@
//See associated .cpp file for copyright and other info
-#ifndef __mdaPiano__
-#define __mdaPiano__
+#ifndef MDA_PIANO_H
+#define MDA_PIANO_H
#pragma GCC system_header
#include "mdaPianoVoice.h"
#include "mdaPiano.peg"
#include <lv2synth.hpp>
-#include <string.h>
-#define NPARAMS 12 //number of parameters
-#define NPROGS 8 //number of programs
-#define NOUTS 2 //number of outputs
-#define NVOICES 32 //max polyphony
-#define SUSTAIN 128
-#define SILENCE 0.0001f //voice choking
-#define WAVELEN 586348 //wave data bytes
-
-class mdaPianoProgram
-{
- friend class mdaPiano;
-public:
- mdaPianoProgram();
- ~mdaPianoProgram() {}
-
-private:
- float param[NPARAMS];
- char name[24];
-};
-
-
-struct VOICE //voice state
-{
- uint32_t delta; //sample playback
- uint32_t frac;
- uint32_t pos;
- uint32_t end;
- uint32_t loop;
-
- float env; //envelope
- float dec;
-
- float f0; //first-order LPF
- float f1;
- float ff;
-
- float outl;
- float outr;
- uint32_t note; //remember what note triggered this
-};
-
-
-struct KGRP //keygroup
-{
- 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> {
public:
diff --git a/src/mdaPianoCommon.h b/src/mdaPianoCommon.h
new file mode 100644
index 0000000..ed0c01d
--- /dev/null
+++ b/src/mdaPianoCommon.h
@@ -0,0 +1,30 @@
+#ifndef MDA_PIANO_COMMON_H
+#define MDA_PIANO_COMMON_H
+
+#define NPARAMS 12 //number of parameters
+#define NOUTS 2 //number of outputs
+#define NVOICES 64 //max polyphony
+#define SUSTAIN 128
+#define SILENCE 0.0001f //voice choking
+#define PARAM_OFFSET 3 //offset for param enum
+
+struct KGRP //keygroup
+{
+ long root; //MIDI root note
+ long high; //highest note
+ long pos;
+ long end;
+ long loop;
+};
+
+static float scale_midi_to_f(unsigned char data)
+{
+ return 0.0078f * (float)(data);
+}
+
+static unsigned char p_offset(unsigned char i)
+{
+ return (i - PARAM_OFFSET);
+}
+
+#endif