1 2 #ifndef _MIDI_H 3 #define _MIDI_H 4 5 #include <BeBuild.h> 6 #include <MidiDefs.h> 7 #include <OS.h> 8 9 class BList; 10 class BMidiLocalProducer; 11 class BMidiLocalConsumer; 12 13 class BMidi 14 { 15 public: 16 17 BMidi(); 18 virtual ~BMidi(); 19 20 virtual void NoteOff( 21 uchar channel, uchar note, uchar velocity, uint32 time = B_NOW); 22 23 virtual void NoteOn( 24 uchar channel, uchar note, uchar velocity, uint32 time = B_NOW); 25 26 virtual void KeyPressure( 27 uchar channel, uchar note, uchar pressure, uint32 time = B_NOW); 28 29 virtual void ControlChange( 30 uchar channel, uchar controlNumber, uchar controlValue, 31 uint32 time = B_NOW); 32 33 virtual void ProgramChange( 34 uchar channel, uchar programNumber, uint32 time = B_NOW); 35 36 virtual void ChannelPressure( 37 uchar channel, uchar pressure, uint32 time = B_NOW); 38 39 virtual void PitchBend( 40 uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW); 41 42 virtual void SystemExclusive( 43 void* data, size_t length, uint32 time = B_NOW); 44 45 virtual void SystemCommon( 46 uchar status, uchar data1, uchar data2, uint32 time = B_NOW); 47 48 virtual void SystemRealTime(uchar status, uint32 time = B_NOW); 49 50 virtual void TempoChange(int32 beatsPerMinute, uint32 time = B_NOW); 51 52 virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW); 53 54 virtual status_t Start(); 55 virtual void Stop(); 56 57 bool IsRunning() const; 58 59 void Connect(BMidi* toObject); 60 void Disconnect(BMidi* fromObject); 61 bool IsConnected(BMidi* toObject) const; 62 BList* Connections() const; 63 64 void SnoozeUntil(uint32 time) const; 65 66 protected: 67 68 void SprayNoteOff( 69 uchar channel, uchar note, uchar velocity, uint32 time) const; 70 71 void SprayNoteOn( 72 uchar channel, uchar note, uchar velocity, uint32 time) const; 73 74 void SprayKeyPressure( 75 uchar channel, uchar note, uchar pressure, uint32 time) const; 76 77 void SprayControlChange( 78 uchar channel, uchar controlNumber, uchar controlValue, 79 uint32 time) const; 80 81 void SprayProgramChange( 82 uchar channel, uchar programNumber, uint32 time) const; 83 84 void SprayChannelPressure( 85 uchar channel, uchar pressure, uint32 time) const; 86 87 void SprayPitchBend( 88 uchar channel, uchar lsb, uchar msb, uint32 time) const; 89 90 void SpraySystemExclusive( 91 void* data, size_t length, uint32 time = B_NOW) const; 92 93 void SpraySystemCommon( 94 uchar status, uchar data1, uchar data2, uint32 time) const; 95 96 void SpraySystemRealTime(uchar status, uint32 time) const; 97 98 void SprayTempoChange(int32 beatsPerMinute, uint32 time) const; 99 100 bool KeepRunning(); 101 102 private: 103 104 friend status_t _run_thread(void* data); 105 106 virtual void _ReservedMidi1(); 107 virtual void _ReservedMidi2(); 108 virtual void _ReservedMidi3(); 109 110 virtual void Run(); 111 112 BMidiLocalProducer* fProducer; 113 BMidiLocalConsumer* fConsumer; 114 115 BList* fConnections; 116 volatile thread_id fThreadId; 117 volatile bool fIsRunning; 118 119 uint32 _reserved2[5]; 120 }; 121 122 #endif // _MIDI_H 123