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 #include "Midi.h" 25 #include "MidiGlue.h" 26 #include "MidiPort.h" 27 28 using namespace BPrivate; 29 30 //------------------------------------------------------------------------------ 31 32 BMidiGlue::BMidiGlue(BMidi* midiObject_, const char* name) 33 : BMidiLocalConsumer(name) 34 { 35 midiObject = midiObject_; 36 } 37 38 //------------------------------------------------------------------------------ 39 40 void BMidiGlue::NoteOff( 41 uchar channel, uchar note, uchar velocity, bigtime_t time) 42 { 43 midiObject->NoteOff(channel + 1, note, velocity, MAKE_TIME(time)); 44 } 45 46 //------------------------------------------------------------------------------ 47 48 void BMidiGlue::NoteOn( 49 uchar channel, uchar note, uchar velocity, bigtime_t time) 50 { 51 midiObject->NoteOn(channel + 1, note, velocity, MAKE_TIME(time)); 52 } 53 54 //------------------------------------------------------------------------------ 55 56 void BMidiGlue::KeyPressure( 57 uchar channel, uchar note, uchar pressure, bigtime_t time) 58 { 59 midiObject->KeyPressure(channel + 1, note, pressure, MAKE_TIME(time)); 60 } 61 62 //------------------------------------------------------------------------------ 63 64 void BMidiGlue::ControlChange( 65 uchar channel, uchar controlNumber, uchar controlValue, bigtime_t time) 66 { 67 midiObject->ControlChange( 68 channel + 1, controlNumber, controlValue, MAKE_TIME(time)); 69 } 70 71 //------------------------------------------------------------------------------ 72 73 void BMidiGlue::ProgramChange( 74 uchar channel, uchar programNumber, bigtime_t time) 75 { 76 midiObject->ProgramChange(channel + 1, programNumber, MAKE_TIME(time)); 77 } 78 79 //------------------------------------------------------------------------------ 80 81 void BMidiGlue::ChannelPressure( 82 uchar channel, uchar pressure, bigtime_t time) 83 { 84 midiObject->ChannelPressure(channel + 1, pressure, MAKE_TIME(time)); 85 } 86 87 //------------------------------------------------------------------------------ 88 89 void BMidiGlue::PitchBend( 90 uchar channel, uchar lsb, uchar msb, bigtime_t time) 91 { 92 midiObject->PitchBend(channel + 1, lsb, msb, MAKE_TIME(time)); 93 } 94 95 //------------------------------------------------------------------------------ 96 97 void BMidiGlue::SystemExclusive( 98 void* data, size_t length, bigtime_t time) 99 { 100 midiObject->SystemExclusive(data, length, MAKE_TIME(time)); 101 } 102 103 //------------------------------------------------------------------------------ 104 105 void BMidiGlue::SystemCommon( 106 uchar status, uchar data1, uchar data2, bigtime_t time) 107 { 108 midiObject->SystemCommon(status, data1, data2, MAKE_TIME(time)); 109 } 110 111 //------------------------------------------------------------------------------ 112 113 void BMidiGlue::SystemRealTime(uchar status, bigtime_t time) 114 { 115 midiObject->SystemRealTime(status, MAKE_TIME(time)); 116 } 117 118 //------------------------------------------------------------------------------ 119 120 void BMidiGlue::TempoChange(int32 beatsPerMinute, bigtime_t time) 121 { 122 midiObject->TempoChange(beatsPerMinute, MAKE_TIME(time)); 123 } 124 125 //------------------------------------------------------------------------------ 126 127 BMidiPortGlue::BMidiPortGlue(BMidiPort* midiObject_, const char* name) 128 : BMidiLocalConsumer(name) 129 { 130 midiObject = midiObject_; 131 } 132 133 //------------------------------------------------------------------------------ 134 135 void BMidiPortGlue::NoteOff( 136 uchar channel, uchar note, uchar velocity, bigtime_t time) 137 { 138 midiObject->SprayNoteOff(channel + 1, note, velocity, MAKE_TIME(time)); 139 } 140 141 //------------------------------------------------------------------------------ 142 143 void BMidiPortGlue::NoteOn( 144 uchar channel, uchar note, uchar velocity, bigtime_t time) 145 { 146 midiObject->SprayNoteOn(channel + 1, note, velocity, MAKE_TIME(time)); 147 } 148 149 //------------------------------------------------------------------------------ 150 151 void BMidiPortGlue::KeyPressure( 152 uchar channel, uchar note, uchar pressure, bigtime_t time) 153 { 154 midiObject->SprayKeyPressure( 155 channel + 1, note, pressure, MAKE_TIME(time)); 156 } 157 158 //------------------------------------------------------------------------------ 159 160 void BMidiPortGlue::ControlChange( 161 uchar channel, uchar controlNumber, uchar controlValue, bigtime_t time) 162 { 163 midiObject->SprayControlChange( 164 channel + 1, controlNumber, controlValue, MAKE_TIME(time)); 165 } 166 167 //------------------------------------------------------------------------------ 168 169 void BMidiPortGlue::ProgramChange( 170 uchar channel, uchar programNumber, bigtime_t time) 171 { 172 midiObject->SprayProgramChange( 173 channel + 1, programNumber, MAKE_TIME(time)); 174 } 175 176 //------------------------------------------------------------------------------ 177 178 void BMidiPortGlue::ChannelPressure( 179 uchar channel, uchar pressure, bigtime_t time) 180 { 181 midiObject->SprayChannelPressure(channel + 1, pressure, MAKE_TIME(time)); 182 } 183 184 //------------------------------------------------------------------------------ 185 186 void BMidiPortGlue::PitchBend( 187 uchar channel, uchar lsb, uchar msb, bigtime_t time) 188 { 189 midiObject->SprayPitchBend(channel + 1, lsb, msb, MAKE_TIME(time)); 190 } 191 192 //------------------------------------------------------------------------------ 193 194 void BMidiPortGlue::SystemExclusive( 195 void* data, size_t length, bigtime_t time) 196 { 197 midiObject->SpraySystemExclusive(data, length, MAKE_TIME(time)); 198 } 199 200 //------------------------------------------------------------------------------ 201 202 void BMidiPortGlue::SystemCommon( 203 uchar status, uchar data1, uchar data2, bigtime_t time) 204 { 205 midiObject->SpraySystemCommon(status, data1, data2, MAKE_TIME(time)); 206 } 207 208 //------------------------------------------------------------------------------ 209 210 void BMidiPortGlue::SystemRealTime(uchar status, bigtime_t time) 211 { 212 midiObject->SpraySystemRealTime(status, MAKE_TIME(time)); 213 } 214 215 //------------------------------------------------------------------------------ 216 217 void BMidiPortGlue::TempoChange(int32 beatsPerMinute, bigtime_t time) 218 { 219 midiObject->SprayTempoChange(beatsPerMinute, MAKE_TIME(time)); 220 } 221 222 //------------------------------------------------------------------------------ 223