/*
 *  ofxMidi.h
 *  openFrameworks MIDI Addon.
 *
 *  Created by Andy Best
 *	www.andybest.net
 *
 *	+Kyle McDonald
 */

#pragma once

#include "ofConstants.h"

#if defined( TARGET_OSX )
	#import <CoreAudio/CoreAudio.h>
	#import <CoreMIDI/CoreMIDI.h>
#endif
#if defined( TARGET_WIN32 )
	#include <windows.h>
	#include <mmsystem.h>
#endif

class ofxMidiOut {

	public:
		#if defined( TARGET_OSX )
			MIDIClientRef   _midiClient;
			MIDIEndpointRef _source;
		#endif
		#if defined( TARGET_WIN32)
			HMIDIOUT device;
			union {
				unsigned long word;
				unsigned char data[4];
			} message;
		#endif

		ofxMidiOut::ofxMidiOut();
		ofxMidiOut::ofxMidiOut(int port);
		unsigned char ofxMidiOut::getNoteNumber(char letter, int octave);
		void ofxMidiOut::sendNoteOn(unsigned char note, unsigned char velocity);
		void ofxMidiOut::sendNoteOn(unsigned char channel, unsigned char note, unsigned char velocity);
		void ofxMidiOut::sendNoteOff(unsigned char note, unsigned char velocity);
		void ofxMidiOut::sendNoteOff(unsigned char channel, unsigned char note, unsigned char velocity);
		void ofxMidiOut::sendControlChange (unsigned char channel, unsigned char controlNum, unsigned char controlVal);
		void ofxMidiOut::sendMidi (unsigned char midiType, unsigned char channel, unsigned char controlNum, unsigned char controlVal);
	private:
		void ofxMidiOut::usePort(int port);
};

