tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / midi / MidiSynth.cpp
blob352500476834baf37ca7a40bf918d7e0229f6f34
1 /*
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.
8 * Authors:
9 *
10 * Matthijs Hollemans
11 * Jérôme Leveque
14 #include <MidiSynth.h>
16 #include "debug.h"
17 #include "SoftSynth.h"
19 using namespace BPrivate;
22 BMidiSynth::BMidiSynth()
24 if (be_synth == NULL) {
25 new BSynth();
28 be_synth->fClientCount++;
30 fInputEnabled = false;
31 fTranspose = 0;
32 fCreationTime = system_time();
36 BMidiSynth::~BMidiSynth()
38 be_synth->fClientCount--;
39 if (be_synth->fClientCount == 0) {
40 delete be_synth;
41 be_synth = NULL;
46 status_t
47 BMidiSynth::EnableInput(bool enable, bool loadInstruments)
49 status_t err = B_OK;
50 fInputEnabled = enable;
52 if (loadInstruments) {
53 err = be_synth->fSynth->LoadAllInstruments();
56 return err;
60 bool
61 BMidiSynth::IsInputEnabled() const
63 return fInputEnabled;
67 void
68 BMidiSynth::SetVolume(double volume)
70 be_synth->fSynth->SetVolume(volume);
74 double
75 BMidiSynth::Volume() const
77 return be_synth->fSynth->Volume();
81 void
82 BMidiSynth::SetTransposition(int16 offset)
84 fTranspose = offset;
88 int16
89 BMidiSynth::Transposition() const
91 return fTranspose;
95 void
96 BMidiSynth::MuteChannel(int16 channel, bool do_mute)
98 fprintf(stderr, "[midi] MuteChannel is broken; don't use it\n");
102 void
103 BMidiSynth::GetMuteMap(char* pChannels) const
105 fprintf(stderr, "[midi] GetMuteMap is broken; don't use it\n");
109 void
110 BMidiSynth::SoloChannel(int16 channel, bool do_solo)
112 fprintf(stderr, "[midi] SoloChannel is broken; don't use it\n");
116 void
117 BMidiSynth::GetSoloMap(char* pChannels) const
119 fprintf(stderr, "[midi] GetSoloMap is broken; don't use it\n");
123 status_t
124 BMidiSynth::LoadInstrument(int16 instrument)
126 return be_synth->fSynth->LoadInstrument(instrument);
130 status_t
131 BMidiSynth::UnloadInstrument(int16 instrument)
133 return be_synth->fSynth->UnloadInstrument(instrument);
137 status_t
138 BMidiSynth::RemapInstrument(int16 from, int16 to)
140 return be_synth->fSynth->RemapInstrument(from, to);
144 void
145 BMidiSynth::FlushInstrumentCache(bool startStopCache)
147 be_synth->fSynth->FlushInstrumentCache(startStopCache);
151 uint32
152 BMidiSynth::Tick() const
154 return (uint32) (system_time() - fCreationTime);
158 void
159 BMidiSynth::NoteOff(
160 uchar channel, uchar note, uchar velocity, uint32 time)
162 if (fInputEnabled)
163 be_synth->fSynth->NoteOff(channel, note + fTranspose, velocity, time);
167 void
168 BMidiSynth::NoteOn(
169 uchar channel, uchar note, uchar velocity, uint32 time)
171 if (fInputEnabled)
172 be_synth->fSynth->NoteOn(channel, note + fTranspose, velocity, time);
176 void
177 BMidiSynth::KeyPressure(
178 uchar channel, uchar note, uchar pressure, uint32 time)
180 if (fInputEnabled)
181 be_synth->fSynth->KeyPressure(
182 channel, note + fTranspose, pressure, time);
186 void
187 BMidiSynth::ControlChange(
188 uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
190 if (fInputEnabled)
191 be_synth->fSynth->ControlChange(
192 channel, controlNumber, controlValue, time);
196 void
197 BMidiSynth::ProgramChange(
198 uchar channel, uchar programNumber, uint32 time)
200 if (fInputEnabled)
201 be_synth->fSynth->ProgramChange(channel, programNumber, time);
205 void
206 BMidiSynth::ChannelPressure(uchar channel, uchar pressure, uint32 time)
208 if (fInputEnabled)
209 be_synth->fSynth->ChannelPressure(channel, pressure, time);
213 void
214 BMidiSynth::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
216 if (fInputEnabled)
217 be_synth->fSynth->PitchBend(channel, lsb, msb, time);
221 void
222 BMidiSynth::AllNotesOff(bool justChannel, uint32 time)
224 if (fInputEnabled)
225 be_synth->fSynth->AllNotesOff(justChannel, time);
229 void BMidiSynth::_ReservedMidiSynth1() { }
230 void BMidiSynth::_ReservedMidiSynth2() { }
231 void BMidiSynth::_ReservedMidiSynth3() { }
232 void BMidiSynth::_ReservedMidiSynth4() { }
235 void
236 BMidiSynth::Run()
238 // do nothing