PageRenderTime 27ms CodeModel.GetById 16ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/midi_data.h

http://ewitool.googlecode.com/
C++ Header | 110 lines | 67 code | 18 blank | 25 comment | 0 complexity | e381adf0ba8b6f05e86342684226d722 MD5 | raw file
  1/***************************************************************************
  2 *   Copyright (C) 2008 by Steve Merrony                                   *
  3 *      *
  4 *                                                                         *
  5 *   This program is free software; you can redistribute it and/or modify  *
  6 *   it under the terms of the GNU General Public License as published by  *
  7 *   the Free Software Foundation; either version 3 of the License, or     *
  8 *   (at your option) any later version.                                   *
  9 *                                                                         *
 10 *   This program is distributed in the hope that it will be useful,       *
 11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 13 *   GNU General Public License for more details.                          *
 14 *                                                                         *
 15 *   You should have received a copy of the GNU General Public License     *
 16 *   along with this program; if not, write to the                         *
 17 *   Free Software Foundation, Inc.,                                       *
 18 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 19 ***************************************************************************/
 20#ifndef MIDI_DATA_H
 21#define MIDI_DATA_H
 22
 23#include "RtMidi.h"
 24
 25#include <QMutex>
 26#include <QStringList>
 27#include <QWaitCondition>
 28
 29#include "ewi4000spatch.h"
 30#include "ewi4000sQuickPC.h"
 31
 32// SysEx commands from Akai
 33#define MIDI_PRESET_DUMP      0x00
 34#define MIDI_PRESET_DUMP_REQ  0x40
 35#define MIDI_QUICKPC_DUMP     0x01
 36#define MIDI_QUICKPC_DUMP_REQ 0x41
 37#define MIDI_EDIT_LOAD        0x10
 38#define MIDI_EDIT_STORE       0x11
 39#define MIDI_EDIT_DUMP        0x20
 40#define MIDI_EDIT_DUMP_REQ    0x60
 41
 42#define MIDI_SYSEX_HEADER     0xf0
 43#define MIDI_SYSEX_TRAILER    0xf7
 44#define MIDI_SYSEX_AKAI_ID    0x47
 45#define MIDI_SYSEX_AKAI_EWI4K 0x64
 46#define MIDI_SYSEX_CHANNEL    0x00
 47#define MIDI_SYSEX_ALLCHANNELS 0x7f
 48
 49#define MIDI_CC_DATA_ENTRY    0x06
 50#define MIDI_CC_NRPN_LSB      0x62
 51#define MIDI_CC_NRPN_MSB      0x63
 52
 53const QString	LIBRARY_EXTENSION	= ".syx";
 54const int	MAX_SYSEX_LENGTH		= 262144;
 55const int   EWI_SYSEX_PRESET_DUMP_LEN = 206;
 56const int   EWI_SYSEX_QUICKPC_DUMP_LEN = 91;
 57const int   MIDI_TIMEOUT_MS         = 3000;
 58const int	EWI_SOUNDBANK_MAX_HEADER_LENGTH = 0x450;	// looks safe from observation
 59// below is the sequence which appears to start the real body of SQS files, there
 60// seem to be various false BODYs before the main one we care about
 61const char	EWI_SQS_BODY_START[]	= { 'B', 'O', 'D', 'Y', 0x00, 0x00, 0x50, 0x78, 0xf0, 0x47, 0x64, 0x7f, 0x00, 0x00 };
 62const int	EWI_SQS_MAX_HEADER_LENGTH = 0x1000;			// looks ok from observation
 63
 64/**
 65	@author Steve Merrony
 66 */
 67
 68class midi_data{
 69	
 70public:
 71    midi_data();
 72    ~midi_data();
 73	
 74	void createOurMIDIports();
 75	void sendPanic();
 76	bool requestPatch( unsigned char );
 77    bool requestQuickPCs();
 78    bool sendQuickPCs();
 79	void sendLiveControl(int, int, int );
 80	void sendCC( int, int, int = 0 );
 81	void sendSysExFile( QString fileName );
 82	void sendPatch( patch_t, unsigned char = EWI_SAVE );
 83	
 84	void scanPorts();
 85	void connectOutput( int );
 86	void connectInput( int );
 87	void disconnectInput();
 88	void disconnectOutput();
 89	
 90	bool    verboseMode;
 91	
 92	QMutex  mymutex;
 93	QWaitCondition sysexDone;
 94	
 95	int			last_patch_loaded;
 96	patch_t 	patches[EWI_NUM_PATCHES];
 97    all_quickpcs_t quickPCs;   
 98	
 99	QStringList inPortList, outPortList;
100	QList<int>  inPortPorts, outPortPorts;
101	int         connectedInPort;
102	int         connectedOutPort;
103	RtMidiIn	*midiIn;
104	RtMidiOut	*midiOut;
105    
106  private:
107    void sendSysEx(char *, int );
108};
109
110#endif