Cleaned up libmidi. See the log message

from the libmidi source for details.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1820 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
mahlzeit
2002-11-01 16:11:03 +00:00
parent a4e33e10fa
commit 173d0cd769
9 changed files with 618 additions and 569 deletions
+99 -62
View File
@@ -1,89 +1,126 @@
//-----------------------------------------------------------------------------
#ifndef _MIDI_H_
#define _MIDI_H_
#ifndef _MIDI_H
#define _MIDI_H
#include <BeBuild.h>
#include <MidiDefs.h> #include <MidiDefs.h>
#include <OS.h> #include <OS.h>
class BMidiEvent; class BMidiEvent;
class BList; class BList;
class BMidi { class BMidi
{
public: public:
BMidi(); BMidi();
virtual ~BMidi(); virtual ~BMidi();
virtual void NoteOff(uchar channel, uchar note, virtual void NoteOff(
uchar velocity, uint32 time = B_NOW); uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
virtual void NoteOn(uchar channel, uchar note,
uchar velocity, uint32 time = B_NOW); virtual void NoteOn(
virtual void KeyPressure(uchar channel, uchar note, uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
uchar pressure, uint32 time = B_NOW);
virtual void ControlChange(uchar channel, uchar control_number, virtual void KeyPressure(
uchar control_value, uint32 time = B_NOW); uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
virtual void ProgramChange(uchar channel, uchar program_number,
virtual void ControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
uint32 time = B_NOW); uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel, uchar pressure,
uint32 time = B_NOW); virtual void ProgramChange(
virtual void PitchBend(uchar channel, uchar lsb, uchar channel, uchar programNumber, uint32 time = B_NOW);
uchar msb, uint32 time = B_NOW);
virtual void SystemExclusive(void * data, size_t data_length, virtual void ChannelPressure(
uint32 time = B_NOW); uchar channel, uchar pressure, uint32 time = B_NOW);
virtual void SystemCommon(uchar status_byte, uchar data1,
uchar data2, uint32 time = B_NOW); virtual void PitchBend(
virtual void SystemRealTime(uchar status_byte, uint32 time = B_NOW); uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
virtual void TempoChange(int32 beats_per_minute, uint32 time = B_NOW);
virtual void AllNotesOff(bool just_channel = true, uint32 time = B_NOW); virtual void SystemExclusive(
void* data, size_t dataLength, 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);
virtual status_t Start(); virtual status_t Start();
virtual void Stop(); virtual void Stop();
bool IsRunning() const; bool IsRunning() const;
void Connect(BMidi * to_object);
void Disconnect(BMidi * from_object); void Connect(BMidi* toObject);
bool IsConnected(BMidi * to_object) const; void Disconnect(BMidi* fromObject);
BList * Connections() const; bool IsConnected(BMidi* toObject) const;
BList* Connections() const;
void SnoozeUntil(uint32 time) const; void SnoozeUntil(uint32 time) const;
protected: protected:
void SprayNoteOff(uchar channel, uchar note,
uchar velocity, uint32 time) const; void SprayNoteOff(
void SprayNoteOn(uchar channel, uchar note, uchar channel, uchar note, uchar velocity, uint32 time) const;
uchar velocity, uint32 time) const;
void SprayKeyPressure(uchar channel, uchar note, void SprayNoteOn(
uchar pressure, uint32 time) const; uchar channel, uchar note, uchar velocity, uint32 time) const;
void SprayControlChange(uchar channel, uchar control_number,
uchar control_value, uint32 time) const; void SprayKeyPressure(
void SprayProgramChange(uchar channel, uchar program_number, uchar channel, uchar note, uchar pressure, uint32 time) const;
void SprayControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
uint32 time) const; uint32 time) const;
void SprayChannelPressure(uchar channel, uchar pressure,
uint32 time) const; void SprayProgramChange(
void SprayPitchBend(uchar channel, uchar lsb, uchar channel, uchar programNumber, uint32 time) const;
uchar msb, uint32 time) const;
void SpraySystemExclusive(void * data, size_t data_length, void SprayChannelPressure(
uint32 time) const; uchar channel, uchar pressure, uint32 time) const;
void SpraySystemCommon(uchar status_byte, uchar data1,
uchar data2, uint32 time) const; void SprayPitchBend(
void SpraySystemRealTime(uchar status_byte, uint32 time) const; uchar channel, uchar lsb, uchar msb, uint32 time) const;
void SprayTempoChange(int32 beats_per_minute, uint32 time) const;
void SpraySystemExclusive(
void* data, size_t dataLength, uint32 time = B_NOW) const;
void SpraySystemCommon(
uchar status, uchar data1, uchar data2, uint32 time) const;
void SpraySystemRealTime(uchar status, uint32 time) const;
void SprayTempoChange(int32 beatsPerMinute, uint32 time) const;
bool KeepRunning(); bool KeepRunning();
private: private:
virtual void Run();
void _Inflow();
void _SprayEvent(BMidiEvent *) const;
static int32 _RunThread(void * data);
static int32 _InflowThread(void * data);
private: friend class BMidiStore;
BList * _con_list;
thread_id _run_thread_id; virtual void _ReservedMidi1();
thread_id _inflow_thread_id; virtual void _ReservedMidi2();
port_id _inflow_port; virtual void _ReservedMidi3();
bool _is_running;
bool _is_inflowing; static int32 RunThread(void* data);
bool _keep_running; static int32 InflowThread(void* data);
virtual void Run();
void Inflow();
void SprayMidiEvent(BMidiEvent* event) const;
BList* connections;
thread_id runThread;
thread_id inflowThread;
port_id inflowPort;
bool isRunning;
bool inflowAlive;
uint32 _reserved[5];
}; };
#endif //_MIDI_H_ #endif // _MIDI_H
+128 -72
View File
@@ -1,33 +1,50 @@
//-----------------------------------------------------------------------------
#ifndef _MIDI_DEFS_H_ #ifndef _MIDI_DEFS_H
#define _MIDI_DEFS_H_ #define _MIDI_DEFS_H
#include <OS.h> #include <OS.h>
#include <Errors.h> #include <Errors.h>
#define B_NOW ((uint32)(system_time()/1000)) //------------------------------------------------------------------------------
#define B_SYNTH_DIRECTORY B_BEOS_ETC_DIRECTORY /* System time converted to int milliseconds */
#define B_BIG_SYNTH_FILE "synth/big_synth.sy"
#define B_LITTLE_SYNTH_FILE "synth/little_synth.sy"
typedef enum synth_mode { #define B_NOW ((uint32)(system_time()/1000))
//------------------------------------------------------------------------------
/* Synthesizer things */
#define B_SYNTH_DIRECTORY B_BEOS_ETC_DIRECTORY
#define B_BIG_SYNTH_FILE "synth/big_synth.sy"
#define B_LITTLE_SYNTH_FILE "synth/little_synth.sy"
typedef enum synth_mode
{
B_NO_SYNTH, B_NO_SYNTH,
B_BIG_SYNTH, B_BIG_SYNTH,
B_LITTLE_SYNTH, B_LITTLE_SYNTH,
B_DEFAULT_SYNTH, B_DEFAULT_SYNTH,
B_SAMPLES_ONLY, B_SAMPLES_ONLY
} synth_mode; }
synth_mode;
enum { //------------------------------------------------------------------------------
/* Need to move these into Errors.h */
enum
{
B_BAD_INSTRUMENT = B_MIDI_ERROR_BASE + 0x100, B_BAD_INSTRUMENT = B_MIDI_ERROR_BASE + 0x100,
B_BAD_MIDI_DATA, B_BAD_MIDI_DATA,
B_ALREADY_PAUSED, B_ALREADY_PAUSED,
B_ALREADY_RESUMED, B_ALREADY_RESUMED,
B_NO_SONG_PLAYING, B_NO_SONG_PLAYING,
B_TOO_MANY_SONGS_PLAYING, B_TOO_MANY_SONGS_PLAYING
}; };
//------------------------------------------------------------------------------
#ifndef uchar #ifndef uchar
typedef unsigned char uchar; typedef unsigned char uchar;
#endif #endif
@@ -35,70 +52,77 @@ typedef unsigned char uchar;
#ifndef _MIDI_CONSTANTS_ #ifndef _MIDI_CONSTANTS_
#define _MIDI_CONSTANTS_ #define _MIDI_CONSTANTS_
const uchar B_NOTE_OFF = 0x80; /* Channel Message Masks*/
const uchar B_NOTE_ON = 0x90; const uchar B_NOTE_OFF = 0x80;
const uchar B_KEY_PRESSURE = 0xa0; const uchar B_NOTE_ON = 0x90;
const uchar B_CONTROL_CHANGE = 0xb0; const uchar B_KEY_PRESSURE = 0xa0;
const uchar B_PROGRAM_CHANGE = 0xc0; const uchar B_CONTROL_CHANGE = 0xb0;
const uchar B_CHANNEL_PRESSURE = 0xd0; const uchar B_PROGRAM_CHANGE = 0xc0;
const uchar B_PITCH_BEND = 0xe0; const uchar B_CHANNEL_PRESSURE = 0xd0;
const uchar B_PITCH_BEND = 0xe0;
const uchar B_SYS_EX_START = 0xf0; /* System Messages*/
const uchar B_MIDI_TIME_CODE = 0xf1; const uchar B_SYS_EX_START = 0xf0;
const uchar B_SONG_POSITION = 0xf2; const uchar B_MIDI_TIME_CODE = 0xf1;
const uchar B_SONG_SELECT = 0xf3; const uchar B_SONG_POSITION = 0xf2;
const uchar B_CABLE_MESSAGE = 0xf5; const uchar B_SONG_SELECT = 0xf3;
const uchar B_TUNE_REQUEST = 0xf6; const uchar B_CABLE_MESSAGE = 0xf5;
const uchar B_SYS_EX_END = 0xf7; const uchar B_TUNE_REQUEST = 0xf6;
const uchar B_TIMING_CLOCK = 0xf8; const uchar B_SYS_EX_END = 0xf7;
const uchar B_START = 0xfa; const uchar B_TIMING_CLOCK = 0xf8;
const uchar B_CONTINUE = 0xfb; const uchar B_START = 0xfa;
const uchar B_STOP = 0xfc; const uchar B_CONTINUE = 0xfb;
const uchar B_ACTIVE_SENSING = 0xfe; const uchar B_STOP = 0xfc;
const uchar B_SYSTEM_RESET = 0xff; const uchar B_ACTIVE_SENSING = 0xfe;
const uchar B_SYSTEM_RESET = 0xff;
const uchar B_MODULATION = 0x01; /* Controller Numbers*/
const uchar B_BREATH_CONTROLLER = 0x02; const uchar B_MODULATION = 0x01;
const uchar B_FOOT_CONTROLLER = 0x04; const uchar B_BREATH_CONTROLLER = 0x02;
const uchar B_PORTAMENTO_TIME = 0x05; const uchar B_FOOT_CONTROLLER = 0x04;
const uchar B_DATA_ENTRY = 0x06; const uchar B_PORTAMENTO_TIME = 0x05;
const uchar B_MAIN_VOLUME = 0x07; const uchar B_DATA_ENTRY = 0x06;
const uchar B_MIDI_BALANCE = 0x08; const uchar B_MAIN_VOLUME = 0x07;
const uchar B_PAN = 0x0a; const uchar B_MIDI_BALANCE = 0x08; /* used to be B_BALANCE */
const uchar B_EXPRESSION_CTRL = 0x0b; const uchar B_PAN = 0x0a;
const uchar B_GENERAL_CTRL_1 = 0x10; const uchar B_EXPRESSION_CTRL = 0x0b;
const uchar B_GENERAL_CTRL_2 = 0x11; const uchar B_GENERAL_CTRL_1 = 0x10;
const uchar B_GENERAL_CTRL_3 = 0x12; const uchar B_GENERAL_CTRL_2 = 0x11;
const uchar B_GENERAL_CTRL_4 = 0x13; const uchar B_GENERAL_CTRL_3 = 0x12;
const uchar B_SUSTAIN_PEDAL = 0x40; const uchar B_GENERAL_CTRL_4 = 0x13;
const uchar B_PORTAMENTO = 0x41; const uchar B_SUSTAIN_PEDAL = 0x40;
const uchar B_SOSTENUTO = 0x42; const uchar B_PORTAMENTO = 0x41;
const uchar B_SOFT_PEDAL = 0x43; const uchar B_SOSTENUTO = 0x42;
const uchar B_HOLD_2 = 0x45; const uchar B_SOFT_PEDAL = 0x43;
const uchar B_GENERAL_CTRL_5 = 0x50; const uchar B_HOLD_2 = 0x45;
const uchar B_GENERAL_CTRL_6 = 0x51; const uchar B_GENERAL_CTRL_5 = 0x50;
const uchar B_GENERAL_CTRL_7 = 0x52; const uchar B_GENERAL_CTRL_6 = 0x51;
const uchar B_GENERAL_CTRL_8 = 0x53; const uchar B_GENERAL_CTRL_7 = 0x52;
const uchar B_EFFECTS_DEPTH = 0x5b; const uchar B_GENERAL_CTRL_8 = 0x53;
const uchar B_TREMOLO_DEPTH = 0x5c; const uchar B_EFFECTS_DEPTH = 0x5b;
const uchar B_CHORUS_DEPTH = 0x5d; const uchar B_TREMOLO_DEPTH = 0x5c;
const uchar B_CELESTE_DEPTH = 0x5e; const uchar B_CHORUS_DEPTH = 0x5d;
const uchar B_PHASER_DEPTH = 0x5f; const uchar B_CELESTE_DEPTH = 0x5e;
const uchar B_DATA_INCREMENT = 0x60; const uchar B_PHASER_DEPTH = 0x5f;
const uchar B_DATA_DECREMENT = 0x61; const uchar B_DATA_INCREMENT = 0x60;
const uchar B_DATA_DECREMENT = 0x61;
const uchar B_RESET_ALL_CONTROLLERS = 0x79; const uchar B_RESET_ALL_CONTROLLERS = 0x79;
const uchar B_LOCAL_CONTROL = 0x7a; const uchar B_LOCAL_CONTROL = 0x7a;
const uchar B_ALL_NOTES_OFF = 0x7b; const uchar B_ALL_NOTES_OFF = 0x7b;
const uchar B_OMNI_MODE_OFF = 0x7c; const uchar B_OMNI_MODE_OFF = 0x7c;
const uchar B_OMNI_MODE_ON = 0x7d; const uchar B_OMNI_MODE_ON = 0x7d;
const uchar B_MONO_MODE_ON = 0x7e; const uchar B_MONO_MODE_ON = 0x7e;
const uchar B_POLY_MODE_ON = 0x7f; const uchar B_POLY_MODE_ON = 0x7f;
const uchar B_TEMPO_CHANGE = 0x51;
const uchar B_TEMPO_CHANGE = 0x51; #endif // _MIDI_CONSTANTS_
#endif //------------------------------------------------------------------------------
typedef enum midi_axe { typedef enum midi_axe
{
/* Pianos */
B_ACOUSTIC_GRAND=0, B_ACOUSTIC_GRAND=0,
B_BRIGHT_GRAND, B_BRIGHT_GRAND,
B_ELECTRIC_GRAND, B_ELECTRIC_GRAND,
@@ -107,6 +131,8 @@ typedef enum midi_axe {
B_ELECTRIC_PIANO_2, B_ELECTRIC_PIANO_2,
B_HARPSICHORD, B_HARPSICHORD,
B_CLAVICHORD, B_CLAVICHORD,
/* Tuned Idiophones */
B_CELESTA, B_CELESTA,
B_GLOCKENSPIEL, B_GLOCKENSPIEL,
B_MUSIC_BOX, B_MUSIC_BOX,
@@ -115,6 +141,8 @@ typedef enum midi_axe {
B_XYLOPHONE, B_XYLOPHONE,
B_TUBULAR_BELLS, B_TUBULAR_BELLS,
B_DULCIMER, B_DULCIMER,
/* Organs */
B_DRAWBAR_ORGAN, B_DRAWBAR_ORGAN,
B_PERCUSSIVE_ORGAN, B_PERCUSSIVE_ORGAN,
B_ROCK_ORGAN, B_ROCK_ORGAN,
@@ -123,6 +151,8 @@ typedef enum midi_axe {
B_ACCORDION, B_ACCORDION,
B_HARMONICA, B_HARMONICA,
B_TANGO_ACCORDION, B_TANGO_ACCORDION,
/* Guitars */
B_ACOUSTIC_GUITAR_NYLON, B_ACOUSTIC_GUITAR_NYLON,
B_ACOUSTIC_GUITAR_STEEL, B_ACOUSTIC_GUITAR_STEEL,
B_ELECTRIC_GUITAR_JAZZ, B_ELECTRIC_GUITAR_JAZZ,
@@ -131,6 +161,8 @@ typedef enum midi_axe {
B_OVERDRIVEN_GUITAR, B_OVERDRIVEN_GUITAR,
B_DISTORTION_GUITAR, B_DISTORTION_GUITAR,
B_GUITAR_HARMONICS, B_GUITAR_HARMONICS,
/* Basses */
B_ACOUSTIC_BASS, B_ACOUSTIC_BASS,
B_ELECTRIC_BASS_FINGER, B_ELECTRIC_BASS_FINGER,
B_ELECTRIC_BASS_PICK, B_ELECTRIC_BASS_PICK,
@@ -139,6 +171,8 @@ typedef enum midi_axe {
B_SLAP_BASS_2, B_SLAP_BASS_2,
B_SYNTH_BASS_1, B_SYNTH_BASS_1,
B_SYNTH_BASS_2, B_SYNTH_BASS_2,
/* Strings */
B_VIOLIN, B_VIOLIN,
B_VIOLA, B_VIOLA,
B_CELLO, B_CELLO,
@@ -147,6 +181,8 @@ typedef enum midi_axe {
B_PIZZICATO_STRINGS, B_PIZZICATO_STRINGS,
B_ORCHESTRAL_STRINGS, B_ORCHESTRAL_STRINGS,
B_TIMPANI, B_TIMPANI,
/* Ensemble strings and voices */
B_STRING_ENSEMBLE_1, B_STRING_ENSEMBLE_1,
B_STRING_ENSEMBLE_2, B_STRING_ENSEMBLE_2,
B_SYNTH_STRINGS_1, B_SYNTH_STRINGS_1,
@@ -155,6 +191,8 @@ typedef enum midi_axe {
B_VOICE_OOH, B_VOICE_OOH,
B_SYNTH_VOICE, B_SYNTH_VOICE,
B_ORCHESTRA_HIT, B_ORCHESTRA_HIT,
/* Brass */
B_TRUMPET, B_TRUMPET,
B_TROMBONE, B_TROMBONE,
B_TUBA, B_TUBA,
@@ -163,6 +201,8 @@ typedef enum midi_axe {
B_BRASS_SECTION, B_BRASS_SECTION,
B_SYNTH_BRASS_1, B_SYNTH_BRASS_1,
B_SYNTH_BRASS_2, B_SYNTH_BRASS_2,
/* Reeds */
B_SOPRANO_SAX, B_SOPRANO_SAX,
B_ALTO_SAX, B_ALTO_SAX,
B_TENOR_SAX, B_TENOR_SAX,
@@ -171,6 +211,8 @@ typedef enum midi_axe {
B_ENGLISH_HORN, B_ENGLISH_HORN,
B_BASSOON, B_BASSOON,
B_CLARINET, B_CLARINET,
/* Pipes */
B_PICCOLO, B_PICCOLO,
B_FLUTE, B_FLUTE,
B_RECORDER, B_RECORDER,
@@ -179,6 +221,8 @@ typedef enum midi_axe {
B_SHAKUHACHI, B_SHAKUHACHI,
B_WHISTLE, B_WHISTLE,
B_OCARINA, B_OCARINA,
/* Synth Leads*/
B_LEAD_1, B_LEAD_1,
B_SQUARE_WAVE = B_LEAD_1, B_SQUARE_WAVE = B_LEAD_1,
B_LEAD_2, B_LEAD_2,
@@ -195,6 +239,8 @@ typedef enum midi_axe {
B_FIFTHS = B_LEAD_7, B_FIFTHS = B_LEAD_7,
B_LEAD_8, B_LEAD_8,
B_BASS_LEAD = B_LEAD_8, B_BASS_LEAD = B_LEAD_8,
/* Synth Pads */
B_PAD_1, B_PAD_1,
B_NEW_AGE = B_PAD_1, B_NEW_AGE = B_PAD_1,
B_PAD_2, B_PAD_2,
@@ -211,6 +257,8 @@ typedef enum midi_axe {
B_HALO = B_PAD_7, B_HALO = B_PAD_7,
B_PAD_8, B_PAD_8,
B_SWEEP = B_PAD_8, B_SWEEP = B_PAD_8,
/* Effects */
B_FX_1, B_FX_1,
B_FX_2, B_FX_2,
B_FX_3, B_FX_3,
@@ -219,6 +267,8 @@ typedef enum midi_axe {
B_FX_6, B_FX_6,
B_FX_7, B_FX_7,
B_FX_8, B_FX_8,
/* Ethnic */
B_SITAR, B_SITAR,
B_BANJO, B_BANJO,
B_SHAMISEN, B_SHAMISEN,
@@ -227,6 +277,8 @@ typedef enum midi_axe {
B_BAGPIPE, B_BAGPIPE,
B_FIDDLE, B_FIDDLE,
B_SHANAI, B_SHANAI,
/* Percussion */
B_TINKLE_BELL, B_TINKLE_BELL,
B_AGOGO, B_AGOGO,
B_STEEL_DRUMS, B_STEEL_DRUMS,
@@ -235,6 +287,8 @@ typedef enum midi_axe {
B_MELODIC_TOM, B_MELODIC_TOM,
B_SYNTH_DRUM, B_SYNTH_DRUM,
B_REVERSE_CYMBAL, B_REVERSE_CYMBAL,
/* Sound Effects */
B_FRET_NOISE, B_FRET_NOISE,
B_BREATH_NOISE, B_BREATH_NOISE,
B_SEASHORE, B_SEASHORE,
@@ -243,6 +297,8 @@ typedef enum midi_axe {
B_HELICOPTER, B_HELICOPTER,
B_APPLAUSE, B_APPLAUSE,
B_GUNSHOT B_GUNSHOT
} midi_axe; }
midi_axe;
#endif // _MIDI_DEFS_H
#endif //_MIDI_DEFS_H_
+57 -82
View File
@@ -1,12 +1,3 @@
/*******************************************************************************
/
/ File: MidiPort.h
/
/ Description: Interface to MIDI hardware ports.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _MIDI_PORT_H #ifndef _MIDI_PORT_H
#define _MIDI_PORT_H #define _MIDI_PORT_H
@@ -16,103 +7,87 @@
class BMidiLocalProducer; class BMidiLocalProducer;
class BMidiPortConsumer; class BMidiPortConsumer;
/*------------------------------------------------------------*/ class BMidiPort : public BMidi
{
class BMidiPort : public BMidi {
public: public:
BMidiPort(const char *name=NULL); BMidiPort(const char* name = NULL);
~BMidiPort(); ~BMidiPort();
status_t InitCheck() const; status_t InitCheck() const;
status_t Open(const char *name); status_t Open(const char* name);
void Close(); void Close();
const char * PortName() const; const char* PortName() const;
virtual void NoteOff(uchar channel, virtual void NoteOff(
uchar note, uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
uchar velocity,
uint32 time = B_NOW);
virtual void NoteOn(uchar channel, virtual void NoteOn(
uchar note, uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
uchar velocity,
uint32 time = B_NOW);
virtual void KeyPressure(uchar channel, virtual void KeyPressure(
uchar note, uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
uchar pressure,
uint32 time = B_NOW);
virtual void ControlChange(uchar channel, virtual void ControlChange(
uchar controlNumber, uchar channel, uchar controlNumber, uchar controlValue,
uchar controlValue, uint32 time = B_NOW);
uint32 time = B_NOW);
virtual void ProgramChange(uchar channel, virtual void ProgramChange(
uchar programNumber, uchar channel, uchar programNumber, uint32 time = B_NOW);
uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel, virtual void ChannelPressure(
uchar pressure, uchar channel, uchar pressure, uint32 time = B_NOW);
uint32 time = B_NOW);
virtual void PitchBend(uchar channel, virtual void PitchBend(
uchar lsb, uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
uchar msb,
uint32 time = B_NOW);
virtual void SystemExclusive(void* data, virtual void SystemExclusive(
size_t dataLength, void* data, size_t dataLength, uint32 time = B_NOW);
uint32 time = B_NOW);
virtual void SystemCommon(uchar statusByte, virtual void SystemCommon(
uchar data1, uchar status, uchar data0, uchar data2, uint32 time = B_NOW);
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 status_t Start(); virtual status_t Start();
virtual void Stop(); virtual void Stop();
int32 CountDevices(); int32 CountDevices();
status_t GetDeviceName(int32 n, char * name,
size_t bufSize = B_OS_NAME_LENGTH);
status_t GetDeviceName(
int32 n, char* name, size_t bufSize = B_OS_NAME_LENGTH);
private: private:
typedef BMidi _inherited; typedef BMidi _inherited;
virtual void _ReservedMidiPort1(); virtual void _ReservedMidiPort1();
virtual void _ReservedMidiPort2(); virtual void _ReservedMidiPort2();
virtual void _ReservedMidiPort3(); virtual void _ReservedMidiPort3();
virtual void Run(); virtual void Run();
friend class BMidiPortConsumer; friend class BMidiPortConsumer;
void Dispatch(const unsigned char * buffer, size_t size, bigtime_t when); void Dispatch(
ssize_t Read(void *buffer, size_t numBytes) const; const unsigned char* buffer, size_t size, bigtime_t when);
ssize_t Write(void *buffer, size_t numBytes, uint32 time) const;
void ScanDevices(); ssize_t Read(void* buffer, size_t numBytes) const;
ssize_t Write(void* buffer, size_t numBytes, uint32 time) const;
BMidiProducer *remote_source; void ScanDevices();
BMidiConsumer *remote_sink;
// used to glue us to the new midi kit
BMidiProducer* remote_source;
BMidiConsumer* remote_sink;
BMidiLocalProducer* local_source;
BMidiPortConsumer* local_sink;
char* fName; char* fName;
status_t fCStatus; status_t fCStatus;
BList * _fDevices; BList* _fDevices;
uint8 _m_prev_cmd; uint8 _m_prev_cmd;
bool _m_enhanced; bool _m_enhanced;
uint8 _m_reserved[2]; uint8 _m_reserved[2];
// used to glue us to the new midi kit
BMidiLocalProducer *local_source;
BMidiPortConsumer *local_sink;
}; };
/*------------------------------------------------------------*/ #endif // _MIDI_PORT_H
#endif
+71 -56
View File
@@ -1,76 +1,91 @@
//-----------------------------------------------------------------------------
#ifndef _MIDI_STORE_H_
#define _MIDI_STORE_H_
#ifndef _MIDI_STORE_H
#define _MIDI_STORE_H
#include <BeBuild.h>
#include <Midi.h> #include <Midi.h>
#include <List.h>
struct entry_ref; struct entry_ref;
class BMidiEvent; class BMidiEvent;
class BFile; class BList;
class BMidiStore : public BMidi { class BMidiStore : public BMidi
{
public: public:
BMidiStore(); BMidiStore();
virtual ~BMidiStore(); virtual ~BMidiStore();
virtual void NoteOff(uchar channel, uchar note, virtual void NoteOff(
uchar velocity, uint32 time = B_NOW); uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
virtual void NoteOn(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 ControlChange(uchar channel, uchar control_number,
uchar control_value, uint32 time = B_NOW);
virtual void ProgramChange(uchar channel, uchar program_number,
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 SystemExclusive(void * data, size_t data_length,
uint32 time = B_NOW);
virtual void SystemCommon(uchar status_byte, uchar data1,
uchar data2, uint32 time = B_NOW);
virtual void SystemRealTime(uchar status_byte, uint32 time = B_NOW);
virtual void TempoChange(int32 beats_per_minute, uint32 time = B_NOW);
virtual void AllNotesOff(bool just_channel = true, uint32 time = B_NOW);
status_t Import(const entry_ref * ref); virtual void NoteOn(
status_t Export(const entry_ref * ref, int32 format); 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 ControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
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 SystemExclusive(
void* data, size_t dataLength, 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);
status_t Import(const entry_ref* ref);
status_t Export(const entry_ref* ref, int32 format);
void SortEvents(bool force = false); void SortEvents(bool force = false);
uint32 CountEvents() const; uint32 CountEvents() const;
uint32 CurrentEvent() const; uint32 CurrentEvent() const;
void SetCurrentEvent(uint32 event_number); void SetCurrentEvent(uint32 eventNumber);
uint32 DeltaOfEvent(uint32 event_number) const;
uint32 DeltaOfEvent(uint32 eventNumber) const;
uint32 EventAtDelta(uint32 time) const; uint32 EventAtDelta(uint32 time) const;
uint32 BeginTime() const;
void SetTempo(int32 beats_per_minute); uint32 BeginTime() const;
void SetTempo(int32 beatsPerMinute);
int32 Tempo() const; int32 Tempo() const;
private: private:
virtual void Run();
void _RunThread();
uint8* _DecodeTrack(uint8 *);
void _DecodeFormat0Tracks(uint8 *, uint16, uint32);
void _DecodeFormat1Tracks(uint8 *, uint16, uint32);
void _DecodeFormat2Tracks(uint8 *, uint16, uint32);
void _EncodeFormat0Tracks(uint8 *);
void _EncodeFormat1Tracks(uint8 *);
void _EncodeFormat2Tracks(uint8 *);
void _ReadEvent(uint8, uint8 **, uint8 *, BMidiEvent *);
void _WriteEvent(BMidiEvent *);
uint32 _ReadVarLength(uint8 **, uint8 *);
void _WriteVarLength(uint32);
static int _CompareEvents(const void *, const void *);
private: virtual void _ReservedMidiStore1();
BList * _evt_list; virtual void _ReservedMidiStore2();
uint32 _tempo;
uint32 _cur_evt; virtual void Run();
uint32 _start_time;
uint32 _ticks_per_beat; BMidiEvent* EventAt(uint32 index) const;
static int CompareEvents(const void* event1, const void* event2);
BList* events;
uint32 tempo;
uint32 curEvent;
uint32 startTime;
uint32 ticksPerBeat;
uint32 _reserved[21];
}; };
#endif _MIDI_STORE_H_ #endif // _MIDI_STORE_H
+53 -75
View File
@@ -1,115 +1,93 @@
/*******************************************************************************
/
/ File: MidiSynth.h
/
/ Description: Midi object that talks to the General MIDI synthesizer.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _MIDI_SYNTH_H #ifndef _MIDI_SYNTH_H
#define _MIDI_SYNTH_H #define _MIDI_SYNTH_H
#ifndef _BE_BUILD_H
#include <BeBuild.h> #include <BeBuild.h>
#endif
#include <Midi.h> #include <Midi.h>
#include <Synth.h> #include <Synth.h>
#include <MidiDefs.h> #include <MidiDefs.h>
class BMidiSynth : public BMidi class BMidiSynth : public BMidi
{ {
public: public:
BMidiSynth(); BMidiSynth();
virtual ~BMidiSynth(); virtual ~BMidiSynth();
status_t EnableInput(bool enable, bool loadInstruments);
bool IsInputEnabled(void) const;
status_t EnableInput(bool enable, bool loadInstruments); /* set volume. You can overdrive by passing values larger than 1.0 */
bool IsInputEnabled(void) const; void SetVolume(double volume);
double Volume(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 */ /* set note offset in semi tones */
/* (12 is down an octave, -12 is up an octave)*/ /* (12 is down an octave, -12 is up an octave) */
void SetTransposition(int16 offset); void SetTransposition(int16 offset);
int16 Transposition(void) const; int16 Transposition(void) const;
/* Mute and unmute channels (0 to 15)*/ /* Mute and unmute channels (0 to 15) */
void MuteChannel(int16 channel, bool do_mute); void MuteChannel(int16 channel, bool do_mute);
void GetMuteMap(char *pChannels) const; void GetMuteMap(char* pChannels) const;
void SoloChannel(int16 channel, bool do_solo); void SoloChannel(int16 channel, bool do_solo);
void GetSoloMap(char *pChannels) const; void GetSoloMap(char* pChannels) const;
/* Use these functions to drive the synth engine directly*/ /* Use these functions to drive the synth engine directly */
status_t LoadInstrument(int16 instrument); status_t LoadInstrument(int16 instrument);
status_t UnloadInstrument(int16 instrument); status_t UnloadInstrument(int16 instrument);
status_t RemapInstrument(int16 from, int16 to); status_t RemapInstrument(int16 from, int16 to);
void FlushInstrumentCache(bool startStopCache); void FlushInstrumentCache(bool startStopCache);
/* get current midi tick in microseconds*/ /* get current midi tick in microseconds */
uint32 Tick(void) const; uint32 Tick(void) const;
/* The channel variable is 1 to 16. Channel 10 is percussion for example.*/ /* The channel variable is 1 to 16. Channel 10 is percussion for example. */
/* The programNumber variable is a number from 0-127*/ /* The programNumber variable is a number from 0-127 */
virtual void NoteOff(uchar channel, virtual void NoteOff(
uchar note, uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
uchar velocity,
uint32 time = B_NOW);
virtual void NoteOn(uchar channel, virtual void NoteOn(
uchar note, uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
uchar velocity,
uint32 time = B_NOW);
virtual void KeyPressure(uchar channel, virtual void KeyPressure(
uchar note, uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
uchar pressure,
uint32 time = B_NOW);
virtual void ControlChange(uchar channel, virtual void ControlChange(
uchar controlNumber, uchar channel, uchar controlNumber, uchar controlValue,
uchar controlValue, uint32 time = B_NOW);
uint32 time = B_NOW);
virtual void ProgramChange(uchar channel, virtual void ProgramChange(
uchar programNumber, uchar channel, uchar programNumber, uint32 time = B_NOW);
uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel, virtual void ChannelPressure(
uchar pressure, uchar channel, uchar pressure, uint32 time = B_NOW);
uint32 time = B_NOW);
virtual void PitchBend(uchar channel, virtual void PitchBend(
uchar lsb, uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
uchar msb,
uint32 time = B_NOW);
virtual void AllNotesOff(bool controlOnly, uint32 time = B_NOW); virtual void AllNotesOff(bool controlOnly, uint32 time = B_NOW);
protected: protected:
void* fSongVariables; void* fSongVariables;
void* fPerformanceVariables; void* fPerformanceVariables;
bool fMidiQueue; bool fMidiQueue;
private: private:
virtual void _ReservedMidiSynth1(); virtual void _ReservedMidiSynth1();
virtual void _ReservedMidiSynth2(); virtual void _ReservedMidiSynth2();
virtual void _ReservedMidiSynth3(); virtual void _ReservedMidiSynth3();
virtual void _ReservedMidiSynth4(); virtual void _ReservedMidiSynth4();
friend class BSynth; friend class BSynth;
virtual void Run();
virtual void Run();
bool fInputEnabled; bool fInputEnabled;
uint32 _reserved[4]; uint32 _reserved[4];
}; };
#endif #endif // _MIDI_SYNTH_H
+44 -53
View File
@@ -1,86 +1,77 @@
/*******************************************************************************
/
/ File: MidiSynthFile.h
/
/ Description: Send a MIDI file to the synthesizer.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _MIDI_SYNTH_FILE_H #ifndef _MIDI_SYNTH_FILE_H
#define _MIDI_SYNTH_FILE_H #define _MIDI_SYNTH_FILE_H
#ifndef _BE_BUILD_H
#include <BeBuild.h> #include <BeBuild.h>
#endif
#include <MidiSynth.h> #include <MidiSynth.h>
#include <Entry.h> #include <Entry.h>
typedef void (*synth_file_hook)(int32 arg); typedef void (*synth_file_hook)(int32 arg);
class BMidiSynthFile : public BMidiSynth class BMidiSynthFile : public BMidiSynth
{ {
public: public:
BMidiSynthFile(); BMidiSynthFile();
~BMidiSynthFile(); ~BMidiSynthFile();
status_t LoadFile(const entry_ref *midi_entry_ref); status_t LoadFile(const entry_ref* midi_entry_ref);
void UnloadFile(void); void UnloadFile(void);
virtual status_t Start(void); virtual status_t Start(void);
virtual void Stop(void); virtual void Stop(void);
void Fade(void); void Fade(void);
void Pause(void);
void Resume(void);
void Pause(void); /* get ticks in microseconds of length of song */
void Resume(void); int32 Duration(void) const;
/* get ticks in microseconds of length of song*/ /* set the current playback position of song in microseconds */
int32 Duration(void) const; int32 Position(int32 ticks) 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*/ /* get the current playback position of a song in microseconds */
status_t GetPatches(int16 *pArray768, int16 *pReturnedCount) const; int32 Seek();
/* Set a call back when song is done*/ /* get the patches required to play this song */
void SetFileHook(synth_file_hook pSongHook, int32 arg); status_t GetPatches(int16* pArray768, int16* pReturnedCount) const;
/* 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*/ /* Set a call back when song is done */
/* song twice as fast, and 0.5 will play song half as fast*/ void SetFileHook(synth_file_hook pSongHook, int32 arg);
void ScaleTempoBy(double tempoFactor);
/* poll to see if song is done */
bool IsFinished(void) const;
/* sets tempo in beats per minute*/ /* set song master tempo. (1.0 uses songs encoded tempo, 2.0 will play */
void SetTempo(int32 newTempoBPM); /* song twice as fast, and 0.5 will play song half as fast */
/* returns tempo in beats per minute*/ void ScaleTempoBy(double tempoFactor);
int32 Tempo(void) const;
/* pass true to loop song, false to not loop*/ /* sets tempo in beats per minute */
void EnableLooping(bool loop); void SetTempo(int32 newTempoBPM);
/* Mute and unmute tracks (0 to 64)*/ /* returns tempo in beats per minute */
void MuteTrack(int16 track, bool do_mute); int32 Tempo(void) const;
void GetMuteMap(char *pTracks) const;
void SoloTrack(int16 track, bool do_solo); /* pass true to loop song, false to not loop */
void GetSoloMap(char *pTracks) const; void EnableLooping(bool loop);
/* Mute and unmute tracks (0 to 64) */
void MuteTrack(int16 track, bool do_mute);
void GetMuteMap(char* pTracks) const;
void SoloTrack(int16 track, bool do_solo);
void GetSoloMap(char* pTracks) const;
private: private:
virtual void _ReservedMidiSynthFile1(); virtual void _ReservedMidiSynthFile1();
virtual void _ReservedMidiSynthFile2(); virtual void _ReservedMidiSynthFile2();
virtual void _ReservedMidiSynthFile3(); virtual void _ReservedMidiSynthFile3();
friend class BSynth; friend class BSynth;
uint32 _reserved[4]; uint32 _reserved[4];
}; };
#endif #endif // _MIDI_SYNTH_FILE
+49 -28
View File
@@ -1,43 +1,64 @@
//-----------------------------------------------------------------------------
#ifndef _MIDI_TEXT_H_
#define _MIDI_TEXT_H_
#ifndef _MIDI_TEXT_H
#define _MIDI_TEXT_H
#include <BeBuild.h>
#include <Midi.h> #include <Midi.h>
#include <stdio.h>
class BMidiText : public BMidi { class BMidiText : public BMidi
{
public: public:
BMidiText(); BMidiText();
virtual ~BMidiText(); virtual ~BMidiText();
virtual void NoteOff(uchar channel, uchar note, virtual void NoteOff(
uchar velocity, uint32 time = B_NOW); uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
virtual void NoteOn(uchar channel, uchar note,
uchar velocity, uint32 time = B_NOW); virtual void NoteOn(
virtual void KeyPressure(uchar channel, uchar note, uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
uchar pressure, uint32 time = B_NOW);
virtual void ControlChange(uchar channel, uchar control_number, virtual void KeyPressure(
uchar control_value, uint32 time = B_NOW); uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
virtual void ProgramChange(uchar channel, uchar program_number,
virtual void ControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
uint32 time = B_NOW); uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel, uchar pressure,
uint32 time = B_NOW); virtual void ProgramChange(
virtual void PitchBend(uchar channel, uchar lsb, uchar channel, uchar programNumber, uint32 time = B_NOW);
uchar msb, uint32 time = B_NOW);
virtual void SystemExclusive(void * data, size_t data_length, virtual void ChannelPressure(
uint32 time = B_NOW); uchar channel, uchar pressure, uint32 time = B_NOW);
virtual void SystemCommon(uchar status_byte, uchar data1,
uchar data2, uint32 time = B_NOW); virtual void PitchBend(
virtual void SystemRealTime(uchar status_byte, uint32 time = B_NOW); uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
virtual void TempoChange(int32 beats_per_minute, uint32 time = B_NOW);
virtual void AllNotesOff(bool just_channel = true, uint32 time = B_NOW); virtual void SystemExclusive(
void* data, size_t dataLength, 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); void ResetTimer(bool start = false);
private: private:
int32 _start_time;
private: virtual void _ReservedMidiText1();
void _PrintTime();
virtual void Run();
void WaitAndPrint(uint32 time);
int32 startTime;
uint32 _reserved[4];
}; };
#endif _MIDI_TEXT_H_ #endif // _MIDI_TEXT_H
+40 -50
View File
@@ -1,19 +1,8 @@
/*******************************************************************************
/
/ File: Samples.h
/
/ Description: Sound effects.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _SAMPLES_H #ifndef _SAMPLES_H
#define _SAMPLES_H #define _SAMPLES_H
#ifndef _BE_BUILD_H
#include <BeBuild.h> #include <BeBuild.h>
#endif
#include <Entry.h> #include <Entry.h>
typedef void (*sample_exit_hook)(int32 arg); typedef void (*sample_exit_hook)(int32 arg);
@@ -22,55 +11,56 @@ typedef bool (*sample_loop_hook)(int32 arg);
class BSamples class BSamples
{ {
public: public:
BSamples(); BSamples();
virtual ~BSamples(); virtual ~BSamples();
/* start a sample playing*/ /* start a sample playing */
void Start(void * sampleData, /* pointer to audio data*/ void Start(
int32 frames, /* number of frames*/ void* sampleData, /* pointer to audio data*/
int16 bytes_per_sample, /* btyes per sample 1 or 2*/ int32 frames, /* number of frames*/
int16 channel_count, /* mono or stereo 1 or 2*/ int16 bytes_per_sample, /* btyes per sample 1 or 2*/
double pitch, /* floating sample rate*/ int16 channel_count, /* mono or stereo 1 or 2*/
int32 loopStart, /* loop start in frames*/ double pitch, /* floating sample rate*/
int32 loopEnd, /* loop end in frames*/ int32 loopStart, /* loop start in frames*/
double sampleVolume, /* sample volume*/ int32 loopEnd, /* loop end in frames*/
double stereoPosition, /* stereo placement*/ double sampleVolume, /* sample volume*/
int32 hook_arg, /* hook argument*/ double stereoPosition, /* stereo placement*/
sample_loop_hook pLoopContinueProc, int32 hook_arg, /* hook argument*/
sample_exit_hook pDoneProc); sample_loop_hook pLoopContinueProc,
sample_exit_hook pDoneProc);
/* currently paused*/ /* currently paused */
bool IsPaused(void) const; bool IsPaused(void) const;
void Pause(void); void Pause(void);
void Resume(void); void Resume(void);
void Stop(void); void Stop(void);
bool IsPlaying(void) const; bool IsPlaying(void) const;
void SetVolume(double newVolume); void SetVolume(double newVolume);
double Volume(void) const; double Volume(void) const;
void SetSamplingRate(double newRate);
double SamplingRate(void) const;
void SetSamplingRate(double newRate); void SetPlacement(double stereoPosition);
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;
/* Set the stereo position (-1.0 left to +1.0 right, 0 is middle)*/ /* Enable/Disable reverb on this particular IgorSound */
double Placement(void) const; void EnableReverb(bool useReverb);
/* Enable/Disable reverb on this particular IgorSound*/
void EnableReverb(bool useReverb);
private: private:
virtual void _ReservedSamples1(); virtual void _ReservedSamples1();
virtual void _ReservedSamples2(); virtual void _ReservedSamples2();
virtual void _ReservedSamples3(); virtual void _ReservedSamples3();
int32 fReference; int32 fReference;
double fPauseVariable; double fPauseVariable;
void* fFileVariables; void* fFileVariables;
uint32 _reserved[4]; uint32 _reserved[4];
}; };
#endif #endif // _SAMPLES_H
+77 -91
View File
@@ -1,29 +1,19 @@
/*******************************************************************************
/
/ File: Synth.h
/
/ Description: Interface to the General MIDI synthesizer.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _SYNTH_H #ifndef _SYNTH_H
#define _SYNTH_H #define _SYNTH_H
#ifndef _BE_BUILD_H
#include <BeBuild.h> #include <BeBuild.h>
#endif
#include <Entry.h> #include <Entry.h>
#include <MidiDefs.h> #include <MidiDefs.h>
#include <OS.h> #include <OS.h>
typedef enum interpolation_mode typedef enum interpolation_mode
{ {
B_DROP_SAMPLE = 0, B_DROP_SAMPLE = 0,
B_2_POINT_INTERPOLATION, B_2_POINT_INTERPOLATION,
B_LINEAR_INTERPOLATION B_LINEAR_INTERPOLATION
} interpolation_mode; }
interpolation_mode;
typedef enum reverb_mode typedef enum reverb_mode
{ {
@@ -33,109 +23,105 @@ typedef enum reverb_mode
B_REVERB_BALLROOM, B_REVERB_BALLROOM,
B_REVERB_CAVERN, B_REVERB_CAVERN,
B_REVERB_DUNGEON B_REVERB_DUNGEON
} reverb_mode; }
reverb_mode;
typedef void (*synth_controller_hook) (
int16 channel, int16 controller, int16 value);
typedef void (*synth_controller_hook) (int16 channel,
int16 controller,
int16 value);
class BMidiSynth; class BMidiSynth;
class BMidiSynthFile; class BMidiSynthFile;
class BSynth class BSynth
{ {
public: public:
BSynth(); BSynth();
BSynth(synth_mode synth); BSynth(synth_mode synth);
virtual ~BSynth();
#if !_PR3_COMPATIBLE_ status_t LoadSynthData(entry_ref* instrumentsFile);
virtual ~BSynth(); status_t LoadSynthData(synth_mode synth);
#else
~BSynth();
#endif
status_t LoadSynthData(entry_ref *instrumentsFile);
status_t LoadSynthData(synth_mode synth);
synth_mode SynthMode(void); synth_mode SynthMode(void);
void Unload(void); void Unload(void);
bool IsLoaded(void) const; bool IsLoaded(void) const;
/* change audio modes*/ /* change audio modes */
status_t SetSamplingRate(int32 sample_rate); status_t SetSamplingRate(int32 sample_rate);
int32 SamplingRate() const; int32 SamplingRate() const;
status_t SetInterpolation(interpolation_mode interp_mode); status_t SetInterpolation(interpolation_mode interp_mode);
interpolation_mode Interpolation() const; interpolation_mode Interpolation() const;
void SetReverb(reverb_mode rev_mode); void SetReverb(reverb_mode rev_mode);
reverb_mode Reverb() const; reverb_mode Reverb() const;
status_t EnableReverb(bool reverb_enabled); status_t EnableReverb(bool reverb_enabled);
bool IsReverbEnabled() const; bool IsReverbEnabled() const;
/* change voice allocation*/ /* change voice allocation */
status_t SetVoiceLimits(int16 maxSynthVoices, status_t SetVoiceLimits(
int16 maxSampleVoices, int16 maxSynthVoices, int16 maxSampleVoices,
int16 limiterThreshhold); int16 limiterThreshhold);
int16 MaxSynthVoices(void) const; int16 MaxSynthVoices(void) const;
int16 MaxSampleVoices(void) const; int16 MaxSampleVoices(void) const;
int16 LimiterThreshhold(void) const; int16 LimiterThreshhold(void) const;
/* get and set the master mix volume. A volume level of 1.0*/ /* 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*/ /* is normal, and volume level of 4.0 will overdrive 4 times */
void SetSynthVolume(double theVolume); void SetSynthVolume(double theVolume);
double SynthVolume(void) const; double SynthVolume(void) const;
void SetSampleVolume(double theVolume); void SetSampleVolume(double theVolume);
double SampleVolume(void) const; double SampleVolume(void) const;
/* display feedback information*/ /* display feedback information */
/* This will return the number of 16-bit samples stored into the pLeft*/ /* This will return the number of 16-bit samples stored into the pLeft*/
/* and pRight arrays. Usually 1024. This returns the current data*/ /* and pRight arrays. Usually 1024. This returns the current data*/
/* points being sent to the hardware.*/ /* points being sent to the hardware.*/
status_t GetAudio(int16 *pLeft, int16 *pRight, status_t GetAudio(
int32 max_samples) const; int16* pLeft, int16* pRight, int32 max_samples) const;
/* disengage from audio output streams*/ /* disengage from audio output streams*/
void Pause(void); void Pause(void);
/* reengage to audio output streams*/ /* reengage to audio output streams*/
void Resume(void); void Resume(void);
/* Set a call back on controller events*/ /* Set a call back on controller events*/
void SetControllerHook(int16 controller, void SetControllerHook(int16 controller, synth_controller_hook cback);
synth_controller_hook cback);
int32 CountClients(void) const;
private: int32 CountClients(void) const;
virtual void _ReservedSynth1(); private:
virtual void _ReservedSynth2();
virtual void _ReservedSynth3(); virtual void _ReservedSynth1();
virtual void _ReservedSynth4(); virtual void _ReservedSynth2();
virtual void _ReservedSynth3();
virtual void _ReservedSynth4();
friend BMidiSynth; friend BMidiSynth;
friend BMidiSynthFile; friend BMidiSynthFile;
int32 fClientCount; int32 fClientCount;
void _init(); void _init();
status_t _do_load(synth_mode synth); status_t _do_load(synth_mode synth);
status_t _load_insts(entry_ref *ref); status_t _load_insts(entry_ref* ref);
synth_mode fMode; synth_mode fMode;
int16 fMaxSynthVox; int16 fMaxSynthVox;
int16 fMaxSampleVox; int16 fMaxSampleVox;
int16 fLimiter; int16 fLimiter;
int32 fSRate; int32 fSRate;
interpolation_mode fInterp; interpolation_mode fInterp;
int32 fModifiers; int32 fModifiers;
reverb_mode fReverb; reverb_mode fReverb;
sem_id fSetupLock; sem_id fSetupLock;
uint32 _reserved[4]; uint32 _reserved[4];
}; };
extern _IMPEXP_MIDI BSynth *be_synth; extern _IMPEXP_MIDI BSynth* be_synth;
#endif // _SYNTH_H
#endif