2 * Copyright 2006, Haiku.
4 * Copyright (c) 2002-2004 Matthijs Hollemans
5 * Copyright (c) 2003 Jerome Leveque
6 * Distributed under the terms of the MIT License.
14 #include <MidiSynth.h>
17 #include "SoftSynth.h"
19 using namespace BPrivate
;
22 BMidiSynth::BMidiSynth()
24 if (be_synth
== NULL
) {
28 be_synth
->fClientCount
++;
30 fInputEnabled
= false;
32 fCreationTime
= system_time();
36 BMidiSynth::~BMidiSynth()
38 be_synth
->fClientCount
--;
39 if (be_synth
->fClientCount
== 0) {
47 BMidiSynth::EnableInput(bool enable
, bool loadInstruments
)
50 fInputEnabled
= enable
;
52 if (loadInstruments
) {
53 err
= be_synth
->fSynth
->LoadAllInstruments();
61 BMidiSynth::IsInputEnabled() const
68 BMidiSynth::SetVolume(double volume
)
70 be_synth
->fSynth
->SetVolume(volume
);
75 BMidiSynth::Volume() const
77 return be_synth
->fSynth
->Volume();
82 BMidiSynth::SetTransposition(int16 offset
)
89 BMidiSynth::Transposition() const
96 BMidiSynth::MuteChannel(int16 channel
, bool do_mute
)
98 fprintf(stderr
, "[midi] MuteChannel is broken; don't use it\n");
103 BMidiSynth::GetMuteMap(char* pChannels
) const
105 fprintf(stderr
, "[midi] GetMuteMap is broken; don't use it\n");
110 BMidiSynth::SoloChannel(int16 channel
, bool do_solo
)
112 fprintf(stderr
, "[midi] SoloChannel is broken; don't use it\n");
117 BMidiSynth::GetSoloMap(char* pChannels
) const
119 fprintf(stderr
, "[midi] GetSoloMap is broken; don't use it\n");
124 BMidiSynth::LoadInstrument(int16 instrument
)
126 return be_synth
->fSynth
->LoadInstrument(instrument
);
131 BMidiSynth::UnloadInstrument(int16 instrument
)
133 return be_synth
->fSynth
->UnloadInstrument(instrument
);
138 BMidiSynth::RemapInstrument(int16 from
, int16 to
)
140 return be_synth
->fSynth
->RemapInstrument(from
, to
);
145 BMidiSynth::FlushInstrumentCache(bool startStopCache
)
147 be_synth
->fSynth
->FlushInstrumentCache(startStopCache
);
152 BMidiSynth::Tick() const
154 return (uint32
) (system_time() - fCreationTime
);
160 uchar channel
, uchar note
, uchar velocity
, uint32 time
)
163 be_synth
->fSynth
->NoteOff(channel
, note
+ fTranspose
, velocity
, time
);
169 uchar channel
, uchar note
, uchar velocity
, uint32 time
)
172 be_synth
->fSynth
->NoteOn(channel
, note
+ fTranspose
, velocity
, time
);
177 BMidiSynth::KeyPressure(
178 uchar channel
, uchar note
, uchar pressure
, uint32 time
)
181 be_synth
->fSynth
->KeyPressure(
182 channel
, note
+ fTranspose
, pressure
, time
);
187 BMidiSynth::ControlChange(
188 uchar channel
, uchar controlNumber
, uchar controlValue
, uint32 time
)
191 be_synth
->fSynth
->ControlChange(
192 channel
, controlNumber
, controlValue
, time
);
197 BMidiSynth::ProgramChange(
198 uchar channel
, uchar programNumber
, uint32 time
)
201 be_synth
->fSynth
->ProgramChange(channel
, programNumber
, time
);
206 BMidiSynth::ChannelPressure(uchar channel
, uchar pressure
, uint32 time
)
209 be_synth
->fSynth
->ChannelPressure(channel
, pressure
, time
);
214 BMidiSynth::PitchBend(uchar channel
, uchar lsb
, uchar msb
, uint32 time
)
217 be_synth
->fSynth
->PitchBend(channel
, lsb
, msb
, time
);
222 BMidiSynth::AllNotesOff(bool justChannel
, uint32 time
)
225 be_synth
->fSynth
->AllNotesOff(justChannel
, time
);
229 void BMidiSynth::_ReservedMidiSynth1() { }
230 void BMidiSynth::_ReservedMidiSynth2() { }
231 void BMidiSynth::_ReservedMidiSynth3() { }
232 void BMidiSynth::_ReservedMidiSynth4() { }