1 /* 2 * Copyright (c) 2003 Matthijs Hollemans 3 * Copyright (c) 2002 Jerome Leveque 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 #ifndef _MIDI_GLUE_H 25 #define _MIDI_GLUE_H 26 27 #include <MidiConsumer.h> 28 29 #define MAKE_TIME(t) (t / (bigtime_t)1000) 30 #define MAKE_BIGTIME(t) (t * (bigtime_t)1000) 31 32 namespace BPrivate { 33 34 class BMidiGlue: public BMidiLocalConsumer 35 { 36 public: 37 38 BMidiGlue(BMidi* midiObject, const char* name = NULL); 39 40 virtual void NoteOff( 41 uchar channel, uchar note, uchar velocity, bigtime_t time); 42 43 virtual void NoteOn( 44 uchar channel, uchar note, uchar velocity, bigtime_t time); 45 46 virtual void KeyPressure( 47 uchar channel, uchar note, uchar pressure, bigtime_t time); 48 49 virtual void ControlChange( 50 uchar channel, uchar controlNumber, uchar controlValue, 51 bigtime_t time); 52 53 virtual void ProgramChange( 54 uchar channel, uchar programNumber, bigtime_t time); 55 56 virtual void ChannelPressure( 57 uchar channel, uchar pressure, bigtime_t time); 58 59 virtual void PitchBend( 60 uchar channel, uchar lsb, uchar msb, bigtime_t time); 61 62 virtual void SystemExclusive( 63 void* data, size_t length, bigtime_t time); 64 65 virtual void SystemCommon( 66 uchar status, uchar data1, uchar data2, bigtime_t time); 67 68 virtual void SystemRealTime(uchar status, bigtime_t time); 69 70 virtual void TempoChange(int32 beatsPerMinute, bigtime_t time); 71 72 private: 73 74 BMidi* midiObject; 75 }; 76 77 class BMidiPortGlue: public BMidiLocalConsumer 78 { 79 public: 80 81 BMidiPortGlue(BMidiPort* midiObject, const char* name = NULL); 82 83 virtual void NoteOff( 84 uchar channel, uchar note, uchar velocity, bigtime_t time); 85 86 virtual void NoteOn( 87 uchar channel, uchar note, uchar velocity, bigtime_t time); 88 89 virtual void KeyPressure( 90 uchar channel, uchar note, uchar pressure, bigtime_t time); 91 92 virtual void ControlChange( 93 uchar channel, uchar controlNumber, uchar controlValue, 94 bigtime_t time); 95 96 virtual void ProgramChange( 97 uchar channel, uchar programNumber, bigtime_t time); 98 99 virtual void ChannelPressure( 100 uchar channel, uchar pressure, bigtime_t time); 101 102 virtual void PitchBend( 103 uchar channel, uchar lsb, uchar msb, bigtime_t time); 104 105 virtual void SystemExclusive( 106 void* data, size_t length, bigtime_t time); 107 108 virtual void SystemCommon( 109 uchar status, uchar data1, uchar data2, bigtime_t time); 110 111 virtual void SystemRealTime(uchar status, bigtime_t time); 112 113 virtual void TempoChange(int32 beatsPerMinute, bigtime_t time); 114 115 private: 116 117 BMidiPort* midiObject; 118 }; 119 120 } // namespace BPrivate 121 122 #endif // _MIDI_GLUE_H 123