xref: /haiku/headers/os/midi/MidiPort.h (revision 4f2fd49bdc6078128b1391191e4edac647044c3d)
1 
2 #ifndef _MIDI_PORT_H
3 #define _MIDI_PORT_H
4 
5 #include <Midi.h>
6 
7 class BMidiConsumer;
8 class BMidiProducer;
9 
10 namespace BPrivate { class BMidiPortGlue; }
11 
12 class BMidiPort : public BMidi
13 {
14 public:
15 
16 	BMidiPort(const char* name = NULL);
17 	~BMidiPort();
18 
19 	status_t InitCheck() const;
20 	status_t Open(const char* name);
21 	void Close();
22 
23 	const char* PortName() const;
24 
25 	virtual	void NoteOff(
26 		uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
27 
28 	virtual void NoteOn(
29 		uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
30 
31 	virtual void KeyPressure(
32 		uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
33 
34 	virtual void ControlChange(
35 		uchar channel, uchar controlNumber, uchar controlValue,
36 		uint32 time = B_NOW);
37 
38 	virtual void ProgramChange(
39 		uchar channel, uchar programNumber, uint32 time = B_NOW);
40 
41 	virtual void ChannelPressure(
42 		uchar channel, uchar pressure, uint32 time = B_NOW);
43 
44 	virtual void PitchBend(
45 		uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
46 
47 	virtual void SystemExclusive(
48 		void* data, size_t length, uint32 time = B_NOW);
49 
50 	virtual void SystemCommon(
51 		uchar status, uchar data0, uchar data2, uint32 time = B_NOW);
52 
53 	virtual void SystemRealTime(uchar status, uint32 time = B_NOW);
54 
55 	virtual status_t Start();
56 	virtual void Stop();
57 
58 	int32 CountDevices();
59 
60 	status_t GetDeviceName(
61 		int32 n, char* name, size_t bufSize = B_OS_NAME_LENGTH);
62 
63 private:
64 
65 	typedef BMidi super;
66 
67 	friend class BPrivate::BMidiPortGlue;
68 
69 	virtual void _ReservedMidiPort1();
70 	virtual void _ReservedMidiPort2();
71 	virtual void _ReservedMidiPort3();
72 
73 	virtual void Run();
74 
75 	void ScanDevices();
76 	void EmptyDeviceList();
77 
78 	BMidiLocalProducer* fLocalSource;
79 	BMidiLocalConsumer* fLocalSink;
80 	BMidiProducer* fRemoteSource;
81 	BMidiConsumer* fRemoteSink;
82 
83 	char* fPortName;
84 	status_t fStatus;
85 	BList* fDevices;
86 
87 	uint32 _reserved[1];
88 };
89 
90 #endif // _MIDI_PORT_H
91