/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. #include "RtMidi.h"
  23. #include <QMutex>
  24. #include <QStringList>
  25. #include <QWaitCondition>
  26. #include "ewi4000spatch.h"
  27. #include "ewi4000sQuickPC.h"
  28. // SysEx commands from Akai
  29. #define MIDI_PRESET_DUMP 0x00
  30. #define MIDI_PRESET_DUMP_REQ 0x40
  31. #define MIDI_QUICKPC_DUMP 0x01
  32. #define MIDI_QUICKPC_DUMP_REQ 0x41
  33. #define MIDI_EDIT_LOAD 0x10
  34. #define MIDI_EDIT_STORE 0x11
  35. #define MIDI_EDIT_DUMP 0x20
  36. #define MIDI_EDIT_DUMP_REQ 0x60
  37. #define MIDI_SYSEX_HEADER 0xf0
  38. #define MIDI_SYSEX_TRAILER 0xf7
  39. #define MIDI_SYSEX_AKAI_ID 0x47
  40. #define MIDI_SYSEX_AKAI_EWI4K 0x64
  41. #define MIDI_SYSEX_CHANNEL 0x00
  42. #define MIDI_SYSEX_ALLCHANNELS 0x7f
  43. #define MIDI_CC_DATA_ENTRY 0x06
  44. #define MIDI_CC_NRPN_LSB 0x62
  45. #define MIDI_CC_NRPN_MSB 0x63
  46. const QString LIBRARY_EXTENSION = ".syx";
  47. const int MAX_SYSEX_LENGTH = 262144;
  48. const int EWI_SYSEX_PRESET_DUMP_LEN = 206;
  49. const int EWI_SYSEX_QUICKPC_DUMP_LEN = 91;
  50. const int MIDI_TIMEOUT_MS = 3000;
  51. const int EWI_SOUNDBANK_MAX_HEADER_LENGTH = 0x450; // looks safe from observation
  52. // below is the sequence which appears to start the real body of SQS files, there
  53. // seem to be various false BODYs before the main one we care about
  54. const char EWI_SQS_BODY_START[] = { 'B', 'O', 'D', 'Y', 0x00, 0x00, 0x50, 0x78, 0xf0, 0x47, 0x64, 0x7f, 0x00, 0x00 };
  55. const int EWI_SQS_MAX_HEADER_LENGTH = 0x1000; // looks ok from observation
  56. /**
  57. @author Steve Merrony
  58. */
  59. class midi_data{
  60. public:
  61. midi_data();
  62. ~midi_data();
  63. void createOurMIDIports();
  64. void sendPanic();
  65. bool requestPatch( unsigned char );
  66. bool requestQuickPCs();
  67. bool sendQuickPCs();
  68. void sendLiveControl(int, int, int );
  69. void sendCC( int, int, int = 0 );
  70. void sendSysExFile( QString fileName );
  71. void sendPatch( patch_t, unsigned char = EWI_SAVE );
  72. void scanPorts();
  73. void connectOutput( int );
  74. void connectInput( int );
  75. void disconnectInput();
  76. void disconnectOutput();
  77. bool verboseMode;
  78. QMutex mymutex;
  79. QWaitCondition sysexDone;
  80. int last_patch_loaded;
  81. patch_t patches[EWI_NUM_PATCHES];
  82. all_quickpcs_t quickPCs;
  83. QStringList inPortList, outPortList;
  84. QList<int> inPortPorts, outPortPorts;
  85. int connectedInPort;
  86. int connectedOutPort;
  87. RtMidiIn *midiIn;
  88. RtMidiOut *midiOut;
  89. private:
  90. void sendSysEx(char *, int );
  91. };
  92. #endif