1/* 2 * Copyright (c) 2004 Matthijs Hollemans 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 * DEALINGS IN THE SOFTWARE. 21 */ 22 23#include "SynthBridge.h" 24 25//------------------------------------------------------------------------------ 26 27SynthBridge::SynthBridge() 28 : BMidiLocalConsumer("Internal Synthesizer") 29{ 30 // do nothing 31} 32 33//------------------------------------------------------------------------------ 34 35bool SynthBridge::Init(synth_mode mode) 36{ 37 if (be_synth->LoadSynthData(mode) == B_OK) 38 { 39 midiSynth.EnableInput(true, true); 40 return true; 41 } 42 return false; 43} 44 45//------------------------------------------------------------------------------ 46 47BMidiSynth* SynthBridge::MidiSynth() 48{ 49 return &midiSynth; 50} 51 52//------------------------------------------------------------------------------ 53 54void SynthBridge::NoteOff( 55 uchar channel, uchar note, uchar velocity, bigtime_t time) 56{ 57 midiSynth.NoteOff(channel + 1, note, velocity, time / 1000); 58} 59 60//------------------------------------------------------------------------------ 61 62void SynthBridge::NoteOn( 63 uchar channel, uchar note, uchar velocity, bigtime_t time) 64{ 65 midiSynth.NoteOn(channel + 1, note, velocity, time / 1000); 66} 67 68//------------------------------------------------------------------------------ 69 70void SynthBridge::KeyPressure( 71 uchar channel, uchar note, uchar pressure, bigtime_t time) 72{ 73 midiSynth.KeyPressure(channel + 1, note, pressure, time / 1000); 74} 75 76//------------------------------------------------------------------------------ 77 78void SynthBridge::ControlChange( 79 uchar channel, uchar controlNumber, uchar controlValue, bigtime_t time) 80{ 81 midiSynth.ControlChange( 82 channel + 1, controlNumber, controlValue, time / 1000); 83} 84 85//------------------------------------------------------------------------------ 86 87void SynthBridge::ProgramChange( 88 uchar channel, uchar programNumber, bigtime_t time) 89{ 90 midiSynth.ProgramChange(channel + 1, programNumber, time / 1000); 91} 92 93//------------------------------------------------------------------------------ 94 95void SynthBridge::ChannelPressure( 96 uchar channel, uchar pressure, bigtime_t time) 97{ 98 midiSynth.ChannelPressure(channel + 1, pressure, time / 1000); 99} 100 101//------------------------------------------------------------------------------ 102 103void SynthBridge::PitchBend( 104 uchar channel, uchar lsb, uchar msb, bigtime_t time) 105{ 106 midiSynth.PitchBend(channel + 1, lsb, msb, time / 1000); 107} 108 109//------------------------------------------------------------------------------ 110 111void SynthBridge::AllNotesOff(bool justChannel, bigtime_t time) 112{ 113 midiSynth.AllNotesOff(justChannel, time / 1000); 114} 115 116//------------------------------------------------------------------------------ 117