1 /* 2 * Copyright (c) 2004 Matthijs Hollemans 3 * Copyright (c) 2008-2014 Haiku, Inc. All rights reserved. 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 25 #include "SynthBridge.h" 26 27 28 // #pragma mark - SynthBridge 29 30 31 SynthBridge::SynthBridge() 32 : 33 BMidiLocalConsumer("Internal Synthesizer") 34 { 35 } 36 37 38 bool 39 SynthBridge::Init(synth_mode mode) 40 { 41 if (be_synth->LoadSynthData(mode) == B_OK) { 42 fMidiSynth.EnableInput(true, true); 43 return true; 44 } 45 46 return false; 47 } 48 49 50 BMidiSynth* 51 SynthBridge::MidiSynth() 52 { 53 return &fMidiSynth; 54 } 55 56 57 void 58 SynthBridge::NoteOff(uchar channel, uchar note, uchar velocity, bigtime_t time) 59 { 60 fMidiSynth.NoteOff(channel + 1, note, velocity, time / 1000); 61 } 62 63 64 void 65 SynthBridge::NoteOn(uchar channel, uchar note, uchar velocity, bigtime_t time) 66 { 67 fMidiSynth.NoteOn(channel + 1, note, velocity, time / 1000); 68 } 69 70 71 void 72 SynthBridge::KeyPressure(uchar channel, uchar note, uchar pressure, 73 bigtime_t time) 74 { 75 fMidiSynth.KeyPressure(channel + 1, note, pressure, time / 1000); 76 } 77 78 79 void 80 SynthBridge::ControlChange(uchar channel, uchar controlNumber, 81 uchar controlValue, bigtime_t time) 82 { 83 fMidiSynth.ControlChange(channel + 1, controlNumber, controlValue, 84 time / 1000); 85 } 86 87 88 void 89 SynthBridge::ProgramChange(uchar channel, uchar programNumber, bigtime_t time) 90 { 91 fMidiSynth.ProgramChange(channel + 1, programNumber, time / 1000); 92 } 93 94 95 void 96 SynthBridge::ChannelPressure(uchar channel, uchar pressure, bigtime_t time) 97 { 98 fMidiSynth.ChannelPressure(channel + 1, pressure, time / 1000); 99 } 100 101 102 void 103 SynthBridge::PitchBend(uchar channel, uchar lsb, uchar msb, bigtime_t time) 104 { 105 fMidiSynth.PitchBend(channel + 1, lsb, msb, time / 1000); 106 } 107 108 109 void 110 SynthBridge::AllNotesOff(bool justChannel, bigtime_t time) 111 { 112 fMidiSynth.AllNotesOff(justChannel, time / 1000); 113 } 114