Files
haiku-beta6/src/kits/midi/MidiSynth.cpp
T

237 lines
3.8 KiB
C++
Raw Normal View History

2003-03-17 22:30:19 +00:00
/*
* Copyright 2006, Haiku.
*
* Copyright (c) 2002-2004 Matthijs Hollemans
* Copyright (c) 2003 Jerome Leveque
2006-06-19 13:24:04 +00:00
* Distributed under the terms of the MIT License.
*
2006-06-19 13:24:04 +00:00
* Authors:
*
* Matthijs Hollemans
* Jérôme Leveque
*/
2005-11-17 22:53:30 +00:00
#include <MidiSynth.h>
#include "debug.h"
#include "SoftSynth.h"
using namespace BPrivate;
BMidiSynth::BMidiSynth()
{
2006-06-19 13:24:04 +00:00
if (be_synth == NULL) {
2004-05-13 09:44:22 +00:00
new BSynth();
}
2006-06-19 13:24:04 +00:00
be_synth->fClientCount++;
2006-06-19 13:24:04 +00:00
fInputEnabled = false;
fTranspose = 0;
fCreationTime = system_time();
}
BMidiSynth::~BMidiSynth()
{
2006-06-19 13:24:04 +00:00
be_synth->fClientCount--;
}
2006-06-19 13:24:04 +00:00
status_t
BMidiSynth::EnableInput(bool enable, bool loadInstruments)
{
status_t err = B_OK;
2006-06-19 13:24:04 +00:00
fInputEnabled = enable;
2006-06-17 14:04:46 +00:00
if (loadInstruments) {
2006-06-19 13:24:04 +00:00
err = be_synth->fSynth->LoadAllInstruments();
}
return err;
}
2006-06-19 13:24:04 +00:00
bool
BMidiSynth::IsInputEnabled() const
{
2006-06-19 13:24:04 +00:00
return fInputEnabled;
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::SetVolume(double volume)
{
2006-06-19 13:24:04 +00:00
be_synth->fSynth->SetVolume(volume);
}
2006-06-19 13:24:04 +00:00
double
BMidiSynth::Volume() const
{
2006-06-19 13:24:04 +00:00
return be_synth->fSynth->Volume();
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::SetTransposition(int16 offset)
{
2006-06-19 13:24:04 +00:00
fTranspose = offset;
}
2006-06-19 13:24:04 +00:00
int16
BMidiSynth::Transposition() const
{
2006-06-19 13:24:04 +00:00
return fTranspose;
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::MuteChannel(int16 channel, bool do_mute)
{
fprintf(stderr, "[midi] MuteChannel is broken; don't use it\n");
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::GetMuteMap(char* pChannels) const
{
fprintf(stderr, "[midi] GetMuteMap is broken; don't use it\n");
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::SoloChannel(int16 channel, bool do_solo)
{
fprintf(stderr, "[midi] SoloChannel is broken; don't use it\n");
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::GetSoloMap(char* pChannels) const
{
fprintf(stderr, "[midi] GetSoloMap is broken; don't use it\n");
}
2006-06-19 13:24:04 +00:00
status_t
BMidiSynth::LoadInstrument(int16 instrument)
{
2006-06-19 13:24:04 +00:00
return be_synth->fSynth->LoadInstrument(instrument);
}
2006-06-19 13:24:04 +00:00
status_t
BMidiSynth::UnloadInstrument(int16 instrument)
{
2006-06-19 13:24:04 +00:00
return be_synth->fSynth->UnloadInstrument(instrument);
}
2006-06-19 13:24:04 +00:00
status_t
BMidiSynth::RemapInstrument(int16 from, int16 to)
{
2006-06-19 13:24:04 +00:00
return be_synth->fSynth->RemapInstrument(from, to);
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::FlushInstrumentCache(bool startStopCache)
{
2006-06-19 13:24:04 +00:00
be_synth->fSynth->FlushInstrumentCache(startStopCache);
}
2006-06-19 13:24:04 +00:00
uint32
BMidiSynth::Tick() const
{
2006-06-19 13:24:04 +00:00
return (uint32) (system_time() - fCreationTime);
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::NoteOff(
uchar channel, uchar note, uchar velocity, uint32 time)
{
2006-06-19 13:24:04 +00:00
if (fInputEnabled)
be_synth->fSynth->NoteOff(channel, note + fTranspose, velocity, time);
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::NoteOn(
uchar channel, uchar note, uchar velocity, uint32 time)
{
2006-06-19 13:24:04 +00:00
if (fInputEnabled)
be_synth->fSynth->NoteOn(channel, note + fTranspose, velocity, time);
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::KeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time)
{
2006-06-19 13:24:04 +00:00
if (fInputEnabled)
be_synth->fSynth->KeyPressure(
channel, note + fTranspose, pressure, time);
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::ControlChange(
uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
{
2006-06-19 13:24:04 +00:00
if (fInputEnabled)
be_synth->fSynth->ControlChange(
channel, controlNumber, controlValue, time);
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::ProgramChange(
uchar channel, uchar programNumber, uint32 time)
{
2006-06-19 13:24:04 +00:00
if (fInputEnabled)
be_synth->fSynth->ProgramChange(channel, programNumber, time);
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::ChannelPressure(uchar channel, uchar pressure, uint32 time)
{
2006-06-19 13:24:04 +00:00
if (fInputEnabled)
be_synth->fSynth->ChannelPressure(channel, pressure, time);
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
{
2006-06-19 13:24:04 +00:00
if (fInputEnabled)
be_synth->fSynth->PitchBend(channel, lsb, msb, time);
}
2006-06-19 13:24:04 +00:00
void
BMidiSynth::AllNotesOff(bool justChannel, uint32 time)
{
2006-06-19 13:24:04 +00:00
if (fInputEnabled)
be_synth->fSynth->AllNotesOff(justChannel, time);
}
void BMidiSynth::_ReservedMidiSynth1() { }
void BMidiSynth::_ReservedMidiSynth2() { }
void BMidiSynth::_ReservedMidiSynth3() { }
void BMidiSynth::_ReservedMidiSynth4() { }
2006-06-19 13:24:04 +00:00
void
BMidiSynth::Run()
{
// do nothing
}