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