Gemphet8 ; 8-polyphonic synthesizer control application

Dependencies:   MIDI REnc button mbed

MIDI_Proc/midi_proc.h

Committer:
ChuckTimber
Date:
2014-08-11
Revision:
4:c18cfcad2c48

File content as of revision 4:c18cfcad2c48:

#ifndef SUB_MIDI_PROC_H
#define SUB_MIDI_PROC_H

#include "mbed.h"
#include "MIDI.h"

/** MIDI System message */
#define MIDI_ALL_NOTE_OFF             0x7B
#define MIDI_RESET_ALL_CONTROLLERS    0x79

#define POLYPHONICE_NOTES 8

namespace mbed
{

/** @structure MIDI Note management structure
 *
 */
typedef struct _MidiNote {
    /// MIDI Note number
    uint8_t Note;
    /// MIDI Note velocity
    uint8_t Velocity;
    /// MIDI Note channel
    uint8_t Channel;
    /// pointer to the next _MidiNote object
    struct _MidiNote *next;
} MN_t, *MN_p;

class MIDI_P
{

private:
    MIDI _midi;

    MN_t NoteEnd;
    MN_t NoteStart;
    MN_t MidiNotes[POLYPHONICE_NOTES];
    uint16_t MidiNotesTag;
    uint8_t NumOfNotes;

    /** @brief Prototypes related to MIDI
     *
     */
    MN_p allocN(void);
    void freeN(MN_p addr);
    void midi_allnoteoff(void);
    void midi_resetcontrol(void);
    void midi_sysreset(void);
    void midi_noteoff(byte channel, byte note, byte velocity);
    void midi_noteon(byte channel, byte note, byte velocity);
    void midi_cc(byte channel, byte number, byte value);
    void midi_pc(byte channel, byte number);
    void midi_pbend(byte channel, int bend);

public:
    MIDI_P(PinName tx, PinName rx);
    ~MIDI_P() { };
    void Init(void);

}; // end of class MIDI_P definition

}  // end of namespace mbed
#endif