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

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 <OS.h>
class BMidiEvent;
class BList;
class BMidi {
class BMidi
{
public:
BMidi();
virtual ~BMidi();
virtual void NoteOff(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,
virtual void NoteOff(
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 controlNumber, uchar controlValue,
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);
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);
virtual status_t Start();
virtual void Stop();
bool IsRunning() const;
void Connect(BMidi * to_object);
void Disconnect(BMidi * from_object);
bool IsConnected(BMidi * to_object) 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 SprayKeyPressure(uchar channel, uchar note,
uchar pressure, uint32 time) const;
void SprayControlChange(uchar channel, uchar control_number,
uchar control_value, uint32 time) const;
void SprayProgramChange(uchar channel, uchar program_number,
void SprayNoteOff(
uchar channel, uchar note, uchar velocity, uint32 time) const;
void SprayNoteOn(
uchar channel, uchar note, uchar velocity, uint32 time) const;
void SprayKeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time) const;
void SprayControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
uint32 time) const;
void SprayChannelPressure(uchar channel, uchar pressure,
uint32 time) const;
void SprayPitchBend(uchar channel, uchar lsb,
uchar msb, uint32 time) const;
void SpraySystemExclusive(void * data, size_t data_length,
uint32 time) const;
void SpraySystemCommon(uchar status_byte, uchar data1,
uchar data2, uint32 time) const;
void SpraySystemRealTime(uchar status_byte, uint32 time) const;
void SprayTempoChange(int32 beats_per_minute, uint32 time) const;
void SprayProgramChange(
uchar channel, uchar programNumber, uint32 time) const;
void SprayChannelPressure(
uchar channel, uchar pressure, uint32 time) const;
void SprayPitchBend(
uchar channel, uchar lsb, uchar msb, 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();
private:
virtual void Run();
void _Inflow();
void _SprayEvent(BMidiEvent *) const;
static int32 _RunThread(void * data);
static int32 _InflowThread(void * data);
private:
BList * _con_list;
thread_id _run_thread_id;
thread_id _inflow_thread_id;
port_id _inflow_port;
bool _is_running;
bool _is_inflowing;
bool _keep_running;
friend class BMidiStore;
virtual void _ReservedMidi1();
virtual void _ReservedMidi2();
virtual void _ReservedMidi3();
static int32 RunThread(void* data);
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

View File

@ -1,33 +1,50 @@
//-----------------------------------------------------------------------------
#ifndef _MIDI_DEFS_H_
#define _MIDI_DEFS_H_
#ifndef _MIDI_DEFS_H
#define _MIDI_DEFS_H
#include <OS.h>
#include <Errors.h>
//------------------------------------------------------------------------------
/* System time converted to int milliseconds */
#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 {
typedef enum synth_mode
{
B_NO_SYNTH,
B_BIG_SYNTH,
B_LITTLE_SYNTH,
B_DEFAULT_SYNTH,
B_SAMPLES_ONLY,
} synth_mode;
B_SAMPLES_ONLY
}
synth_mode;
enum {
//------------------------------------------------------------------------------
/* Need to move these into Errors.h */
enum
{
B_BAD_INSTRUMENT = B_MIDI_ERROR_BASE + 0x100,
B_BAD_MIDI_DATA,
B_ALREADY_PAUSED,
B_ALREADY_RESUMED,
B_NO_SONG_PLAYING,
B_TOO_MANY_SONGS_PLAYING,
B_TOO_MANY_SONGS_PLAYING
};
//------------------------------------------------------------------------------
#ifndef uchar
typedef unsigned char uchar;
#endif
@ -35,6 +52,7 @@ typedef unsigned char uchar;
#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;
@ -43,6 +61,7 @@ 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;
@ -57,13 +76,14 @@ 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;
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;
@ -96,9 +116,13 @@ const uchar B_POLY_MODE_ON = 0x7f;
const uchar B_TEMPO_CHANGE = 0x51;
#endif
#endif // _MIDI_CONSTANTS_
typedef enum midi_axe {
//------------------------------------------------------------------------------
typedef enum midi_axe
{
/* Pianos */
B_ACOUSTIC_GRAND=0,
B_BRIGHT_GRAND,
B_ELECTRIC_GRAND,
@ -107,6 +131,8 @@ typedef enum midi_axe {
B_ELECTRIC_PIANO_2,
B_HARPSICHORD,
B_CLAVICHORD,
/* Tuned Idiophones */
B_CELESTA,
B_GLOCKENSPIEL,
B_MUSIC_BOX,
@ -115,6 +141,8 @@ typedef enum midi_axe {
B_XYLOPHONE,
B_TUBULAR_BELLS,
B_DULCIMER,
/* Organs */
B_DRAWBAR_ORGAN,
B_PERCUSSIVE_ORGAN,
B_ROCK_ORGAN,
@ -123,6 +151,8 @@ typedef enum midi_axe {
B_ACCORDION,
B_HARMONICA,
B_TANGO_ACCORDION,
/* Guitars */
B_ACOUSTIC_GUITAR_NYLON,
B_ACOUSTIC_GUITAR_STEEL,
B_ELECTRIC_GUITAR_JAZZ,
@ -131,6 +161,8 @@ typedef enum midi_axe {
B_OVERDRIVEN_GUITAR,
B_DISTORTION_GUITAR,
B_GUITAR_HARMONICS,
/* Basses */
B_ACOUSTIC_BASS,
B_ELECTRIC_BASS_FINGER,
B_ELECTRIC_BASS_PICK,
@ -139,6 +171,8 @@ typedef enum midi_axe {
B_SLAP_BASS_2,
B_SYNTH_BASS_1,
B_SYNTH_BASS_2,
/* Strings */
B_VIOLIN,
B_VIOLA,
B_CELLO,
@ -147,6 +181,8 @@ typedef enum midi_axe {
B_PIZZICATO_STRINGS,
B_ORCHESTRAL_STRINGS,
B_TIMPANI,
/* Ensemble strings and voices */
B_STRING_ENSEMBLE_1,
B_STRING_ENSEMBLE_2,
B_SYNTH_STRINGS_1,
@ -155,6 +191,8 @@ typedef enum midi_axe {
B_VOICE_OOH,
B_SYNTH_VOICE,
B_ORCHESTRA_HIT,
/* Brass */
B_TRUMPET,
B_TROMBONE,
B_TUBA,
@ -163,6 +201,8 @@ typedef enum midi_axe {
B_BRASS_SECTION,
B_SYNTH_BRASS_1,
B_SYNTH_BRASS_2,
/* Reeds */
B_SOPRANO_SAX,
B_ALTO_SAX,
B_TENOR_SAX,
@ -171,6 +211,8 @@ typedef enum midi_axe {
B_ENGLISH_HORN,
B_BASSOON,
B_CLARINET,
/* Pipes */
B_PICCOLO,
B_FLUTE,
B_RECORDER,
@ -179,6 +221,8 @@ typedef enum midi_axe {
B_SHAKUHACHI,
B_WHISTLE,
B_OCARINA,
/* Synth Leads*/
B_LEAD_1,
B_SQUARE_WAVE = B_LEAD_1,
B_LEAD_2,
@ -195,6 +239,8 @@ typedef enum midi_axe {
B_FIFTHS = B_LEAD_7,
B_LEAD_8,
B_BASS_LEAD = B_LEAD_8,
/* Synth Pads */
B_PAD_1,
B_NEW_AGE = B_PAD_1,
B_PAD_2,
@ -211,6 +257,8 @@ typedef enum midi_axe {
B_HALO = B_PAD_7,
B_PAD_8,
B_SWEEP = B_PAD_8,
/* Effects */
B_FX_1,
B_FX_2,
B_FX_3,
@ -219,6 +267,8 @@ typedef enum midi_axe {
B_FX_6,
B_FX_7,
B_FX_8,
/* Ethnic */
B_SITAR,
B_BANJO,
B_SHAMISEN,
@ -227,6 +277,8 @@ typedef enum midi_axe {
B_BAGPIPE,
B_FIDDLE,
B_SHANAI,
/* Percussion */
B_TINKLE_BELL,
B_AGOGO,
B_STEEL_DRUMS,
@ -235,6 +287,8 @@ typedef enum midi_axe {
B_MELODIC_TOM,
B_SYNTH_DRUM,
B_REVERSE_CYMBAL,
/* Sound Effects */
B_FRET_NOISE,
B_BREATH_NOISE,
B_SEASHORE,
@ -243,6 +297,8 @@ typedef enum midi_axe {
B_HELICOPTER,
B_APPLAUSE,
B_GUNSHOT
} midi_axe;
}
midi_axe;
#endif // _MIDI_DEFS_H
#endif //_MIDI_DEFS_H_

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
#define _MIDI_PORT_H
@ -16,10 +7,8 @@
class BMidiLocalProducer;
class BMidiPortConsumer;
/*------------------------------------------------------------*/
class BMidiPort : public BMidi {
class BMidiPort : public BMidi
{
public:
BMidiPort(const char* name = NULL);
~BMidiPort();
@ -30,57 +19,43 @@ public:
const char* PortName() const;
virtual void NoteOff(uchar channel,
uchar note,
uchar velocity,
virtual void NoteOff(
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 controlNumber, uchar controlValue,
uint32 time = B_NOW);
virtual void NoteOn(uchar channel,
uchar note,
uchar velocity,
uint32 time = B_NOW);
virtual void ProgramChange(
uchar channel, uchar programNumber, uint32 time = B_NOW);
virtual void KeyPressure(uchar channel,
uchar note,
uchar pressure,
uint32 time = B_NOW);
virtual void ChannelPressure(
uchar channel, uchar pressure, uint32 time = B_NOW);
virtual void ControlChange(uchar channel,
uchar controlNumber,
uchar controlValue,
uint32 time = B_NOW);
virtual void PitchBend(
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
virtual void ProgramChange(uchar channel,
uchar programNumber,
uint32 time = B_NOW);
virtual void SystemExclusive(
void* data, size_t dataLength, uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel,
uchar pressure,
uint32 time = B_NOW);
virtual void SystemCommon(
uchar status, uchar data0, uchar data2, 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 statusByte,
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 status_t Start();
virtual void Stop();
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:
typedef BMidi _inherited;
@ -92,14 +67,19 @@ virtual void _ReservedMidiPort3();
virtual void Run();
friend class BMidiPortConsumer;
void Dispatch(const unsigned char * buffer, size_t size, bigtime_t when);
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();
// used to glue us to the new midi kit
BMidiProducer* remote_source;
BMidiConsumer* remote_sink;
BMidiLocalProducer* local_source;
BMidiPortConsumer* local_sink;
char* fName;
status_t fCStatus;
@ -107,12 +87,7 @@ friend class BMidiPortConsumer;
uint8 _m_prev_cmd;
bool _m_enhanced;
uint8 _m_reserved[2];
// used to glue us to the new midi kit
BMidiLocalProducer *local_source;
BMidiPortConsumer *local_sink;
};
/*------------------------------------------------------------*/
#endif // _MIDI_PORT_H
#endif

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 <List.h>
struct entry_ref;
class BMidiEvent;
class BFile;
class BMidiStore : public BMidi {
class BMidiEvent;
class BList;
class BMidiStore : public BMidi
{
public:
BMidiStore();
virtual ~BMidiStore();
virtual void NoteOff(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,
virtual void NoteOff(
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 controlNumber, uchar controlValue,
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);
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);
uint32 CountEvents() const;
uint32 CurrentEvent() const;
void SetCurrentEvent(uint32 event_number);
uint32 DeltaOfEvent(uint32 event_number) const;
void SetCurrentEvent(uint32 eventNumber);
uint32 DeltaOfEvent(uint32 eventNumber) const;
uint32 EventAtDelta(uint32 time) const;
uint32 BeginTime() const;
void SetTempo(int32 beats_per_minute);
void SetTempo(int32 beatsPerMinute);
int32 Tempo() const;
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:
BList * _evt_list;
uint32 _tempo;
uint32 _cur_evt;
uint32 _start_time;
uint32 _ticks_per_beat;
virtual void _ReservedMidiStore1();
virtual void _ReservedMidiStore2();
virtual void Run();
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

View File

@ -1,31 +1,18 @@
/*******************************************************************************
/
/ 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
#define _MIDI_SYNTH_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <Midi.h>
#include <Synth.h>
#include <MidiDefs.h>
class BMidiSynth : public BMidi
{
public:
BMidiSynth();
virtual ~BMidiSynth();
status_t EnableInput(bool enable, bool loadInstruments);
bool IsInputEnabled(void) const;
@ -58,38 +45,27 @@ public:
/* 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,
virtual void NoteOff(
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 controlNumber, uchar controlValue,
uint32 time = B_NOW);
virtual void NoteOn(uchar channel,
uchar note,
uchar velocity,
uint32 time = B_NOW);
virtual void ProgramChange(
uchar channel, uchar programNumber, uint32 time = B_NOW);
virtual void KeyPressure(uchar channel,
uchar note,
uchar pressure,
uint32 time = B_NOW);
virtual void ChannelPressure(
uchar channel, 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 PitchBend(
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
virtual void AllNotesOff(bool controlOnly, uint32 time = B_NOW);
@ -108,8 +84,10 @@ virtual void _ReservedMidiSynth4();
friend class BSynth;
virtual void Run();
bool fInputEnabled;
uint32 _reserved[4];
};
#endif
#endif // _MIDI_SYNTH_H

View File

@ -1,25 +1,13 @@
/*******************************************************************************
/
/ File: MidiSynthFile.h
/
/ Description: Send a MIDI file to the synthesizer.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _MIDI_SYNTH_FILE_H
#define _MIDI_SYNTH_FILE_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <MidiSynth.h>
#include <Entry.h>
typedef void (*synth_file_hook)(int32 arg);
class BMidiSynthFile : public BMidiSynth
{
public:
@ -33,14 +21,15 @@ public:
virtual void Stop(void);
void Fade(void);
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();
@ -49,6 +38,7 @@ public:
/* 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;
@ -56,9 +46,9 @@ public:
/* 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;
@ -83,4 +73,5 @@ friend class BSynth;
uint32 _reserved[4];
};
#endif
#endif // _MIDI_SYNTH_FILE

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 <stdio.h>
class BMidiText : public BMidi {
class BMidiText : public BMidi
{
public:
BMidiText();
virtual ~BMidiText();
virtual void NoteOff(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,
virtual void NoteOff(
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 controlNumber, uchar controlValue,
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);
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);
void ResetTimer(bool start = false);
private:
int32 _start_time;
private:
void _PrintTime();
virtual void _ReservedMidiText1();
virtual void Run();
void WaitAndPrint(uint32 time);
int32 startTime;
uint32 _reserved[4];
};
#endif _MIDI_TEXT_H_
#endif // _MIDI_TEXT_H

View File

@ -1,19 +1,8 @@
/*******************************************************************************
/
/ File: Samples.h
/
/ Description: Sound effects.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _SAMPLES_H
#define _SAMPLES_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <Entry.h>
typedef void (*sample_exit_hook)(int32 arg);
@ -26,7 +15,8 @@ public:
virtual ~BSamples();
/* start a sample playing */
void Start(void * sampleData, /* pointer to audio data*/
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*/
@ -49,7 +39,6 @@ public:
void SetVolume(double newVolume);
double Volume(void) const;
void SetSamplingRate(double newRate);
double SamplingRate(void) const;
@ -73,4 +62,5 @@ virtual void _ReservedSamples3();
uint32 _reserved[4];
};
#endif
#endif // _SAMPLES_H

View File

@ -1,19 +1,8 @@
/*******************************************************************************
/
/ File: Synth.h
/
/ Description: Interface to the General MIDI synthesizer.
/
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _SYNTH_H
#define _SYNTH_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <Entry.h>
#include <MidiDefs.h>
#include <OS.h>
@ -23,7 +12,8 @@ typedef enum interpolation_mode
B_DROP_SAMPLE = 0,
B_2_POINT_INTERPOLATION,
B_LINEAR_INTERPOLATION
} interpolation_mode;
}
interpolation_mode;
typedef enum reverb_mode
{
@ -33,11 +23,12 @@ typedef enum reverb_mode
B_REVERB_BALLROOM,
B_REVERB_CAVERN,
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 BMidiSynthFile;
@ -46,12 +37,7 @@ class BSynth
public:
BSynth();
BSynth(synth_mode synth);
#if !_PR3_COMPATIBLE_
virtual ~BSynth();
#else
~BSynth();
#endif
status_t LoadSynthData(entry_ref* instrumentsFile);
status_t LoadSynthData(synth_mode synth);
@ -74,8 +60,8 @@ virtual ~BSynth();
bool IsReverbEnabled() const;
/* change voice allocation */
status_t SetVoiceLimits(int16 maxSynthVoices,
int16 maxSampleVoices,
status_t SetVoiceLimits(
int16 maxSynthVoices, int16 maxSampleVoices,
int16 limiterThreshhold);
int16 MaxSynthVoices(void) const;
@ -94,17 +80,17 @@ virtual ~BSynth();
/* 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;
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);
void SetControllerHook(int16 controller, synth_controller_hook cback);
int32 CountClients(void) const;
@ -137,5 +123,5 @@ virtual void _ReservedSynth4();
extern _IMPEXP_MIDI BSynth* be_synth;
#endif // _SYNTH_H
#endif