14810cdcdSJérôme Duval/*
277f87987SJérôme Duval * Copyright 2006, Haiku.
377f87987SJérôme Duval *
477f87987SJérôme Duval * Copyright (c) 2003 Matthijs Hollemans
577f87987SJérôme Duval * Copyright (c) 2002 Jerome Leveque
64810cdcdSJérôme Duval * Distributed under the terms of the MIT License.
749fa1748Smahlzeit *
84810cdcdSJérôme Duval * Authors:
94810cdcdSJérôme Duval *		Matthijs Hollemans
104810cdcdSJérôme Duval *		J��r��me Leveque
1149fa1748Smahlzeit */
1249fa1748Smahlzeit
134810cdcdSJérôme Duval#include <Midi.h>
1449fa1748Smahlzeit#include "MidiGlue.h"
154810cdcdSJérôme Duval#include <MidiPort.h>
1649fa1748Smahlzeit
1732ed9cc8Smahlzeitusing namespace BPrivate;
1832ed9cc8Smahlzeit
1949fa1748Smahlzeit
2049fa1748SmahlzeitBMidiGlue::BMidiGlue(BMidi* midiObject_, const char* name)
2149fa1748Smahlzeit	: BMidiLocalConsumer(name)
2249fa1748Smahlzeit{
234810cdcdSJérôme Duval	fMidiObject = midiObject_;
2449fa1748Smahlzeit}
2549fa1748Smahlzeit
2649fa1748Smahlzeit
274810cdcdSJérôme Duvalvoid
284810cdcdSJérôme DuvalBMidiGlue::NoteOff(
2949fa1748Smahlzeit	uchar channel, uchar note, uchar velocity, bigtime_t time)
3049fa1748Smahlzeit{
314810cdcdSJérôme Duval	fMidiObject->NoteOff(channel + 1, note, velocity, MAKE_TIME(time));
3249fa1748Smahlzeit}
3349fa1748Smahlzeit
3449fa1748Smahlzeit
354810cdcdSJérôme Duvalvoid
364810cdcdSJérôme DuvalBMidiGlue::NoteOn(
3749fa1748Smahlzeit	uchar channel, uchar note, uchar velocity, bigtime_t time)
3849fa1748Smahlzeit{
394810cdcdSJérôme Duval	fMidiObject->NoteOn(channel + 1, note, velocity, MAKE_TIME(time));
4049fa1748Smahlzeit}
4149fa1748Smahlzeit
4249fa1748Smahlzeit
434810cdcdSJérôme Duvalvoid
444810cdcdSJérôme DuvalBMidiGlue::KeyPressure(
4549fa1748Smahlzeit	uchar channel, uchar note, uchar pressure, bigtime_t time)
4649fa1748Smahlzeit{
474810cdcdSJérôme Duval	fMidiObject->KeyPressure(channel + 1, note, pressure, MAKE_TIME(time));
4849fa1748Smahlzeit}
4949fa1748Smahlzeit
5049fa1748Smahlzeit
514810cdcdSJérôme Duvalvoid
524810cdcdSJérôme DuvalBMidiGlue::ControlChange(
5349fa1748Smahlzeit	uchar channel, uchar controlNumber, uchar controlValue, bigtime_t time)
5449fa1748Smahlzeit{
554810cdcdSJérôme Duval	fMidiObject->ControlChange(
5649fa1748Smahlzeit		channel + 1, controlNumber, controlValue, MAKE_TIME(time));
5749fa1748Smahlzeit}
5849fa1748Smahlzeit
5949fa1748Smahlzeit
604810cdcdSJérôme Duvalvoid
614810cdcdSJérôme DuvalBMidiGlue::ProgramChange(
6249fa1748Smahlzeit	uchar channel, uchar programNumber, bigtime_t time)
6349fa1748Smahlzeit{
644810cdcdSJérôme Duval	fMidiObject->ProgramChange(channel + 1, programNumber, MAKE_TIME(time));
6549fa1748Smahlzeit}
6649fa1748Smahlzeit
6749fa1748Smahlzeit
684810cdcdSJérôme Duvalvoid
694810cdcdSJérôme DuvalBMidiGlue::ChannelPressure(
7049fa1748Smahlzeit	uchar channel, uchar pressure, bigtime_t time)
7149fa1748Smahlzeit{
724810cdcdSJérôme Duval	fMidiObject->ChannelPressure(channel + 1, pressure, MAKE_TIME(time));
7349fa1748Smahlzeit}
7449fa1748Smahlzeit
7549fa1748Smahlzeit
764810cdcdSJérôme Duvalvoid
774810cdcdSJérôme DuvalBMidiGlue::PitchBend(
7849fa1748Smahlzeit	uchar channel, uchar lsb, uchar msb, bigtime_t time)
7949fa1748Smahlzeit{
804810cdcdSJérôme Duval	fMidiObject->PitchBend(channel + 1, lsb, msb, MAKE_TIME(time));
8149fa1748Smahlzeit}
8249fa1748Smahlzeit
8349fa1748Smahlzeit
844810cdcdSJérôme Duvalvoid
854810cdcdSJérôme DuvalBMidiGlue::SystemExclusive(
8649fa1748Smahlzeit	void* data, size_t length, bigtime_t time)
8749fa1748Smahlzeit{
884810cdcdSJérôme Duval	fMidiObject->SystemExclusive(data, length, MAKE_TIME(time));
8949fa1748Smahlzeit}
9049fa1748Smahlzeit
9149fa1748Smahlzeit
924810cdcdSJérôme Duvalvoid
934810cdcdSJérôme DuvalBMidiGlue::SystemCommon(
9449fa1748Smahlzeit	uchar status, uchar data1, uchar data2, bigtime_t time)
9549fa1748Smahlzeit{
964810cdcdSJérôme Duval	fMidiObject->SystemCommon(status, data1, data2, MAKE_TIME(time));
9749fa1748Smahlzeit}
9849fa1748Smahlzeit
9949fa1748Smahlzeit
1004810cdcdSJérôme Duvalvoid
1014810cdcdSJérôme DuvalBMidiGlue::SystemRealTime(uchar status, bigtime_t time)
10249fa1748Smahlzeit{
1034810cdcdSJérôme Duval	fMidiObject->SystemRealTime(status, MAKE_TIME(time));
10449fa1748Smahlzeit}
10549fa1748Smahlzeit
10649fa1748Smahlzeit
1074810cdcdSJérôme Duvalvoid
1084810cdcdSJérôme DuvalBMidiGlue::TempoChange(int32 beatsPerMinute, bigtime_t time)
10949fa1748Smahlzeit{
1104810cdcdSJérôme Duval	fMidiObject->TempoChange(beatsPerMinute, MAKE_TIME(time));
11149fa1748Smahlzeit}
11249fa1748Smahlzeit
11349fa1748Smahlzeit
11449fa1748SmahlzeitBMidiPortGlue::BMidiPortGlue(BMidiPort* midiObject_, const char* name)
11549fa1748Smahlzeit	: BMidiLocalConsumer(name)
11649fa1748Smahlzeit{
1174810cdcdSJérôme Duval	fMidiObject = midiObject_;
11849fa1748Smahlzeit}
11949fa1748Smahlzeit
12049fa1748Smahlzeit
1214810cdcdSJérôme Duvalvoid
1224810cdcdSJérôme DuvalBMidiPortGlue::NoteOff(
12349fa1748Smahlzeit	uchar channel, uchar note, uchar velocity, bigtime_t time)
12449fa1748Smahlzeit{
1254810cdcdSJérôme Duval	fMidiObject->SprayNoteOff(channel + 1, note, velocity, MAKE_TIME(time));
12649fa1748Smahlzeit}
12749fa1748Smahlzeit
12849fa1748Smahlzeit
1294810cdcdSJérôme Duvalvoid
1304810cdcdSJérôme DuvalBMidiPortGlue::NoteOn(
13149fa1748Smahlzeit	uchar channel, uchar note, uchar velocity, bigtime_t time)
13249fa1748Smahlzeit{
1334810cdcdSJérôme Duval	fMidiObject->SprayNoteOn(channel + 1, note, velocity, MAKE_TIME(time));
13449fa1748Smahlzeit}
13549fa1748Smahlzeit
13649fa1748Smahlzeit
1374810cdcdSJérôme Duvalvoid
1384810cdcdSJérôme DuvalBMidiPortGlue::KeyPressure(
13949fa1748Smahlzeit	uchar channel, uchar note, uchar pressure, bigtime_t time)
14049fa1748Smahlzeit{
1414810cdcdSJérôme Duval	fMidiObject->SprayKeyPressure(
14249fa1748Smahlzeit		channel + 1, note, pressure, MAKE_TIME(time));
14349fa1748Smahlzeit}
14449fa1748Smahlzeit
14549fa1748Smahlzeit
1464810cdcdSJérôme Duvalvoid
1474810cdcdSJérôme DuvalBMidiPortGlue::ControlChange(
14849fa1748Smahlzeit	uchar channel, uchar controlNumber, uchar controlValue, bigtime_t time)
14949fa1748Smahlzeit{
1504810cdcdSJérôme Duval	fMidiObject->SprayControlChange(
15149fa1748Smahlzeit		channel + 1, controlNumber, controlValue, MAKE_TIME(time));
15249fa1748Smahlzeit}
15349fa1748Smahlzeit
15449fa1748Smahlzeit
1554810cdcdSJérôme Duvalvoid
1564810cdcdSJérôme DuvalBMidiPortGlue::ProgramChange(
15749fa1748Smahlzeit	uchar channel, uchar programNumber, bigtime_t time)
15849fa1748Smahlzeit{
1594810cdcdSJérôme Duval	fMidiObject->SprayProgramChange(
16049fa1748Smahlzeit		channel + 1, programNumber, MAKE_TIME(time));
16149fa1748Smahlzeit}
16249fa1748Smahlzeit
16349fa1748Smahlzeit
1644810cdcdSJérôme Duvalvoid
1654810cdcdSJérôme DuvalBMidiPortGlue::ChannelPressure(
16649fa1748Smahlzeit	uchar channel, uchar pressure, bigtime_t time)
16749fa1748Smahlzeit{
1684810cdcdSJérôme Duval	fMidiObject->SprayChannelPressure(channel + 1, pressure, MAKE_TIME(time));
16949fa1748Smahlzeit}
17049fa1748Smahlzeit
17149fa1748Smahlzeit
1724810cdcdSJérôme Duvalvoid
1734810cdcdSJérôme DuvalBMidiPortGlue::PitchBend(
17449fa1748Smahlzeit	uchar channel, uchar lsb, uchar msb, bigtime_t time)
17549fa1748Smahlzeit{
1764810cdcdSJérôme Duval	fMidiObject->SprayPitchBend(channel + 1, lsb, msb, MAKE_TIME(time));
17749fa1748Smahlzeit}
17849fa1748Smahlzeit
17949fa1748Smahlzeit
1804810cdcdSJérôme Duvalvoid
1814810cdcdSJérôme DuvalBMidiPortGlue::SystemExclusive(
18249fa1748Smahlzeit	void* data, size_t length, bigtime_t time)
18349fa1748Smahlzeit{
1844810cdcdSJérôme Duval	fMidiObject->SpraySystemExclusive(data, length, MAKE_TIME(time));
18549fa1748Smahlzeit}
18649fa1748Smahlzeit
18749fa1748Smahlzeit
1884810cdcdSJérôme Duvalvoid
1894810cdcdSJérôme DuvalBMidiPortGlue::SystemCommon(
19049fa1748Smahlzeit	uchar status, uchar data1, uchar data2, bigtime_t time)
19149fa1748Smahlzeit{
1924810cdcdSJérôme Duval	fMidiObject->SpraySystemCommon(status, data1, data2, MAKE_TIME(time));
19349fa1748Smahlzeit}
19449fa1748Smahlzeit
19549fa1748Smahlzeit
1964810cdcdSJérôme Duvalvoid
1974810cdcdSJérôme DuvalBMidiPortGlue::SystemRealTime(uchar status, bigtime_t time)
19849fa1748Smahlzeit{
1994810cdcdSJérôme Duval	fMidiObject->SpraySystemRealTime(status, MAKE_TIME(time));
20049fa1748Smahlzeit}
20149fa1748Smahlzeit
20249fa1748Smahlzeit
2034810cdcdSJérôme Duvalvoid
2044810cdcdSJérôme DuvalBMidiPortGlue::TempoChange(int32 beatsPerMinute, bigtime_t time)
20549fa1748Smahlzeit{
2064810cdcdSJérôme Duval	fMidiObject->SprayTempoChange(beatsPerMinute, MAKE_TIME(time));
20749fa1748Smahlzeit}
20849fa1748Smahlzeit
209