xref: /haiku/headers/os/midi2/MidiConsumer.h (revision 1d9d47fc72028bb71b5f232a877231e59cfe2438)
1 
2 #ifndef _MIDI_CONSUMER_H
3 #define _MIDI_CONSUMER_H
4 
5 #include <MidiEndpoint.h>
6 
7 namespace BPrivate { class BMidiRosterLooper; }
8 
9 class BMidiConsumer : public BMidiEndpoint
10 {
11 public:
12 
13 	bigtime_t Latency() const;
14 
15 private:
16 
17 	friend class BMidiLocalConsumer;
18 	friend class BMidiLocalProducer;
19 	friend class BMidiRoster;
20 	friend class BPrivate::BMidiRosterLooper;
21 
22 	BMidiConsumer(const char* name = NULL);
23 	virtual ~BMidiConsumer();
24 
25 	virtual void _Reserved1();
26 	virtual void _Reserved2();
27 	virtual void _Reserved3();
28 	virtual void _Reserved4();
29 	virtual void _Reserved5();
30 	virtual void _Reserved6();
31 	virtual void _Reserved7();
32 	virtual void _Reserved8();
33 
34 	port_id fPort;
35 	bigtime_t fLatency;
36 
37 	uint32 _reserved[2];
38 };
39 
40 class BMidiLocalConsumer : public BMidiConsumer
41 {
42 public:
43 
44 	BMidiLocalConsumer(const char* name = NULL);
45 
46 	void SetLatency(bigtime_t latency);
47 	int32 GetProducerID(void);
48 
49 	void SetTimeout(bigtime_t when, void* data);
50 	virtual void Timeout(void* data);
51 
52 	virtual void Data(
53 		uchar* data, size_t length, bool atomic, bigtime_t time);
54 
55 	virtual	void NoteOff(
56 		uchar channel, uchar note, uchar velocity, bigtime_t time);
57 
58 	virtual	void NoteOn(
59 		uchar channel, uchar note, uchar velocity, bigtime_t time);
60 
61 	virtual	void KeyPressure(
62 		uchar channel, uchar note, uchar pressure, bigtime_t time);
63 
64 	virtual	void ControlChange(
65 		uchar channel, uchar controlNumber, uchar controlValue,
66 		bigtime_t time);
67 
68 	virtual	void ProgramChange(
69 		uchar channel, uchar programNumber, bigtime_t time);
70 
71 	virtual	void ChannelPressure(
72 		uchar channel, uchar pressure, bigtime_t time);
73 
74 	virtual	void PitchBend(
75 		uchar channel, uchar lsb, uchar msb, bigtime_t time);
76 
77 	virtual	void SystemExclusive(
78 		void* data, size_t length, bigtime_t time);
79 
80 	virtual	void SystemCommon(
81 		uchar status, uchar data1, uchar data2, bigtime_t time);
82 
83 	virtual	void SystemRealTime(uchar status, bigtime_t time);
84 
85 	virtual	void TempoChange(int32 beatsPerMinute, bigtime_t time);
86 
87 	virtual void AllNotesOff(bool justChannel, bigtime_t time);
88 
89 protected:
90 
91 	~BMidiLocalConsumer();
92 
93 private:
94 
95 	friend class BMidiRoster;
96 	friend int32 _midi_event_thread(void*);
97 
98 	virtual void _Reserved1();
99 	virtual void _Reserved2();
100 	virtual void _Reserved3();
101 	virtual void _Reserved4();
102 	virtual void _Reserved5();
103 	virtual void _Reserved6();
104 	virtual void _Reserved7();
105 	virtual void _Reserved8();
106 
107 	int32 EventThread();
108 
109 	bigtime_t fTimeout;
110 	void* fTimeoutData;
111 	int32 fCurrentProducer;
112 	thread_id fThread;
113 
114 	uint32 _reserved[1];
115 };
116 
117 #endif // _MIDI_CONSUMER_H
118