2002-11-01 19:11:03 +03:00
|
|
|
#ifndef _MIDI_H
|
|
|
|
#define _MIDI_H
|
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
#ifndef _BE_BUILD_H
|
2002-11-01 19:11:03 +03:00
|
|
|
#include <BeBuild.h>
|
2002-11-21 22:23:22 +03:00
|
|
|
#endif
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <MidiDefs.h>
|
|
|
|
#include <OS.h>
|
|
|
|
|
|
|
|
class BMidiEvent;
|
|
|
|
class BList;
|
|
|
|
|
2002-11-01 19:11:03 +03:00
|
|
|
class BMidi
|
|
|
|
{
|
2002-07-09 16:24:59 +04:00
|
|
|
public:
|
2002-11-21 22:23:22 +03:00
|
|
|
BMidi();
|
|
|
|
virtual ~BMidi();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void NoteOff(uchar channel,
|
|
|
|
uchar note,
|
|
|
|
uchar velocity,
|
|
|
|
uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void NoteOn(uchar channel,
|
|
|
|
uchar note,
|
|
|
|
uchar velocity,
|
|
|
|
uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void KeyPressure(uchar channel,
|
|
|
|
uchar note,
|
|
|
|
uchar pressure,
|
|
|
|
uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void ControlChange(uchar channel,
|
|
|
|
uchar controlNumber,
|
|
|
|
uchar controlValue,
|
|
|
|
uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void ProgramChange(uchar channel,
|
|
|
|
uchar programNumber,
|
|
|
|
uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void ChannelPressure(uchar channel,
|
|
|
|
uchar pressure,
|
|
|
|
uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void PitchBend(uchar channel,
|
|
|
|
uchar lsb,
|
|
|
|
uchar msb,
|
|
|
|
uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void SystemExclusive(void* data,
|
|
|
|
size_t dataLength,
|
|
|
|
uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void SystemCommon(uchar statusByte,
|
|
|
|
uchar data1,
|
|
|
|
uchar data2,
|
|
|
|
uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void SystemRealTime(uchar statusByte, uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void TempoChange(int32 bpm, uint32 time = B_NOW);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual status_t Start();
|
|
|
|
virtual void Stop();
|
|
|
|
bool IsRunning() const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void Connect(BMidi* toObject);
|
|
|
|
void Disconnect(BMidi* fromObject);
|
|
|
|
bool IsConnected(BMidi* toObject) const;
|
|
|
|
BList* Connections() const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SnoozeUntil(uint32 time) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
protected:
|
2002-11-21 22:23:22 +03:00
|
|
|
void SprayNoteOff(uchar channel,
|
|
|
|
uchar note,
|
|
|
|
uchar velocity,
|
|
|
|
uint32 time) const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SprayNoteOn(uchar channel,
|
|
|
|
uchar note,
|
|
|
|
uchar velocity,
|
|
|
|
uint32 time) const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SprayKeyPressure(uchar channel,
|
|
|
|
uchar note,
|
|
|
|
uchar pressure,
|
|
|
|
uint32 time) const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SprayControlChange(uchar channel,
|
|
|
|
uchar controlNumber,
|
|
|
|
uchar controlValue,
|
|
|
|
uint32 time) const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SprayProgramChange(uchar channel,
|
|
|
|
uchar programNumber,
|
|
|
|
uint32 time) const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SprayChannelPressure(uchar channel,
|
|
|
|
uchar pressure,
|
|
|
|
uint32 time) const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SprayPitchBend(uchar channel,
|
|
|
|
uchar lsb,
|
|
|
|
uchar msb,
|
|
|
|
uint32 time) const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SpraySystemExclusive(void* data,
|
|
|
|
size_t dataLength,
|
|
|
|
uint32 time = B_NOW) const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SpraySystemCommon(uchar statusByte,
|
|
|
|
uchar data1,
|
|
|
|
uchar data2,
|
|
|
|
uint32 time) const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SpraySystemRealTime(uchar statusByte, uint32 time) const;
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SprayTempoChange(int32 bpm, uint32 time) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
bool KeepRunning();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
private:
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
friend class BMidiPort; /* for debugging */
|
|
|
|
friend class BMidiStore; /* for debugging */
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void _ReservedMidi1();
|
|
|
|
virtual void _ReservedMidi2();
|
|
|
|
virtual void _ReservedMidi3();
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
friend status_t _run_thread_(void *arg);
|
|
|
|
friend status_t _inflow_task_(void *arg);
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
void SprayMidiEvent(BMidiEvent* event) const;
|
|
|
|
port_id ID() const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
virtual void Run();
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
status_t StartInflow();
|
|
|
|
void StopInflow();
|
|
|
|
bool IsInflowing();
|
|
|
|
void InflowTask();
|
|
|
|
bool InflowIsAlive();
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
BList* fConnectionList;
|
|
|
|
volatile thread_id fRunTask;
|
|
|
|
volatile bool fIsRunning;
|
|
|
|
volatile thread_id fInflowTask;
|
|
|
|
volatile bool fInflowAlive;
|
|
|
|
port_id fInflowPort;
|
|
|
|
uint32 _reserved[4];
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2002-11-01 19:11:03 +03:00
|
|
|
|
2002-11-21 22:23:22 +03:00
|
|
|
|
|
|
|
#endif
|