summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2014-04-28 02:35:55 +1000
committerDamien Zammit <damien@zamaudio.com>2014-04-28 02:35:55 +1000
commit4abb9e1d658ab6fb8075ab594d79a6139b40b242 (patch)
treee5a03bd504f8c47e7a1d8afc08abb2600ae5360e
parentd1bff512b834684e1cb84b4124cc7caf3cb53bcb (diff)
Added toggle
Signed-off-by: Damien Zammit <damien@zamaudio.com>
-rw-r--r--plugins/ZamSynth/ZamSynthArtwork.cpp34
-rw-r--r--plugins/ZamSynth/ZamSynthArtwork.hpp10
-rw-r--r--plugins/ZamSynth/ZamSynthPlugin.cpp99
-rw-r--r--plugins/ZamSynth/ZamSynthPlugin.hpp9
-rw-r--r--plugins/ZamSynth/ZamSynthUI.cpp103
-rw-r--r--plugins/ZamSynth/ZamSynthUI.hpp9
6 files changed, 195 insertions, 69 deletions
diff --git a/plugins/ZamSynth/ZamSynthArtwork.cpp b/plugins/ZamSynth/ZamSynthArtwork.cpp
index 0866ec7..3fc791f 100644
--- a/plugins/ZamSynth/ZamSynthArtwork.cpp
+++ b/plugins/ZamSynth/ZamSynthArtwork.cpp
@@ -261,6 +261,38 @@ static const unsigned char temp3[] = {
const char* ZamSynthArtwork::smoothyData = (const char*)temp3;
static const unsigned char temp4[] = {
+ 0, 0, 0, 61, 0, 0, 0, 199, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 199, 0, 0, 0, 61, 0, 0, 0, 203, 0, 0, 0, 255, 0, 0, 0, 223, 0, 0, 0, 216, 0, 0, 0, 216, 0, 0, 0, 216, 0, 0, 0, 216, 0, 0, 0, 216, 0, 0, 0, 216,
+ 0, 0, 0, 223, 0, 0, 0, 255, 0, 0, 0, 203, 0, 0, 0, 255, 0, 0, 0, 224, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 224, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
+ 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0,
+ 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255,
+ 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
+ 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
+ 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 220, 0, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 220, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 4, 220, 0, 0, 23, 119,
+ 0, 0, 23, 119, 0, 0, 23, 119, 0, 0, 23, 119, 0, 0, 23, 119, 0, 0, 23, 119, 0, 0, 23, 119, 0, 0, 23, 119, 0, 0, 4, 220, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 14, 219, 0, 0, 180, 88, 0, 0, 180, 88, 0, 0, 180, 88, 0, 0, 180, 88, 0, 0, 180, 88, 0, 0, 180, 88, 0, 0, 180, 88, 0, 0, 180, 88, 0, 0, 14, 219, 0, 0, 0, 255,
+ 0, 0, 0, 255, 0, 0, 17, 219, 0, 0, 181, 113, 0, 0, 181, 113, 0, 0, 181, 113, 0, 0, 181, 113, 0, 0, 181, 113, 0, 0, 181, 113, 0, 0, 181, 113, 0, 0, 181, 113, 0, 0, 17, 219, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 21, 220, 0, 0, 180, 139, 0, 0, 180, 139, 0, 0, 180, 139, 0, 0, 180, 139, 0, 0, 180, 139, 0, 0, 180, 139, 0, 0, 180, 139,
+ 0, 0, 180, 139, 0, 0, 21, 220, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 25, 221, 0, 0, 180, 164, 0, 0, 180, 164, 0, 0, 180, 164, 0, 0, 180, 164, 0, 0, 180, 164, 0, 0, 180, 164, 0, 0, 180, 164, 0, 0, 180, 164, 0, 0, 25, 221, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 29, 221, 0, 0, 180, 190, 0, 0, 180, 190, 0, 0, 180, 190, 0, 0, 180, 190,
+ 0, 0, 180, 190, 0, 0, 180, 190, 0, 0, 180, 190, 0, 0, 180, 190, 0, 0, 29, 221, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 33, 222, 0, 0, 180, 215, 0, 0, 180, 215, 0, 0, 180, 215, 0, 0, 180, 215, 0, 0, 180, 215, 0, 0, 180, 215, 0, 0, 180, 215, 0, 0, 180, 215, 0, 0, 33, 222, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 36, 228, 0, 0, 180, 241,
+ 0, 0, 180, 241, 0, 0, 180, 241, 0, 0, 180, 241, 0, 0, 180, 241, 0, 0, 180, 241, 0, 0, 180, 241, 0, 0, 180, 241, 0, 0, 36, 228, 0, 0, 0, 255, 0, 0, 0, 203, 0, 0, 6, 255, 0, 0, 38, 227, 0, 0, 39, 223, 0, 0, 39, 223, 0, 0, 39, 223, 0, 0, 39, 223, 0, 0, 39, 223, 0, 0, 39, 223, 0, 0, 38, 227, 0, 0, 6, 255, 0, 0, 0, 203,
+ 0, 0, 0, 61, 0, 0, 0, 203, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 203, 0, 0, 0, 61,};
+const char* ZamSynthArtwork::toggleoffData = (const char*)temp4;
+
+static const unsigned char temp5[] = {
+ 0, 0, 0, 81, 0, 0, 0, 222, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 222, 0, 0, 0, 81, 0, 0, 0, 225, 0, 6, 0, 254, 0, 39, 0, 224, 0, 39, 0, 223, 0, 39, 0, 223, 0, 39, 0, 223, 0, 39, 0, 223, 0, 39, 0, 223, 0, 39, 0, 223,
+ 0, 39, 0, 224, 0, 6, 0, 254, 0, 0, 0, 225, 0, 0, 0, 255, 0, 36, 0, 224, 0, 180, 0, 238, 0, 180, 0, 238, 0, 180, 0, 238, 0, 180, 0, 238, 0, 180, 0, 238, 0, 180, 0, 238, 0, 180, 0, 238, 0, 180, 0, 238, 0, 36, 0, 224, 0, 0, 0, 255, 0, 0, 0, 255, 0, 32, 0, 222, 0, 180, 0, 214, 0, 180, 0, 214, 0, 180, 0, 214, 0, 180, 0, 214,
+ 0, 180, 0, 214, 0, 180, 0, 214, 0, 180, 0, 214, 0, 180, 0, 214, 0, 32, 0, 222, 0, 0, 0, 255, 0, 0, 0, 255, 0, 29, 0, 221, 0, 179, 0, 189, 0, 179, 0, 189, 0, 179, 0, 189, 0, 179, 0, 189, 0, 179, 0, 189, 0, 179, 0, 189, 0, 179, 0, 189, 0, 179, 0, 189, 0, 29, 0, 221, 0, 0, 0, 255, 0, 0, 0, 255, 0, 25, 0, 221, 0, 180, 0, 164,
+ 0, 180, 0, 164, 0, 180, 0, 164, 0, 180, 0, 164, 0, 180, 0, 164, 0, 180, 0, 164, 0, 180, 0, 164, 0, 180, 0, 164, 0, 25, 0, 221, 0, 0, 0, 255, 0, 0, 0, 255, 0, 22, 0, 220, 0, 180, 0, 140, 0, 180, 0, 140, 0, 180, 0, 140, 0, 180, 0, 140, 0, 180, 0, 140, 0, 180, 0, 140, 0, 180, 0, 140, 0, 180, 0, 140, 0, 22, 0, 220, 0, 0, 0, 255,
+ 0, 0, 0, 255, 0, 17, 0, 219, 0, 180, 0, 115, 0, 180, 0, 115, 0, 180, 0, 115, 0, 180, 0, 115, 0, 180, 0, 115, 0, 180, 0, 115, 0, 180, 0, 115, 0, 180, 0, 115, 0, 17, 0, 219, 0, 0, 0, 255, 0, 0, 0, 255, 0, 14, 0, 219, 0, 181, 0, 90, 0, 181, 0, 90, 0, 181, 0, 90, 0, 181, 0, 90, 0, 181, 0, 90, 0, 181, 0, 90, 0, 181, 0, 90,
+ 0, 181, 0, 90, 0, 14, 0, 219, 0, 0, 0, 255, 0, 0, 0, 255, 0, 5, 0, 223, 0, 3, 0, 235, 0, 3, 0, 235, 0, 3, 0, 235, 0, 3, 0, 235, 0, 3, 0, 235, 0, 3, 0, 235, 0, 3, 0, 235, 0, 3, 0, 235, 0, 5, 0, 223, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
+ 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0,
+ 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255,
+ 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
+ 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
+ 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 216, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 216, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 217, 255, 255, 255, 0,
+ 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 217, 0, 0, 0, 255, 0, 0, 0, 225, 0, 0, 0, 254, 0, 0, 0, 217, 0, 0, 0, 216, 0, 0, 0, 216, 0, 0, 0, 216, 0, 0, 0, 216, 0, 0, 0, 216, 0, 0, 0, 216, 0, 0, 0, 217, 0, 0, 0, 254, 0, 0, 0, 225,
+ 0, 0, 0, 83, 0, 0, 0, 225, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 225, 0, 0, 0, 83,};
+const char* ZamSynthArtwork::toggleonData = (const char*)temp5;
+
+static const unsigned char temp6[] = {
194, 194, 194, 168, 168, 168, 149, 149, 149, 143, 143, 143, 144, 144, 144, 144, 144, 144, 144, 144, 144, 142, 142, 142, 144, 144, 144, 143, 143, 143, 139, 139, 139, 135, 135, 135, 132, 132, 132, 133, 133, 133, 134, 134, 134, 129, 129, 129, 125, 125, 125, 127, 127, 127, 130, 130, 130, 133, 133, 133, 131, 131, 131,
128, 128, 128, 130, 130, 130, 125, 125, 125, 122, 122, 122, 122, 122, 122, 119, 119, 119, 115, 115, 115, 117, 117, 117, 116, 116, 116, 115, 115, 115, 117, 117, 117, 116, 116, 116, 115, 115, 115, 110, 110, 110, 110, 110, 110, 108, 108, 108, 110, 110, 110, 107, 107, 107, 102, 102, 102, 108, 108, 108, 103, 103, 103,
100, 100, 100, 100, 100, 100, 100, 100, 100, 98, 98, 98, 100, 100, 100, 98, 98, 98, 96, 96, 96, 96, 96, 96, 94, 94, 94, 92, 92, 92, 96, 96, 96, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 97, 97, 97, 100, 100, 100, 103, 103, 103, 103, 103, 103, 102, 102, 102, 104, 104, 104,
@@ -5262,5 +5294,5 @@ static const unsigned char temp4[] = {
103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 105, 105, 105, 107, 107, 107, 107, 107, 107, 108, 108, 108, 108, 108, 108, 112, 112, 112, 112, 112, 112, 116, 116, 116, 117, 117, 117, 115, 115, 115, 115, 115, 115, 118, 118, 118, 118, 118, 118, 122, 122, 122, 119, 119, 119, 119, 119, 119, 122, 122, 122,
123, 123, 123, 125, 125, 125, 125, 125, 125, 127, 127, 127, 129, 129, 129, 129, 129, 129, 133, 133, 133, 133, 133, 133, 133, 133, 133, 132, 132, 132, 134, 134, 134, 134, 134, 134, 135, 135, 135, 138, 138, 138, 141, 141, 141, 141, 141, 141, 141, 141, 141, 147, 147, 147, 148, 148, 148, 157, 157, 157, 176, 176, 176,
};
-const char* ZamSynthArtwork::zamsynthData = (const char*)temp4;
+const char* ZamSynthArtwork::zamsynthData = (const char*)temp6;
diff --git a/plugins/ZamSynth/ZamSynthArtwork.hpp b/plugins/ZamSynth/ZamSynthArtwork.hpp
index 5858690..d4f51c2 100644
--- a/plugins/ZamSynth/ZamSynthArtwork.hpp
+++ b/plugins/ZamSynth/ZamSynthArtwork.hpp
@@ -20,6 +20,16 @@ namespace ZamSynthArtwork
const unsigned int smoothyWidth = 78;
const unsigned int smoothyHeight = 22;
+ extern const char* toggleoffData;
+ const unsigned int toggleoffDataSize = 1056;
+ const unsigned int toggleoffWidth = 12;
+ const unsigned int toggleoffHeight = 22;
+
+ extern const char* toggleonData;
+ const unsigned int toggleonDataSize = 1056;
+ const unsigned int toggleonWidth = 12;
+ const unsigned int toggleonHeight = 22;
+
extern const char* zamsynthData;
const unsigned int zamsynthDataSize = 315000;
const unsigned int zamsynthWidth = 350;
diff --git a/plugins/ZamSynth/ZamSynthPlugin.cpp b/plugins/ZamSynth/ZamSynthPlugin.cpp
index 8ed3d23..f49d1df 100644
--- a/plugins/ZamSynth/ZamSynthPlugin.cpp
+++ b/plugins/ZamSynth/ZamSynthPlugin.cpp
@@ -51,6 +51,15 @@ void ZamSynthPlugin::d_initParameter(uint32_t index, Parameter& parameter)
parameter.ranges.min = -30.0f;
parameter.ranges.max = 30.0f;
break;
+ case paramGraph:
+ parameter.hints = PARAMETER_IS_AUTOMABLE | PARAMETER_IS_BOOLEAN;
+ parameter.name = "Graph toggle";
+ parameter.symbol = "graph";
+ parameter.unit = " ";
+ parameter.ranges.def = 0.0f;
+ parameter.ranges.min = 0.0f;
+ parameter.ranges.max = 1.0f;
+ break;
}
}
@@ -72,6 +81,9 @@ float ZamSynthPlugin::d_getParameterValue(uint32_t index) const
case paramGain:
return gain;
break;
+ case paramGraph:
+ return graph;
+ break;
default:
return 0.0f;
}
@@ -84,6 +96,9 @@ void ZamSynthPlugin::d_setParameterValue(uint32_t index, float value)
case paramGain:
gain = value;
break;
+ case paramGraph:
+ graph = value;
+ break;
}
}
@@ -94,12 +109,13 @@ void ZamSynthPlugin::d_setProgram(uint32_t index)
/* Default parameter values */
gain = 0.0f;
+ graph = 0.0f;
/* Default variable values */
for (int i = 0; i < 127; i++) {
voice[i].playing = false;
voice[i].notenum = 0;
- voice[i].envpos = 0;
+ voice[i].envpos = 0.f;
voice[i].curamp = 0.f;
voice[i].vi = 0.f;
voice[i].rampstate = 0.f;
@@ -112,7 +128,7 @@ void ZamSynthPlugin::d_setProgram(uint32_t index)
}
for (int i = 0; i < MAX_ENV; i++) {
- env_y[i] = sin(i*2.*M_PI/d_getSampleRate()*1000./2.*24);
+ env_y[i] = sin(i*2.*M_PI/d_getSampleRate()*1000./2.);
}
/* reset filter values */
d_activate();
@@ -120,26 +136,37 @@ void ZamSynthPlugin::d_setProgram(uint32_t index)
void ZamSynthPlugin::d_setState(const char* key, const char* value)
{
- if (strcmp(key, "waveform") != 0) return;
-
- char* tmp;
- int i = 0;
- char tmpbuf[4*AREAHEIGHT+1] = {0};
- snprintf(tmpbuf, 4*AREAHEIGHT, "%s", value);
- tmp = strtok(tmpbuf, " ");
- while ((tmp != NULL) && (i < AREAHEIGHT)) {
- wave_y[i] = ((float) atoi(tmp))/AREAHEIGHT - 0.5;
- i++;
- //printf("dsp wave_y[%d]=%.2f ", i, wave_y[i]);
- tmp = strtok(NULL, " ");
+ if (strcmp(key, "waveform") == 0) {
+ char* tmp;
+ int i = 0;
+ char tmpbuf[4*AREAHEIGHT+1] = {0};
+ snprintf(tmpbuf, 4*AREAHEIGHT, "%s", value);
+ tmp = strtok(tmpbuf, " ");
+ while ((tmp != NULL) && (i < AREAHEIGHT)) {
+ wave_y[i] = ((float) atoi(tmp))/AREAHEIGHT - 0.5;
+ i++;
+ //printf("dsp wave_y[%d]=%.2f ", i, wave_y[i]);
+ tmp = strtok(NULL, " ");
+ }
+ } else if (strcmp(key, "envelope") == 0) {
+ char* tmp;
+ int i = 0;
+ char tmpbuf[4*MAX_ENV+1] = {0};
+ snprintf(tmpbuf, 4*MAX_ENV, "%s", value);
+ tmp = strtok(tmpbuf, " ");
+ while ((tmp != NULL) && (i < MAX_ENV)) {
+ env_y[i] = ((float) atoi(tmp))/MAX_ENV - 0.5;
+ i++;
+ //printf("dsp wave_y[%d]=%.2f ", i, wave_y[i]);
+ tmp = strtok(NULL, " ");
+ }
}
}
void ZamSynthPlugin::d_initStateKey(unsigned int index, d_string& key)
{
- if (index != 0)
- return;
- key = "waveform";
+ if (index == 0) key = "waveform";
+ if (index == 1) key = "envelope";
}
// -----------------------------------------------------------------------
@@ -166,11 +193,11 @@ void ZamSynthPlugin::d_run(float**, float** outputs, uint32_t frames,
const MidiEvent* midievent, uint32_t midicount)
{
float srate = d_getSampleRate();
- float max_envcounter = srate / 5; // 1/20th of a second for both attack and release
+ int slowdown = (int) srate / 2000;
uint32_t i,j;
float RD_0;
int vn;
-
+
for (i = 0; i < midicount; i++) {
int type = midievent[i].buf[0] & 0xF0;
int chan = midievent[i].buf[0] & 0x0F;
@@ -178,7 +205,7 @@ void ZamSynthPlugin::d_run(float**, float** outputs, uint32_t frames,
int vel = midievent[i].buf[2];
if (type == 0x90 && chan == 0x0) {
// NOTE ON
- printf("ON: Note\n");
+ //printf("ON: Note\n");
//find voice with current notenum
vn = -1;
nvoices = 0;
@@ -191,7 +218,7 @@ void ZamSynthPlugin::d_run(float**, float** outputs, uint32_t frames,
}
}
if (vn != -1) {
- printf("note already playing\n");
+ //printf("note already playing\n");
//begin attack
voice[vn].playing = true;
voice[vn].envpos = 1;
@@ -204,12 +231,12 @@ void ZamSynthPlugin::d_run(float**, float** outputs, uint32_t frames,
nvoices++;
curvoice = &voice[nvoices];
if (nvoices > MAX_VOICES) {
- printf("steal first voice\n");
+ //printf("steal first voice\n");
curvoice = voice; // steal first voice
nvoices--;
}
- printf("ON: nvoices = %d\n", nvoices);
- printf("ON: begin attack\n");
+ //printf("ON: nvoices = %d\n", nvoices);
+ //printf("ON: begin attack\n");
curvoice->envpos = 1; // begin attack
curvoice->playing = true;
curvoice->notenum = num;
@@ -219,7 +246,7 @@ void ZamSynthPlugin::d_run(float**, float** outputs, uint32_t frames,
}
else if (type == 0x80 && chan == 0x0) {
// NOTE OFF
- printf("OFF: Note\n");
+ //printf("OFF: Note\n");
//find voice with current notenum
vn = -1;
int v2 = -1;
@@ -237,16 +264,16 @@ void ZamSynthPlugin::d_run(float**, float** outputs, uint32_t frames,
}
if (vn != -1) {
voice[vn].envpos = MAX_ENV / 2 + 1; // begin release;
- printf("begin release\n");
+ //printf("begin release\n");
continue;
}
if (v2 != -1) {
- printf("note already off, do nothing\n");
+ //printf("note already off, do nothing\n");
voice[v2].envpos = 0;
voice[v2].curamp = 0.f;
voice[v2].vi = 0.f;
voice[v2].playing = false;
- printf("OFF: nvoices = %d\n", nvoices);
+ //printf("OFF: nvoices = %d\n", nvoices);
}
}
}
@@ -266,24 +293,24 @@ void ZamSynthPlugin::d_run(float**, float** outputs, uint32_t frames,
for (k = 0; k < 128; k++) {
j = &voice[k];
if (j->playing) {
- if (j->envpos <= 0) {
+ if ((int) j->envpos <= 0) {
//silence
j->curamp = 0.f;
j->playing = false;
j->envpos = 0;
- } else if (j->envpos > 0 && j->envpos < MAX_ENV / 2) {
+ } else if ((int) j->envpos > 0 && (int) j->envpos < MAX_ENV / 2) {
//attack
j->curamp = j->vi * env_y[(int)(j->envpos)];
//printf("att: %d %d curamp=%.2f\n",k,j->envpos, j->curamp);
- j->envpos++;
- } else if (j->envpos > MAX_ENV / 2) {
+ j->envpos += 1. / slowdown;
+ } else if ((int) j->envpos > MAX_ENV / 2) {
//release
j->curamp = j->vi * env_y[(int)(j->envpos)];
//printf("rel: %d %d curamp=%.2f\n",k,j->envpos, j->curamp);
- j->envpos++;
- if (j->envpos == MAX_ENV) {
+ j->envpos += 1. / slowdown;
+ if ((int) j->envpos == MAX_ENV) {
//end of release
- j->envpos = 0;
+ j->envpos = 0.f;
j->curamp = 0.f;
j->vi = 0.f;
j->playing = false;
@@ -293,7 +320,7 @@ void ZamSynthPlugin::d_run(float**, float** outputs, uint32_t frames,
curvoice = voice + MAX_VOICES-1;
nvoices++;
}
- printf("killed, nvoices=%d\n",nvoices);
+ //printf("killed, nvoices=%d\n",nvoices);
}
} else {
//sustain
diff --git a/plugins/ZamSynth/ZamSynthPlugin.hpp b/plugins/ZamSynth/ZamSynthPlugin.hpp
index 441e59f..27eb23c 100644
--- a/plugins/ZamSynth/ZamSynthPlugin.hpp
+++ b/plugins/ZamSynth/ZamSynthPlugin.hpp
@@ -22,9 +22,7 @@
#include "DistrhoPlugin.hpp"
#define MAX_VOICES 64
#define AREAHEIGHT 250
-#define MAX_ENV 3000
-#define MAX_ENVCOUNTER 48000
-#define NOTPLAYING -1
+#define MAX_ENV AREAHEIGHT
START_NAMESPACE_DISTRHO
@@ -36,6 +34,7 @@ public:
enum Parameters
{
paramGain,
+ paramGraph,
paramCount
};
@@ -114,14 +113,14 @@ protected:
// -------------------------------------------------------------------
private:
- float gain;
+ float gain, graph;
int nvoices;
float wave_y[AREAHEIGHT];
float env_y[MAX_ENV];
typedef struct v {
bool playing;
int notenum;
- int envpos;
+ float envpos;
float curamp;
float vi;
float rampstate;
diff --git a/plugins/ZamSynth/ZamSynthUI.cpp b/plugins/ZamSynth/ZamSynthUI.cpp
index 47c7dcb..2afc28c 100644
--- a/plugins/ZamSynth/ZamSynthUI.cpp
+++ b/plugins/ZamSynth/ZamSynthUI.cpp
@@ -31,9 +31,15 @@ ZamSynthUI::ZamSynthUI()
// knob
Image knobImage(ZamSynthArtwork::knobData, ZamSynthArtwork::knobWidth, ZamSynthArtwork::knobHeight);
+
+ // button
Image smoothrImage(ZamSynthArtwork::smoothrData, ZamSynthArtwork::smoothrWidth, ZamSynthArtwork::smoothrHeight);
Image smoothyImage(ZamSynthArtwork::smoothyData, ZamSynthArtwork::smoothyWidth, ZamSynthArtwork::smoothyHeight);
+ // toggle
+ Image toggleonImage(ZamSynthArtwork::toggleonData, ZamSynthArtwork::toggleonWidth, ZamSynthArtwork::toggleonHeight);
+ Image toggleoffImage(ZamSynthArtwork::toggleoffData, ZamSynthArtwork::toggleoffWidth, ZamSynthArtwork::toggleoffHeight);
+
// knob
fKnobGain = new ImageKnob(this, knobImage);
@@ -48,35 +54,56 @@ ZamSynthUI::ZamSynthUI()
fButtonSmooth->setPos(265, 55);
fButtonSmooth->setCallback(this);
+ // drawing area
fCanvasArea.setPos(10,10);
fCanvasArea.setSize(AREAHEIGHT,AREAHEIGHT);
for (int i = 0; i < AREAHEIGHT; i++) {
wave_y[i] = -(AREAHEIGHT*(sin(2.*i*M_PI/AREAHEIGHT)-1.0))/2.;
+ env_y[i] = -(2*AREAHEIGHT*(sin(2.*i*M_PI/AREAHEIGHT/2.)-1.0))/2.;
}
+
+ // toggle
+ fToggleGraph = new ImageToggle(this, toggleonImage, toggleoffImage, toggleoffImage);
+ fToggleGraph->setPos(290, 85);
+ fToggleGraph->setCallback(this);
+
+ fGraph = false;
}
ZamSynthUI::~ZamSynthUI()
{
delete fKnobGain;
delete fButtonSmooth;
+ delete fToggleGraph;
}
void ZamSynthUI::d_stateChanged(const char* key, const char* value)
{
- if (strcmp(key, "waveform") != 0) return;
-
- char* tmp;
- char* saveptr;
- int i = 0;
- char tmpbuf[4*AREAHEIGHT+1] = {0};
- snprintf(tmpbuf, 4*AREAHEIGHT, "%s", value);
- tmp = strtok(tmpbuf, " ");
- while ((tmp != NULL) && (i < AREAHEIGHT)) {
- wave_y[i] = AREAHEIGHT-((float)atoi(tmp));
- i++;
- //printf("reload dsp wave_y[%d]=%.2f ", i, wave_y[i]);
- tmp = strtok(NULL, " ");
- }
+ if (strcmp(key, "waveform") == 0) {
+ char* tmp;
+ int i = 0;
+ char tmpbuf[4*AREAHEIGHT+1] = {0};
+ snprintf(tmpbuf, 4*AREAHEIGHT, "%s", value);
+ tmp = strtok(tmpbuf, " ");
+ while ((tmp != NULL) && (i < AREAHEIGHT)) {
+ wave_y[i] = AREAHEIGHT-((float)atoi(tmp));
+ i++;
+ //printf("reload dsp wave_y[%d]=%.2f ", i, wave_y[i]);
+ tmp = strtok(NULL, " ");
+ }
+ } else if (strcmp(key, "envelope") == 0) {
+ char* tmp;
+ int i = 0;
+ char tmpbuf[4*AREAHEIGHT+1] = {0};
+ snprintf(tmpbuf, 4*AREAHEIGHT, "%s", value);
+ tmp = strtok(tmpbuf, " ");
+ while ((tmp != NULL) && (i < AREAHEIGHT)) {
+ env_y[i] = AREAHEIGHT-((float)atoi(tmp));
+ i++;
+ //printf("reload dsp env_y[%d]=%.2f ", i, env_y[i]);
+ tmp = strtok(NULL, " ");
+ }
+ }
}
// -----------------------------------------------------------------------
@@ -121,7 +148,7 @@ void ZamSynthUI::imageKnobValueChanged(ImageKnob* knob, float value)
d_setParameterValue(ZamSynthPlugin::paramGain, value);
}
-void ZamSynthUI::imageButtonClicked(ImageButton* button, int)
+void ZamSynthUI::imageButtonClicked(ImageButton*, int)
{
float wavesmooth[AREAHEIGHT];
float xs[AREAHEIGHT];
@@ -129,17 +156,29 @@ void ZamSynthUI::imageButtonClicked(ImageButton* button, int)
for (i = 0; i < AREAHEIGHT; i++) {
xs[i] = i;
}
- gaussiansmooth(wavesmooth, xs, wave_y, AREAHEIGHT, 4);
- memcpy(wave_y, wavesmooth, AREAHEIGHT*sizeof(float));
+
+ float *gr;
+ gr = (fGraph) ? env_y : wave_y;
+
+ gaussiansmooth(wavesmooth, xs, gr, AREAHEIGHT, 4);
+ memcpy(gr, wavesmooth, AREAHEIGHT*sizeof(float));
char tmp[4*AREAHEIGHT+1] = {0};
for(i = 0; i < AREAHEIGHT; i++) {
char wavestr[5] = {0};
- snprintf(wavestr, sizeof(wavestr), "%03d ", (int) (fCanvasArea.getHeight()-wave_y[i]));
+ snprintf(wavestr, sizeof(wavestr), "%03d ", (int) (fCanvasArea.getHeight()-gr[i]));
strcat(tmp, wavestr);
}
- d_setState("waveform", tmp);
+ if (fGraph)
+ d_setState("envelope", tmp);
+ else
+ d_setState("waveform", tmp);
+}
+
+void ZamSynthUI::imageToggleClicked(ImageToggle*, int)
+{
+ fGraph = !fGraph;
}
void ZamSynthUI::gaussiansmooth(float* smoothed, float* xs, float* ys, int n, int radius)
@@ -201,18 +240,27 @@ bool ZamSynthUI::onMotion(int x, int y)
if (x < 10) x = 10;
if (y < 10) y = 10;
- if (wave_y[x-10] != (y-10)) {
+ float *gr;
+
+ gr = (fGraph) ? env_y : wave_y;
+
+ if (gr[x-10] != (y-10)) {
char tmp[4*AREAHEIGHT+1] = {0};
int i;
for(i = 0; i < AREAHEIGHT; i++) {
char wavestr[5] = {0};
- snprintf(wavestr, sizeof(wavestr), "%03d ", (int) (fCanvasArea.getHeight()-wave_y[i]));
+ snprintf(wavestr, sizeof(wavestr), "%03d ", (int) (fCanvasArea.getHeight()-gr[i]));
strcat(tmp, wavestr);
}
- wave_y[x-10] = y-10;
- d_setState("waveform",tmp);
- repaint();
+ gr[x-10] = y-10;
+
+ if (gr == env_y)
+ d_setState("envelope",tmp);
+ else
+ d_setState("waveform",tmp);
+
+ repaint();
}
return true;
@@ -229,12 +277,15 @@ void ZamSynthUI::onDisplay()
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glLineWidth(2);
+ float *gr;
+ gr = (fGraph) ? env_y : wave_y;
+
int i;
glColor4f(0.235f, 1.f, 0.235f, 1.0f);
for (i = 2; i < AREAHEIGHT; ++i) {
glBegin(GL_LINES);
- glVertex2i(i-1+fCanvasArea.getX(), wave_y[i-1]+fCanvasArea.getY());
- glVertex2i(i+fCanvasArea.getX(), wave_y[i]+fCanvasArea.getY());
+ glVertex2i(i-1+fCanvasArea.getX(), gr[i-1]+fCanvasArea.getY());
+ glVertex2i(i+fCanvasArea.getX(), gr[i]+fCanvasArea.getY());
glEnd();
}
// reset color
diff --git a/plugins/ZamSynth/ZamSynthUI.hpp b/plugins/ZamSynth/ZamSynthUI.hpp
index 3758ff7..75616ab 100644
--- a/plugins/ZamSynth/ZamSynthUI.hpp
+++ b/plugins/ZamSynth/ZamSynthUI.hpp
@@ -23,6 +23,7 @@
#include "Geometry.hpp"
#include "ImageKnob.hpp"
#include "ImageButton.hpp"
+#include "ImageToggle.hpp"
#include "ZamSynthArtwork.hpp"
#include "ZamSynthPlugin.hpp"
@@ -30,6 +31,7 @@
using DGL::Image;
using DGL::ImageKnob;
using DGL::ImageButton;
+using DGL::ImageToggle;
#define AREAHEIGHT 250
@@ -39,7 +41,8 @@ START_NAMESPACE_DISTRHO
class ZamSynthUI : public UI,
public ImageKnob::Callback,
- public ImageButton::Callback
+ public ImageButton::Callback,
+ public ImageToggle::Callback
{
public:
ZamSynthUI();
@@ -76,6 +79,7 @@ protected:
void imageKnobValueChanged(ImageKnob* knob, float value) override;
void imageButtonClicked(ImageButton* button, int) override;
+ void imageToggleClicked(ImageToggle* toggle, int) override;
void onDisplay() override;
bool onMouse(int, bool, int, int) override;
@@ -85,7 +89,10 @@ private:
Image fImgBackground;
ImageKnob* fKnobGain;
ImageButton* fButtonSmooth;
+ ImageToggle* fToggleGraph;
float wave_y[AREAHEIGHT];
+ float env_y[AREAHEIGHT];
+ bool fGraph;
bool fDragging;
bool fDragValid;