xref: /haiku/src/kits/midi/MidiGlue.h (revision d5cd5d63ff0ad395989db6cf4841a64d5b545d1d)
1 /*
2  * Copyright (c) 2003 Matthijs Hollemans
3  * Copyright (c) 2002 Jerome Leveque
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef _MIDI_GLUE_H
25 #define _MIDI_GLUE_H
26 
27 #include <MidiConsumer.h>
28 
29 #define MAKE_TIME(t)    (t / (bigtime_t)1000)
30 #define MAKE_BIGTIME(t) (t * (bigtime_t)1000)
31 
32 class BMidiGlue: public BMidiLocalConsumer
33 {
34 public:
35 
36 	BMidiGlue(BMidi* midiObject, const char* name = NULL);
37 
38 	virtual void NoteOff(
39 		uchar channel, uchar note, uchar velocity, bigtime_t time);
40 
41 	virtual void NoteOn(
42 		uchar channel, uchar note, uchar velocity, bigtime_t time);
43 
44 	virtual void KeyPressure(
45 		uchar channel, uchar note, uchar pressure, bigtime_t time);
46 
47 	virtual void ControlChange(
48 		uchar channel, uchar controlNumber, uchar controlValue,
49 		bigtime_t time);
50 
51 	virtual void ProgramChange(
52 		uchar channel, uchar programNumber, bigtime_t time);
53 
54 	virtual void ChannelPressure(
55 		uchar channel, uchar pressure, bigtime_t time);
56 
57 	virtual void PitchBend(
58 		uchar channel, uchar lsb, uchar msb, bigtime_t time);
59 
60 	virtual void SystemExclusive(
61 		void* data, size_t length, bigtime_t time);
62 
63 	virtual void SystemCommon(
64 		uchar status, uchar data1, uchar data2, bigtime_t time);
65 
66 	virtual void SystemRealTime(uchar status, bigtime_t time);
67 
68 	virtual void TempoChange(int32 beatsPerMinute, bigtime_t time);
69 
70 private:
71 
72 	BMidi* midiObject;
73 };
74 
75 class BMidiPortGlue: public BMidiLocalConsumer
76 {
77 public:
78 
79 	BMidiPortGlue(BMidiPort* midiObject, const char* name = NULL);
80 
81 	virtual void NoteOff(
82 		uchar channel, uchar note, uchar velocity, bigtime_t time);
83 
84 	virtual void NoteOn(
85 		uchar channel, uchar note, uchar velocity, bigtime_t time);
86 
87 	virtual void KeyPressure(
88 		uchar channel, uchar note, uchar pressure, bigtime_t time);
89 
90 	virtual void ControlChange(
91 		uchar channel, uchar controlNumber, uchar controlValue,
92 		bigtime_t time);
93 
94 	virtual void ProgramChange(
95 		uchar channel, uchar programNumber, bigtime_t time);
96 
97 	virtual void ChannelPressure(
98 		uchar channel, uchar pressure, bigtime_t time);
99 
100 	virtual void PitchBend(
101 		uchar channel, uchar lsb, uchar msb, bigtime_t time);
102 
103 	virtual void SystemExclusive(
104 		void* data, size_t length, bigtime_t time);
105 
106 	virtual void SystemCommon(
107 		uchar status, uchar data1, uchar data2, bigtime_t time);
108 
109 	virtual void SystemRealTime(uchar status, bigtime_t time);
110 
111 	virtual void TempoChange(int32 beatsPerMinute, bigtime_t time);
112 
113 private:
114 
115 	BMidiPort* midiObject;
116 };
117 
118 #endif // _MIDI_GLUE_H
119