some midi2 headers
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1613 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
|
||||
#ifndef _MIDI2_DEFS_H
|
||||
#define _MIDI2_DEFS_H
|
||||
|
||||
#include <OS.h>
|
||||
#include <Errors.h>
|
||||
|
||||
#ifndef _MIDI_CONSTANTS_
|
||||
#define _MIDI_CONSTANTS_
|
||||
|
||||
/* Channel Message Masks*/
|
||||
const uchar B_NOTE_OFF = 0x80;
|
||||
const uchar B_NOTE_ON = 0x90;
|
||||
const uchar B_KEY_PRESSURE = 0xa0;
|
||||
const uchar B_CONTROL_CHANGE = 0xb0;
|
||||
const uchar B_PROGRAM_CHANGE = 0xc0;
|
||||
const uchar B_CHANNEL_PRESSURE = 0xd0;
|
||||
const uchar B_PITCH_BEND = 0xe0;
|
||||
|
||||
/* System Messages*/
|
||||
const uchar B_SYS_EX_START = 0xf0;
|
||||
const uchar B_MIDI_TIME_CODE = 0xf1;
|
||||
const uchar B_SONG_POSITION = 0xf2;
|
||||
const uchar B_SONG_SELECT = 0xf3;
|
||||
const uchar B_CABLE_MESSAGE = 0xf5;
|
||||
const uchar B_TUNE_REQUEST = 0xf6;
|
||||
const uchar B_SYS_EX_END = 0xf7;
|
||||
const uchar B_TIMING_CLOCK = 0xf8;
|
||||
const uchar B_START = 0xfa;
|
||||
const uchar B_CONTINUE = 0xfb;
|
||||
const uchar B_STOP = 0xfc;
|
||||
const uchar B_ACTIVE_SENSING = 0xfe;
|
||||
const uchar B_SYSTEM_RESET = 0xff;
|
||||
|
||||
/* Controller Numbers*/
|
||||
const uchar B_MODULATION = 0x01;
|
||||
const uchar B_BREATH_CONTROLLER = 0x02;
|
||||
const uchar B_FOOT_CONTROLLER = 0x04;
|
||||
const uchar B_PORTAMENTO_TIME = 0x05;
|
||||
const uchar B_DATA_ENTRY = 0x06;
|
||||
const uchar B_MAIN_VOLUME = 0x07;
|
||||
const uchar B_MIDI_BALANCE = 0x08; /* used to be B_BALANCE */
|
||||
const uchar B_PAN = 0x0a;
|
||||
const uchar B_EXPRESSION_CTRL = 0x0b;
|
||||
const uchar B_GENERAL_CTRL_1 = 0x10;
|
||||
const uchar B_GENERAL_CTRL_2 = 0x11;
|
||||
const uchar B_GENERAL_CTRL_3 = 0x12;
|
||||
const uchar B_GENERAL_CTRL_4 = 0x13;
|
||||
const uchar B_SUSTAIN_PEDAL = 0x40;
|
||||
const uchar B_PORTAMENTO = 0x41;
|
||||
const uchar B_SOSTENUTO = 0x42;
|
||||
const uchar B_SOFT_PEDAL = 0x43;
|
||||
const uchar B_HOLD_2 = 0x45;
|
||||
const uchar B_GENERAL_CTRL_5 = 0x50;
|
||||
const uchar B_GENERAL_CTRL_6 = 0x51;
|
||||
const uchar B_GENERAL_CTRL_7 = 0x52;
|
||||
const uchar B_GENERAL_CTRL_8 = 0x53;
|
||||
const uchar B_EFFECTS_DEPTH = 0x5b;
|
||||
const uchar B_TREMOLO_DEPTH = 0x5c;
|
||||
const uchar B_CHORUS_DEPTH = 0x5d;
|
||||
const uchar B_CELESTE_DEPTH = 0x5e;
|
||||
const uchar B_PHASER_DEPTH = 0x5f;
|
||||
const uchar B_DATA_INCREMENT = 0x60;
|
||||
const uchar B_DATA_DECREMENT = 0x61;
|
||||
const uchar B_RESET_ALL_CONTROLLERS = 0x79;
|
||||
const uchar B_LOCAL_CONTROL = 0x7a;
|
||||
const uchar B_ALL_NOTES_OFF = 0x7b;
|
||||
const uchar B_OMNI_MODE_OFF = 0x7c;
|
||||
const uchar B_OMNI_MODE_ON = 0x7d;
|
||||
const uchar B_MONO_MODE_ON = 0x7e;
|
||||
const uchar B_POLY_MODE_ON = 0x7f;
|
||||
|
||||
const uchar B_TEMPO_CHANGE = 0x51;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,99 @@
|
||||
#ifndef _MIDI_SINK_H
|
||||
#define _MIDI_SINK_H
|
||||
|
||||
#include <MidiEndpoint.h>
|
||||
|
||||
class BMidiDispatcher;
|
||||
|
||||
class BMidiConsumer : public BMidiEndpoint
|
||||
{
|
||||
public:
|
||||
bigtime_t Latency() const;
|
||||
|
||||
private:
|
||||
friend class BMidiLocalConsumer;
|
||||
friend class BMidiLocalProducer;
|
||||
friend class BMidiRoster;
|
||||
|
||||
BMidiConsumer(const char *name = NULL);
|
||||
virtual ~BMidiConsumer();
|
||||
|
||||
virtual void _Reserved1();
|
||||
virtual void _Reserved2();
|
||||
virtual void _Reserved3();
|
||||
virtual void _Reserved4();
|
||||
virtual void _Reserved5();
|
||||
virtual void _Reserved6();
|
||||
virtual void _Reserved7();
|
||||
virtual void _Reserved8();
|
||||
|
||||
port_id fEventPort;
|
||||
bigtime_t fLatency;
|
||||
|
||||
uint32 _reserved[2];
|
||||
};
|
||||
|
||||
class BMidiLocalConsumer : public BMidiConsumer
|
||||
{
|
||||
public:
|
||||
BMidiLocalConsumer(const char *name = NULL);
|
||||
|
||||
void SetLatency(bigtime_t latency);
|
||||
|
||||
void SetTimeout(bigtime_t when, void *data);
|
||||
virtual void Timeout(void *data);
|
||||
|
||||
virtual void Data(uchar *data, size_t length, bool atomic,
|
||||
bigtime_t time);
|
||||
// Raw Midi data has been received.
|
||||
// The default implementation calls one of the virtuals below:
|
||||
|
||||
virtual void NoteOff(uchar channel, uchar note, uchar velocity,
|
||||
bigtime_t time);
|
||||
virtual void NoteOn(uchar channel, uchar note, uchar velocity,
|
||||
bigtime_t time);
|
||||
virtual void KeyPressure(uchar channel, uchar note, uchar pressure,
|
||||
bigtime_t time);
|
||||
virtual void ControlChange(uchar channel, uchar controlNumber,
|
||||
uchar controlValue,
|
||||
bigtime_t time);
|
||||
virtual void ProgramChange(uchar channel, uchar programNumber,
|
||||
bigtime_t time);
|
||||
virtual void ChannelPressure(uchar channel, uchar pressure,
|
||||
bigtime_t time);
|
||||
virtual void PitchBend(uchar channel, uchar lsb, uchar msb,
|
||||
bigtime_t time);
|
||||
virtual void SystemExclusive(void* data, size_t dataLength,
|
||||
bigtime_t time);
|
||||
virtual void SystemCommon(uchar statusByte, uchar data1, uchar data2,
|
||||
bigtime_t time);
|
||||
virtual void SystemRealTime(uchar statusByte,
|
||||
bigtime_t time);
|
||||
virtual void TempoChange(int32 bpm,
|
||||
bigtime_t time);
|
||||
virtual void AllNotesOff(bool justChannel,
|
||||
bigtime_t time);
|
||||
protected:
|
||||
~BMidiLocalConsumer();
|
||||
|
||||
private:
|
||||
|
||||
friend class BMidiRoster;
|
||||
|
||||
virtual void _Reserved1();
|
||||
virtual void _Reserved2();
|
||||
virtual void _Reserved3();
|
||||
virtual void _Reserved4();
|
||||
virtual void _Reserved5();
|
||||
virtual void _Reserved6();
|
||||
virtual void _Reserved7();
|
||||
virtual void _Reserved8();
|
||||
|
||||
BMidiDispatcher *fDispatcher;
|
||||
bigtime_t fTimeout;
|
||||
void *fTimeoutData;
|
||||
|
||||
uint32 _reserved[2];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
#ifndef _MIDI_ENDPOINT_H
|
||||
#define _MIDI_ENDPOINT_H
|
||||
|
||||
#ifndef _BE_BUILD_H
|
||||
#include <BeBuild.h>
|
||||
#endif
|
||||
#include <Midi2Defs.h>
|
||||
#include <OS.h>
|
||||
|
||||
#include <String.h>
|
||||
|
||||
class BMidiList;
|
||||
class BList;
|
||||
|
||||
class BMidiProducer;
|
||||
class BMidiConsumer;
|
||||
|
||||
class BMidiList;
|
||||
|
||||
// dynamic_cast<BMidiProducer*> (ptr_to_endpoint)
|
||||
|
||||
class BMidiEndpoint
|
||||
{
|
||||
public:
|
||||
const char *Name() const;
|
||||
void SetName(const char *name);
|
||||
|
||||
int32 ID() const;
|
||||
|
||||
bool IsProducer() const;
|
||||
bool IsConsumer() const;
|
||||
bool IsRemote() const;
|
||||
bool IsLocal() const;
|
||||
bool IsPersistent() const;
|
||||
bool IsValid() const;
|
||||
|
||||
status_t Release();
|
||||
status_t Acquire();
|
||||
|
||||
status_t SetProperties(const BMessage *props);
|
||||
status_t GetProperties(BMessage *props) const;
|
||||
|
||||
status_t Register(void);
|
||||
status_t Unregister(void);
|
||||
|
||||
private:
|
||||
friend class BMidiRoster;
|
||||
friend class BMidiProducer;
|
||||
friend class BMidiConsumer;
|
||||
friend class BMidiLocalProducer;
|
||||
friend class BMidiLocalConsumer;
|
||||
friend class BMidiList;
|
||||
|
||||
BMidiEndpoint(const char *name);
|
||||
virtual ~BMidiEndpoint();
|
||||
BMidiEndpoint(const BMidiEndpoint &) {}
|
||||
BMidiEndpoint& operator=(const BMidiEndpoint &) { return *this; }
|
||||
|
||||
virtual void _Reserved1();
|
||||
virtual void _Reserved2();
|
||||
virtual void _Reserved3();
|
||||
virtual void _Reserved4();
|
||||
virtual void _Reserved5();
|
||||
virtual void _Reserved6();
|
||||
virtual void _Reserved7();
|
||||
virtual void _Reserved8();
|
||||
|
||||
int32 fID;
|
||||
BString fName;
|
||||
status_t fStatus;
|
||||
|
||||
int32 fFlags;
|
||||
int32 fRefCount;
|
||||
|
||||
uint32 _reserved[4];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,93 @@
|
||||
#ifndef _MIDI_SOURCE_H
|
||||
#define _MIDI_SOURCE_H
|
||||
|
||||
#include <Locker.h>
|
||||
#include <MidiEndpoint.h>
|
||||
|
||||
class BMidiEvent;
|
||||
|
||||
class BMidiProducer : public BMidiEndpoint
|
||||
{
|
||||
public:
|
||||
status_t Connect(BMidiConsumer *toObject);
|
||||
status_t Disconnect(BMidiConsumer *toObject);
|
||||
bool IsConnected(BMidiConsumer *toObject) const;
|
||||
BList* Connections() const;
|
||||
|
||||
private:
|
||||
friend class BMidiLocalProducer;
|
||||
friend class BMidiRoster;
|
||||
|
||||
BMidiProducer(const char *name = NULL);
|
||||
virtual ~BMidiProducer();
|
||||
|
||||
virtual void _Reserved1();
|
||||
virtual void _Reserved2();
|
||||
virtual void _Reserved3();
|
||||
virtual void _Reserved4();
|
||||
virtual void _Reserved5();
|
||||
virtual void _Reserved6();
|
||||
virtual void _Reserved7();
|
||||
virtual void _Reserved8();
|
||||
|
||||
BMidiList *fConnections;
|
||||
mutable BLocker fLock;
|
||||
|
||||
int fConnectionCount;
|
||||
uint32 _reserved[1];
|
||||
};
|
||||
|
||||
class BMidiLocalProducer : public BMidiProducer
|
||||
{
|
||||
public:
|
||||
BMidiLocalProducer(const char *name = NULL);
|
||||
|
||||
virtual void Connected(BMidiConsumer *dest);
|
||||
virtual void Disconnected(BMidiConsumer *dest);
|
||||
|
||||
// Spray some MIDI data downstream to the targets of this object
|
||||
void SprayData(void *data, size_t length,
|
||||
bool atomic = false, bigtime_t time = 0) const;
|
||||
|
||||
void SprayNoteOff(uchar channel, uchar note, uchar velocity,
|
||||
bigtime_t time = 0) const;
|
||||
void SprayNoteOn(uchar channel, uchar note, uchar velocity,
|
||||
bigtime_t time = 0) const;
|
||||
void SprayKeyPressure(uchar channel, uchar note, uchar pressure,
|
||||
bigtime_t time = 0) const;
|
||||
void SprayControlChange(uchar channel, uchar controlNumber,
|
||||
uchar controlValue, bigtime_t time = 0) const;
|
||||
void SprayProgramChange(uchar channel, uchar programNumber,
|
||||
bigtime_t time = 0) const;
|
||||
void SprayChannelPressure(uchar channel, uchar pressure,
|
||||
bigtime_t time = 0) const;
|
||||
void SprayPitchBend(uchar channel, uchar lsb, uchar msb,
|
||||
bigtime_t time = 0) const;
|
||||
void SpraySystemExclusive(void* data, size_t dataLength,
|
||||
bigtime_t time = 0) const;
|
||||
void SpraySystemCommon(uchar statusByte, uchar data1, uchar data2,
|
||||
bigtime_t time = 0) const;
|
||||
void SpraySystemRealTime(uchar statusByte,
|
||||
bigtime_t time = 0) const;
|
||||
void SprayTempoChange(int32 bpm,
|
||||
bigtime_t time = 0) const;
|
||||
|
||||
protected:
|
||||
~BMidiLocalProducer();
|
||||
|
||||
private:
|
||||
void SprayEvent(BMidiEvent *event, size_t length) const;
|
||||
|
||||
virtual void _Reserved1();
|
||||
virtual void _Reserved2();
|
||||
virtual void _Reserved3();
|
||||
virtual void _Reserved4();
|
||||
virtual void _Reserved5();
|
||||
virtual void _Reserved6();
|
||||
virtual void _Reserved7();
|
||||
virtual void _Reserved8();
|
||||
|
||||
uint32 _reserved[2];
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user