www.pudn.com > reacTIVision-1.3.rar > MidiServer.h


/*  reacTIVision fiducial tracking framework
    MidiServer.h
    Copyright (C) 2006 Martin Kaltenbrunner 

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef MIDISERVER_H
#define MIDISERVER_H

#include 
#include 
#include 

#include "MessageServer.h"

#include "portmidi.h"
#include "porttime.h"

#include "tinyxml.h"

#define NOTE_ON 0x90
#define NOTE_OFF 0x80

#define XPOS 0
#define YPOS 1
#define ANGLE 2
#define PRESENCE 3

#ifndef M_PI
#define M_PI        3.14159265358979323846
#endif

class MidiServer: public MessageServer {

	private:

		struct mapping {
			int f_id;
			int dimension;
			int channel;
			int control;
			float min;
			float max;
			float range;
			int value;
		};

		PmStream* midi_out;

		void readConfig(char* cfg);
		std::list mapping_list;
		void parseString(const std::string& str, std::list& values);

	public:
		MidiServer(char* cfg, int device);
		void sendAddMessage(int f_id);
		void sendRemoveMessage(int f_id);
		void sendControlMessage(int f_id, float xpos, float ypos, float angle);
		void sendNullMessages();
		~MidiServer();

		int getType() { return MIDI_SERVER; }
		
		static void listDevices();
};
#endif