Just wondering how would go about doing this and or if anyone has done it. I'm looking for the distinctive NES sound and I want to make it out of an existing 25 key toy keyboard. Any help/code will be appreciated!
Use keyboard as inputs to a mega with sketch like this, where I used 13 buttons with a '1284P:
I can't help you with the input, but I have a working square wave synth library that I can link to you! It's got pretty much all the customisation for square wave synth stuff you could think of, and I'm working on programming some more specific sound effects. You've got variable duty cycles, pseudo noise, arpeggiated chords, automated note sliding, pitch bending (that one's not tested fully yet), and delayed note kills.
I've just finished polishing up a release-able version for you, without the experimental stuff so it should be stable. It works on my Guitar Hero controller pretty well!
Also, it only requires one pin to send signal, so you don't need to worry about running out of pins!
SquareSynth.cpp (10.8 KB)
SquareSynth.h (6.55 KB)
SquareSynthNoteDefs.h (2.02 KB)
SquareSynth_RELEASE.ino (2.16 KB)
To give you an idea of how this library works, here's a look at my example sketch included with my previous post. (SquareSynth_RELEASE.ino)
#include "SquareSynth.h"
void setup(){
Synth.begin(12); // specify output pin
}
// note that there is also the option for running multiple synth instances in an array. check out the commands in the .h file for more info.
void loop(){
// This is all you need for some rudimentary synthing
Synth.note(_C4);
// A generate() command MUST be placed in a running loop to generate the waves!
Synth.generate();
}
/*
Summary of most common commands:
(use Channel[].command() OR Synth.command() for these. If only using one output, use Synth. It's much simpler)
( The Channel[] array of objects are initialised with SquareSynth.begin(instances,pin,...); )
Synth.begin(int pin);
Synth.generate(); // place in loop for wave generation.
Synth.pitchBend(int bend=0); // not fully tested yet! bend from -1000 to +1000 for a bend of +- two notes
Synth.arpeggioOn(int offset1, int offset2=0, int offset3=0, int offset4=0);
Synth.arpeggioOff();
Synth.dutyCycle(int percent); // change duty cycle on the fly!
Synth.noise(int pitch=60, int minDuty=1, int maxDuty=51); // pseudo noise!
Synth.noteOff(); // stops the note being played!
Synth.transposeOn(int transposition); // +- amount of notes you want to transpose by!
Synth.transposeOff();
Synth.clearFlags(); // use this to clear effects you applied if you lose count, or want to jump to clean play without much overhead
Synth.transform(int destination, int steps); // transforms current note to specified note, spanning x many steps
Synth.addDepth(int duty=15, int steps=2); // bends the duty cycle briefly, starting at specified duty and ending at original; spanning x many steps
Synth.autoKill(int steps=1, bool killArpeggio=false); // kills note after specified number of steps. the boolean arguments are used in some of the drum synth functions.
////////////////////////////////////////////////
// High-level routines (instruments & stuff!) //
////////////////////////////////////////////////
// Simple commands:
Synth.note(int pitch=60, int duty=50, int depth=30, int steps=1);
// other commands available, but not vetted yet.
*/