Austin Suszek / Mbed 2 deprecated MIDISynthesizer

Dependencies:   mbed USBDevice PinDetect

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AudioEngine.h Source File

AudioEngine.h

00001 /**
00002  * The interface for all audio input and output.
00003  * This class acts as a container for individual voices.
00004  * It takes in MIDI events and handles processing and output.
00005  *
00006  * @author Austin Suszek
00007  */
00008 
00009 #ifndef AS_AUDIO_ENGINE_H
00010 #define AS_AUDIO_ENGINE_H
00011 
00012 #include "../Constants.h"
00013 #include "../mbed.h"
00014 #include "Synthesizer.h"
00015 
00016 class AudioEngine {
00017 public:
00018 
00019     /**
00020      * Constructor
00021      */
00022     AudioEngine();
00023     
00024     /**
00025      * Signal the beginning of a note being pressed.
00026      *
00027      * @param key The integer representation of the note
00028      * @param velocity (optional) The note velocity in the range of 0-127
00029      */
00030     void midiNoteOn(const int key, const int velocity = 0x7F);
00031     
00032     /**
00033      * Signal the end of a note being pressed.
00034      *
00035      * @param key The integer representation of the note
00036      */
00037     void midiNoteOff(const int key);
00038     
00039     /**
00040      * Switch to a new synth instrument.
00041      *
00042      * @param direction 1 for next, -1 for previous.
00043      * @return The new index being played.
00044      */
00045     int nextSynth(int direction);
00046     
00047 private:
00048     
00049     Ticker samplePeriod;
00050     
00051     float outputSample;
00052     void outputAudio();
00053     
00054     Synthesizer synthesizers[C::MAX_POLYPHONY];
00055     
00056 };
00057 
00058 #endif