aboutsummaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-04-01 11:21:01 +0200
committerlonkaars <loek@pipeframe.xyz>2022-04-01 11:21:01 +0200
commit178433e53d2e5fe9ccc5bc5862494d811b938e51 (patch)
tree8b15bb2a99c4d9954e7902816dbf43e647ac553f /software
parent659b44912e9a307d51ecb5a5ea0c76e3a3fff096 (diff)
more hardwre debugging
Diffstat (limited to 'software')
-rw-r--r--software/software.ino69
1 files changed, 57 insertions, 12 deletions
diff --git a/software/software.ino b/software/software.ino
index 376a8d5..28edfaf 100644
--- a/software/software.ino
+++ b/software/software.ino
@@ -1,23 +1,68 @@
#include "lib/the_synth/synth.h"
+#define PINOUT_AUDIO_OUT CHA
+#define PINOUT_POT_ATK A0
+#define PINOUT_POT_REL A1
+#define PINOUT_POT_WAV A2
+#define PINOUT_KB_IN A3
+
synth bernard;
+const static unsigned int notes[] = {
+ 751, // f3
+ 751, // f#3
+ 744, // g3
+ 743, // g#3
+ 736, // a3
+ 733, // a#3
+ 730, // b3
+ 725, // c4
+ 720, // c#4
+ 660, // d4
+ 655, // d#4
+ 650, // e4
+ 642, // f4
+ 635, // f#4
+ 626, // g4
+ 610, // g#4
+ 602, // a4
+ 595, // a#4
+ 580, // b4
+ 550, // c5
+};
+
void setup() {
- bernard.begin();
+ pinMode(PINOUT_AUDIO_OUT, OUTPUT);
+ bernard.begin(PINOUT_AUDIO_OUT);
+
+ pinMode(PINOUT_POT_ATK, INPUT);
+ pinMode(PINOUT_POT_WAV, INPUT);
+ pinMode(PINOUT_POT_REL, INPUT);
+ pinMode(PINOUT_KB_IN, INPUT);
bernard.setupVoice(0,SINE,60,ENVELOPE0,90,64);
- bernard.setupVoice(1,SINE,62,ENVELOPE1,90,64);
- bernard.setupVoice(2,SINE,64,ENVELOPE2,90,64);
- bernard.setupVoice(3,SINE,67,ENVELOPE0,90,64);
+ bernard.setupVoice(1,TRIANGLE,62,ENVELOPE1,90,64);
+ bernard.setupVoice(2,SAW,64,ENVELOPE2,90,64);
+ bernard.setupVoice(3,SQUARE,67,ENVELOPE0,90,64);
+
+ Serial.begin(9600);
}
void loop() {
- bernard.trigger(0);
- delay(1000);
- bernard.trigger(1);
- delay(1000);
- bernard.trigger(2);
- delay(1000);
- bernard.trigger(3);
- delay(1000);
+ int samples = 100;
+ double average = 0.0;
+ for (int i = 0; i < samples; i++) {
+ average += ((double) analogRead(PINOUT_KB_IN)) / samples;
+ }
+
+ unsigned int pot_rel = analogRead(PINOUT_POT_REL);
+ unsigned int pot_atk = analogRead(PINOUT_POT_ATK);
+ unsigned int pot_wav = analogRead(PINOUT_POT_WAV);
+ unsigned int kb_in = analogRead(PINOUT_KB_IN);
+ unsigned char env = pot_rel / (1024/4);
+ unsigned char mod = 572 + pot_atk / 100;
+ unsigned char wave = pot_wav / (1024/4);
+ bernard.setEnvelope(wave, env);
+ bernard.mTrigger(wave, 116 - average / 10);
+ delay(500 - pot_atk / 5);
}