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