I just finished building my own synthetiser ! My first electronic device ever. Was so fun !! It s crazy how many hours i spent making holes and cutting wires, I m not a very craftish person, I like digital stuff more. But this electronic sculpture was a blast to build ! I ve never done any sort of electronics before this, so it was a lot of learning : )
// TONES ==========================================
// note, period, & frequency.
#define R 0
#define c 3830 // 261 Hz
#define d 3400 // 294 Hz
#define e 3038 // 329 Hz
#define f 2864 // 349 Hz
#define g 2550 // 392 Hz
#define a 2272 // 440 Hz
#define b 2028 // 493 Hz
#define C 1912 // 523 Hz
#define SN 10000 // SNARE
#define KI 13000 // SNARE
// SETUP ============================================
int videoOut = 8;
int speakerOut = 9;
int subOut = 10;
int ledPin = 12;
int potPin = 2;
int tempoOut = 0;
int inPin = 7; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
// Do we want debugging on serial out? 1 for yes, 0 for no
int DEBUG = 1;
void setup() {
pinMode(speakerOut, OUTPUT);
pinMode(subOut, OUTPUT);
pinMode(videoOut, OUTPUT);
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(inPin, INPUT); // declare pushbutton as input
if (DEBUG) {
Serial.begin(9600); // Set serial out if we want debugging
}
}
// MELODY and TIMING =======================================
int melody[] = { KI};
int beats[] = { 16};
int MAX_COUNT = sizeof(melody) / 2; // Melody length, for looping.
// CONFIG =======================================
long tempo = 60000;
int pause = 5000;
int rest_count = 0; //<-BLETCHEROUS HACK; See NOTES
int tone = 0;
int beat = 0;
long duration = 10;
// PLAY TONE ==============================================
void playTone() {
long elapsed_time = 0;
if (tone > 0) {
while (elapsed_time < duration) {
val = digitalRead(inPin); // read input value
digitalWrite(speakerOut,HIGH);
if (val == HIGH) { digitalWrite(subOut,HIGH); } else { };
digitalWrite(videoOut,HIGH);
digitalWrite(ledPin, HIGH); // sets the LED on
delayMicroseconds(tone / 2);
digitalWrite(speakerOut, LOW);
if (val == HIGH) { digitalWrite(subOut,LOW); } else { };
digitalWrite(videoOut, LOW);
digitalWrite(ledPin, LOW); // sets the LED off
delayMicroseconds(tone / 2);
// Keep track of how long we pulsed
elapsed_time += (tone);
}
}
else { // Rest beat; loop times delay
for (int j = 0; j < rest_count; j++) { // See NOTE on rest_count
delayMicroseconds(duration);
}
}
}
// LET THE WILD RUMPUS BEGIN =============================
void loop() {
int potone = analogRead(potPin); // read the value from the sensor
// Set up a counter to pull from melody[] and beats[]
for (int i=0; i<MAX_COUNT; i++) {
tone = potone*10 ;
beat = beats[i];
playTone();
// A pause between notes...
delayMicroseconds(potone*1000);
if (DEBUG) { // If debugging, report loop, tone, beat, and duration
Serial.print(i);
Serial.print(":");
Serial.print(beat);
Serial.print(" ");
Serial.print(tone);
Serial.print(" ");
Serial.println(duration);
}
}
}
Voila!
I m glad you liek
For the schematics well .. I ll make them tonight , they re gonna be a asshole to draw, there s 7-8 output pins and a couple more : p