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 : SharedLibrary midi :
Midi.cpp Midi.cpp
MidiPort.cpp
MidiStore.cpp MidiStore.cpp
MidiSynth.cpp
MidiSynthFile.cpp
MidiText.cpp MidiText.cpp
MidiEvent.cpp MidiEvent.cpp
Samples.cpp
Synth.cpp
; ;
LinkSharedOSLibs libmidi.so : LinkSharedOSLibs libmidi.so :
be be
stdc++.r4 stdc++.r4
midi2
; ;
+404 -292
View File
@@ -1,334 +1,446 @@
//----------------------------------------------------------------------------- /**
// * @file Midi.cpp
#include <Midi.h> *
* @author Matthijs Hollemans
* @author Jerome Leveque
* @author Paul Stadler
*/
#include <List.h> #include <List.h>
#include <iostream.h>
#include "debug.h"
#include "Midi.h"
#include "MidiEvent.h" #include "MidiEvent.h"
#define MSG_CODE_PROCESS_EVENT 1 #define MSG_CODE_PROCESS_EVENT 1
#define MSG_CODE_TERMINATE_THREAD 0 #define MSG_CODE_TERMINATE_THREAD 0
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Initialization Stuff
BMidi::BMidi() { BMidi::BMidi()
_con_list = new BList(); {
_is_running = false; connections = new BList();
_is_inflowing = false; isRunning = false;
_inflow_port = create_port(1,"Inflow Port");
_inflow_thread_id = spawn_thread(_InflowThread, inflowPort = create_port(1, "Inflow Port");
"BMidi Inflow Thread", B_REAL_TIME_PRIORITY, (void *)this);
status_t ret = resume_thread(_inflow_thread_id); 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); BMidi::~BMidi()
wait_for_thread(_inflow_thread_id,&exit_value); {
delete_port(_inflow_port); write_port(inflowPort, MSG_CODE_TERMINATE_THREAD, NULL, 0);
delete _con_list;
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) {
}
//----------------------------------------------------------------------------- void BMidi::NoteOff(uchar, uchar, uchar, uint32) { }
// Public API Functions void BMidi::NoteOn(uchar, uchar, uchar, uint32) { }
status_t BMidi::Start() { void BMidi::KeyPressure(uchar, uchar, uchar, uint32) { }
_keep_running = true; void BMidi::ControlChange(uchar, uchar, uchar, uint32) { }
_run_thread_id = spawn_thread(_RunThread, void BMidi::ProgramChange(uchar, uchar, uint32) { }
"BMidi Run Thread", B_REAL_TIME_PRIORITY, (void *)this); void BMidi::ChannelPressure(uchar, uchar, uint32) { }
status_t ret = resume_thread(_run_thread_id); void BMidi::PitchBend(uchar, uchar, uchar, uint32) { }
if(ret != B_OK) { void BMidi::SystemExclusive(void*, size_t, uint32) { }
return ret; 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; void BMidi::Stop()
status_t ret; {
ret = wait_for_thread(_run_thread_id,&exit_value); status_t exitValue;
_is_running = false; wait_for_thread(runThread, &exitValue);
}
isRunning = 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::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); 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, void BMidi::Inflow()
uint32 time) const { {
BMidiEvent e; BMidiEvent event;
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;
int32 code; int32 code;
size_t len; size_t len;
while(true) {
len = read_port(_inflow_port,&code,&e,sizeof(e)); while (true)
if (len < 0) continue; // ignore errors {
if(code == MSG_CODE_TERMINATE_THREAD) return; len = read_port(inflowPort, &code, &event, sizeof(event));
if (len != sizeof(e)) continue; // ignore data in wrong size
// Otherwise we process an event. if (len != sizeof(event)) { continue; } // ignore errors
switch(e.opcode) {
case BMidiEvent::OP_NONE: if (code == MSG_CODE_TERMINATE_THREAD) { return; }
case BMidiEvent::OP_TRACK_END:
case BMidiEvent::OP_ALL_NOTES_OFF: switch (event.opcode)
break; {
case BMidiEvent::OP_NOTE_OFF: case BMidiEvent::OP_NONE:
NoteOff(e.data.note_off.channel, case BMidiEvent::OP_TRACK_END:
e.data.note_off.note, case BMidiEvent::OP_ALL_NOTES_OFF:
e.data.note_off.velocity, break;
e.time);
break; case BMidiEvent::OP_NOTE_OFF:
case BMidiEvent::OP_NOTE_ON: NoteOff(
NoteOff(e.data.note_on.channel, event.noteOff.channel,
e.data.note_on.note, event.noteOff.note,
e.data.note_on.velocity, event.noteOff.velocity,
e.time); event.time);
break; break;
case BMidiEvent::OP_KEY_PRESSURE:
KeyPressure(e.data.key_pressure.channel, case BMidiEvent::OP_NOTE_ON:
e.data.key_pressure.note, NoteOff(
e.data.key_pressure.pressure, event.noteOn.channel,
e.time); event.noteOn.note,
break; event.noteOn.velocity,
case BMidiEvent::OP_CONTROL_CHANGE: event.time);
ControlChange(e.data.control_change.channel, break;
e.data.control_change.number,
e.data.control_change.value, case BMidiEvent::OP_KEY_PRESSURE:
e.time); KeyPressure(
break; event.keyPressure.channel,
case BMidiEvent::OP_PROGRAM_CHANGE: event.keyPressure.note,
ProgramChange(e.data.program_change.channel, event.keyPressure.pressure,
e.data.program_change.number, event.time);
e.time); break;
break;
case BMidiEvent::OP_CHANNEL_PRESSURE: case BMidiEvent::OP_CONTROL_CHANGE:
ChannelPressure(e.data.channel_pressure.channel, ControlChange(
e.data.channel_pressure.pressure, event.controlChange.channel,
e.time); event.controlChange.controlNumber,
break; event.controlChange.controlValue,
case BMidiEvent::OP_PITCH_BEND: event.time);
PitchBend(e.data.pitch_bend.channel, break;
e.data.pitch_bend.lsb,
e.data.pitch_bend.msb, case BMidiEvent::OP_PROGRAM_CHANGE:
e.time); ProgramChange(
break; event.programChange.channel,
case BMidiEvent::OP_SYSTEM_EXCLUSIVE: event.programChange.programNumber,
SystemExclusive(e.data.system_exclusive.data, event.time);
e.data.system_exclusive.length, break;
e.time);
break; case BMidiEvent::OP_CHANNEL_PRESSURE:
case BMidiEvent::OP_SYSTEM_COMMON: ChannelPressure(
SystemCommon(e.data.system_common.status, event.channelPressure.channel,
e.data.system_common.data1, event.channelPressure.pressure,
e.data.system_common.data2, event.time);
e.time); break;
break;
case BMidiEvent::OP_SYSTEM_REAL_TIME: case BMidiEvent::OP_PITCH_BEND:
SystemRealTime(e.data.system_real_time.status, e.time); PitchBend(
break; event.pitchBend.channel,
case BMidiEvent::OP_TEMPO_CHANGE: event.pitchBend.lsb,
TempoChange(e.data.tempo_change.beats_per_minute, e.time); event.pitchBend.msb,
break; event.time);
default: break;
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; return 0;
} }
int32 BMidi::_InflowThread(void * data) { //------------------------------------------------------------------------------
((BMidi *)data)->_Inflow();
int32 BMidi::InflowThread(void* data)
{
((BMidi*) data)->Inflow();
return 0; return 0;
} }
//------------------------------------------------------------------------------
+18 -4
View File
@@ -1,10 +1,24 @@
//----------------------------------------------------------------------------- /**
// * @file MidiEvent.cpp
*
* @author Matthijs Hollemans
* @author Paul Stadler
*/
#include "MidiEvent.h" #include "MidiEvent.h"
BMidiEvent::BMidiEvent() { //------------------------------------------------------------------------------
BMidiEvent::BMidiEvent()
{
opcode = OP_NONE; opcode = OP_NONE;
} }
BMidiEvent::~BMidiEvent() { //------------------------------------------------------------------------------
BMidiEvent::~BMidiEvent()
{
} }
//------------------------------------------------------------------------------
+111 -64
View File
@@ -1,16 +1,26 @@
//----------------------------------------------------------------------------- /**
// * @file MidiEvent.h
#ifndef _MIDI_EVENT_H_ *
#define _MIDI_EVENT_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: public:
BMidiEvent(); BMidiEvent();
~BMidiEvent(); ~BMidiEvent();
enum Opcode { enum
{
OP_NONE, OP_NONE,
OP_NOTE_OFF, OP_NOTE_OFF,
OP_NOTE_ON, OP_NOTE_ON,
@@ -25,64 +35,101 @@ public:
OP_TEMPO_CHANGE, OP_TEMPO_CHANGE,
OP_ALL_NOTES_OFF, OP_ALL_NOTES_OFF,
OP_TRACK_END, OP_TRACK_END,
OP_NUM }
}; opcode;
uint32 time; uint32 time;
Opcode opcode;
union Data { union
struct NoteOffData { {
uint8 channel; struct
uint8 note; {
uint8 velocity; uchar channel;
} note_off; uchar note;
struct NoteOnData { uchar velocity;
uint8 channel; }
uint8 note; noteOff;
uint8 velocity;
} note_on; struct
struct KeyPressureData { {
uint8 channel; uchar channel;
uint8 note; uchar note;
uint8 pressure; uchar velocity;
} key_pressure; }
struct ControlChangeData { noteOn;
uint8 channel;
uint8 number; struct
uint8 value; {
} control_change; uchar channel;
struct ProgramChangeData { uchar note;
uint8 channel; uchar pressure;
uint8 number; }
} program_change; keyPressure;
struct ChannelPressureData {
uint8 channel; struct
uint8 pressure; {
} channel_pressure; uchar channel;
struct PitchBendData { uchar controlNumber;
uint8 channel; uchar controlValue;
uint8 lsb; }
uint8 msb; controlChange;
} pitch_bend;
struct SystemExclusiveData { struct
uint8 * data; {
int32 length; uchar channel;
} system_exclusive; uchar programNumber;
struct SystemCommonData { }
uint8 status; programChange;
uint8 data1;
uint8 data2; struct
} system_common; {
struct SystemRealTimeData { uchar channel;
uint8 status; uchar pressure;
} system_real_time; }
struct TempoChangeData { channelPressure;
uint32 beats_per_minute;
} tempo_change; struct
struct AllNotesOffData { {
bool just_channel; uchar channel;
} all_notes_off; uchar lsb;
} data; 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 @@
//----------------------------------------------------------------------------- /**
// * @file MidiStore.cpp
#include <MidiStore.h> *
* @author Matthijs Hollemans
* @author Jerome Leveque
* @author Paul Stadler
*/
#include <iostream>
#include <fstream>
#include <string.h>
#include <Entry.h> #include <Entry.h>
#include <Path.h> #include <Path.h>
#include <iostream.h> #include <List.h>
#include <fstream.h>
#include <string.h> #include "debug.h"
#include "MidiEvent.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];
//----------------------------------------------------------------------------- BMidiStore::BMidiStore()
// Public Access Routines {
BMidiStore::BMidiStore() { events = new BList();
_evt_list = new BList(); tempo = 60;
_tempo = 60; curEvent = 0;
_cur_evt = 0;
} }
BMidiStore::~BMidiStore() { //------------------------------------------------------------------------------
int32 num_items = _evt_list->CountItems();
for(int i = num_items - 1; i >= 0; i--) { BMidiStore::~BMidiStore()
delete (BMidiEvent *)_evt_list->RemoveItem(i); {
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; void BMidiStore::NoteOff(
e->time = B_NOW; uchar channel, uchar note, uchar velocity, uint32 time)
e->data.note_off.channel = chan; {
e->data.note_off.note = note; BMidiEvent* event = new BMidiEvent;
e->data.note_off.velocity = vel; event->opcode = BMidiEvent::OP_NOTE_OFF;
_evt_list->AddItem(e); event->time = B_NOW;
} event->noteOff.channel = channel;
event->noteOff.note = note;
void BMidiStore::NoteOn(uchar chan, uchar note, uchar vel, uint32 time) { event->noteOff.velocity = velocity;
BMidiEvent * e = new BMidiEvent; events->AddItem(event);
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::KeyPressure(uchar chan, uchar note, uchar pres, //------------------------------------------------------------------------------
uint32 time) {
BMidiEvent * e = new BMidiEvent; void BMidiStore::NoteOn(
e->opcode = BMidiEvent::OP_KEY_PRESSURE; uchar channel, uchar note, uchar velocity, uint32 time)
e->time = B_NOW; {
e->data.key_pressure.channel = chan; BMidiEvent* event = new BMidiEvent;
e->data.key_pressure.note = note; event->opcode = BMidiEvent::OP_NOTE_ON;
e->data.key_pressure.pressure = pres; event->time = B_NOW;
_evt_list->AddItem(e); 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; void BMidiStore::KeyPressure(
e->opcode = BMidiEvent::OP_CONTROL_CHANGE; uchar channel, uchar note, uchar pressure, uint32 time)
e->time = B_NOW; {
e->data.control_change.channel = chan; BMidiEvent* event = new BMidiEvent;
e->data.control_change.number = ctrl_num; event->opcode = BMidiEvent::OP_KEY_PRESSURE;
e->data.control_change.value = ctrl_val; event->time = B_NOW;
_evt_list->AddItem(e); event->keyPressure.channel = channel;
} event->keyPressure.note = note;
event->keyPressure.pressure = pressure;
void BMidiStore::ProgramChange(uchar chan, uchar prog_num, uint32 time) { events->AddItem(event);
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::ChannelPressure(uchar chan, uchar pres, uint32 time) { //------------------------------------------------------------------------------
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_CHANNEL_PRESSURE; void BMidiStore::ControlChange(
e->time = B_NOW; uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
e->data.channel_pressure.channel = chan; {
e->data.channel_pressure.pressure = pres; BMidiEvent* event = new BMidiEvent;
_evt_list->AddItem(e); event->opcode = BMidiEvent::OP_CONTROL_CHANGE;
} event->time = B_NOW;
event->controlChange.channel = channel;
void BMidiStore::PitchBend(uchar chan, uchar lsb, uchar msb, uint32 time) { event->controlChange.controlNumber = controlNumber;
BMidiEvent * e = new BMidiEvent; event->controlChange.controlValue = controlValue;
e->opcode = BMidiEvent::OP_PITCH_BEND; events->AddItem(event);
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::SystemExclusive(void * data, size_t data_len, uint32 time) { //------------------------------------------------------------------------------
BMidiEvent * e = new BMidiEvent;
e->opcode = BMidiEvent::OP_SYSTEM_EXCLUSIVE; void BMidiStore::ProgramChange(
e->time = B_NOW; uchar channel, uchar programNumber, uint32 time)
e->data.system_exclusive.data = (uint8 *)data; {
e->data.system_exclusive.length = data_len; BMidiEvent* event = new BMidiEvent;
_evt_list->AddItem(e); 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; void BMidiStore::ChannelPressure(uchar channel, uchar pressure, uint32 time)
e->opcode = BMidiEvent::OP_SYSTEM_COMMON; {
e->time = B_NOW; BMidiEvent* event = new BMidiEvent;
e->data.system_common.status = stat_byte; event->opcode = BMidiEvent::OP_CHANNEL_PRESSURE;
e->data.system_common.data1 = data1; event->time = B_NOW;
e->data.system_common.data2 = data2; event->channelPressure.channel = channel;
_evt_list->AddItem(e); 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; void BMidiStore::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
e->time = B_NOW; {
e->data.system_real_time.status = stat_byte; BMidiEvent* event = new BMidiEvent;
_evt_list->AddItem(e); 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; void BMidiStore::SystemExclusive(void* data, size_t dataLength, uint32 time)
e->time = B_NOW; {
e->data.tempo_change.beats_per_minute = bpm; BMidiEvent* event = new BMidiEvent;
_evt_list->AddItem(e); 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; void BMidiStore::SystemCommon(
e->time = B_NOW; uchar status, uchar data1, uchar data2, uint32 time)
e->data.all_notes_off.just_channel = just_chan; {
_evt_list->AddItem(e); 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; void BMidiStore::SystemRealTime(uchar status, uint32 time)
file_entry.GetPath(&file_path); {
ifstream inf(file_path.Path(), ios::in | ios::binary); BMidiEvent* event = new BMidiEvent;
if(!inf) { event->opcode = BMidiEvent::OP_SYSTEM_REAL_TIME;
return B_ERROR; event->time = B_NOW;
} event->systemRealTime.status = status;
inf.seekg(0,ios::end); events->AddItem(event);
uint32 file_len = inf.tellg(); }
if(file_len < 16) {
return B_BAD_MIDI_DATA; //------------------------------------------------------------------------------
}
inf.seekg(ios::beg); void BMidiStore::TempoChange(int32 beatsPerMinute, uint32 time)
uint8 * data = new uint8[file_len]; {
if(data == NULL) { BMidiEvent* event = new BMidiEvent;
return B_ERROR; event->opcode = BMidiEvent::OP_TEMPO_CHANGE;
} event->time = B_NOW;
inf.read(data,file_len); event->tempoChange.beatsPerMinute = beatsPerMinute;
inf.close(); events->AddItem(event);
uint8 * d = data; }
if(strncmp((const char *)d,"MThd",4) != 0) {
return B_BAD_MIDI_DATA; //------------------------------------------------------------------------------
}
d += 4; void BMidiStore::AllNotesOff(bool justChannel, uint32 time)
uint32 hdr_len; {
PACK_4_U8_TO_U32(d,hdr_len); BMidiEvent* event = new BMidiEvent;
if(hdr_len != 6) { event->opcode = BMidiEvent::OP_ALL_NOTES_OFF;
return B_BAD_MIDI_DATA; event->time = B_NOW;
} event->allNotesOff.justChannel = justChannel;
d += 4; events->AddItem(event);
uint32 format; }
uint32 tracks;
uint32 division; //------------------------------------------------------------------------------
PACK_2_U8_TO_U16(d,format);
d += 2; status_t BMidiStore::Import(const entry_ref* ref)
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;
}
return B_OK; return B_OK;
} }
status_t BMidiStore::Export(const entry_ref * ref, int32 format) { //------------------------------------------------------------------------------
ofstream ouf(ref->name, ios::out | ios::binary);
if(!ouf) { status_t BMidiStore::Export(const entry_ref* ref, int32 format)
return B_ERROR; {
}
ouf.write("MHdr",4);
ouf.close();
return B_OK; 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; void BMidiStore::_ReservedMidiStore1() { }
uint32 last_time = _start_time; void BMidiStore::_ReservedMidiStore2() { }
while(KeepRunning()) {
BMidiEvent * e = (BMidiEvent *)_evt_list->ItemAt(_cur_evt); //------------------------------------------------------------------------------
if(e == NULL) {
return; void BMidiStore::Run()
} {
uint32 tick = e->time; startTime = B_NOW;
uint32 tick_delta = tick - last_tick;
uint32 beat_len = (60000 / _tempo); while (KeepRunning())
uint32 delta_time = (beat_len * tick_delta) / _ticks_per_beat; {
uint32 time = last_time + delta_time; BMidiEvent* event = EventAt(curEvent);
last_time = time;
last_tick = tick; if (event == NULL) { return; }
BMidiEvent::Data & d = e->data;
cerr << "event 0x" << hex << e->opcode << " time = " << time << endl; uint32 oldTime = event->time;
switch(e->opcode) { event->time += startTime;
case BMidiEvent::OP_NOTE_OFF: SprayMidiEvent(event);
SprayNoteOff(d.note_off.channel, event->time = oldTime;
d.note_off.note, d.note_off.velocity,time);
break; ++curEvent;
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++;
} }
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Decode and Encode Routines
uint8* BMidiStore::_DecodeTrack(uint8* d) { BMidiEvent* BMidiStore::EventAt(uint32 index) const
if(strncmp((const char *)d,"MTrk",4) != 0) { {
throw B_BAD_MIDI_DATA; return (BMidiEvent*) events->ItemAt(index);
}
// 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;
} }
//------------------------------------------------------------------------------
void BMidiStore::_DecodeFormat0Tracks(uint8 * data, uint16 tracks, int BMidiStore::CompareEvents(const void* event1, const void* event2)
uint32 len) { {
_DecodeTrack(data); 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 @@
//----------------------------------------------------------------------------- /**
// * @file MidiText.cpp
#include <MidiText.h> *
#include <iostream.h> * @author Matthijs Hollemans
* @author Jerome Leveque
* @author Paul Stadler
*/
#include <iostream>
#include "debug.h"
#include "MidiEvent.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(); void BMidiText::NoteOff(
cout << ":NOTE OFF;channel = " << (int)chan uchar channel, uchar note, uchar velocity, uint32 time)
<< ",note = " << (int)note << ",velocity = " << (int)vel << endl; {
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(); void BMidiText::NoteOn(
cout << ":NOTE ON;channel = " << (int)chan uchar channel, uchar note, uchar velocity, uint32 time)
<< ",note = " << (int)note << ",velocity = " << (int)vel << endl; {
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(); void BMidiText::KeyPressure(
cout << ":KEY PRESSURE;channel = " << (int)chan uchar channel, uchar note, uchar pressure, uint32 time)
<< ",note = " << (int)note << ",pressure = " << (int)pres << endl; {
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); void BMidiText::ControlChange(
_PrintTime(); uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
cout << ":CONTROL CHANGE;channel = " << (int)chan {
<< ",control = " << (int)ctrl_num WaitAndPrint(time);
<< ",value = "<< (int)ctrl_val << endl; 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(); void BMidiText::ProgramChange(
cout << ":PROGRAM CHANGE;channel = " << (int)chan uchar channel, uchar programNumber, uint32 time)
<< ",program = " << (int)prog_num << endl; {
WaitAndPrint(time);
cout << ": PROGRAM CHANGE; channel = " << (int) channel
<< ", program = " << (int) programNumber << endl;
} }
void BMidiText::ChannelPressure(uchar chan, uchar pres, uint32 time) { //------------------------------------------------------------------------------
SnoozeUntil(time);
_PrintTime(); void BMidiText::ChannelPressure(uchar channel, uchar pressure, uint32 time)
cout << ":CHANNEL PRESSURE;channel = " << (int)chan {
<< ",pressure = " << (int)pres << endl; 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(); void BMidiText::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
cout << ":PITCH BEND;channel = " << (int)chan << hex {
<< ",lsb = " << (int)lsb << ",msb = " << (int)msb << endl; 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(); void BMidiText::SystemExclusive(void* data, size_t dataLength, uint32 time)
cout << ":SYSTEM EXCLUSIVE;"; {
for(size_t i = 0; i < data_len; i++) { WaitAndPrint(time);
cout << hex << (int)((char *)data)[i];
cout << ": SYSTEM EXCLUSIVE;";
for (size_t i = 0; i < dataLength; i++)
{
cout << " " << hex << (int) ((uint8*) data)[i];
} }
cout << endl; cout << endl;
} }
void BMidiText::SystemCommon(uchar stat_byte, uchar data1, //------------------------------------------------------------------------------
uchar data2, uint32 time) {
SnoozeUntil(time); void BMidiText::SystemCommon(
_PrintTime(); uchar status, uchar data1, uchar data2, uint32 time)
cout << ":SYSTEM COMMON;status = " << hex << (int)stat_byte {
<< ",data1 = " << (int)data1 << ",data2 = " << (int)data2 << endl; 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(); void BMidiText::SystemRealTime(uchar status, uint32 time)
cout << ":SYSTEM REAL TIME;status = " << hex << (int)stat << endl; {
WaitAndPrint(time);
cout << ": SYSTEM REAL TIME; status = " << hex << (int) status << endl;
} }
void BMidiText::TempoChange(int32 bpm, uint32 time) { //------------------------------------------------------------------------------
SnoozeUntil(time);
_PrintTime(); void BMidiText::TempoChange(int32 beatsPerMinute, uint32 time)
cout << ":TEMPO CHANGE;" << "beatsperminute = " << bpm << endl; {
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(); void BMidiText::ResetTimer(bool start)
cout << ":ALL NOTES OFF;" << endl; {
startTime = start ? B_NOW : 0;
} }
void BMidiText::ResetTimer(bool start) { //------------------------------------------------------------------------------
if(start) {
_start_time = (uint32)(system_time() / 1000); void BMidiText::_ReservedMidiText1() { }
} else {
_start_time = 0; //------------------------------------------------------------------------------
void BMidiText::Run()
{
while (KeepRunning())
{
snooze(50000);
} }
} }
//----------------------------------------------------------------------------- //------------------------------------------------------------------------------
//
void BMidiText::_PrintTime() { void BMidiText::WaitAndPrint(uint32 time)
uint32 cur_time = B_NOW; {
if(_start_time == 0) { if (startTime == 0) { startTime = time; }
_start_time = cur_time;
} SnoozeUntil(time);
cout << (cur_time - _start_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;
}
//------------------------------------------------------------------------------