Armstrong is a collection of routines to make the building and prototyping of musical instruments on the Arduino very much easier. It abstracts the hardware pins from their function and supports serial communications, allowing sounds to be played on remote hardware (PC or synthesizer) without additional coding.
It comprises of Arduino source code to:
It provides separate, loosely-coupled, components for each part of the signal chain (input-processing-output) and abstracts the hardware ideas of 'pins' with 'channels'. In this way, the code of each component does not need to change if your circuit design does. Furthermore, you need not specify a hardware pin at all, since the abstraction allows the note data to be sent by serial (either to the PC, or a MIDI keyboard) to trigger remote sounds.
As an example, you could create a channel with a push button,
adiInitializePushButton(CHANNEL_INPUT_NOTETEST_SWITCH, buttonPin);Read its state inside 'loop'
if (adiDidStateChange(CHANNEL_INPUT_NOTETEST_SWITCH)) { // state changed! int state = adiGetState(CHANNEL_INPUT_NOTETEST_SWITCH);Then place notes onto the various output channels. Such as,
ancNoteOn(CHANNEL_OUTPUT_PIEZO_SPEAKER, MIDI_NOTE_C4, DEFAULT_VOLUME);The ancUpdate() function is also called each time around loop(), and it is this which controls the pizeo/speaker. The pitch and volume of each channel can be changed at run-time.
There are also examples, and PC sample code for handling the serial protocol.
They are:
Current supports scaled inputs and one-shot triggers using piezo transducers.
This handles digital input switches. It currently supports toggle and push buttons.
This contains the main output code for handling play individual notes. The basic interface comprises of NoteOn-ChangePitch-ChangeVolume-NoteOff, which the specific parameters being sent to either the local hardware speaker, the serial output to PC, or a MIDI port. This may be changed with ' ancSetOutputMode'.
This handles basic note playback, using the note control library. The oscillation of the piezo/speaker for each note can be handled by either:
In the first case, you start a note with anpPlayNote (and stop it with the equivalent anpStopNote) and ensure ancUpdate is called within loop.
In the second, ancUpdate is called automatically.
Utility code to play complete pieces of music, as described by the Armstrong music format. This format is state system using a list of notes (C, D, E, etc) which are played with the current duration, volume, and octave. It uses the play functions anp.
The commands are:
Sharps and flats may be created by suffixing the note name with + and - respectively.
These are simple helper functions that understand frequencies. You can convert between MIDI note ID and frequency, and quantize to the nearest note.
The full source to Armstrong - The Arduino Music System is now available!