#include <MIDI.h> // MIDI_CREATE_DEFAULT_INSTANCE(); #define PBMAX 8191 // defines for MIDI Shield components only #define POT 0 #define POT2 1 #define BUTTON1 2 #define BUTTON2 3 #define BUTTON3 4 #define LED 7 #define LED2 6 // #define SINSAMPLES 256 int sineData [SINSAMPLES]; bool ledOn = false; bool ledOn2 = false; unsigned int inc = 0; uint16_t noteIn = 0; uint16_t lastnote = 0; char off = 0; char lastplay = 0; //char drv = 0; // digital read variable void setup() { sine(); pinMode(LED, OUTPUT); pinMode(LED2, OUTPUT); pinMode(POT, INPUT); pinMode(POT2, INPUT); pinMode(BUTTON1, INPUT); // defines for MIDI Shield components only digitalWrite(LED2, HIGH); digitalWrite(LED, HIGH); digitalWrite(BUTTON1, HIGH); // MIDI.begin(); // Launch MIDI } void loop() { uint16_t average = noteIn; uint16_t anIn = analogRead(POT); char play = !(digitalRead(BUTTON1)); if (lastplay != play) { if (play == 0) off = 1; } lastplay = play; noteIn = analogRead(POT2); average = (average + noteIn) >> 1; uint8_t note = average >> 3; if (play == 1) { if (lastnote != note) { MIDI.sendPitchBend(0, 1);//reset pitch bend delay(10); MIDI.sendNoteOff(lastnote, 0, 1); // Stop the note delay(10); MIDI.sendNoteOn(note, 127, 1); // Send a Note (pitch , velo 127 on channel 1) lastnote = note; } else { lastnote = note; } int smpl = sineData[inc]; int var = (smpl - PBMAX); // this calculation can be avoided MIDI.sendPitchBend(var, 1); delay(10); ledOn = !ledOn; digitalWrite(LED, ledOn); inc++; inc += (anIn >> 4); if (inc >= SINSAMPLES) { inc -= SINSAMPLES; ledOn2 = !ledOn2; digitalWrite(LED2, ledOn2); } } if (play == 0) { if (off == 1) { MIDI.sendPitchBend(0, 1);//reset pitch bend delay(10); MIDI.sendNoteOff(lastnote, 0, 1); // Stop the note inc = 0; lastnote = 0; digitalWrite(LED2, HIGH); digitalWrite(LED, HIGH); off = 0; } } } void sine () { int i; int b; for (i = 0; i < SINSAMPLES; i++) { b = PBMAX * sin((2 * PI / SINSAMPLES) * i); b += PBMAX; sineData [i] = b; } }
Electronics, Synth, Sound effects, Microcontrollers, , Digital signal processing,AVR, PIC, PIC32,ARM, etc
Showing posts with label Dub Synth. Show all posts
Showing posts with label Dub Synth. Show all posts
Monday, 1 June 2015
Dub Siren For The Keyboard PLayer ( Code )
For the last post DUB SIREN FOR THE LIVE KEYBOARD PLAYER, all you need is an Arduino Midi Shield ( ( you should find a local distributor for all these) , an Arduino Uno, R3 preferably, and MIDI library ( I am using the Arduino_MIDI_Library_v4.2) along with this code. NO SOLDERING DONE !
Sunday, 26 April 2015
Atmega 328/Uno simple Dub synth
R2R DAC -view picture in the end of article. Usa same principle to build an 8 Bit R2R DAC from D0 to D7
Some intial test sounds out of a Uno mini Dub synth. The file was recorded , unfiltered ( 0 to 5V) and lined out of a guitar amp in clean mode. - Some noise was introduced by the guitar amd as well.
Next step of project is to AC couple signal also with a suitable RC filter, decoupling capacitors and prepare the rest of line out for use with sound gear.
The limitations of the ATMega328 are big compared to the DUE for this kind of project, but good enough to get some interesting sounds, plus it can also double as a dub siren . Sr @ 16kHz-8Bit Dac
You can download /preview it in mp3 here
a 6 bit R2R Dac
Labels:
Arduino,
ATMega328,
Drum Synth,
Dub Drum Synth,
Dub Siren,
Dub Synth,
Jah Shaka,
R2R Dac,
Synare,
Uno
Subscribe to:
Posts (Atom)