Cleaned up libmidi. Added stubs for missing classes and made the

existing classes binary compatible. To achieve this, I copied the
original Be headers and backported Paul Stadler's original code.
I also merged Jerome Leveque's changes from the VeryLotOfChange
subdir, which is now no longer needed. Of course, I could not stop
myself from changing the coding style in the heat of the moment.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1818 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
mahlzeit
2002-11-01 15:07:39 +00:00
parent 5849a93fb8
commit 6ba6040582
11 changed files with 1965 additions and 985 deletions
+6
View File
@@ -6,12 +6,18 @@ UsePublicHeaders midi ;
SharedLibrary midi :
Midi.cpp
MidiPort.cpp
MidiStore.cpp
MidiSynth.cpp
MidiSynthFile.cpp
MidiText.cpp
MidiEvent.cpp
Samples.cpp
Synth.cpp
;
LinkSharedOSLibs libmidi.so :
be
stdc++.r4
midi2
;
+404 -292
View File
@@ -1,334 +1,446 @@
//-----------------------------------------------------------------------------
//
#include <Midi.h>
/**
* @file Midi.cpp
*
* @author Matthijs Hollemans
* @author Jerome Leveque
* @author Paul Stadler
*/
#include <List.h>
#include <iostream.h>
#include "debug.h"
#include "Midi.h"
#include "MidiEvent.h"
#define MSG_CODE_PROCESS_EVENT 1
#define MSG_CODE_TERMINATE_THREAD 0
#define MSG_CODE_PROCESS_EVENT 1
#define MSG_CODE_TERMINATE_THREAD 0
//-----------------------------------------------------------------------------
// Initialization Stuff
BMidi::BMidi() {
_con_list = new BList();
_is_running = false;
_is_inflowing = false;
_inflow_port = create_port(1,"Inflow Port");
_inflow_thread_id = spawn_thread(_InflowThread,
"BMidi Inflow Thread", B_REAL_TIME_PRIORITY, (void *)this);
status_t ret = resume_thread(_inflow_thread_id);
//------------------------------------------------------------------------------
BMidi::BMidi()
{
connections = new BList();
isRunning = false;
inflowPort = create_port(1, "Inflow Port");
inflowThread = spawn_thread(
InflowThread, "BMidi Inflow Thread",
B_REAL_TIME_PRIORITY, (void*) this);
inflowAlive = (resume_thread(inflowThread) == B_OK);
}
BMidi::~BMidi() {
status_t exit_value;
write_port(_inflow_port,MSG_CODE_TERMINATE_THREAD,NULL,0);
wait_for_thread(_inflow_thread_id,&exit_value);
delete_port(_inflow_port);
delete _con_list;
//------------------------------------------------------------------------------
BMidi::~BMidi()
{
write_port(inflowPort, MSG_CODE_TERMINATE_THREAD, NULL, 0);
status_t exitValue;
wait_for_thread(inflowThread, &exitValue);
delete_port(inflowPort);
delete connections;
}
//-----------------------------------------------------------------------------
// Stubs for midi event hooks.
void BMidi::NoteOff(uchar chan, uchar note, uchar vel, uint32 time) {
}
void BMidi::NoteOn(uchar chan, uchar note, uchar vel, uint32 time) {
}
void BMidi::KeyPressure(uchar chan, uchar note, uchar pres, uint32 time) {
}
void BMidi::ControlChange(uchar chan, uchar ctrl_num, uchar ctrl_val,
uint32 time) {
}
void BMidi::ProgramChange(uchar chan, uchar prog_num, uint32 time) {
}
void BMidi::ChannelPressure(uchar chan, uchar pres, uint32 time) {
}
void BMidi::PitchBend(uchar chan, uchar lsb, uchar msb, uint32 time) {
}
void BMidi::SystemExclusive(void * data, size_t data_len, uint32 time) {
}
void BMidi::SystemCommon(uchar stat_byte, uchar data1, uchar data2,
uint32 time) {
}
void BMidi::SystemRealTime(uchar stat_byte, uint32 time) {
}
void BMidi::TempoChange(int32 bpm, uint32 time) {
}
void BMidi::AllNotesOff(bool just_chan, uint32 time) {
}
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Public API Functions
status_t BMidi::Start() {
_keep_running = true;
_run_thread_id = spawn_thread(_RunThread,
"BMidi Run Thread", B_REAL_TIME_PRIORITY, (void *)this);
status_t ret = resume_thread(_run_thread_id);
if(ret != B_OK) {
return ret;
void BMidi::NoteOff(uchar, uchar, uchar, uint32) { }
void BMidi::NoteOn(uchar, uchar, uchar, uint32) { }
void BMidi::KeyPressure(uchar, uchar, uchar, uint32) { }
void BMidi::ControlChange(uchar, uchar, uchar, uint32) { }
void BMidi::ProgramChange(uchar, uchar, uint32) { }
void BMidi::ChannelPressure(uchar, uchar, uint32) { }
void BMidi::PitchBend(uchar, uchar, uchar, uint32) { }
void BMidi::SystemExclusive(void*, size_t, uint32) { }
void BMidi::SystemCommon(uchar, uchar, uchar, uint32) { }
void BMidi::SystemRealTime(uchar, uint32) { }
void BMidi::TempoChange(int32, uint32) { }
void BMidi::AllNotesOff(bool, uint32) { }
//------------------------------------------------------------------------------
status_t BMidi::Start()
{
runThread = spawn_thread(
RunThread, "BMidi Run Thread",
B_REAL_TIME_PRIORITY, (void*) this);
status_t ret = resume_thread(runThread);
if (ret == B_OK)
{
isRunning = true;
}
_is_running = true;
return B_OK;
return ret;
}
void BMidi::Stop() {
_keep_running = false;
status_t exit_value;
status_t ret;
ret = wait_for_thread(_run_thread_id,&exit_value);
_is_running = false;
}
bool BMidi::IsRunning() const {
thread_info info;
get_thread_info(_run_thread_id,&info);
if(find_thread("BMidi Run Thread") == _run_thread_id) {
return true;
}
return false;
//------------------------------------------------------------------------------
void BMidi::Stop()
{
status_t exitValue;
wait_for_thread(runThread, &exitValue);
isRunning = false;
}
void BMidi::Connect(BMidi * to_object) {
_con_list->AddItem((void *)to_object);
//------------------------------------------------------------------------------
bool BMidi::IsRunning() const
{
return isRunning;
}
void BMidi::Disconnect(BMidi * from_object) {
_con_list->RemoveItem((void *)from_object);
//------------------------------------------------------------------------------
void BMidi::Connect(BMidi* toObject)
{
connections->AddItem(toObject);
}
bool BMidi::IsConnected(BMidi * to_object) const {
return _con_list->HasItem((void *)to_object);
//------------------------------------------------------------------------------
void BMidi::Disconnect(BMidi* fromObject)
{
connections->RemoveItem(fromObject);
}
BList * BMidi::Connections() const {
return _con_list;
//------------------------------------------------------------------------------
bool BMidi::IsConnected(BMidi* toObject) const
{
return connections->HasItem(toObject);
}
void BMidi::SnoozeUntil(uint32 time) const {
snooze_until((uint64)time*1000,B_SYSTEM_TIMEBASE);
//------------------------------------------------------------------------------
BList* BMidi::Connections() const
{
return connections;
}
bool BMidi::KeepRunning() {
return _keep_running;
//------------------------------------------------------------------------------
void BMidi::SnoozeUntil(uint32 time) const
{
snooze_until((uint64) time * 1000, B_SYSTEM_TIMEBASE);
}
void BMidi::Run() {
while(KeepRunning()) {
//------------------------------------------------------------------------------
void BMidi::SprayNoteOff(
uchar channel, uchar note, uchar velocity, uint32 time) const
{
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_NOTE_OFF;
event.noteOff.channel = channel;
event.noteOff.note = note;
event.noteOff.velocity = velocity;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
void BMidi::SprayNoteOn(
uchar channel, uchar note, uchar velocity, uint32 time) const
{
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_NOTE_ON;
event.noteOn.channel = channel;
event.noteOn.note = note;
event.noteOn.velocity = velocity;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
void BMidi::SprayKeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time) const
{
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_KEY_PRESSURE;
event.keyPressure.channel = channel;
event.keyPressure.note = note;
event.keyPressure.pressure = pressure;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
void BMidi::SprayControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
uint32 time) const
{
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_CONTROL_CHANGE;
event.controlChange.channel = channel;
event.controlChange.controlNumber = controlNumber;
event.controlChange.controlValue = controlValue;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
void BMidi::SprayProgramChange(
uchar channel, uchar programNumber, uint32 time) const
{
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_PROGRAM_CHANGE;
event.programChange.channel = channel;
event.programChange.programNumber = programNumber;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
void BMidi::SprayChannelPressure(
uchar channel, uchar pressure, uint32 time) const
{
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_CHANNEL_PRESSURE;
event.channelPressure.channel = channel;
event.channelPressure.pressure = pressure;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
void BMidi::SprayPitchBend(
uchar channel, uchar lsb, uchar msb, uint32 time) const
{
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_PITCH_BEND;
event.pitchBend.channel = channel;
event.pitchBend.lsb = lsb;
event.pitchBend.msb = msb;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
void BMidi::SpraySystemExclusive(
void* data, size_t dataLength, uint32 time) const
{
//TODO: Should this data be duplicated!!??
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_SYSTEM_EXCLUSIVE;
event.systemExclusive.data = (uint8*) data;
event.systemExclusive.dataLength = dataLength;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
void BMidi::SpraySystemCommon(
uchar status, uchar data1, uchar data2, uint32 time) const
{
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_SYSTEM_COMMON;
event.systemCommon.status = status;
event.systemCommon.data1 = data1;
event.systemCommon.data2 = data2;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
void BMidi::SpraySystemRealTime(uchar status, uint32 time) const
{
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_SYSTEM_REAL_TIME;
event.systemRealTime.status = status;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
void BMidi::SprayTempoChange(int32 beatsPerMinute, uint32 time) const
{
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_TEMPO_CHANGE;
event.tempoChange.beatsPerMinute = beatsPerMinute;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
bool BMidi::KeepRunning()
{
return isRunning;
}
//------------------------------------------------------------------------------
void BMidi::_ReservedMidi1() { }
void BMidi::_ReservedMidi2() { }
void BMidi::_ReservedMidi3() { }
//------------------------------------------------------------------------------
void BMidi::Run()
{
while (KeepRunning())
{
snooze(50000);
}
}
//-----------------------------------------------------------------------------
// Spray Functions
void BMidi::_SprayEvent(BMidiEvent * e) const {
int32 num_connections = _con_list->CountItems();
BMidi * m;
cerr << "SprayEvent time = " << e->time << " cur_time " << B_NOW << endl;
for(int32 i = 0; i < num_connections; i++) {
m = (BMidi *)_con_list->ItemAt(i);
write_port(m->_inflow_port,MSG_CODE_PROCESS_EVENT,e,sizeof(*e));
}
}
//------------------------------------------------------------------------------
void BMidi::SprayNoteOff(uchar chan, uchar note, uchar vel,
uint32 time) const {
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_NOTE_OFF;
e.data.note_off.channel = chan;
e.data.note_off.note = note;
e.data.note_off.velocity = vel;
_SprayEvent(&e);
}
void BMidi::SprayNoteOn(uchar chan, uchar note, uchar vel,
uint32 time) const {
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_NOTE_ON;
e.data.note_on.channel = chan;
e.data.note_on.note = note;
e.data.note_on.velocity = vel;
_SprayEvent(&e);
}
void BMidi::SprayKeyPressure(uchar chan, uchar note, uchar pres,
uint32 time) const {
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_NOTE_OFF;
e.data.key_pressure.channel = chan;
e.data.key_pressure.note = note;
e.data.key_pressure.pressure = pres;
_SprayEvent(&e);
}
void BMidi::SprayControlChange(uchar chan, uchar ctrl_num, uchar ctrl_val,
uint32 time) const {
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_CONTROL_CHANGE;
e.data.control_change.channel = chan;
e.data.control_change.number = ctrl_num;
e.data.control_change.value = ctrl_val;
_SprayEvent(&e);
}
void BMidi::SprayProgramChange(uchar chan, uchar prog_num,
uint32 time) const {
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_PROGRAM_CHANGE;
e.data.program_change.channel = chan;
e.data.program_change.number = prog_num;
_SprayEvent(&e);
}
void BMidi::SprayChannelPressure(uchar chan, uchar pres,
uint32 time) const {
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_CHANNEL_PRESSURE;
e.data.channel_pressure.channel = chan;
e.data.channel_pressure.pressure = pres;
_SprayEvent(&e);
}
void BMidi::SprayPitchBend(uchar chan, uchar lsb, uchar msb,
uint32 time) const {
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_PITCH_BEND;
e.data.pitch_bend.channel = chan;
e.data.pitch_bend.lsb = lsb;
e.data.pitch_bend.msb = msb;
_SprayEvent(&e);
}
void BMidi::SpraySystemExclusive(void * data, size_t data_len,
uint32 time) const {
// Should this data be duplicated!!??
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_SYSTEM_EXCLUSIVE;
e.data.system_exclusive.data = (uint8 *)data;
e.data.system_exclusive.length = data_len;
_SprayEvent(&e);
}
void BMidi::SpraySystemCommon(uchar stat_byte, uchar data1, uchar data2,
uint32 time) const {
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_SYSTEM_COMMON;
e.data.system_common.status = stat_byte;
e.data.system_common.data1 = data1;
e.data.system_common.data2 = data2;
_SprayEvent(&e);
}
void BMidi::SpraySystemRealTime(uchar stat_byte, uint32 time) const {
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_SYSTEM_REAL_TIME;
e.data.system_real_time.status = stat_byte;
_SprayEvent(&e);
}
void BMidi::SprayTempoChange(int32 bpm, uint32 time) const {
BMidiEvent e;
e.time = time;
e.opcode = BMidiEvent::OP_TEMPO_CHANGE;
e.data.tempo_change.beats_per_minute = bpm;
_SprayEvent(&e);
}
//-----------------------------------------------------------------------------
// The Inflow Thread
void BMidi::_Inflow() {
BMidiEvent e;
void BMidi::Inflow()
{
BMidiEvent event;
int32 code;
size_t len;
while(true) {
len = read_port(_inflow_port,&code,&e,sizeof(e));
if (len < 0) continue; // ignore errors
if(code == MSG_CODE_TERMINATE_THREAD) return;
if (len != sizeof(e)) continue; // ignore data in wrong size
// Otherwise we process an event.
switch(e.opcode) {
case BMidiEvent::OP_NONE:
case BMidiEvent::OP_TRACK_END:
case BMidiEvent::OP_ALL_NOTES_OFF:
break;
case BMidiEvent::OP_NOTE_OFF:
NoteOff(e.data.note_off.channel,
e.data.note_off.note,
e.data.note_off.velocity,
e.time);
break;
case BMidiEvent::OP_NOTE_ON:
NoteOff(e.data.note_on.channel,
e.data.note_on.note,
e.data.note_on.velocity,
e.time);
break;
case BMidiEvent::OP_KEY_PRESSURE:
KeyPressure(e.data.key_pressure.channel,
e.data.key_pressure.note,
e.data.key_pressure.pressure,
e.time);
break;
case BMidiEvent::OP_CONTROL_CHANGE:
ControlChange(e.data.control_change.channel,
e.data.control_change.number,
e.data.control_change.value,
e.time);
break;
case BMidiEvent::OP_PROGRAM_CHANGE:
ProgramChange(e.data.program_change.channel,
e.data.program_change.number,
e.time);
break;
case BMidiEvent::OP_CHANNEL_PRESSURE:
ChannelPressure(e.data.channel_pressure.channel,
e.data.channel_pressure.pressure,
e.time);
break;
case BMidiEvent::OP_PITCH_BEND:
PitchBend(e.data.pitch_bend.channel,
e.data.pitch_bend.lsb,
e.data.pitch_bend.msb,
e.time);
break;
case BMidiEvent::OP_SYSTEM_EXCLUSIVE:
SystemExclusive(e.data.system_exclusive.data,
e.data.system_exclusive.length,
e.time);
break;
case BMidiEvent::OP_SYSTEM_COMMON:
SystemCommon(e.data.system_common.status,
e.data.system_common.data1,
e.data.system_common.data2,
e.time);
break;
case BMidiEvent::OP_SYSTEM_REAL_TIME:
SystemRealTime(e.data.system_real_time.status, e.time);
break;
case BMidiEvent::OP_TEMPO_CHANGE:
TempoChange(e.data.tempo_change.beats_per_minute, e.time);
break;
default:
break;
while (true)
{
len = read_port(inflowPort, &code, &event, sizeof(event));
if (len != sizeof(event)) { continue; } // ignore errors
if (code == MSG_CODE_TERMINATE_THREAD) { return; }
switch (event.opcode)
{
case BMidiEvent::OP_NONE:
case BMidiEvent::OP_TRACK_END:
case BMidiEvent::OP_ALL_NOTES_OFF:
break;
case BMidiEvent::OP_NOTE_OFF:
NoteOff(
event.noteOff.channel,
event.noteOff.note,
event.noteOff.velocity,
event.time);
break;
case BMidiEvent::OP_NOTE_ON:
NoteOff(
event.noteOn.channel,
event.noteOn.note,
event.noteOn.velocity,
event.time);
break;
case BMidiEvent::OP_KEY_PRESSURE:
KeyPressure(
event.keyPressure.channel,
event.keyPressure.note,
event.keyPressure.pressure,
event.time);
break;
case BMidiEvent::OP_CONTROL_CHANGE:
ControlChange(
event.controlChange.channel,
event.controlChange.controlNumber,
event.controlChange.controlValue,
event.time);
break;
case BMidiEvent::OP_PROGRAM_CHANGE:
ProgramChange(
event.programChange.channel,
event.programChange.programNumber,
event.time);
break;
case BMidiEvent::OP_CHANNEL_PRESSURE:
ChannelPressure(
event.channelPressure.channel,
event.channelPressure.pressure,
event.time);
break;
case BMidiEvent::OP_PITCH_BEND:
PitchBend(
event.pitchBend.channel,
event.pitchBend.lsb,
event.pitchBend.msb,
event.time);
break;
case BMidiEvent::OP_SYSTEM_EXCLUSIVE:
SystemExclusive(
event.systemExclusive.data,
event.systemExclusive.dataLength,
event.time);
break;
case BMidiEvent::OP_SYSTEM_COMMON:
SystemCommon(
event.systemCommon.status,
event.systemCommon.data1,
event.systemCommon.data2,
event.time);
break;
case BMidiEvent::OP_SYSTEM_REAL_TIME:
SystemRealTime(
event.systemRealTime.status,
event.time);
break;
case BMidiEvent::OP_TEMPO_CHANGE:
TempoChange(
event.tempoChange.beatsPerMinute,
event.time);
break;
default: break;
}
}
}
int32 BMidi::_RunThread(void * data) {
((BMidi *)data)->Run();
//------------------------------------------------------------------------------
void BMidi::SprayMidiEvent(BMidiEvent* event) const
{
TRACE(("[midi] BMidi::SprayMidiEvent, event time = %u, "
"current time = %u\n", event->time, B_NOW))
int32 count = connections->CountItems();
for (int32 i = 0; i < count; ++i)
{
write_port(
((BMidi*) connections->ItemAt(i))->inflowPort,
MSG_CODE_PROCESS_EVENT, event, sizeof(*event));
}
}
//------------------------------------------------------------------------------
int32 BMidi::RunThread(void* data)
{
((BMidi*) data)->Run();
return 0;
}
int32 BMidi::_InflowThread(void * data) {
((BMidi *)data)->_Inflow();
//------------------------------------------------------------------------------
int32 BMidi::InflowThread(void* data)
{
((BMidi*) data)->Inflow();
return 0;
}
//------------------------------------------------------------------------------
+18 -4
View File
@@ -1,10 +1,24 @@
//-----------------------------------------------------------------------------
//
/**
* @file MidiEvent.cpp
*
* @author Matthijs Hollemans
* @author Paul Stadler
*/
#include "MidiEvent.h"
BMidiEvent::BMidiEvent() {
//------------------------------------------------------------------------------
BMidiEvent::BMidiEvent()
{
opcode = OP_NONE;
}
BMidiEvent::~BMidiEvent() {
//------------------------------------------------------------------------------
BMidiEvent::~BMidiEvent()
{
}
//------------------------------------------------------------------------------
+111 -64
View File
@@ -1,16 +1,26 @@
//-----------------------------------------------------------------------------
//
#ifndef _MIDI_EVENT_H_
#define _MIDI_EVENT_H_
/**
* @file MidiEvent.h
*
* @author Matthijs Hollemans
* @author Paul Stadler
*/
#include <MidiDefs.h>
#ifndef _MIDI_EVENT_H
#define _MIDI_EVENT_H
class BMidiEvent {
#include "MidiDefs.h"
/**
* Describes a MIDI message and its attributes.
*/
class BMidiEvent
{
public:
BMidiEvent();
~BMidiEvent();
enum Opcode {
enum
{
OP_NONE,
OP_NOTE_OFF,
OP_NOTE_ON,
@@ -25,64 +35,101 @@ public:
OP_TEMPO_CHANGE,
OP_ALL_NOTES_OFF,
OP_TRACK_END,
OP_NUM
};
}
opcode;
uint32 time;
Opcode opcode;
union Data {
struct NoteOffData {
uint8 channel;
uint8 note;
uint8 velocity;
} note_off;
struct NoteOnData {
uint8 channel;
uint8 note;
uint8 velocity;
} note_on;
struct KeyPressureData {
uint8 channel;
uint8 note;
uint8 pressure;
} key_pressure;
struct ControlChangeData {
uint8 channel;
uint8 number;
uint8 value;
} control_change;
struct ProgramChangeData {
uint8 channel;
uint8 number;
} program_change;
struct ChannelPressureData {
uint8 channel;
uint8 pressure;
} channel_pressure;
struct PitchBendData {
uint8 channel;
uint8 lsb;
uint8 msb;
} pitch_bend;
struct SystemExclusiveData {
uint8 * data;
int32 length;
} system_exclusive;
struct SystemCommonData {
uint8 status;
uint8 data1;
uint8 data2;
} system_common;
struct SystemRealTimeData {
uint8 status;
} system_real_time;
struct TempoChangeData {
uint32 beats_per_minute;
} tempo_change;
struct AllNotesOffData {
bool just_channel;
} all_notes_off;
} data;
union
{
struct
{
uchar channel;
uchar note;
uchar velocity;
}
noteOff;
struct
{
uchar channel;
uchar note;
uchar velocity;
}
noteOn;
struct
{
uchar channel;
uchar note;
uchar pressure;
}
keyPressure;
struct
{
uchar channel;
uchar controlNumber;
uchar controlValue;
}
controlChange;
struct
{
uchar channel;
uchar programNumber;
}
programChange;
struct
{
uchar channel;
uchar pressure;
}
channelPressure;
struct
{
uchar channel;
uchar lsb;
uchar msb;
}
pitchBend;
struct
{
uint8* data;
size_t dataLength;
}
systemExclusive;
struct
{
uchar status;
uchar data1;
uchar data2;
}
systemCommon;
struct
{
uchar status;
}
systemRealTime;
struct
{
uint32 beatsPerMinute;
}
tempoChange;
struct
{
bool justChannel;
}
allNotesOff;
};
};
#endif _MIDI_EVENT_H_
#endif _MIDI_EVENT_H
+207
View File
@@ -0,0 +1,207 @@
/**
* @file MidiPort.cpp
*
* @author Matthijs Hollemans
*/
#include "debug.h"
#include "MidiPort.h"
//------------------------------------------------------------------------------
BMidiPort::BMidiPort(const char* name)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
BMidiPort::~BMidiPort()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
status_t BMidiPort::InitCheck() const
{
UNIMPLEMENTED
return B_NO_INIT;
}
//------------------------------------------------------------------------------
status_t BMidiPort::Open(const char* name)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
void BMidiPort::Close()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
const char* BMidiPort::PortName() const
{
UNIMPLEMENTED
return NULL;
}
//------------------------------------------------------------------------------
void BMidiPort::NoteOff(
uchar channel, uchar note, uchar velocity, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiPort::NoteOn(
uchar channel, uchar note, uchar velocity, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiPort::KeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiPort::ControlChange(
uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiPort::ProgramChange(
uchar channel, uchar programNumber, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiPort::ChannelPressure(uchar channel, uchar pressure, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiPort::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiPort::SystemExclusive(void* data, size_t dataLength, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiPort::SystemCommon(
uchar status, uchar data1, uchar data2, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiPort::SystemRealTime(uchar status, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
status_t BMidiPort::Start()
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
void BMidiPort::Stop()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
int32 BMidiPort::CountDevices()
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
status_t BMidiPort::GetDeviceName(int32 n, char* name, size_t bufSize)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
void BMidiPort::_ReservedMidiPort1() { }
void BMidiPort::_ReservedMidiPort2() { }
void BMidiPort::_ReservedMidiPort3() { }
//------------------------------------------------------------------------------
void BMidiPort::Run()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiPort::Dispatch(
const unsigned char* buffer, size_t size, bigtime_t when)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
ssize_t BMidiPort::Read(void* buffer, size_t numBytes) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
ssize_t BMidiPort::Write(void* buffer, size_t numBytes, uint32 time) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
void BMidiPort::ScanDevices()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
+276 -544
View File
@@ -1,606 +1,338 @@
//-----------------------------------------------------------------------------
//
#include <MidiStore.h>
/**
* @file MidiStore.cpp
*
* @author Matthijs Hollemans
* @author Jerome Leveque
* @author Paul Stadler
*/
#include <iostream>
#include <fstream>
#include <string.h>
#include <Entry.h>
#include <Path.h>
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <List.h>
#include "debug.h"
#include "MidiEvent.h"
#include "MidiStore.h"
#define PACK_4_U8_TO_U32(_d1, _d2) \
_d2 = (uint32)_d1[0] << 24 | (uint32)_d1[1] << 16 | \
(uint32)_d1[2] << 8 | (uint32)_d1[3];
#define PACK_2_U8_TO_U16(_d1, _d2) \
_d2 = (uint16)_d1[0] << 8 | (uint16)_d1[1];
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Public Access Routines
BMidiStore::BMidiStore() {
_evt_list = new BList();
_tempo = 60;
_cur_evt = 0;
BMidiStore::BMidiStore()
{
events = new BList();
tempo = 60;
curEvent = 0;
}
BMidiStore::~BMidiStore() {
int32 num_items = _evt_list->CountItems();
for(int i = num_items - 1; i >= 0; i--) {
delete (BMidiEvent *)_evt_list->RemoveItem(i);
//------------------------------------------------------------------------------
BMidiStore::~BMidiStore()
{
int32 count = events->CountItems();
for (int i = count - 1; i >= 0; i--)
{
delete (BMidiEvent*) events->RemoveItem(i);
}
_evt_list->MakeEmpty();
delete _evt_list;
delete events;
}
void BMidiStore::NoteOff(uchar chan, uchar note, uchar vel, uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_NOTE_OFF;
e->time = B_NOW;
e->data.note_off.channel = chan;
e->data.note_off.note = note;
e->data.note_off.velocity = vel;
_evt_list->AddItem(e);
}
void BMidiStore::NoteOn(uchar chan, uchar note, uchar vel, uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_NOTE_ON;
e->time = B_NOW;
e->data.note_on.channel = chan;
e->data.note_on.note = note;
e->data.note_on.velocity = vel;
_evt_list->AddItem(e);
//------------------------------------------------------------------------------
void BMidiStore::NoteOff(
uchar channel, uchar note, uchar velocity, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_NOTE_OFF;
event->time = B_NOW;
event->noteOff.channel = channel;
event->noteOff.note = note;
event->noteOff.velocity = velocity;
events->AddItem(event);
}
void BMidiStore::KeyPressure(uchar chan, uchar note, uchar pres,
uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_KEY_PRESSURE;
e->time = B_NOW;
e->data.key_pressure.channel = chan;
e->data.key_pressure.note = note;
e->data.key_pressure.pressure = pres;
_evt_list->AddItem(e);
//------------------------------------------------------------------------------
void BMidiStore::NoteOn(
uchar channel, uchar note, uchar velocity, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_NOTE_ON;
event->time = B_NOW;
event->noteOn.channel = channel;
event->noteOn.note = note;
event->noteOn.velocity = velocity;
events->AddItem(event);
}
void BMidiStore::ControlChange(uchar chan, uchar ctrl_num, uchar ctrl_val,
uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_CONTROL_CHANGE;
e->time = B_NOW;
e->data.control_change.channel = chan;
e->data.control_change.number = ctrl_num;
e->data.control_change.value = ctrl_val;
_evt_list->AddItem(e);
}
void BMidiStore::ProgramChange(uchar chan, uchar prog_num, uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_PROGRAM_CHANGE;
e->time = B_NOW;
e->data.program_change.channel = chan;
e->data.program_change.number = prog_num;
_evt_list->AddItem(e);
//------------------------------------------------------------------------------
void BMidiStore::KeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_KEY_PRESSURE;
event->time = B_NOW;
event->keyPressure.channel = channel;
event->keyPressure.note = note;
event->keyPressure.pressure = pressure;
events->AddItem(event);
}
void BMidiStore::ChannelPressure(uchar chan, uchar pres, uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_CHANNEL_PRESSURE;
e->time = B_NOW;
e->data.channel_pressure.channel = chan;
e->data.channel_pressure.pressure = pres;
_evt_list->AddItem(e);
}
void BMidiStore::PitchBend(uchar chan, uchar lsb, uchar msb, uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_PITCH_BEND;
e->time = B_NOW;
e->data.pitch_bend.channel = chan;
e->data.pitch_bend.lsb = lsb;
e->data.pitch_bend.msb = msb;
_evt_list->AddItem(e);
//------------------------------------------------------------------------------
void BMidiStore::ControlChange(
uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_CONTROL_CHANGE;
event->time = B_NOW;
event->controlChange.channel = channel;
event->controlChange.controlNumber = controlNumber;
event->controlChange.controlValue = controlValue;
events->AddItem(event);
}
void BMidiStore::SystemExclusive(void * data, size_t data_len, uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_SYSTEM_EXCLUSIVE;
e->time = B_NOW;
e->data.system_exclusive.data = (uint8 *)data;
e->data.system_exclusive.length = data_len;
_evt_list->AddItem(e);
//------------------------------------------------------------------------------
void BMidiStore::ProgramChange(
uchar channel, uchar programNumber, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_PROGRAM_CHANGE;
event->time = B_NOW;
event->programChange.channel = channel;
event->programChange.programNumber = programNumber;
events->AddItem(event);
}
void BMidiStore::SystemCommon(uchar stat_byte, uchar data1, uchar data2,
uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_SYSTEM_COMMON;
e->time = B_NOW;
e->data.system_common.status = stat_byte;
e->data.system_common.data1 = data1;
e->data.system_common.data2 = data2;
_evt_list->AddItem(e);
//------------------------------------------------------------------------------
void BMidiStore::ChannelPressure(uchar channel, uchar pressure, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_CHANNEL_PRESSURE;
event->time = B_NOW;
event->channelPressure.channel = channel;
event->channelPressure.pressure = pressure;
events->AddItem(event);
}
void BMidiStore::SystemRealTime(uchar stat_byte, uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_SYSTEM_REAL_TIME;
e->time = B_NOW;
e->data.system_real_time.status = stat_byte;
_evt_list->AddItem(e);
//------------------------------------------------------------------------------
void BMidiStore::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_PITCH_BEND;
event->time = B_NOW;
event->pitchBend.channel = channel;
event->pitchBend.lsb = lsb;
event->pitchBend.msb = msb;
events->AddItem(event);
}
void BMidiStore::TempoChange(int32 bpm, uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_TEMPO_CHANGE;
e->time = B_NOW;
e->data.tempo_change.beats_per_minute = bpm;
_evt_list->AddItem(e);
//------------------------------------------------------------------------------
void BMidiStore::SystemExclusive(void* data, size_t dataLength, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_SYSTEM_EXCLUSIVE;
event->time = B_NOW;
event->systemExclusive.data = (uint8*) data;
event->systemExclusive.dataLength = dataLength;
events->AddItem(event);
}
void BMidiStore::AllNotesOff(bool just_chan, uint32 time) {
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_ALL_NOTES_OFF;
e->time = B_NOW;
e->data.all_notes_off.just_channel = just_chan;
_evt_list->AddItem(e);
//------------------------------------------------------------------------------
void BMidiStore::SystemCommon(
uchar status, uchar data1, uchar data2, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_SYSTEM_COMMON;
event->time = B_NOW;
event->systemCommon.status = status;
event->systemCommon.data1 = data1;
event->systemCommon.data2 = data2;
events->AddItem(event);
}
status_t BMidiStore::Import(const entry_ref * ref) {
BEntry file_entry(ref,true);
BPath file_path;
file_entry.GetPath(&file_path);
ifstream inf(file_path.Path(), ios::in | ios::binary);
if(!inf) {
return B_ERROR;
}
inf.seekg(0,ios::end);
uint32 file_len = inf.tellg();
if(file_len < 16) {
return B_BAD_MIDI_DATA;
}
inf.seekg(ios::beg);
uint8 * data = new uint8[file_len];
if(data == NULL) {
return B_ERROR;
}
inf.read(data,file_len);
inf.close();
uint8 * d = data;
if(strncmp((const char *)d,"MThd",4) != 0) {
return B_BAD_MIDI_DATA;
}
d += 4;
uint32 hdr_len;
PACK_4_U8_TO_U32(d,hdr_len);
if(hdr_len != 6) {
return B_BAD_MIDI_DATA;
}
d += 4;
uint32 format;
uint32 tracks;
uint32 division;
PACK_2_U8_TO_U16(d,format);
d += 2;
PACK_2_U8_TO_U16(d,tracks);
d += 2;
PACK_2_U8_TO_U16(d,division);
if(!(division & 0x8000)) {
_ticks_per_beat = division;
}
d += 2;
try {
switch(format) {
case 0:
_DecodeFormat0Tracks(d,tracks,file_len-(data-d));
break;
case 1:
_DecodeFormat1Tracks(d,tracks,file_len-(data-d));
break;
case 2:
_DecodeFormat2Tracks(d,tracks,file_len-(data-d));
break;
default:
return B_BAD_MIDI_DATA;
}
} catch(status_t err) {
return err;
}
//------------------------------------------------------------------------------
void BMidiStore::SystemRealTime(uchar status, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_SYSTEM_REAL_TIME;
event->time = B_NOW;
event->systemRealTime.status = status;
events->AddItem(event);
}
//------------------------------------------------------------------------------
void BMidiStore::TempoChange(int32 beatsPerMinute, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_TEMPO_CHANGE;
event->time = B_NOW;
event->tempoChange.beatsPerMinute = beatsPerMinute;
events->AddItem(event);
}
//------------------------------------------------------------------------------
void BMidiStore::AllNotesOff(bool justChannel, uint32 time)
{
BMidiEvent* event = new BMidiEvent;
event->opcode = BMidiEvent::OP_ALL_NOTES_OFF;
event->time = B_NOW;
event->allNotesOff.justChannel = justChannel;
events->AddItem(event);
}
//------------------------------------------------------------------------------
status_t BMidiStore::Import(const entry_ref* ref)
{
return B_OK;
}
status_t BMidiStore::Export(const entry_ref * ref, int32 format) {
ofstream ouf(ref->name, ios::out | ios::binary);
if(!ouf) {
return B_ERROR;
}
ouf.write("MHdr",4);
ouf.close();
//------------------------------------------------------------------------------
status_t BMidiStore::Export(const entry_ref* ref, int32 format)
{
return B_OK;
}
void BMidiStore::SortEvents(bool force) {
_evt_list->SortItems(_CompareEvents);
//------------------------------------------------------------------------------
void BMidiStore::SortEvents(bool force)
{
events->SortItems(CompareEvents);
}
uint32 BMidiStore::CountEvents() const {
return _evt_list->CountItems();
//------------------------------------------------------------------------------
uint32 BMidiStore::CountEvents() const
{
return events->CountItems();
}
uint32 BMidiStore::CurrentEvent() const {
return _cur_evt;
//------------------------------------------------------------------------------
uint32 BMidiStore::CurrentEvent() const
{
return curEvent;
}
void BMidiStore::SetCurrentEvent(uint32 event_num) {
_cur_evt = event_num;
//------------------------------------------------------------------------------
void BMidiStore::SetCurrentEvent(uint32 eventNumber)
{
curEvent = eventNumber;
}
uint32 BMidiStore::DeltaOfEvent(uint32 event_num) const {
BMidiEvent * e = (BMidiEvent *)_evt_list->ItemAt(event_num);
return e->time - _start_time;
//------------------------------------------------------------------------------
uint32 BMidiStore::DeltaOfEvent(uint32 eventNumber) const
{
BMidiEvent* first = EventAt(0);
if (first == NULL) { return 0; }
BMidiEvent* event = EventAt(eventNumber);
if (event == NULL) { return 0; }
return event->time - first->time;
}
uint32 BMidiStore::EventAtDelta(uint32 time) const {
uint32 event_num = 0;
//------------------------------------------------------------------------------
uint32 BMidiStore::EventAtDelta(uint32 time) const
{
uint32 count = CountEvents();
uint32 delta = 0;
for (uint32 t = 0; t < count; ++t)
{
if (delta >= time)
{
return t;
}
else
{
delta += EventAt(t)->time;
}
}
return event_num;
return 0;
}
uint32 BMidiStore::BeginTime() const {
return _start_time;
//------------------------------------------------------------------------------
uint32 BMidiStore::BeginTime() const
{
return startTime;
}
void BMidiStore::SetTempo(int32 bpm) {
_tempo = bpm;
//------------------------------------------------------------------------------
void BMidiStore::SetTempo(int32 beatsPerMinute)
{
tempo = beatsPerMinute;
}
int32 BMidiStore::Tempo() const {
return _tempo;
//------------------------------------------------------------------------------
int32 BMidiStore::Tempo() const
{
return tempo;
}
void BMidiStore::Run() {
_start_time = B_NOW;
uint32 last_tick = 0;
uint32 last_time = _start_time;
while(KeepRunning()) {
BMidiEvent * e = (BMidiEvent *)_evt_list->ItemAt(_cur_evt);
if(e == NULL) {
return;
}
uint32 tick = e->time;
uint32 tick_delta = tick - last_tick;
uint32 beat_len = (60000 / _tempo);
uint32 delta_time = (beat_len * tick_delta) / _ticks_per_beat;
uint32 time = last_time + delta_time;
last_time = time;
last_tick = tick;
BMidiEvent::Data & d = e->data;
cerr << "event 0x" << hex << e->opcode << " time = " << time << endl;
switch(e->opcode) {
case BMidiEvent::OP_NOTE_OFF:
SprayNoteOff(d.note_off.channel,
d.note_off.note, d.note_off.velocity,time);
break;
case BMidiEvent::OP_NOTE_ON:
SprayNoteOn(d.note_on.channel,
d.note_on.note,d.note_on.velocity,time);
break;
case BMidiEvent::OP_KEY_PRESSURE:
SprayKeyPressure(d.key_pressure.channel,
d.key_pressure.note,d.key_pressure.pressure,time);
break;
case BMidiEvent::OP_CONTROL_CHANGE:
SprayControlChange(d.control_change.channel,
d.control_change.number,d.control_change.value,time);
break;
case BMidiEvent::OP_PROGRAM_CHANGE:
SprayProgramChange(d.program_change.channel,
d.program_change.number,time);
break;
case BMidiEvent::OP_CHANNEL_PRESSURE:
SprayChannelPressure(d.channel_pressure.channel,
d.channel_pressure.pressure,time);
break;
case BMidiEvent::OP_PITCH_BEND:
SprayPitchBend(d.pitch_bend.channel,
d.pitch_bend.lsb,d.pitch_bend.msb,time);
break;
case BMidiEvent::OP_SYSTEM_EXCLUSIVE:
SpraySystemExclusive(d.system_exclusive.data,
d.system_exclusive.length,time);
break;
case BMidiEvent::OP_SYSTEM_COMMON:
SpraySystemCommon(d.system_common.status,
d.system_common.data1,d.system_common.data2,time);
break;
case BMidiEvent::OP_SYSTEM_REAL_TIME:
SpraySystemRealTime(d.system_real_time.status,time);
break;
case BMidiEvent::OP_TEMPO_CHANGE:
SprayTempoChange(d.tempo_change.beats_per_minute,time);
_tempo = d.tempo_change.beats_per_minute;
break;
case BMidiEvent::OP_ALL_NOTES_OFF:
break;
default:
break;
}
_cur_evt++;
//------------------------------------------------------------------------------
void BMidiStore::_ReservedMidiStore1() { }
void BMidiStore::_ReservedMidiStore2() { }
//------------------------------------------------------------------------------
void BMidiStore::Run()
{
startTime = B_NOW;
while (KeepRunning())
{
BMidiEvent* event = EventAt(curEvent);
if (event == NULL) { return; }
uint32 oldTime = event->time;
event->time += startTime;
SprayMidiEvent(event);
event->time = oldTime;
++curEvent;
}
}
//-----------------------------------------------------------------------------
// Decode and Encode Routines
uint8* BMidiStore::_DecodeTrack(uint8* d) {
if(strncmp((const char *)d,"MTrk",4) != 0) {
throw B_BAD_MIDI_DATA;
}
// cerr << "Track " << (track+1) << " offset = " << (unsigned long)(d-data) << "\n";
d += 4;
uint32 trk_len;
PACK_4_U8_TO_U32(d,trk_len);
d += 4;
uint32 ticks = 0;
uint8* track_last_byte = d + trk_len;
uint8* next_chunk = track_last_byte;
BMidiEvent* event = NULL;
uint8 status = 0;
try {
while(d < track_last_byte) {
uint32 evt_dticks = _ReadVarLength(&d, track_last_byte);
ticks += evt_dticks;
event = new BMidiEvent();
if ((d[0] & 0x80) != 0) { // running status
status = d[0]; d ++;
}
_ReadEvent(status, &d, track_last_byte, event);
event->time = ticks; // TODO: convert ticks to milliseconds
if(event->opcode == BMidiEvent::OP_TRACK_END) {
delete event; event = NULL;
break;
}
if (event->opcode != BMidiEvent::OP_NONE) {
_evt_list->AddItem(event);
} else { // skip unknown event
delete event; event = NULL;
}
}
} catch(status_t e) {
delete event;
throw e;
}
return next_chunk;
//------------------------------------------------------------------------------
BMidiEvent* BMidiStore::EventAt(uint32 index) const
{
return (BMidiEvent*) events->ItemAt(index);
}
//------------------------------------------------------------------------------
void BMidiStore::_DecodeFormat0Tracks(uint8 * data, uint16 tracks,
uint32 len) {
_DecodeTrack(data);
int BMidiStore::CompareEvents(const void* event1, const void* event2)
{
return ((BMidiEvent*) event1)->time - ((BMidiEvent*) event2)->time;
}
void BMidiStore::_DecodeFormat1Tracks(uint8 * data, uint16 tracks,
uint32 len) {
if(tracks == 0) {
throw B_BAD_MIDI_DATA;
}
// simply merge all tracks into one and sort the events afterwards
uint8 * next_track = data;
for (int track = 0; track < tracks; track ++) {
next_track = _DecodeTrack(next_track);
}
SortEvents();
}
//------------------------------------------------------------------------------
void BMidiStore::_DecodeFormat2Tracks(uint8 * data, uint16 tracks,
uint32 len) {
return;
}
void BMidiStore::_EncodeFormat0Tracks(uint8 *) {
}
void BMidiStore::_EncodeFormat1Tracks(uint8 *) {
}
void BMidiStore::_EncodeFormat2Tracks(uint8 *) {
}
void BMidiStore::_ReadEvent(uint8 status, uint8 ** data, uint8 * max_d, BMidiEvent * event) {
#define CHECK_DATA(_d) if((_d) > max_d) throw B_BAD_MIDI_DATA;
#define INC_DATA(_d) CHECK_DATA(_d); d = _d;
uint8 * d = *data;
if(d == NULL) {
throw B_BAD_MIDI_DATA;
}
// cerr << "ReadEvent 0x" << hex << (int)status << "\n";
if(status == 0xff) {
uint32 len;
if(d[0] == 0x0) {
INC_DATA(d+1);
if(d[0] == 0x00) {
// Sequence number!
INC_DATA(d+1);
} else if(d[0] == 0x02) {
// Sequence number!
INC_DATA(d+3);
} else {
throw B_BAD_MIDI_DATA;
}
} else if(d[0] > 0x00 && d[0] < 0x0a) {
INC_DATA(d+1);
len = _ReadVarLength(&d,max_d);
INC_DATA(d+len);
} else if(d[0] == 0x2f) {
INC_DATA(d+1);
if(d[0] == 0x00) {
INC_DATA(d+1);
event->opcode = BMidiEvent::OP_TRACK_END;
} else {
throw B_BAD_MIDI_DATA;
}
} else if(d[0] == 0x51) {
INC_DATA(d+1);
if(d[0] == 0x03) {
event->opcode = BMidiEvent::OP_TEMPO_CHANGE;
INC_DATA(d+1);
CHECK_DATA(d+2);
uint32 mspb = (uint32)d[0] << 16 |
(uint32)d[1] << 8 | (uint32)d[2];
uint32 bpm = 60000000 / mspb;
event->data.tempo_change.beats_per_minute = bpm;
INC_DATA(d+3);
} else {
throw B_BAD_MIDI_DATA;
}
} else if(d[0] == 0x54) {
INC_DATA(d+1);
if(d[0] == 0x05) {
INC_DATA(d+1);
// SMPTE start time.
// hour = d[0];
// minute = d[1];
// second = d[2];
// frame = d[3];
// fraction = d[4];
INC_DATA(d+5);
} else {
throw B_BAD_MIDI_DATA;
}
} else if(d[0] == 0x58) {
INC_DATA(d+1);
if(d[0] == 0x04) {
INC_DATA(d+1);
// Time signature.
// numerator = d[0];
// denominator = d[1];
// midi clocks = d[2];
// 32nd notes in a quarter = d[3];
INC_DATA(d+4);
} else {
throw B_BAD_MIDI_DATA;
}
} else if(d[0] == 0x59) {
INC_DATA(d+1);
if(d[0] == 0x02) {
INC_DATA(d+1);
// Key signature.
// sf = d[0];
// minor = d[1];
INC_DATA(d+2);
} else {
throw B_BAD_MIDI_DATA;
}
} else if(d[0] == 0x7f) {
INC_DATA(d+1);
uint32 len = _ReadVarLength(&d,max_d);
INC_DATA(d+len);
} else if(d[0] == 0x20) {
INC_DATA(d+1);
if(d[0] == 0x01) {
INC_DATA(d+2);
} else {
throw B_BAD_MIDI_DATA;
}
} else if(d[0] == 0x21) {
INC_DATA(d+1);
if(d[0] == 0x01) {
INC_DATA(d+2);
}
} else {
throw B_BAD_MIDI_DATA;
}
} else if(status == 0xf0) {
// Manufacturer ID = d[0];
while(d[0] != 0xf7) {
// Read data eliding the msb.
INC_DATA(d+1);
}
} else if((status & 0xf0) == 0x80) {
event->opcode = BMidiEvent::OP_NOTE_OFF;
event->data.note_off.channel = status & 0x0f;
event->data.note_off.note = d[0];
INC_DATA(d+1);
event->data.note_off.velocity = d[0];
INC_DATA(d+1);
} else if((status & 0xf0) == 0x90) {
event->opcode = BMidiEvent::OP_NOTE_ON;
event->data.note_on.channel = status & 0x0f;
event->data.note_on.note = d[0];
INC_DATA(d+1);
event->data.note_on.velocity = d[0];
INC_DATA(d+1);
} else if((status & 0xf0) == 0xa0) {
event->opcode = BMidiEvent::OP_KEY_PRESSURE;
event->data.key_pressure.channel = status & 0x0f;
event->data.key_pressure.note = d[0];
INC_DATA(d+1);
event->data.key_pressure.pressure = d[0];
INC_DATA(d+1);
} else if((status & 0xf0) == 0xb0) {
event->opcode = BMidiEvent::OP_CONTROL_CHANGE;
event->data.control_change.channel = status & 0x0f;
event->data.control_change.number = d[0];
INC_DATA(d+1);
event->data.control_change.value = d[0];
INC_DATA(d+1);
} else if((status & 0xf0) == 0xc0) {
event->opcode = BMidiEvent::OP_PROGRAM_CHANGE;
event->data.program_change.channel = status & 0x0f;
event->data.program_change.number = d[0];
INC_DATA(d+1);
} else if((status & 0xf0) == 0xd0) {
event->opcode = BMidiEvent::OP_CHANNEL_PRESSURE;
event->data.channel_pressure.channel = status & 0x0f;
event->data.channel_pressure.pressure = d[0];
INC_DATA(d+1);
} else if((status & 0xf0) == 0xe0) {
event->opcode = BMidiEvent::OP_PITCH_BEND;
event->data.pitch_bend.channel = d[0] & 0x0f;
event->data.pitch_bend.lsb = d[0];
INC_DATA(d+1);
event->data.pitch_bend.msb = d[0];
INC_DATA(d+1);
} else {
cerr << "Unsupported Code:0x" << hex << (int)status << endl;
throw B_BAD_MIDI_DATA;
}
*data = d;
#undef INC_DATA
#undef CHECK_DATA
}
void BMidiStore::_WriteEvent(BMidiEvent * e) {
}
uint32 BMidiStore::_ReadVarLength(uint8 ** data, uint8 * max_d) {
uint32 val;
uint8 bytes = 1;
uint8 byte = 0;
uint8 * d = *data;
val = *d;
d++;
if(val & 0x80) {
val &= 0x7f;
do {
if(d > max_d) {
throw B_BAD_MIDI_DATA;
}
byte = *d;
val = (val << 7) + byte & 0x7f;
bytes++;
d++;
} while(byte & 0x80);
}
*data = d;
return val;
}
void BMidiStore::_WriteVarLength(uint32 length) {
}
int BMidiStore::_CompareEvents(const void * e1, const void *e2) {
BMidiEvent * evt1 = (BMidiEvent *)e1;
BMidiEvent * evt2 = (BMidiEvent *)e2;
return evt1->time - evt2->time;
}
+212
View File
@@ -0,0 +1,212 @@
/**
* @file MidiSynth.cpp
*
* @author Matthijs Hollemans
*/
#include "debug.h"
#include "MidiSynth.h"
//------------------------------------------------------------------------------
BMidiSynth::BMidiSynth()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
BMidiSynth::~BMidiSynth()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
status_t BMidiSynth::EnableInput(bool enable, bool loadInstruments)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
bool BMidiSynth::IsInputEnabled(void) const
{
UNIMPLEMENTED
return false;
}
//------------------------------------------------------------------------------
void BMidiSynth::SetVolume(double volume)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
double BMidiSynth::Volume(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
void BMidiSynth::SetTransposition(int16 offset)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
int16 BMidiSynth::Transposition(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
void BMidiSynth::MuteChannel(int16 channel, bool do_mute)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::GetMuteMap(char* pChannels) const
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::SoloChannel(int16 channel, bool do_solo)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::GetSoloMap(char* pChannels) const
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
status_t BMidiSynth::LoadInstrument(int16 instrument)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
status_t BMidiSynth::UnloadInstrument(int16 instrument)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
status_t BMidiSynth::RemapInstrument(int16 from, int16 to)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
void BMidiSynth::FlushInstrumentCache(bool startStopCache)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
uint32 BMidiSynth::Tick(void) const
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::NoteOff(
uchar channel, uchar note, uchar velocity, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::NoteOn(
uchar channel, uchar note, uchar velocity, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::KeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::ControlChange(
uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::ProgramChange(
uchar channel, uchar programNumber, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::ChannelPressure(uchar channel, uchar pressure, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::AllNotesOff(bool controlOnly, uint32 time)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BMidiSynth::_ReservedMidiSynth1() { }
void BMidiSynth::_ReservedMidiSynth2() { }
void BMidiSynth::_ReservedMidiSynth3() { }
void BMidiSynth::_ReservedMidiSynth4() { }
//------------------------------------------------------------------------------
void BMidiSynth::Run()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
+187
View File
@@ -0,0 +1,187 @@
/**
* @file MidiSynthFile.h
*
* @author Matthijs Hollemans
*/
#include "debug.h"
#include "MidiSynthFile.h"
// -----------------------------------------------------------------------------
BMidiSynthFile::BMidiSynthFile()
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
BMidiSynthFile::~BMidiSynthFile()
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
status_t BMidiSynthFile::LoadFile(const entry_ref* midi_entry_ref)
{
UNIMPLEMENTED
return B_ERROR;
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::UnloadFile(void)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
status_t BMidiSynthFile::Start(void)
{
UNIMPLEMENTED
return B_ERROR;
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::Stop(void)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::Fade(void)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::Pause(void)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::Resume(void)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
int32 BMidiSynthFile::Duration(void) const
{
UNIMPLEMENTED
return 0;
}
// -----------------------------------------------------------------------------
int32 BMidiSynthFile::Position(int32 ticks) const
{
UNIMPLEMENTED
return 0;
}
// -----------------------------------------------------------------------------
int32 BMidiSynthFile::Seek()
{
UNIMPLEMENTED
return 0;
}
// -----------------------------------------------------------------------------
status_t BMidiSynthFile::GetPatches(
int16* pArray768, int16* pReturnedCount) const
{
UNIMPLEMENTED
return B_ERROR;
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::SetFileHook(synth_file_hook pSongHook, int32 arg)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
bool BMidiSynthFile::IsFinished(void) const
{
UNIMPLEMENTED
return false;
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::ScaleTempoBy(double tempoFactor)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::SetTempo(int32 newTempoBPM)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
int32 BMidiSynthFile::Tempo(void) const
{
UNIMPLEMENTED
return 0;
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::EnableLooping(bool loop)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::MuteTrack(int16 track, bool do_mute)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::GetMuteMap(char* pTracks) const
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::SoloTrack(int16 track, bool do_solo)
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::GetSoloMap(char* pTracks) const
{
UNIMPLEMENTED
}
// -----------------------------------------------------------------------------
void BMidiSynthFile::_ReservedMidiSynthFile1() { }
void BMidiSynthFile::_ReservedMidiSynthFile2() { }
void BMidiSynthFile::_ReservedMidiSynthFile3() { }
// -----------------------------------------------------------------------------
+148 -81
View File
@@ -1,117 +1,184 @@
//-----------------------------------------------------------------------------
//
#include <MidiText.h>
#include <iostream.h>
/**
* @file MidiText.cpp
*
* @author Matthijs Hollemans
* @author Jerome Leveque
* @author Paul Stadler
*/
#include <iostream>
#include "debug.h"
#include "MidiEvent.h"
#include "MidiText.h"
BMidiText::BMidiText() {
_start_time = 0x0;
//------------------------------------------------------------------------------
BMidiText::BMidiText()
{
startTime = 0;
}
BMidiText::~BMidiText() {
//------------------------------------------------------------------------------
BMidiText::~BMidiText()
{
// Do nothing
}
void BMidiText::NoteOff(uchar chan, uchar note, uchar vel, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":NOTE OFF;channel = " << (int)chan
<< ",note = " << (int)note << ",velocity = " << (int)vel << endl;
//------------------------------------------------------------------------------
void BMidiText::NoteOff(
uchar channel, uchar note, uchar velocity, uint32 time)
{
WaitAndPrint(time);
cout << ": NOTE OFF; channel = " << (int) channel
<< ", note = " << (int) note
<< ", velocity = " << (int) velocity << endl;
}
void BMidiText::NoteOn(uchar chan, uchar note, uchar vel, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":NOTE ON;channel = " << (int)chan
<< ",note = " << (int)note << ",velocity = " << (int)vel << endl;
//------------------------------------------------------------------------------
void BMidiText::NoteOn(
uchar channel, uchar note, uchar velocity, uint32 time)
{
WaitAndPrint(time);
cout << ": NOTE ON; channel = " << (int) channel
<< ", note = " << (int) note
<< ", velocity = " << (int) velocity << endl;
}
void BMidiText::KeyPressure(uchar chan, uchar note, uchar pres, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":KEY PRESSURE;channel = " << (int)chan
<< ",note = " << (int)note << ",pressure = " << (int)pres << endl;
//------------------------------------------------------------------------------
void BMidiText::KeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time)
{
WaitAndPrint(time);
cout << ": KEY PRESSURE; channel = " << (int) channel
<< ", note = " << (int) note
<< ", pressure = " << (int) pressure << endl;
}
void BMidiText::ControlChange(uchar chan, uchar ctrl_num,
uchar ctrl_val, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":CONTROL CHANGE;channel = " << (int)chan
<< ",control = " << (int)ctrl_num
<< ",value = "<< (int)ctrl_val << endl;
//------------------------------------------------------------------------------
void BMidiText::ControlChange(
uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
{
WaitAndPrint(time);
cout << ": CONTROL CHANGE; channel = " << (int) channel
<< ", control = " << (int) controlNumber
<< ", value = "<< (int) controlValue << endl;
}
void BMidiText::ProgramChange(uchar chan, uchar prog_num, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":PROGRAM CHANGE;channel = " << (int)chan
<< ",program = " << (int)prog_num << endl;
//------------------------------------------------------------------------------
void BMidiText::ProgramChange(
uchar channel, uchar programNumber, uint32 time)
{
WaitAndPrint(time);
cout << ": PROGRAM CHANGE; channel = " << (int) channel
<< ", program = " << (int) programNumber << endl;
}
void BMidiText::ChannelPressure(uchar chan, uchar pres, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":CHANNEL PRESSURE;channel = " << (int)chan
<< ",pressure = " << (int)pres << endl;
//------------------------------------------------------------------------------
void BMidiText::ChannelPressure(uchar channel, uchar pressure, uint32 time)
{
WaitAndPrint(time);
cout << ": CHANNEL PRESSURE; channel = " << (int) channel
<< ", pressure = " << (int) pressure << endl;
}
void BMidiText::PitchBend(uchar chan, uchar lsb, uchar msb, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":PITCH BEND;channel = " << (int)chan << hex
<< ",lsb = " << (int)lsb << ",msb = " << (int)msb << endl;
//------------------------------------------------------------------------------
void BMidiText::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
{
WaitAndPrint(time);
cout << ": PITCH BEND; channel = " << (int) channel << hex
<< ", lsb = " << (int) lsb
<< ", msb = " << (int) msb << endl;
}
void BMidiText::SystemExclusive(void * data, size_t data_len, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":SYSTEM EXCLUSIVE;";
for(size_t i = 0; i < data_len; i++) {
cout << hex << (int)((char *)data)[i];
//------------------------------------------------------------------------------
void BMidiText::SystemExclusive(void* data, size_t dataLength, uint32 time)
{
WaitAndPrint(time);
cout << ": SYSTEM EXCLUSIVE;";
for (size_t i = 0; i < dataLength; i++)
{
cout << " " << hex << (int) ((uint8*) data)[i];
}
cout << endl;
}
void BMidiText::SystemCommon(uchar stat_byte, uchar data1,
uchar data2, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":SYSTEM COMMON;status = " << hex << (int)stat_byte
<< ",data1 = " << (int)data1 << ",data2 = " << (int)data2 << endl;
//------------------------------------------------------------------------------
void BMidiText::SystemCommon(
uchar status, uchar data1, uchar data2, uint32 time)
{
WaitAndPrint(time);
cout << ": SYSTEM COMMON; status = " << hex << (int) status
<< ", data1 = " << (int) data1
<< ", data2 = " << (int) data2 << endl;
}
void BMidiText::SystemRealTime(uchar stat_byte, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":SYSTEM REAL TIME;status = " << hex << (int)stat << endl;
//------------------------------------------------------------------------------
void BMidiText::SystemRealTime(uchar status, uint32 time)
{
WaitAndPrint(time);
cout << ": SYSTEM REAL TIME; status = " << hex << (int) status << endl;
}
void BMidiText::TempoChange(int32 bpm, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":TEMPO CHANGE;" << "beatsperminute = " << bpm << endl;
//------------------------------------------------------------------------------
void BMidiText::TempoChange(int32 beatsPerMinute, uint32 time)
{
WaitAndPrint(time);
cout << ": TEMPO CHANGE; beatsperminute = " << beatsPerMinute << endl;
}
//------------------------------------------------------------------------------
void BMidiText::AllNotesOff(bool justChannel, uint32 time)
{
WaitAndPrint(time);
cout << ": ALL NOTES OFF;" << endl;
}
void BMidiText::AllNotesOff(bool just_chan, uint32 time) {
SnoozeUntil(time);
_PrintTime();
cout << ":ALL NOTES OFF;" << endl;
//------------------------------------------------------------------------------
void BMidiText::ResetTimer(bool start)
{
startTime = start ? B_NOW : 0;
}
void BMidiText::ResetTimer(bool start) {
if(start) {
_start_time = (uint32)(system_time() / 1000);
} else {
_start_time = 0;
//------------------------------------------------------------------------------
void BMidiText::_ReservedMidiText1() { }
//------------------------------------------------------------------------------
void BMidiText::Run()
{
while (KeepRunning())
{
snooze(50000);
}
}
//-----------------------------------------------------------------------------
//
void BMidiText::_PrintTime() {
uint32 cur_time = B_NOW;
if(_start_time == 0) {
_start_time = cur_time;
}
cout << (cur_time - _start_time);
//------------------------------------------------------------------------------
void BMidiText::WaitAndPrint(uint32 time)
{
if (startTime == 0) { startTime = time; }
SnoozeUntil(time);
cout << dec << (time - startTime);
}
//------------------------------------------------------------------------------
+131
View File
@@ -0,0 +1,131 @@
/**
* @file Samples.cpp
*
* @author Matthijs Hollemans
*/
#include "debug.h"
#include "Samples.h"
//------------------------------------------------------------------------------
BSamples::BSamples()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
BSamples::~BSamples()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BSamples::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)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
bool BSamples::IsPaused(void) const
{
UNIMPLEMENTED
return false;
}
//------------------------------------------------------------------------------
void BSamples::Pause(void)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BSamples::Resume(void)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BSamples::Stop(void)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
bool BSamples::IsPlaying(void) const
{
UNIMPLEMENTED
return false;
}
//------------------------------------------------------------------------------
void BSamples::SetVolume(double newVolume)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
double BSamples::Volume(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
void BSamples::SetSamplingRate(double newRate)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
double BSamples::SamplingRate(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
void BSamples::SetPlacement(double stereoPosition)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
double BSamples::Placement(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
void BSamples::EnableReverb(bool useReverb)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BSamples::_ReservedSamples1() { }
void BSamples::_ReservedSamples2() { }
void BSamples::_ReservedSamples3() { }
//------------------------------------------------------------------------------
+265
View File
@@ -0,0 +1,265 @@
/**
* @file Synth.cpp
*
* @author Matthijs Hollemans
*/
#include "debug.h"
#include "Synth.h"
//------------------------------------------------------------------------------
BSynth::BSynth()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
BSynth::BSynth(synth_mode synth)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
BSynth::~BSynth()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
status_t BSynth::LoadSynthData(entry_ref* instrumentsFile)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
status_t BSynth::LoadSynthData(synth_mode synth)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
synth_mode BSynth::SynthMode(void)
{
UNIMPLEMENTED
return B_NO_SYNTH;
}
//------------------------------------------------------------------------------
void BSynth::Unload(void)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
bool BSynth::IsLoaded(void) const
{
UNIMPLEMENTED
return false;
}
//------------------------------------------------------------------------------
status_t BSynth::SetSamplingRate(int32 sample_rate)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
int32 BSynth::SamplingRate() const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
status_t BSynth::SetInterpolation(interpolation_mode interp_mode)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
interpolation_mode BSynth::Interpolation() const
{
UNIMPLEMENTED
return B_DROP_SAMPLE;
}
//------------------------------------------------------------------------------
void BSynth::SetReverb(reverb_mode rev_mode)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
reverb_mode BSynth::Reverb() const
{
UNIMPLEMENTED
return B_REVERB_NONE;
}
//------------------------------------------------------------------------------
status_t BSynth::EnableReverb(bool reverb_enabled)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
bool BSynth::IsReverbEnabled() const
{
UNIMPLEMENTED
return false;
}
//------------------------------------------------------------------------------
status_t BSynth::SetVoiceLimits(
int16 maxSynthVoices, int16 maxSampleVoices, int16 limiterThreshhold)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
int16 BSynth::MaxSynthVoices(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
int16 BSynth::MaxSampleVoices(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
int16 BSynth::LimiterThreshhold(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
void BSynth::SetSynthVolume(double theVolume)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
double BSynth::SynthVolume(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
void BSynth::SetSampleVolume(double theVolume)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
double BSynth::SampleVolume(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
status_t BSynth::GetAudio(
int16* pLeft, int16* pRight, int32 max_samples) const
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
void BSynth::Pause(void)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BSynth::Resume(void)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
void BSynth::SetControllerHook(int16 controller, synth_controller_hook cback)
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
int32 BSynth::CountClients(void) const
{
UNIMPLEMENTED
return 0;
}
//------------------------------------------------------------------------------
void BSynth::_ReservedSynth1() { }
void BSynth::_ReservedSynth2() { }
void BSynth::_ReservedSynth3() { }
void BSynth::_ReservedSynth4() { }
//------------------------------------------------------------------------------
void BSynth::_init()
{
UNIMPLEMENTED
}
//------------------------------------------------------------------------------
status_t BSynth::_do_load(synth_mode synth)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------
status_t BSynth::_load_insts(entry_ref* ref)
{
UNIMPLEMENTED
return B_ERROR;
}
//------------------------------------------------------------------------------