Merged changes from branch build_system_redesign at revision 14573.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14574 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
|
||||
#ifndef _MIDI_H
|
||||
#define _MIDI_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <MidiDefs.h>
|
||||
#include <OS.h>
|
||||
|
||||
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);
|
||||
|
||||
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 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 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);
|
||||
|
||||
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;
|
||||
|
||||
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 controlNumber, uchar controlValue,
|
||||
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 length, 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:
|
||||
|
||||
friend status_t _run_thread(void* data);
|
||||
|
||||
virtual void _ReservedMidi1();
|
||||
virtual void _ReservedMidi2();
|
||||
virtual void _ReservedMidi3();
|
||||
|
||||
virtual void Run();
|
||||
|
||||
BMidiLocalProducer* producer;
|
||||
BMidiLocalConsumer* consumer;
|
||||
|
||||
BList* connections;
|
||||
volatile thread_id threadId;
|
||||
volatile bool isRunning;
|
||||
|
||||
uint8 _reserved1[3];
|
||||
uint32 _reserved2[5];
|
||||
};
|
||||
|
||||
#endif // _MIDI_H
|
||||
@@ -0,0 +1,302 @@
|
||||
|
||||
#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
|
||||
{
|
||||
B_NO_SYNTH,
|
||||
B_BIG_SYNTH,
|
||||
B_LITTLE_SYNTH,
|
||||
B_DEFAULT_SYNTH,
|
||||
B_SAMPLES_ONLY
|
||||
}
|
||||
synth_mode;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/* 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
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef uchar
|
||||
typedef unsigned char uchar;
|
||||
#endif
|
||||
|
||||
#ifndef _MIDI_CONSTANTS_
|
||||
#define _MIDI_CONSTANTS_
|
||||
|
||||
/* Channel Message Masks*/
|
||||
const uchar B_NOTE_OFF = 0x80;
|
||||
const uchar B_NOTE_ON = 0x90;
|
||||
const uchar B_KEY_PRESSURE = 0xa0;
|
||||
const uchar B_CONTROL_CHANGE = 0xb0;
|
||||
const uchar B_PROGRAM_CHANGE = 0xc0;
|
||||
const uchar B_CHANNEL_PRESSURE = 0xd0;
|
||||
const uchar B_PITCH_BEND = 0xe0;
|
||||
|
||||
/* System Messages*/
|
||||
const uchar B_SYS_EX_START = 0xf0;
|
||||
const uchar B_MIDI_TIME_CODE = 0xf1;
|
||||
const uchar B_SONG_POSITION = 0xf2;
|
||||
const uchar B_SONG_SELECT = 0xf3;
|
||||
const uchar B_CABLE_MESSAGE = 0xf5;
|
||||
const uchar B_TUNE_REQUEST = 0xf6;
|
||||
const uchar B_SYS_EX_END = 0xf7;
|
||||
const uchar B_TIMING_CLOCK = 0xf8;
|
||||
const uchar B_START = 0xfa;
|
||||
const uchar B_CONTINUE = 0xfb;
|
||||
const uchar B_STOP = 0xfc;
|
||||
const uchar B_ACTIVE_SENSING = 0xfe;
|
||||
const uchar B_SYSTEM_RESET = 0xff;
|
||||
|
||||
/* Controller Numbers*/
|
||||
const uchar B_MODULATION = 0x01;
|
||||
const uchar B_BREATH_CONTROLLER = 0x02;
|
||||
const uchar B_FOOT_CONTROLLER = 0x04;
|
||||
const uchar B_PORTAMENTO_TIME = 0x05;
|
||||
const uchar B_DATA_ENTRY = 0x06;
|
||||
const uchar B_MAIN_VOLUME = 0x07;
|
||||
const uchar B_MIDI_BALANCE = 0x08; /* used to be B_BALANCE */
|
||||
const uchar B_PAN = 0x0a;
|
||||
const uchar B_EXPRESSION_CTRL = 0x0b;
|
||||
const uchar B_GENERAL_CTRL_1 = 0x10;
|
||||
const uchar B_GENERAL_CTRL_2 = 0x11;
|
||||
const uchar B_GENERAL_CTRL_3 = 0x12;
|
||||
const uchar B_GENERAL_CTRL_4 = 0x13;
|
||||
const uchar B_SUSTAIN_PEDAL = 0x40;
|
||||
const uchar B_PORTAMENTO = 0x41;
|
||||
const uchar B_SOSTENUTO = 0x42;
|
||||
const uchar B_SOFT_PEDAL = 0x43;
|
||||
const uchar B_HOLD_2 = 0x45;
|
||||
const uchar B_GENERAL_CTRL_5 = 0x50;
|
||||
const uchar B_GENERAL_CTRL_6 = 0x51;
|
||||
const uchar B_GENERAL_CTRL_7 = 0x52;
|
||||
const uchar B_GENERAL_CTRL_8 = 0x53;
|
||||
const uchar B_EFFECTS_DEPTH = 0x5b;
|
||||
const uchar B_TREMOLO_DEPTH = 0x5c;
|
||||
const uchar B_CHORUS_DEPTH = 0x5d;
|
||||
const uchar B_CELESTE_DEPTH = 0x5e;
|
||||
const uchar B_PHASER_DEPTH = 0x5f;
|
||||
const uchar B_DATA_INCREMENT = 0x60;
|
||||
const uchar B_DATA_DECREMENT = 0x61;
|
||||
const uchar B_RESET_ALL_CONTROLLERS = 0x79;
|
||||
const uchar B_LOCAL_CONTROL = 0x7a;
|
||||
const uchar B_ALL_NOTES_OFF = 0x7b;
|
||||
const uchar B_OMNI_MODE_OFF = 0x7c;
|
||||
const uchar B_OMNI_MODE_ON = 0x7d;
|
||||
const uchar B_MONO_MODE_ON = 0x7e;
|
||||
const uchar B_POLY_MODE_ON = 0x7f;
|
||||
|
||||
const uchar B_TEMPO_CHANGE = 0x51;
|
||||
|
||||
#endif // _MIDI_CONSTANTS_
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
typedef enum midi_axe
|
||||
{
|
||||
/* Pianos */
|
||||
B_ACOUSTIC_GRAND=0,
|
||||
B_BRIGHT_GRAND,
|
||||
B_ELECTRIC_GRAND,
|
||||
B_HONKY_TONK,
|
||||
B_ELECTRIC_PIANO_1,
|
||||
B_ELECTRIC_PIANO_2,
|
||||
B_HARPSICHORD,
|
||||
B_CLAVICHORD,
|
||||
|
||||
/* Tuned Idiophones */
|
||||
B_CELESTA,
|
||||
B_GLOCKENSPIEL,
|
||||
B_MUSIC_BOX,
|
||||
B_VIBRAPHONE,
|
||||
B_MARIMBA,
|
||||
B_XYLOPHONE,
|
||||
B_TUBULAR_BELLS,
|
||||
B_DULCIMER,
|
||||
|
||||
/* Organs */
|
||||
B_DRAWBAR_ORGAN,
|
||||
B_PERCUSSIVE_ORGAN,
|
||||
B_ROCK_ORGAN,
|
||||
B_CHURCH_ORGAN,
|
||||
B_REED_ORGAN,
|
||||
B_ACCORDION,
|
||||
B_HARMONICA,
|
||||
B_TANGO_ACCORDION,
|
||||
|
||||
/* Guitars */
|
||||
B_ACOUSTIC_GUITAR_NYLON,
|
||||
B_ACOUSTIC_GUITAR_STEEL,
|
||||
B_ELECTRIC_GUITAR_JAZZ,
|
||||
B_ELECTRIC_GUITAR_CLEAN,
|
||||
B_ELECTRIC_GUITAR_MUTED,
|
||||
B_OVERDRIVEN_GUITAR,
|
||||
B_DISTORTION_GUITAR,
|
||||
B_GUITAR_HARMONICS,
|
||||
|
||||
/* Basses */
|
||||
B_ACOUSTIC_BASS,
|
||||
B_ELECTRIC_BASS_FINGER,
|
||||
B_ELECTRIC_BASS_PICK,
|
||||
B_FRETLESS_BASS,
|
||||
B_SLAP_BASS_1,
|
||||
B_SLAP_BASS_2,
|
||||
B_SYNTH_BASS_1,
|
||||
B_SYNTH_BASS_2,
|
||||
|
||||
/* Strings */
|
||||
B_VIOLIN,
|
||||
B_VIOLA,
|
||||
B_CELLO,
|
||||
B_CONTRABASS,
|
||||
B_TREMOLO_STRINGS,
|
||||
B_PIZZICATO_STRINGS,
|
||||
B_ORCHESTRAL_STRINGS,
|
||||
B_TIMPANI,
|
||||
|
||||
/* Ensemble strings and voices */
|
||||
B_STRING_ENSEMBLE_1,
|
||||
B_STRING_ENSEMBLE_2,
|
||||
B_SYNTH_STRINGS_1,
|
||||
B_SYNTH_STRINGS_2,
|
||||
B_VOICE_AAH,
|
||||
B_VOICE_OOH,
|
||||
B_SYNTH_VOICE,
|
||||
B_ORCHESTRA_HIT,
|
||||
|
||||
/* Brass */
|
||||
B_TRUMPET,
|
||||
B_TROMBONE,
|
||||
B_TUBA,
|
||||
B_MUTED_TRUMPET,
|
||||
B_FRENCH_HORN,
|
||||
B_BRASS_SECTION,
|
||||
B_SYNTH_BRASS_1,
|
||||
B_SYNTH_BRASS_2,
|
||||
|
||||
/* Reeds */
|
||||
B_SOPRANO_SAX,
|
||||
B_ALTO_SAX,
|
||||
B_TENOR_SAX,
|
||||
B_BARITONE_SAX,
|
||||
B_OBOE,
|
||||
B_ENGLISH_HORN,
|
||||
B_BASSOON,
|
||||
B_CLARINET,
|
||||
|
||||
/* Pipes */
|
||||
B_PICCOLO,
|
||||
B_FLUTE,
|
||||
B_RECORDER,
|
||||
B_PAN_FLUTE,
|
||||
B_BLOWN_BOTTLE,
|
||||
B_SHAKUHACHI,
|
||||
B_WHISTLE,
|
||||
B_OCARINA,
|
||||
|
||||
/* Synth Leads*/
|
||||
B_LEAD_1,
|
||||
B_SQUARE_WAVE = B_LEAD_1,
|
||||
B_LEAD_2,
|
||||
B_SAWTOOTH_WAVE = B_LEAD_2,
|
||||
B_LEAD_3,
|
||||
B_CALLIOPE = B_LEAD_3,
|
||||
B_LEAD_4,
|
||||
B_CHIFF = B_LEAD_4,
|
||||
B_LEAD_5,
|
||||
B_CHARANG = B_LEAD_5,
|
||||
B_LEAD_6,
|
||||
B_VOICE = B_LEAD_6,
|
||||
B_LEAD_7,
|
||||
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,
|
||||
B_WARM = B_PAD_2,
|
||||
B_PAD_3,
|
||||
B_POLYSYNTH = B_PAD_3,
|
||||
B_PAD_4,
|
||||
B_CHOIR = B_PAD_4,
|
||||
B_PAD_5,
|
||||
B_BOWED = B_PAD_5,
|
||||
B_PAD_6,
|
||||
B_METALLIC = B_PAD_6,
|
||||
B_PAD_7,
|
||||
B_HALO = B_PAD_7,
|
||||
B_PAD_8,
|
||||
B_SWEEP = B_PAD_8,
|
||||
|
||||
/* Effects */
|
||||
B_FX_1,
|
||||
B_FX_2,
|
||||
B_FX_3,
|
||||
B_FX_4,
|
||||
B_FX_5,
|
||||
B_FX_6,
|
||||
B_FX_7,
|
||||
B_FX_8,
|
||||
|
||||
/* Ethnic */
|
||||
B_SITAR,
|
||||
B_BANJO,
|
||||
B_SHAMISEN,
|
||||
B_KOTO,
|
||||
B_KALIMBA,
|
||||
B_BAGPIPE,
|
||||
B_FIDDLE,
|
||||
B_SHANAI,
|
||||
|
||||
/* Percussion */
|
||||
B_TINKLE_BELL,
|
||||
B_AGOGO,
|
||||
B_STEEL_DRUMS,
|
||||
B_WOODBLOCK,
|
||||
B_TAIKO_DRUMS,
|
||||
B_MELODIC_TOM,
|
||||
B_SYNTH_DRUM,
|
||||
B_REVERSE_CYMBAL,
|
||||
|
||||
/* Sound Effects */
|
||||
B_FRET_NOISE,
|
||||
B_BREATH_NOISE,
|
||||
B_SEASHORE,
|
||||
B_BIRD_TWEET,
|
||||
B_TELEPHONE,
|
||||
B_HELICOPTER,
|
||||
B_APPLAUSE,
|
||||
B_GUNSHOT
|
||||
}
|
||||
midi_axe;
|
||||
|
||||
#endif // _MIDI_DEFS_H
|
||||
@@ -0,0 +1,87 @@
|
||||
|
||||
#ifndef _MIDI_PORT_H
|
||||
#define _MIDI_PORT_H
|
||||
|
||||
#include <Midi.h>
|
||||
|
||||
namespace BPrivate { class BMidiPortGlue; }
|
||||
|
||||
class BMidiPort : public BMidi
|
||||
{
|
||||
public:
|
||||
|
||||
BMidiPort(const char* name = NULL);
|
||||
~BMidiPort();
|
||||
|
||||
status_t InitCheck() const;
|
||||
status_t Open(const char* name);
|
||||
void Close();
|
||||
|
||||
const char* PortName() const;
|
||||
|
||||
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 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 length, uint32 time = B_NOW);
|
||||
|
||||
virtual void SystemCommon(
|
||||
uchar status, uchar data0, uchar data2, 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);
|
||||
|
||||
private:
|
||||
|
||||
typedef BMidi super;
|
||||
|
||||
friend class BPrivate::BMidiPortGlue;
|
||||
|
||||
virtual void _ReservedMidiPort1();
|
||||
virtual void _ReservedMidiPort2();
|
||||
virtual void _ReservedMidiPort3();
|
||||
|
||||
virtual void Run();
|
||||
|
||||
void ScanDevices();
|
||||
void EmptyDeviceList();
|
||||
|
||||
BMidiLocalProducer* localSource;
|
||||
BMidiLocalConsumer* localSink;
|
||||
BMidiProducer* remoteSource;
|
||||
BMidiConsumer* remoteSink;
|
||||
|
||||
char* portName;
|
||||
status_t status;
|
||||
BList* devices;
|
||||
|
||||
uint32 _reserved[1];
|
||||
};
|
||||
|
||||
#endif // _MIDI_PORT_H
|
||||
@@ -0,0 +1,134 @@
|
||||
|
||||
#ifndef _MIDI_STORE_H
|
||||
#define _MIDI_STORE_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <Midi.h>
|
||||
#include <MidiSynthFile.h>
|
||||
|
||||
struct entry_ref;
|
||||
|
||||
class BFile;
|
||||
class BList;
|
||||
class BMidiEvent;
|
||||
|
||||
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 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 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);
|
||||
|
||||
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 eventNumber);
|
||||
|
||||
uint32 DeltaOfEvent(uint32 eventNumber) const;
|
||||
uint32 EventAtDelta(uint32 time) const;
|
||||
|
||||
uint32 BeginTime() const;
|
||||
|
||||
void SetTempo(int32 beatsPerMinute);
|
||||
int32 Tempo() const;
|
||||
|
||||
private:
|
||||
|
||||
friend class BMidiSynthFile;
|
||||
|
||||
virtual void _ReservedMidiStore1();
|
||||
virtual void _ReservedMidiStore2();
|
||||
virtual void _ReservedMidiStore3();
|
||||
|
||||
virtual void Run();
|
||||
|
||||
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;
|
||||
|
||||
BList* events;
|
||||
int32 currentEvent;
|
||||
uint32 startTime;
|
||||
int32 beatsPerMinute;
|
||||
int16 ticksPerBeat;
|
||||
bool needsSorting;
|
||||
|
||||
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();
|
||||
|
||||
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];
|
||||
|
||||
bool* instruments;
|
||||
synth_file_hook hookFunc;
|
||||
int32 hookArg;
|
||||
bool looping;
|
||||
bool paused;
|
||||
bool finished;
|
||||
|
||||
uint32 _reserved2[12];
|
||||
};
|
||||
|
||||
#endif // _MIDI_STORE_H
|
||||
@@ -0,0 +1,88 @@
|
||||
|
||||
#ifndef _MIDI_SYNTH_H
|
||||
#define _MIDI_SYNTH_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#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;
|
||||
|
||||
void SetVolume(double volume);
|
||||
double Volume(void) const;
|
||||
|
||||
void SetTransposition(int16 offset);
|
||||
int16 Transposition(void) const;
|
||||
|
||||
void MuteChannel(int16 channel, bool do_mute);
|
||||
void GetMuteMap(char* pChannels) const;
|
||||
|
||||
void SoloChannel(int16 channel, bool do_solo);
|
||||
void GetSoloMap(char* pChannels) const;
|
||||
|
||||
status_t LoadInstrument(int16 instrument);
|
||||
status_t UnloadInstrument(int16 instrument);
|
||||
status_t RemapInstrument(int16 from, int16 to);
|
||||
|
||||
void FlushInstrumentCache(bool startStopCache);
|
||||
|
||||
uint32 Tick(void) const;
|
||||
|
||||
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 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 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();
|
||||
|
||||
virtual void Run();
|
||||
|
||||
bigtime_t creationTime;
|
||||
int16 transpose;
|
||||
bool inputEnabled;
|
||||
|
||||
uint32 _reserved;
|
||||
};
|
||||
|
||||
#endif // _MIDI_SYNTH_H
|
||||
@@ -0,0 +1,65 @@
|
||||
|
||||
#ifndef _MIDI_SYNTH_FILE_H
|
||||
#define _MIDI_SYNTH_FILE_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <MidiSynth.h>
|
||||
#include <Entry.h>
|
||||
|
||||
typedef void (*synth_file_hook)(int32 arg);
|
||||
|
||||
class BMidiStore;
|
||||
|
||||
class BMidiSynthFile : public BMidiSynth
|
||||
{
|
||||
public:
|
||||
|
||||
BMidiSynthFile();
|
||||
~BMidiSynthFile();
|
||||
|
||||
status_t LoadFile(const entry_ref* midi_entry_ref);
|
||||
void UnloadFile(void);
|
||||
|
||||
virtual status_t Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
void Fade(void);
|
||||
void Pause(void);
|
||||
void Resume(void);
|
||||
|
||||
int32 Duration(void) const;
|
||||
int32 Position(int32 ticks) const;
|
||||
int32 Seek();
|
||||
|
||||
status_t GetPatches(int16* pArray768, int16* pReturnedCount) const;
|
||||
|
||||
void SetFileHook(synth_file_hook pSongHook, int32 arg);
|
||||
|
||||
bool IsFinished(void) const;
|
||||
|
||||
void ScaleTempoBy(double tempoFactor);
|
||||
void SetTempo(int32 newTempoBPM);
|
||||
int32 Tempo(void) const;
|
||||
|
||||
void EnableLooping(bool loop);
|
||||
|
||||
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:
|
||||
|
||||
friend class BSynth;
|
||||
|
||||
virtual void _ReservedMidiSynthFile1();
|
||||
virtual void _ReservedMidiSynthFile2();
|
||||
virtual void _ReservedMidiSynthFile3();
|
||||
|
||||
BMidiStore* store;
|
||||
|
||||
int32 _reserved[3];
|
||||
};
|
||||
|
||||
#endif // _MIDI_SYNTH_FILE
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
#ifndef _MIDI_TEXT_H
|
||||
#define _MIDI_TEXT_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <Midi.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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 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 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);
|
||||
|
||||
void ResetTimer(bool start = false);
|
||||
|
||||
private:
|
||||
|
||||
virtual void _ReservedMidiText1();
|
||||
virtual void _ReservedMidiText2();
|
||||
virtual void _ReservedMidiText3();
|
||||
|
||||
virtual void Run();
|
||||
|
||||
void WaitAndPrint(uint32 time);
|
||||
|
||||
uint32 startTime;
|
||||
uint32 _reserved[4];
|
||||
};
|
||||
|
||||
#endif // _MIDI_TEXT_H
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
|
||||
#ifndef _SAMPLES_H
|
||||
#define _SAMPLES_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <Entry.h>
|
||||
|
||||
typedef void (*sample_exit_hook)(int32 arg);
|
||||
typedef bool (*sample_loop_hook)(int32 arg);
|
||||
|
||||
class BSamples
|
||||
{
|
||||
public:
|
||||
|
||||
BSamples();
|
||||
virtual ~BSamples();
|
||||
|
||||
void Start(
|
||||
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);
|
||||
|
||||
bool IsPaused(void) const;
|
||||
void Pause(void);
|
||||
void Resume(void);
|
||||
void Stop(void);
|
||||
bool IsPlaying(void) const;
|
||||
|
||||
void SetVolume(double newVolume);
|
||||
double Volume(void) const;
|
||||
|
||||
void SetSamplingRate(double newRate);
|
||||
double SamplingRate(void) const;
|
||||
|
||||
void SetPlacement(double stereoPosition);
|
||||
double Placement(void) const;
|
||||
|
||||
void EnableReverb(bool useReverb);
|
||||
|
||||
private:
|
||||
|
||||
virtual void _ReservedSamples1();
|
||||
virtual void _ReservedSamples2();
|
||||
virtual void _ReservedSamples3();
|
||||
|
||||
uint32 _reserved[8];
|
||||
};
|
||||
|
||||
#endif // _SAMPLES_H
|
||||
@@ -0,0 +1,109 @@
|
||||
|
||||
#ifndef _SYNTH_H
|
||||
#define _SYNTH_H
|
||||
|
||||
#include <BeBuild.h>
|
||||
#include <Entry.h>
|
||||
#include <MidiDefs.h>
|
||||
#include <OS.h>
|
||||
|
||||
typedef enum interpolation_mode
|
||||
{
|
||||
B_DROP_SAMPLE = 0,
|
||||
B_2_POINT_INTERPOLATION,
|
||||
B_LINEAR_INTERPOLATION
|
||||
}
|
||||
interpolation_mode;
|
||||
|
||||
typedef enum reverb_mode
|
||||
{
|
||||
B_REVERB_NONE = 1,
|
||||
B_REVERB_CLOSET,
|
||||
B_REVERB_GARAGE,
|
||||
B_REVERB_BALLROOM,
|
||||
B_REVERB_CAVERN,
|
||||
B_REVERB_DUNGEON
|
||||
}
|
||||
reverb_mode;
|
||||
|
||||
typedef void (*synth_controller_hook) (
|
||||
int16 channel, int16 controller, int16 value);
|
||||
|
||||
class BMidiSynth;
|
||||
class BMidiSynthFile;
|
||||
|
||||
namespace BPrivate { class BSoftSynth; }
|
||||
|
||||
class BSynth
|
||||
{
|
||||
public:
|
||||
|
||||
BSynth();
|
||||
BSynth(synth_mode synth);
|
||||
virtual ~BSynth();
|
||||
|
||||
status_t LoadSynthData(entry_ref* instrumentsFile);
|
||||
status_t LoadSynthData(synth_mode synth);
|
||||
synth_mode SynthMode(void);
|
||||
|
||||
void Unload(void);
|
||||
bool IsLoaded(void) const;
|
||||
|
||||
status_t SetSamplingRate(int32 sample_rate);
|
||||
int32 SamplingRate() const;
|
||||
|
||||
status_t SetInterpolation(interpolation_mode interp_mode);
|
||||
interpolation_mode Interpolation() const;
|
||||
|
||||
void SetReverb(reverb_mode rev_mode);
|
||||
reverb_mode Reverb() const;
|
||||
|
||||
status_t EnableReverb(bool reverb_enabled);
|
||||
bool IsReverbEnabled() const;
|
||||
|
||||
status_t SetVoiceLimits(
|
||||
int16 maxSynthVoices, int16 maxSampleVoices,
|
||||
int16 limiterThreshhold);
|
||||
|
||||
int16 MaxSynthVoices(void) const;
|
||||
int16 MaxSampleVoices(void) const;
|
||||
int16 LimiterThreshhold(void) const;
|
||||
|
||||
void SetSynthVolume(double theVolume);
|
||||
double SynthVolume(void) const;
|
||||
|
||||
void SetSampleVolume(double theVolume);
|
||||
double SampleVolume(void) const;
|
||||
|
||||
status_t GetAudio(
|
||||
int16* pLeft, int16* pRight, int32 max_samples) const;
|
||||
|
||||
void Pause(void);
|
||||
void Resume(void);
|
||||
|
||||
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();
|
||||
|
||||
void Init();
|
||||
|
||||
BPrivate::BSoftSynth* synth;
|
||||
synth_mode synthMode;
|
||||
int32 clientCount;
|
||||
|
||||
uint32 _reserved[10];
|
||||
};
|
||||
|
||||
extern _IMPEXP_MIDI BSynth* be_synth;
|
||||
|
||||
#endif // _SYNTH_H
|
||||
Reference in New Issue
Block a user