xref: /haiku/headers/os/midi2/MidiProducer.h (revision db10640de90f7f9519ba2da9577b7c1af3c64f6b)
1 
2 #ifndef _MIDI_PRODUCER_H
3 #define _MIDI_PRODUCER_H
4 
5 #include <Locker.h>
6 #include <MidiEndpoint.h>
7 
8 class BList;
9 
10 namespace BPrivate { class BMidiRosterLooper; }
11 
12 class BMidiProducer : public BMidiEndpoint
13 {
14 public:
15 
16 	status_t Connect(BMidiConsumer* cons);
17 	status_t Disconnect(BMidiConsumer* cons);
18 	bool IsConnected(BMidiConsumer* cons) const;
19 	BList* Connections() const;
20 
21 private:
22 
23 	friend class BMidiLocalProducer;
24 	friend class BMidiRoster;
25 	friend class BPrivate::BMidiRosterLooper;
26 
27 	BMidiProducer(const char* name = NULL);
28 	virtual ~BMidiProducer();
29 
30 	virtual void _Reserved1();
31 	virtual void _Reserved2();
32 	virtual void _Reserved3();
33 	virtual void _Reserved4();
34 	virtual void _Reserved5();
35 	virtual void _Reserved6();
36 	virtual void _Reserved7();
37 	virtual void _Reserved8();
38 
39 	status_t SendConnectRequest(BMidiConsumer*, bool);
40 	void ConnectionMade(BMidiConsumer*);
41 	bool ConnectionBroken(BMidiConsumer*);
42 
43 	int32 CountConsumers() const;
44 	BMidiConsumer* ConsumerAt(int32) const;
45 
46 	bool LockProducer() const;
47 	void UnlockProducer() const;
48 
49 	BList* connections;
50 	BLocker* locker;
51 
52 	uint32 _reserved[10];
53 };
54 
55 class BMidiLocalProducer : public BMidiProducer
56 {
57 public:
58 
59 	BMidiLocalProducer(const char* name = NULL);
60 
61 	virtual void Connected(BMidiConsumer* cons);
62 	virtual void Disconnected(BMidiConsumer* cons);
63 
64 	void SprayData(
65 		void* data, size_t length, bool atomic = false,
66 		bigtime_t time = 0) const;
67 
68 	void SprayNoteOff(
69 		uchar channel, uchar note, uchar velocity,
70 		bigtime_t time = 0) const;
71 
72 	void SprayNoteOn(
73 		uchar channel, uchar note, uchar velocity,
74 		bigtime_t time = 0) const;
75 
76 	void SprayKeyPressure(
77 		uchar channel, uchar note, uchar pressure,
78 		bigtime_t time = 0) const;
79 
80 	void SprayControlChange(
81 		uchar channel, uchar controlNumber, uchar controlValue,
82 		bigtime_t time = 0) const;
83 
84 	void SprayProgramChange(
85 		uchar channel, uchar programNumber, bigtime_t time = 0) const;
86 
87 	void SprayChannelPressure(
88 		uchar channel, uchar pressure, bigtime_t time = 0) const;
89 
90 	void SprayPitchBend(
91 		uchar channel, uchar lsb, uchar msb, bigtime_t time = 0) const;
92 
93 	void SpraySystemExclusive(
94 		void* data, size_t length, bigtime_t time = 0) const;
95 
96 	void SpraySystemCommon(
97 		uchar status, uchar data1, uchar data2, bigtime_t time = 0) const;
98 
99 	void SpraySystemRealTime(
100 		uchar status, bigtime_t time = 0) const;
101 
102 	void SprayTempoChange(
103 		int32 beatsPerMinute, bigtime_t time = 0) const;
104 
105 protected:
106 
107 	~BMidiLocalProducer();
108 
109 private:
110 
111 	void SprayEvent(
112 		const void* data, size_t length, bool atomic, bigtime_t time,
113 		bool sysex = false) const;
114 
115 	virtual void _Reserved1();
116 	virtual void _Reserved2();
117 	virtual void _Reserved3();
118 	virtual void _Reserved4();
119 	virtual void _Reserved5();
120 	virtual void _Reserved6();
121 	virtual void _Reserved7();
122 	virtual void _Reserved8();
123 
124 	uint32 _reserved[2];
125 };
126 
127 #endif // _MIDI_PRODUCER_H
128