1/*
2 * Copyright 2006, Haiku.
3 *
4 * Copyright (c) 2003 Matthijs Hollemans
5 * Copyright (c) 2002 Jerome Leveque
6 * Distributed under the terms of the MIT License.
7 *
8 * Authors:
9 *		Matthijs Hollemans
10 *		Jérôme Leveque
11 */
12
13#include <Midi.h>
14#include "MidiGlue.h"
15#include <MidiPort.h>
16
17using namespace BPrivate;
18
19
20BMidiGlue::BMidiGlue(BMidi* midiObject_, const char* name)
21	: BMidiLocalConsumer(name)
22{
23	fMidiObject = midiObject_;
24}
25
26
27void
28BMidiGlue::NoteOff(
29	uchar channel, uchar note, uchar velocity, bigtime_t time)
30{
31	fMidiObject->NoteOff(channel + 1, note, velocity, MAKE_TIME(time));
32}
33
34
35void
36BMidiGlue::NoteOn(
37	uchar channel, uchar note, uchar velocity, bigtime_t time)
38{
39	fMidiObject->NoteOn(channel + 1, note, velocity, MAKE_TIME(time));
40}
41
42
43void
44BMidiGlue::KeyPressure(
45	uchar channel, uchar note, uchar pressure, bigtime_t time)
46{
47	fMidiObject->KeyPressure(channel + 1, note, pressure, MAKE_TIME(time));
48}
49
50
51void
52BMidiGlue::ControlChange(
53	uchar channel, uchar controlNumber, uchar controlValue, bigtime_t time)
54{
55	fMidiObject->ControlChange(
56		channel + 1, controlNumber, controlValue, MAKE_TIME(time));
57}
58
59
60void
61BMidiGlue::ProgramChange(
62	uchar channel, uchar programNumber, bigtime_t time)
63{
64	fMidiObject->ProgramChange(channel + 1, programNumber, MAKE_TIME(time));
65}
66
67
68void
69BMidiGlue::ChannelPressure(
70	uchar channel, uchar pressure, bigtime_t time)
71{
72	fMidiObject->ChannelPressure(channel + 1, pressure, MAKE_TIME(time));
73}
74
75
76void
77BMidiGlue::PitchBend(
78	uchar channel, uchar lsb, uchar msb, bigtime_t time)
79{
80	fMidiObject->PitchBend(channel + 1, lsb, msb, MAKE_TIME(time));
81}
82
83
84void
85BMidiGlue::SystemExclusive(
86	void* data, size_t length, bigtime_t time)
87{
88	fMidiObject->SystemExclusive(data, length, MAKE_TIME(time));
89}
90
91
92void
93BMidiGlue::SystemCommon(
94	uchar status, uchar data1, uchar data2, bigtime_t time)
95{
96	fMidiObject->SystemCommon(status, data1, data2, MAKE_TIME(time));
97}
98
99
100void
101BMidiGlue::SystemRealTime(uchar status, bigtime_t time)
102{
103	fMidiObject->SystemRealTime(status, MAKE_TIME(time));
104}
105
106
107void
108BMidiGlue::TempoChange(int32 beatsPerMinute, bigtime_t time)
109{
110	fMidiObject->TempoChange(beatsPerMinute, MAKE_TIME(time));
111}
112
113
114BMidiPortGlue::BMidiPortGlue(BMidiPort* midiObject_, const char* name)
115	: BMidiLocalConsumer(name)
116{
117	fMidiObject = midiObject_;
118}
119
120
121void
122BMidiPortGlue::NoteOff(
123	uchar channel, uchar note, uchar velocity, bigtime_t time)
124{
125	fMidiObject->SprayNoteOff(channel + 1, note, velocity, MAKE_TIME(time));
126}
127
128
129void
130BMidiPortGlue::NoteOn(
131	uchar channel, uchar note, uchar velocity, bigtime_t time)
132{
133	fMidiObject->SprayNoteOn(channel + 1, note, velocity, MAKE_TIME(time));
134}
135
136
137void
138BMidiPortGlue::KeyPressure(
139	uchar channel, uchar note, uchar pressure, bigtime_t time)
140{
141	fMidiObject->SprayKeyPressure(
142		channel + 1, note, pressure, MAKE_TIME(time));
143}
144
145
146void
147BMidiPortGlue::ControlChange(
148	uchar channel, uchar controlNumber, uchar controlValue, bigtime_t time)
149{
150	fMidiObject->SprayControlChange(
151		channel + 1, controlNumber, controlValue, MAKE_TIME(time));
152}
153
154
155void
156BMidiPortGlue::ProgramChange(
157	uchar channel, uchar programNumber, bigtime_t time)
158{
159	fMidiObject->SprayProgramChange(
160		channel + 1, programNumber, MAKE_TIME(time));
161}
162
163
164void
165BMidiPortGlue::ChannelPressure(
166	uchar channel, uchar pressure, bigtime_t time)
167{
168	fMidiObject->SprayChannelPressure(channel + 1, pressure, MAKE_TIME(time));
169}
170
171
172void
173BMidiPortGlue::PitchBend(
174	uchar channel, uchar lsb, uchar msb, bigtime_t time)
175{
176	fMidiObject->SprayPitchBend(channel + 1, lsb, msb, MAKE_TIME(time));
177}
178
179
180void
181BMidiPortGlue::SystemExclusive(
182	void* data, size_t length, bigtime_t time)
183{
184	fMidiObject->SpraySystemExclusive(data, length, MAKE_TIME(time));
185}
186
187
188void
189BMidiPortGlue::SystemCommon(
190	uchar status, uchar data1, uchar data2, bigtime_t time)
191{
192	fMidiObject->SpraySystemCommon(status, data1, data2, MAKE_TIME(time));
193}
194
195
196void
197BMidiPortGlue::SystemRealTime(uchar status, bigtime_t time)
198{
199	fMidiObject->SpraySystemRealTime(status, MAKE_TIME(time));
200}
201
202
203void
204BMidiPortGlue::TempoChange(int32 beatsPerMinute, bigtime_t time)
205{
206	fMidiObject->SprayTempoChange(beatsPerMinute, MAKE_TIME(time));
207}
208
209