cleaned up midi1
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2932 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d89d006239
commit
38c7401ebe
@ -1,161 +1,123 @@
|
||||
|
||||
#ifndef _MIDI_H
|
||||
#define _MIDI_H
|
||||
|
||||
#ifndef _BE_BUILD_H
|
||||
#include <BeBuild.h>
|
||||
#endif
|
||||
#include <MidiDefs.h>
|
||||
#include <OS.h>
|
||||
|
||||
class BMidiEvent;
|
||||
class BList;
|
||||
class BMidiLocalProducer;
|
||||
class BMidiLocalConsumer;
|
||||
|
||||
class BMidi
|
||||
{
|
||||
public:
|
||||
BMidi();
|
||||
virtual ~BMidi();
|
||||
|
||||
virtual void NoteOff(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW);
|
||||
BMidi();
|
||||
virtual ~BMidi();
|
||||
|
||||
virtual void NoteOn(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW);
|
||||
virtual void NoteOff(
|
||||
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
|
||||
|
||||
virtual void KeyPressure(uchar channel,
|
||||
uchar note,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW);
|
||||
virtual void NoteOn(
|
||||
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
|
||||
|
||||
virtual void ControlChange(uchar channel,
|
||||
uchar controlNumber,
|
||||
uchar controlValue,
|
||||
uint32 time = B_NOW);
|
||||
virtual void KeyPressure(
|
||||
uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
|
||||
|
||||
virtual void ProgramChange(uchar channel,
|
||||
uchar programNumber,
|
||||
uint32 time = B_NOW);
|
||||
virtual void ControlChange(
|
||||
uchar channel, uchar controlNumber, uchar controlValue,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ChannelPressure(uchar channel,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW);
|
||||
virtual void ProgramChange(
|
||||
uchar channel, uchar programNumber, uint32 time = B_NOW);
|
||||
|
||||
virtual void ChannelPressure(
|
||||
uchar channel, uchar pressure, uint32 time = B_NOW);
|
||||
|
||||
virtual void PitchBend(uchar channel,
|
||||
uchar lsb,
|
||||
uchar msb,
|
||||
uint32 time = B_NOW);
|
||||
virtual void PitchBend(
|
||||
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemExclusive(void* data,
|
||||
size_t dataLength,
|
||||
uint32 time = B_NOW);
|
||||
virtual void SystemExclusive(
|
||||
void* data, size_t length, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemCommon(uchar statusByte,
|
||||
uchar data1,
|
||||
uchar data2,
|
||||
uint32 time = B_NOW);
|
||||
virtual void SystemCommon(
|
||||
uchar status, uchar data1, uchar data2, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemRealTime(uchar statusByte, uint32 time = B_NOW);
|
||||
virtual void SystemRealTime(uchar status, uint32 time = B_NOW);
|
||||
|
||||
virtual void TempoChange(int32 bpm, uint32 time = B_NOW);
|
||||
virtual void TempoChange(int32 beatsPerMinute, uint32 time = B_NOW);
|
||||
|
||||
virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW);
|
||||
virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW);
|
||||
|
||||
virtual status_t Start();
|
||||
virtual void Stop();
|
||||
bool IsRunning() const;
|
||||
|
||||
void Connect(BMidi* toObject);
|
||||
void Disconnect(BMidi* fromObject);
|
||||
bool IsConnected(BMidi* toObject) const;
|
||||
BList* Connections() const;
|
||||
virtual status_t Start();
|
||||
virtual void Stop();
|
||||
|
||||
void SnoozeUntil(uint32 time) const;
|
||||
bool IsRunning() const;
|
||||
|
||||
void Connect(BMidi* toObject);
|
||||
void Disconnect(BMidi* fromObject);
|
||||
bool IsConnected(BMidi* toObject) const;
|
||||
BList* Connections() const;
|
||||
|
||||
void SnoozeUntil(uint32 time) const;
|
||||
|
||||
protected:
|
||||
void SprayNoteOff(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time) const;
|
||||
|
||||
void SprayNoteOn(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time) const;
|
||||
void SprayNoteOff(
|
||||
uchar channel, uchar note, uchar velocity, uint32 time) const;
|
||||
|
||||
void SprayKeyPressure(uchar channel,
|
||||
uchar note,
|
||||
uchar pressure,
|
||||
uint32 time) const;
|
||||
void SprayNoteOn(
|
||||
uchar channel, uchar note, uchar velocity, uint32 time) const;
|
||||
|
||||
void SprayControlChange(uchar channel,
|
||||
uchar controlNumber,
|
||||
uchar controlValue,
|
||||
uint32 time) const;
|
||||
void SprayKeyPressure(
|
||||
uchar channel, uchar note, uchar pressure, uint32 time) const;
|
||||
|
||||
void SprayProgramChange(uchar channel,
|
||||
uchar programNumber,
|
||||
uint32 time) const;
|
||||
void SprayControlChange(
|
||||
uchar channel, uchar controlNumber, uchar controlValue,
|
||||
uint32 time) const;
|
||||
|
||||
void SprayChannelPressure(uchar channel,
|
||||
uchar pressure,
|
||||
uint32 time) const;
|
||||
void SprayProgramChange(
|
||||
uchar channel, uchar programNumber, uint32 time) const;
|
||||
|
||||
void SprayPitchBend(uchar channel,
|
||||
uchar lsb,
|
||||
uchar msb,
|
||||
uint32 time) const;
|
||||
void SprayChannelPressure(
|
||||
uchar channel, uchar pressure, uint32 time) const;
|
||||
|
||||
void SpraySystemExclusive(void* data,
|
||||
size_t dataLength,
|
||||
uint32 time = B_NOW) const;
|
||||
void SprayPitchBend(
|
||||
uchar channel, uchar lsb, uchar msb, uint32 time) const;
|
||||
|
||||
void SpraySystemCommon(uchar statusByte,
|
||||
uchar data1,
|
||||
uchar data2,
|
||||
uint32 time) const;
|
||||
void SpraySystemExclusive(
|
||||
void* data, size_t length, uint32 time = B_NOW) const;
|
||||
|
||||
void SpraySystemRealTime(uchar statusByte, uint32 time) const;
|
||||
void SpraySystemCommon(
|
||||
uchar status, uchar data1, uchar data2, uint32 time) const;
|
||||
|
||||
void SprayTempoChange(int32 bpm, uint32 time) const;
|
||||
void SpraySystemRealTime(uchar status, uint32 time) const;
|
||||
|
||||
bool KeepRunning();
|
||||
void SprayTempoChange(int32 beatsPerMinute, uint32 time) const;
|
||||
|
||||
bool KeepRunning();
|
||||
|
||||
private:
|
||||
|
||||
friend class BMidiPort; /* for debugging */
|
||||
friend class BMidiStore; /* for debugging */
|
||||
friend status_t _run_thread(void* data);
|
||||
|
||||
virtual void _ReservedMidi1();
|
||||
virtual void _ReservedMidi2();
|
||||
virtual void _ReservedMidi3();
|
||||
virtual void _ReservedMidi1();
|
||||
virtual void _ReservedMidi2();
|
||||
virtual void _ReservedMidi3();
|
||||
|
||||
friend status_t _run_thread_(void *arg);
|
||||
friend status_t _inflow_task_(void *arg);
|
||||
virtual void Run();
|
||||
|
||||
void SprayMidiEvent(BMidiEvent* event) const;
|
||||
port_id ID() const;
|
||||
BMidiLocalProducer* producer;
|
||||
BMidiLocalConsumer* consumer;
|
||||
|
||||
virtual void Run();
|
||||
BList* connections;
|
||||
volatile thread_id threadId;
|
||||
volatile bool isRunning;
|
||||
|
||||
status_t StartInflow();
|
||||
void StopInflow();
|
||||
bool IsInflowing();
|
||||
void InflowTask();
|
||||
bool InflowIsAlive();
|
||||
|
||||
BList* fConnectionList;
|
||||
volatile thread_id fRunTask;
|
||||
volatile bool fIsRunning;
|
||||
volatile thread_id fInflowTask;
|
||||
volatile bool fInflowAlive;
|
||||
port_id fInflowPort;
|
||||
uint32 _reserved[4];
|
||||
uint8 _reserved1[3];
|
||||
uint32 _reserved2[5];
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif // _MIDI_H
|
||||
|
@ -8,7 +8,6 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/* System time converted to int milliseconds */
|
||||
|
||||
#define B_NOW ((uint32)(system_time()/1000))
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -301,4 +300,3 @@ typedef enum midi_axe
|
||||
midi_axe;
|
||||
|
||||
#endif // _MIDI_DEFS_H
|
||||
|
||||
|
@ -4,12 +4,10 @@
|
||||
|
||||
#include <Midi.h>
|
||||
|
||||
class BMidiLocalProducer;
|
||||
class BMidiPortConsumer;
|
||||
|
||||
class BMidiPort : public BMidi
|
||||
{
|
||||
public:
|
||||
|
||||
BMidiPort(const char* name = NULL);
|
||||
~BMidiPort();
|
||||
|
||||
@ -42,7 +40,7 @@ public:
|
||||
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemExclusive(
|
||||
void* data, size_t dataLength, uint32 time = B_NOW);
|
||||
void* data, size_t length, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemCommon(
|
||||
uchar status, uchar data0, uchar data2, uint32 time = B_NOW);
|
||||
@ -58,38 +56,30 @@ public:
|
||||
int32 n, char* name, size_t bufSize = B_OS_NAME_LENGTH);
|
||||
|
||||
private:
|
||||
typedef BMidi _inherited;
|
||||
|
||||
typedef BMidi super;
|
||||
|
||||
friend class BMidiPortGlue;
|
||||
|
||||
virtual void _ReservedMidiPort1();
|
||||
virtual void _ReservedMidiPort2();
|
||||
virtual void _ReservedMidiPort3();
|
||||
|
||||
virtual void Run();
|
||||
friend class BMidiPortConsumer;
|
||||
|
||||
//Can I do that?
|
||||
// void Dispatch(
|
||||
// const unsigned char* buffer, size_t size, bigtime_t when);
|
||||
|
||||
// ssize_t Read(void* buffer, size_t numBytes) const;
|
||||
// ssize_t Write(void* buffer, size_t numBytes, uint32 time) const;
|
||||
|
||||
void ScanDevices();
|
||||
void EmptyDeviceList();
|
||||
|
||||
// used to glue us to the new midi kit
|
||||
BMidiProducer* remote_source;
|
||||
BMidiConsumer* remote_sink;
|
||||
BMidiLocalProducer* local_source;
|
||||
BMidiPortConsumer* local_sink;
|
||||
BMidiLocalProducer* localSource;
|
||||
BMidiLocalConsumer* localSink;
|
||||
BMidiProducer* remoteSource;
|
||||
BMidiConsumer* remoteSink;
|
||||
|
||||
char* fName;
|
||||
status_t fCStatus;
|
||||
BList* _fDevices;
|
||||
// uint8 _m_prev_cmd;
|
||||
// bool _m_enhanced;
|
||||
// uint8 _m_reserved[2];
|
||||
uint8 _reserved[4];
|
||||
char* portName;
|
||||
status_t status;
|
||||
BList* devices;
|
||||
|
||||
uint32 _reserved[1];
|
||||
};
|
||||
|
||||
#endif // _MIDI_PORT_H
|
||||
|
||||
|
@ -1,178 +1,123 @@
|
||||
|
||||
#ifndef _MIDI_STORE_H
|
||||
#define _MIDI_STORE_H
|
||||
|
||||
#ifndef _BE_BUILD_H
|
||||
#include <BeBuild.h>
|
||||
#endif
|
||||
#include <Midi.h>
|
||||
|
||||
struct entry_ref;
|
||||
|
||||
class BMidiEvent;
|
||||
class BFile;
|
||||
class BList;
|
||||
class BMidiEvent;
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
|
||||
class BMidiStore : public BMidi {
|
||||
class BMidiStore : public BMidi
|
||||
{
|
||||
public:
|
||||
BMidiStore();
|
||||
virtual ~BMidiStore();
|
||||
|
||||
virtual void NoteOff(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW);
|
||||
BMidiStore();
|
||||
virtual ~BMidiStore();
|
||||
|
||||
virtual void NoteOn(uchar channel,
|
||||
uchar note,
|
||||
uchar velocity,
|
||||
uint32 time = B_NOW);
|
||||
virtual void NoteOff(
|
||||
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
|
||||
|
||||
virtual void KeyPressure(uchar channel,
|
||||
uchar note,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW);
|
||||
virtual void NoteOn(
|
||||
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
|
||||
|
||||
virtual void ControlChange(uchar channel,
|
||||
uchar controlNumber,
|
||||
uchar controlValue,
|
||||
uint32 time = B_NOW);
|
||||
virtual void KeyPressure(
|
||||
uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
|
||||
|
||||
virtual void ProgramChange(uchar channel,
|
||||
uchar programNumber,
|
||||
uint32 time = B_NOW);
|
||||
virtual void ControlChange(
|
||||
uchar channel, uchar controlNumber, uchar controlValue,
|
||||
uint32 time = B_NOW);
|
||||
|
||||
virtual void ChannelPressure(uchar channel,
|
||||
uchar pressure,
|
||||
uint32 time = B_NOW);
|
||||
virtual void ProgramChange(
|
||||
uchar channel, uchar programNumber, uint32 time = B_NOW);
|
||||
|
||||
virtual void PitchBend(uchar channel,
|
||||
uchar lsb,
|
||||
uchar msb,
|
||||
uint32 time = B_NOW);
|
||||
virtual void ChannelPressure(
|
||||
uchar channel, uchar pressure, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemExclusive(void* data,
|
||||
size_t dataLength,
|
||||
uint32 time = B_NOW);
|
||||
virtual void PitchBend(
|
||||
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemCommon(uchar statusByte,
|
||||
uchar data1,
|
||||
uchar data2,
|
||||
uint32 time = B_NOW);
|
||||
virtual void SystemExclusive(
|
||||
void* data, size_t length, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemRealTime(uchar statusByte, uint32 time = B_NOW);
|
||||
virtual void SystemCommon(
|
||||
uchar status, uchar data1, uchar data2, uint32 time = B_NOW);
|
||||
|
||||
virtual void TempoChange(int32 bpm, uint32 time = B_NOW);
|
||||
virtual void SystemRealTime(uchar status, uint32 time = B_NOW);
|
||||
|
||||
status_t Import(const entry_ref *ref);
|
||||
status_t Export(const entry_ref *ref, int32 format);
|
||||
virtual void TempoChange(int32 beatsPerMinute, uint32 time = B_NOW);
|
||||
|
||||
void SortEvents(bool force=false);
|
||||
uint32 CountEvents() const;
|
||||
status_t Import(const entry_ref* ref);
|
||||
status_t Export(const entry_ref* ref, int32 format);
|
||||
|
||||
uint32 CurrentEvent() const;
|
||||
void SetCurrentEvent(uint32 eventNumber);
|
||||
void SortEvents(bool force = false);
|
||||
uint32 CountEvents() const;
|
||||
|
||||
uint32 DeltaOfEvent(uint32 eventNumber) const;
|
||||
uint32 EventAtDelta(uint32 time) const;
|
||||
uint32 CurrentEvent() const;
|
||||
void SetCurrentEvent(uint32 eventNumber);
|
||||
|
||||
uint32 BeginTime() const;
|
||||
|
||||
void SetTempo(int32 bpm);
|
||||
int32 Tempo() const;
|
||||
uint32 DeltaOfEvent(uint32 eventNumber) const;
|
||||
uint32 EventAtDelta(uint32 time) const;
|
||||
|
||||
uint32 BeginTime() const;
|
||||
|
||||
void SetTempo(int32 beatsPerMinute);
|
||||
int32 Tempo() const;
|
||||
|
||||
private:
|
||||
|
||||
virtual void _ReservedMidiStore1();
|
||||
virtual void _ReservedMidiStore2();
|
||||
virtual void _ReservedMidiStore3();
|
||||
virtual void _ReservedMidiStore1();
|
||||
virtual void _ReservedMidiStore2();
|
||||
virtual void _ReservedMidiStore3();
|
||||
|
||||
virtual void Run();
|
||||
virtual void Run();
|
||||
|
||||
void AddEvent(uint32 time,
|
||||
bool inMS,
|
||||
uchar type,
|
||||
uchar data1 = 0,
|
||||
uchar data2 = 0,
|
||||
uchar data3 = 0,
|
||||
uchar data4 = 0);
|
||||
void AddEvent(BMidiEvent* event);
|
||||
void SprayEvent(const BMidiEvent* event, uint32 time);
|
||||
BMidiEvent* EventAt(int32 index) const;
|
||||
uint32 GetEventTime(const BMidiEvent* event) const;
|
||||
uint32 TicksToMilliseconds(uint32 ticks) const;
|
||||
uint32 MillisecondsToTicks(uint32 ms) const;
|
||||
|
||||
void AddSystemExclusive(void* data, size_t dataLength);
|
||||
|
||||
status_t ReadHeader();
|
||||
bool ReadMT(char*);
|
||||
int32 Read32Bit();
|
||||
int32 EGetC();
|
||||
int32 To32Bit(int32, int32, int32, int32);
|
||||
int32 Read16Bit();
|
||||
int32 To16Bit(int32, int32);
|
||||
bool ReadTrack();
|
||||
int32 ReadVariNum();
|
||||
void ChannelMessage(int32, int32, int32);
|
||||
void MsgInit();
|
||||
void MsgAdd(int32);
|
||||
void BiggerMsg();
|
||||
void MetaEvent(int32);
|
||||
int32 MsgLength();
|
||||
uchar* Msg();
|
||||
void BadByte(int32);
|
||||
|
||||
int32 PutC(int32 c);
|
||||
bool WriteTrack(int32 track);
|
||||
void WriteTempoTrack();
|
||||
bool WriteTrackChunk(int32 whichTrack);
|
||||
void WriteHeaderChunk(int32 format);
|
||||
bool WriteMidiEvent(uint32 deltaTime,
|
||||
uint32 type,
|
||||
uint32 channel,
|
||||
uchar* data,
|
||||
uint32 size);
|
||||
bool WriteMetaEvent(uint32 deltaTime,
|
||||
uint32 type,
|
||||
uchar* data,
|
||||
uint32 size);
|
||||
bool WriteSystemExclusiveEvent(uint32 deltaTime,
|
||||
uchar* data,
|
||||
uint32 size);
|
||||
void WriteTempo(uint32 deltaTime, int32 tempo);
|
||||
void WriteVarLen(uint32 value);
|
||||
void Write32Bit(uint32 data);
|
||||
void Write16Bit(ushort data);
|
||||
int32 EPutC(uchar c);
|
||||
|
||||
uint32 TicksToMilliseconds(uint32 ticks) const;
|
||||
uint32 MillisecondsToTicks(uint32 ms) const;
|
||||
BList* events;
|
||||
int32 currentEvent;
|
||||
uint32 startTime;
|
||||
int32 beatsPerMinute;
|
||||
int16 ticksPerBeat;
|
||||
bool needsSorting;
|
||||
|
||||
BList *events;
|
||||
// uint32 fNumEvents;
|
||||
// uint32 fEventsSize;
|
||||
uint32 fCurrEvent;
|
||||
bool fNeedsSorting;
|
||||
// bool fResetTimer;
|
||||
uint32 fStartTime;
|
||||
BFile* fFile;
|
||||
short fDivision;
|
||||
float fDivisionFactor;
|
||||
int32 fTempo;
|
||||
int32 fCurrTime;
|
||||
int32 fCurrTrack;
|
||||
int32 fNumTracks;
|
||||
|
||||
// int32 fToBeRead;
|
||||
// int32 fMsgIndex;
|
||||
// int32 fMsgSize;
|
||||
// uchar* fMsgBuff;
|
||||
|
||||
int32 fNumBytesWritten;
|
||||
void ReadFourCC(char* fourcc);
|
||||
uint32 Read32Bit();
|
||||
uint16 Read16Bit();
|
||||
uint8 PeekByte();
|
||||
uint8 NextByte();
|
||||
void SkipBytes(uint32 length);
|
||||
uint32 ReadVarLength();
|
||||
void ReadChunk();
|
||||
void ReadTrack();
|
||||
void ReadSystemExclusive();
|
||||
void ReadMetaEvent();
|
||||
|
||||
uchar* fFileBuffer;
|
||||
int32 fFileBufferMax;
|
||||
int32 fFileBufferSize;
|
||||
int32 fFileBufferIndex;
|
||||
uint32 _reserved[4];
|
||||
void WriteFourCC(char a, char b, char c, char d);
|
||||
void Write32Bit(uint32 val);
|
||||
void Write16Bit(uint16 val);
|
||||
void WriteByte(uint8 val);
|
||||
void WriteVarLength(uint32 val);
|
||||
void WriteTrack();
|
||||
void WriteMetaEvent(BMidiEvent* event);
|
||||
|
||||
BFile* file;
|
||||
uint32 byteCount;
|
||||
uint32 totalTicks;
|
||||
uint16 numTracks;
|
||||
uint16 currTrack;
|
||||
uint16 format;
|
||||
|
||||
uint16 _reserved1[1];
|
||||
uint32 _reserved2[16];
|
||||
};
|
||||
|
||||
|
||||
/*------------------------------------------------------------*/
|
||||
|
||||
#endif
|
||||
#endif // _MIDI_STORE_H
|
||||
|
@ -10,41 +10,33 @@
|
||||
class BMidiSynth : public BMidi
|
||||
{
|
||||
public:
|
||||
|
||||
BMidiSynth();
|
||||
virtual ~BMidiSynth();
|
||||
|
||||
status_t EnableInput(bool enable, bool loadInstruments);
|
||||
bool IsInputEnabled(void) const;
|
||||
|
||||
/* set volume. You can overdrive by passing values larger than 1.0 */
|
||||
void SetVolume(double volume);
|
||||
double Volume(void) const;
|
||||
|
||||
/* set note offset in semi tones */
|
||||
/* (12 is down an octave, -12 is up an octave) */
|
||||
void SetTransposition(int16 offset);
|
||||
int16 Transposition(void) const;
|
||||
|
||||
/* Mute and unmute channels (0 to 15) */
|
||||
void MuteChannel(int16 channel, bool do_mute);
|
||||
void GetMuteMap(char* pChannels) const;
|
||||
|
||||
void SoloChannel(int16 channel, bool do_solo);
|
||||
void GetSoloMap(char* pChannels) const;
|
||||
|
||||
/* Use these functions to drive the synth engine directly */
|
||||
status_t LoadInstrument(int16 instrument);
|
||||
status_t UnloadInstrument(int16 instrument);
|
||||
status_t RemapInstrument(int16 from, int16 to);
|
||||
|
||||
void FlushInstrumentCache(bool startStopCache);
|
||||
|
||||
/* get current midi tick in microseconds */
|
||||
uint32 Tick(void) const;
|
||||
|
||||
/* The channel variable is 1 to 16. Channel 10 is percussion for example. */
|
||||
/* The programNumber variable is a number from 0-127 */
|
||||
|
||||
virtual void NoteOff(
|
||||
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
|
||||
|
||||
@ -67,27 +59,26 @@ public:
|
||||
virtual void PitchBend(
|
||||
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
|
||||
|
||||
virtual void AllNotesOff(bool controlOnly, uint32 time = B_NOW);
|
||||
virtual void AllNotesOff(bool justChannel, uint32 time = B_NOW);
|
||||
|
||||
protected:
|
||||
|
||||
void* fSongVariables;
|
||||
void* fPerformanceVariables;
|
||||
bool fMidiQueue;
|
||||
|
||||
private:
|
||||
|
||||
friend class BSynth;
|
||||
|
||||
virtual void _ReservedMidiSynth1();
|
||||
virtual void _ReservedMidiSynth2();
|
||||
virtual void _ReservedMidiSynth3();
|
||||
virtual void _ReservedMidiSynth4();
|
||||
|
||||
friend class BSynth;
|
||||
|
||||
virtual void Run();
|
||||
|
||||
bool fInputEnabled;
|
||||
uint32 _reserved[4];
|
||||
};
|
||||
|
||||
#endif // _MIDI_SYNTH_H
|
||||
|
||||
|
@ -11,6 +11,7 @@ typedef void (*synth_file_hook)(int32 arg);
|
||||
class BMidiSynthFile : public BMidiSynth
|
||||
{
|
||||
public:
|
||||
|
||||
BMidiSynthFile();
|
||||
~BMidiSynthFile();
|
||||
|
||||
@ -24,38 +25,22 @@ public:
|
||||
void Pause(void);
|
||||
void Resume(void);
|
||||
|
||||
/* get ticks in microseconds of length of song */
|
||||
int32 Duration(void) const;
|
||||
|
||||
/* set the current playback position of song in microseconds */
|
||||
int32 Position(int32 ticks) const;
|
||||
|
||||
/* get the current playback position of a song in microseconds */
|
||||
int32 Seek();
|
||||
|
||||
/* get the patches required to play this song */
|
||||
status_t GetPatches(int16* pArray768, int16* pReturnedCount) const;
|
||||
|
||||
/* Set a call back when song is done */
|
||||
void SetFileHook(synth_file_hook pSongHook, int32 arg);
|
||||
|
||||
/* poll to see if song is done */
|
||||
bool IsFinished(void) const;
|
||||
|
||||
/* set song master tempo. (1.0 uses songs encoded tempo, 2.0 will play */
|
||||
/* song twice as fast, and 0.5 will play song half as fast */
|
||||
void ScaleTempoBy(double tempoFactor);
|
||||
|
||||
/* sets tempo in beats per minute */
|
||||
void SetTempo(int32 newTempoBPM);
|
||||
|
||||
/* returns tempo in beats per minute */
|
||||
int32 Tempo(void) const;
|
||||
|
||||
/* pass true to loop song, false to not loop */
|
||||
void EnableLooping(bool loop);
|
||||
|
||||
/* Mute and unmute tracks (0 to 64) */
|
||||
void MuteTrack(int16 track, bool do_mute);
|
||||
void GetMuteMap(char* pTracks) const;
|
||||
|
||||
@ -64,14 +49,13 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
friend class BSynth;
|
||||
|
||||
virtual void _ReservedMidiSynthFile1();
|
||||
virtual void _ReservedMidiSynthFile2();
|
||||
virtual void _ReservedMidiSynthFile3();
|
||||
|
||||
friend class BSynth;
|
||||
|
||||
uint32 _reserved[4];
|
||||
};
|
||||
|
||||
#endif // _MIDI_SYNTH_FILE
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
class BMidiText : public BMidi
|
||||
{
|
||||
public:
|
||||
|
||||
BMidiText();
|
||||
virtual ~BMidiText();
|
||||
|
||||
@ -35,28 +36,26 @@ public:
|
||||
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemExclusive(
|
||||
void* data, size_t dataLength, uint32 time = B_NOW);
|
||||
void* data, size_t length, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemCommon(
|
||||
uchar status, uchar data1, uchar data2, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemRealTime(uchar status, uint32 time = B_NOW);
|
||||
|
||||
virtual void TempoChange(int32 beatsPerMinute, uint32 time = B_NOW);
|
||||
|
||||
virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW);
|
||||
|
||||
void ResetTimer(bool start = false);
|
||||
|
||||
private:
|
||||
|
||||
virtual void _ReservedMidiText1();
|
||||
virtual void _ReservedMidiText2();
|
||||
virtual void _ReservedMidiText3();
|
||||
|
||||
virtual void Run();
|
||||
|
||||
void WaitAndPrint(uint32 time);
|
||||
|
||||
int32 startTime;
|
||||
uint32 startTime;
|
||||
uint32 _reserved[4];
|
||||
};
|
||||
|
||||
|
@ -11,25 +11,16 @@ typedef bool (*sample_loop_hook)(int32 arg);
|
||||
class BSamples
|
||||
{
|
||||
public:
|
||||
|
||||
BSamples();
|
||||
virtual ~BSamples();
|
||||
|
||||
/* start a sample playing */
|
||||
void Start(
|
||||
void* sampleData, /* pointer to audio data*/
|
||||
int32 frames, /* number of frames*/
|
||||
int16 bytes_per_sample, /* btyes per sample 1 or 2*/
|
||||
int16 channel_count, /* mono or stereo 1 or 2*/
|
||||
double pitch, /* floating sample rate*/
|
||||
int32 loopStart, /* loop start in frames*/
|
||||
int32 loopEnd, /* loop end in frames*/
|
||||
double sampleVolume, /* sample volume*/
|
||||
double stereoPosition, /* stereo placement*/
|
||||
int32 hook_arg, /* hook argument*/
|
||||
sample_loop_hook pLoopContinueProc,
|
||||
sample_exit_hook pDoneProc);
|
||||
void* sampleData, int32 frames, int16 bytes_per_sample,
|
||||
int16 channel_count, double pitch, int32 loopStart, int32 loopEnd,
|
||||
double sampleVolume, double stereoPosition, int32 hook_arg,
|
||||
sample_loop_hook pLoopContinueProc, sample_exit_hook pDoneProc);
|
||||
|
||||
/* currently paused */
|
||||
bool IsPaused(void) const;
|
||||
void Pause(void);
|
||||
void Resume(void);
|
||||
@ -43,11 +34,8 @@ public:
|
||||
double SamplingRate(void) const;
|
||||
|
||||
void SetPlacement(double stereoPosition);
|
||||
|
||||
/* Set the stereo position (-1.0 left to +1.0 right, 0 is middle) */
|
||||
double Placement(void) const;
|
||||
|
||||
/* Enable/Disable reverb on this particular IgorSound */
|
||||
void EnableReverb(bool useReverb);
|
||||
|
||||
private:
|
||||
@ -56,11 +44,7 @@ private:
|
||||
virtual void _ReservedSamples2();
|
||||
virtual void _ReservedSamples3();
|
||||
|
||||
int32 fReference;
|
||||
double fPauseVariable;
|
||||
void* fFileVariables;
|
||||
uint32 _reserved[4];
|
||||
uint32 _reserved[8];
|
||||
};
|
||||
|
||||
#endif // _SAMPLES_H
|
||||
|
||||
|
@ -35,6 +35,7 @@ class BMidiSynthFile;
|
||||
class BSynth
|
||||
{
|
||||
public:
|
||||
|
||||
BSynth();
|
||||
BSynth(synth_mode synth);
|
||||
virtual ~BSynth();
|
||||
@ -46,7 +47,6 @@ public:
|
||||
void Unload(void);
|
||||
bool IsLoaded(void) const;
|
||||
|
||||
/* change audio modes */
|
||||
status_t SetSamplingRate(int32 sample_rate);
|
||||
int32 SamplingRate() const;
|
||||
|
||||
@ -59,7 +59,6 @@ public:
|
||||
status_t EnableReverb(bool reverb_enabled);
|
||||
bool IsReverbEnabled() const;
|
||||
|
||||
/* change voice allocation */
|
||||
status_t SetVoiceLimits(
|
||||
int16 maxSynthVoices, int16 maxSampleVoices,
|
||||
int16 limiterThreshhold);
|
||||
@ -68,60 +67,35 @@ public:
|
||||
int16 MaxSampleVoices(void) const;
|
||||
int16 LimiterThreshhold(void) const;
|
||||
|
||||
/* get and set the master mix volume. A volume level of 1.0 */
|
||||
/* is normal, and volume level of 4.0 will overdrive 4 times */
|
||||
void SetSynthVolume(double theVolume);
|
||||
double SynthVolume(void) const;
|
||||
|
||||
void SetSampleVolume(double theVolume);
|
||||
double SampleVolume(void) const;
|
||||
|
||||
/* display feedback information */
|
||||
/* This will return the number of 16-bit samples stored into the pLeft*/
|
||||
/* and pRight arrays. Usually 1024. This returns the current data*/
|
||||
/* points being sent to the hardware.*/
|
||||
status_t GetAudio(
|
||||
int16* pLeft, int16* pRight, int32 max_samples) const;
|
||||
|
||||
/* disengage from audio output streams*/
|
||||
void Pause(void);
|
||||
|
||||
/* reengage to audio output streams*/
|
||||
void Resume(void);
|
||||
|
||||
/* Set a call back on controller events*/
|
||||
void SetControllerHook(int16 controller, synth_controller_hook cback);
|
||||
|
||||
int32 CountClients(void) const;
|
||||
|
||||
private:
|
||||
|
||||
friend BMidiSynth;
|
||||
friend BMidiSynthFile;
|
||||
|
||||
virtual void _ReservedSynth1();
|
||||
virtual void _ReservedSynth2();
|
||||
virtual void _ReservedSynth3();
|
||||
virtual void _ReservedSynth4();
|
||||
|
||||
friend BMidiSynth;
|
||||
friend BMidiSynthFile;
|
||||
|
||||
int32 fClientCount;
|
||||
void _init();
|
||||
status_t _do_load(synth_mode synth);
|
||||
status_t _load_insts(entry_ref* ref);
|
||||
synth_mode fMode;
|
||||
int16 fMaxSynthVox;
|
||||
int16 fMaxSampleVox;
|
||||
int16 fLimiter;
|
||||
|
||||
int32 fSRate;
|
||||
interpolation_mode fInterp;
|
||||
int32 fModifiers;
|
||||
reverb_mode fReverb;
|
||||
sem_id fSetupLock;
|
||||
uint32 _reserved[4];
|
||||
uint32 _reserved[13];
|
||||
};
|
||||
|
||||
extern _IMPEXP_MIDI BSynth* be_synth;
|
||||
|
||||
#endif // _SYNTH_H
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user