xref: /haiku/src/kits/midi/MidiGlue.cpp (revision 922e7ba1f3228e6f28db69b0ded8f86eb32dea17)
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 
17 using namespace BPrivate;
18 
19 
20 BMidiGlue::BMidiGlue(BMidi* midiObject_, const char* name)
21 	: BMidiLocalConsumer(name)
22 {
23 	fMidiObject = midiObject_;
24 }
25 
26 
27 void
28 BMidiGlue::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 
35 void
36 BMidiGlue::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 
43 void
44 BMidiGlue::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 
51 void
52 BMidiGlue::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 
60 void
61 BMidiGlue::ProgramChange(
62 	uchar channel, uchar programNumber, bigtime_t time)
63 {
64 	fMidiObject->ProgramChange(channel + 1, programNumber, MAKE_TIME(time));
65 }
66 
67 
68 void
69 BMidiGlue::ChannelPressure(
70 	uchar channel, uchar pressure, bigtime_t time)
71 {
72 	fMidiObject->ChannelPressure(channel + 1, pressure, MAKE_TIME(time));
73 }
74 
75 
76 void
77 BMidiGlue::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 
84 void
85 BMidiGlue::SystemExclusive(
86 	void* data, size_t length, bigtime_t time)
87 {
88 	fMidiObject->SystemExclusive(data, length, MAKE_TIME(time));
89 }
90 
91 
92 void
93 BMidiGlue::SystemCommon(
94 	uchar status, uchar data1, uchar data2, bigtime_t time)
95 {
96 	fMidiObject->SystemCommon(status, data1, data2, MAKE_TIME(time));
97 }
98 
99 
100 void
101 BMidiGlue::SystemRealTime(uchar status, bigtime_t time)
102 {
103 	fMidiObject->SystemRealTime(status, MAKE_TIME(time));
104 }
105 
106 
107 void
108 BMidiGlue::TempoChange(int32 beatsPerMinute, bigtime_t time)
109 {
110 	fMidiObject->TempoChange(beatsPerMinute, MAKE_TIME(time));
111 }
112 
113 
114 BMidiPortGlue::BMidiPortGlue(BMidiPort* midiObject_, const char* name)
115 	: BMidiLocalConsumer(name)
116 {
117 	fMidiObject = midiObject_;
118 }
119 
120 
121 void
122 BMidiPortGlue::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 
129 void
130 BMidiPortGlue::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 
137 void
138 BMidiPortGlue::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 
146 void
147 BMidiPortGlue::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 
155 void
156 BMidiPortGlue::ProgramChange(
157 	uchar channel, uchar programNumber, bigtime_t time)
158 {
159 	fMidiObject->SprayProgramChange(
160 		channel + 1, programNumber, MAKE_TIME(time));
161 }
162 
163 
164 void
165 BMidiPortGlue::ChannelPressure(
166 	uchar channel, uchar pressure, bigtime_t time)
167 {
168 	fMidiObject->SprayChannelPressure(channel + 1, pressure, MAKE_TIME(time));
169 }
170 
171 
172 void
173 BMidiPortGlue::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 
180 void
181 BMidiPortGlue::SystemExclusive(
182 	void* data, size_t length, bigtime_t time)
183 {
184 	fMidiObject->SpraySystemExclusive(data, length, MAKE_TIME(time));
185 }
186 
187 
188 void
189 BMidiPortGlue::SystemCommon(
190 	uchar status, uchar data1, uchar data2, bigtime_t time)
191 {
192 	fMidiObject->SpraySystemCommon(status, data1, data2, MAKE_TIME(time));
193 }
194 
195 
196 void
197 BMidiPortGlue::SystemRealTime(uchar status, bigtime_t time)
198 {
199 	fMidiObject->SpraySystemRealTime(status, MAKE_TIME(time));
200 }
201 
202 
203 void
204 BMidiPortGlue::TempoChange(int32 beatsPerMinute, bigtime_t time)
205 {
206 	fMidiObject->SprayTempoChange(beatsPerMinute, MAKE_TIME(time));
207 }
208 
209