1 #ifndef _MIDI_SOURCE_H 2 #define _MIDI_SOURCE_H 3 4 #include <Locker.h> 5 #include <MidiEndpoint.h> 6 7 class BMidiEvent; 8 9 class BMidiProducer : public BMidiEndpoint 10 { 11 public: 12 status_t Connect(BMidiConsumer *toObject); 13 status_t Disconnect(BMidiConsumer *toObject); 14 bool IsConnected(BMidiConsumer *toObject) const; 15 BList* Connections() const; 16 17 private: 18 friend class BMidiLocalProducer; 19 friend class BMidiRoster; 20 21 BMidiProducer(const char *name = NULL); 22 virtual ~BMidiProducer(); 23 24 virtual void _Reserved1(); 25 virtual void _Reserved2(); 26 virtual void _Reserved3(); 27 virtual void _Reserved4(); 28 virtual void _Reserved5(); 29 virtual void _Reserved6(); 30 virtual void _Reserved7(); 31 virtual void _Reserved8(); 32 33 BMidiList *fConnections; 34 mutable BLocker fLock; 35 36 int fConnectionCount; 37 uint32 _reserved[1]; 38 }; 39 40 class BMidiLocalProducer : public BMidiProducer 41 { 42 public: 43 BMidiLocalProducer(const char *name = NULL); 44 45 virtual void Connected(BMidiConsumer *dest); 46 virtual void Disconnected(BMidiConsumer *dest); 47 48 // Spray some MIDI data downstream to the targets of this object 49 void SprayData(void *data, size_t length, 50 bool atomic = false, bigtime_t time = 0) const; 51 52 void SprayNoteOff(uchar channel, uchar note, uchar velocity, 53 bigtime_t time = 0) const; 54 void SprayNoteOn(uchar channel, uchar note, uchar velocity, 55 bigtime_t time = 0) const; 56 void SprayKeyPressure(uchar channel, uchar note, uchar pressure, 57 bigtime_t time = 0) const; 58 void SprayControlChange(uchar channel, uchar controlNumber, 59 uchar controlValue, bigtime_t time = 0) const; 60 void SprayProgramChange(uchar channel, uchar programNumber, 61 bigtime_t time = 0) const; 62 void SprayChannelPressure(uchar channel, uchar pressure, 63 bigtime_t time = 0) const; 64 void SprayPitchBend(uchar channel, uchar lsb, uchar msb, 65 bigtime_t time = 0) const; 66 void SpraySystemExclusive(void* data, size_t dataLength, 67 bigtime_t time = 0) const; 68 void SpraySystemCommon(uchar statusByte, uchar data1, uchar data2, 69 bigtime_t time = 0) const; 70 void SpraySystemRealTime(uchar statusByte, 71 bigtime_t time = 0) const; 72 void SprayTempoChange(int32 bpm, 73 bigtime_t time = 0) const; 74 75 protected: 76 ~BMidiLocalProducer(); 77 78 private: 79 void SprayEvent(BMidiEvent *event, size_t length) const; 80 81 virtual void _Reserved1(); 82 virtual void _Reserved2(); 83 virtual void _Reserved3(); 84 virtual void _Reserved4(); 85 virtual void _Reserved5(); 86 virtual void _Reserved6(); 87 virtual void _Reserved7(); 88 virtual void _Reserved8(); 89 90 uint32 _reserved[2]; 91 }; 92 93 #endif 94