xref: /haiku/src/kits/midi/MidiGlue.h (revision 239222b2369c39dc52df52b0a7cdd6cc0a91bc92)
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 #ifndef _MIDI_GLUE_H
14 #define _MIDI_GLUE_H
15 
16 #include <MidiPort.h>
17 #include <MidiConsumer.h>
18 
19 #define MAKE_TIME(t)    (t / (bigtime_t)1000)
20 #define MAKE_BIGTIME(t) (t * (bigtime_t)1000)
21 
22 namespace BPrivate {
23 
24 class BMidiGlue: public BMidiLocalConsumer
25 {
26 public:
27 
28 	BMidiGlue(BMidi* midiObject, const char* name = NULL);
29 
30 	virtual void NoteOff(
31 		uchar channel, uchar note, uchar velocity, bigtime_t time);
32 
33 	virtual void NoteOn(
34 		uchar channel, uchar note, uchar velocity, bigtime_t time);
35 
36 	virtual void KeyPressure(
37 		uchar channel, uchar note, uchar pressure, bigtime_t time);
38 
39 	virtual void ControlChange(
40 		uchar channel, uchar controlNumber, uchar controlValue,
41 		bigtime_t time);
42 
43 	virtual void ProgramChange(
44 		uchar channel, uchar programNumber, bigtime_t time);
45 
46 	virtual void ChannelPressure(
47 		uchar channel, uchar pressure, bigtime_t time);
48 
49 	virtual void PitchBend(
50 		uchar channel, uchar lsb, uchar msb, bigtime_t time);
51 
52 	virtual void SystemExclusive(
53 		void* data, size_t length, bigtime_t time);
54 
55 	virtual void SystemCommon(
56 		uchar status, uchar data1, uchar data2, bigtime_t time);
57 
58 	virtual void SystemRealTime(uchar status, bigtime_t time);
59 
60 	virtual void TempoChange(int32 beatsPerMinute, bigtime_t time);
61 
62 private:
63 
64 	BMidi* fMidiObject;
65 };
66 
67 class BMidiPortGlue: public BMidiLocalConsumer
68 {
69 public:
70 
71 	BMidiPortGlue(BMidiPort* midiObject, const char* name = NULL);
72 
73 	virtual void NoteOff(
74 		uchar channel, uchar note, uchar velocity, bigtime_t time);
75 
76 	virtual void NoteOn(
77 		uchar channel, uchar note, uchar velocity, bigtime_t time);
78 
79 	virtual void KeyPressure(
80 		uchar channel, uchar note, uchar pressure, bigtime_t time);
81 
82 	virtual void ControlChange(
83 		uchar channel, uchar controlNumber, uchar controlValue,
84 		bigtime_t time);
85 
86 	virtual void ProgramChange(
87 		uchar channel, uchar programNumber, bigtime_t time);
88 
89 	virtual void ChannelPressure(
90 		uchar channel, uchar pressure, bigtime_t time);
91 
92 	virtual void PitchBend(
93 		uchar channel, uchar lsb, uchar msb, bigtime_t time);
94 
95 	virtual void SystemExclusive(
96 		void* data, size_t length, bigtime_t time);
97 
98 	virtual void SystemCommon(
99 		uchar status, uchar data1, uchar data2, bigtime_t time);
100 
101 	virtual void SystemRealTime(uchar status, bigtime_t time);
102 
103 	virtual void TempoChange(int32 beatsPerMinute, bigtime_t time);
104 
105 private:
106 
107 	BMidiPort* fMidiObject;
108 };
109 
110 } // namespace BPrivate
111 
112 #endif // _MIDI_GLUE_H
113