Some correction, and class BMidiStore.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2047 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
jerl1
2002-11-21 19:23:22 +00:00
parent ef3a275d0f
commit eac71506d6
8 changed files with 1253 additions and 595 deletions
+108 -73
View File
@@ -1,8 +1,9 @@
#ifndef _MIDI_H
#define _MIDI_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <MidiDefs.h>
#include <OS.h>
@@ -12,115 +13,149 @@ class BList;
class BMidi
{
public:
BMidi();
virtual ~BMidi();
BMidi();
virtual ~BMidi();
virtual void NoteOff(
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
virtual void NoteOff(uchar channel,
uchar note,
uchar velocity,
uint32 time = B_NOW);
virtual void NoteOn(
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
virtual void NoteOn(uchar channel,
uchar note,
uchar velocity,
uint32 time = B_NOW);
virtual void KeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
virtual void KeyPressure(uchar channel,
uchar note,
uchar pressure,
uint32 time = B_NOW);
virtual void ControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
uint32 time = B_NOW);
virtual void ControlChange(uchar channel,
uchar controlNumber,
uchar controlValue,
uint32 time = B_NOW);
virtual void ProgramChange(
uchar channel, uchar programNumber, uint32 time = B_NOW);
virtual void ProgramChange(uchar channel,
uchar programNumber,
uint32 time = B_NOW);
virtual void ChannelPressure(
uchar channel, uchar pressure, uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel,
uchar pressure,
uint32 time = B_NOW);
virtual void PitchBend(
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
virtual void PitchBend(uchar channel,
uchar lsb,
uchar msb,
uint32 time = B_NOW);
virtual void SystemExclusive(
void* data, size_t dataLength, uint32 time = B_NOW);
virtual void SystemExclusive(void* data,
size_t dataLength,
uint32 time = B_NOW);
virtual void SystemCommon(
uchar status, uchar data1, uchar data2, uint32 time = B_NOW);
virtual void SystemCommon(uchar statusByte,
uchar data1,
uchar data2,
uint32 time = B_NOW);
virtual void SystemRealTime(uchar status, uint32 time = B_NOW);
virtual void SystemRealTime(uchar statusByte, uint32 time = B_NOW);
virtual void TempoChange(int32 beatsPerMinute, uint32 time = B_NOW);
virtual void TempoChange(int32 bpm, uint32 time = B_NOW);
virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW);
virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW);
virtual status_t Start();
virtual void Stop();
bool IsRunning() const;
virtual status_t Start();
virtual void Stop();
bool IsRunning() const;
void Connect(BMidi* toObject);
void Disconnect(BMidi* fromObject);
bool IsConnected(BMidi* toObject) const;
BList* Connections() const;
void Connect(BMidi* toObject);
void Disconnect(BMidi* fromObject);
bool IsConnected(BMidi* toObject) const;
BList* Connections() const;
void SnoozeUntil(uint32 time) const;
void SnoozeUntil(uint32 time) const;
protected:
void SprayNoteOff(uchar channel,
uchar note,
uchar velocity,
uint32 time) const;
void SprayNoteOff(
uchar channel, uchar note, uchar velocity, uint32 time) const;
void SprayNoteOn(uchar channel,
uchar note,
uchar velocity,
uint32 time) const;
void SprayNoteOn(
uchar channel, uchar note, uchar velocity, uint32 time) const;
void SprayKeyPressure(uchar channel,
uchar note,
uchar pressure,
uint32 time) const;
void SprayKeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time) const;
void SprayControlChange(uchar channel,
uchar controlNumber,
uchar controlValue,
uint32 time) const;
void SprayControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
uint32 time) const;
void SprayProgramChange(uchar channel,
uchar programNumber,
uint32 time) const;
void SprayProgramChange(
uchar channel, uchar programNumber, uint32 time) const;
void SprayChannelPressure(uchar channel,
uchar pressure,
uint32 time) const;
void SprayChannelPressure(
uchar channel, uchar pressure, uint32 time) const;
void SprayPitchBend(uchar channel,
uchar lsb,
uchar msb,
uint32 time) const;
void SprayPitchBend(
uchar channel, uchar lsb, uchar msb, uint32 time) const;
void SpraySystemExclusive(void* data,
size_t dataLength,
uint32 time = B_NOW) const;
void SpraySystemExclusive(
void* data, size_t dataLength, uint32 time = B_NOW) const;
void SpraySystemCommon(uchar statusByte,
uchar data1,
uchar data2,
uint32 time) const;
void SpraySystemCommon(
uchar status, uchar data1, uchar data2, uint32 time) const;
void SpraySystemRealTime(uchar statusByte, uint32 time) const;
void SpraySystemRealTime(uchar status, uint32 time) const;
void SprayTempoChange(int32 bpm, uint32 time) const;
void SprayTempoChange(int32 beatsPerMinute, uint32 time) const;
bool KeepRunning();
bool KeepRunning();
private:
friend class BMidiStore;
friend class BMidiPort; /* for debugging */
friend class BMidiStore; /* for debugging */
virtual void _ReservedMidi1();
virtual void _ReservedMidi2();
virtual void _ReservedMidi3();
virtual void _ReservedMidi1();
virtual void _ReservedMidi2();
virtual void _ReservedMidi3();
static int32 RunThread(void* data);
static int32 InflowThread(void* data);
friend status_t _run_thread_(void *arg);
friend status_t _inflow_task_(void *arg);
virtual void Run();
void Inflow();
void SprayMidiEvent(BMidiEvent* event) const;
port_id ID() const;
void SprayMidiEvent(BMidiEvent* event) const;
virtual void Run();
BList* connections;
thread_id runThread;
thread_id inflowThread;
port_id inflowPort;
bool isRunning;
bool inflowAlive;
status_t StartInflow();
void StopInflow();
bool IsInflowing();
void InflowTask();
bool InflowIsAlive();
uint32 _reserved[5];
BList* fConnectionList;
volatile thread_id fRunTask;
volatile bool fIsRunning;
volatile thread_id fInflowTask;
volatile bool fInflowAlive;
port_id fInflowPort;
uint32 _reserved[4];
};
#endif // _MIDI_H
#endif
+139 -66
View File
@@ -1,105 +1,178 @@
#ifndef _MIDI_STORE_H
#define _MIDI_STORE_H
#ifndef _BE_BUILD_H
#include <BeBuild.h>
#endif
#include <Midi.h>
struct entry_ref;
class BMidiEvent;
class BList;
class BFile;
class BMidiStore : public BMidi
{
/*------------------------------------------------------------*/
class BMidiStore : public BMidi {
public:
BMidiStore();
virtual ~BMidiStore();
BMidiStore();
virtual ~BMidiStore();
virtual void NoteOff(
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
virtual void NoteOff(uchar channel,
uchar note,
uchar velocity,
uint32 time = B_NOW);
virtual void NoteOn(
uchar channel, uchar note, uchar velocity, uint32 time = B_NOW);
virtual void NoteOn(uchar channel,
uchar note,
uchar velocity,
uint32 time = B_NOW);
virtual void KeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time = B_NOW);
virtual void KeyPressure(uchar channel,
uchar note,
uchar pressure,
uint32 time = B_NOW);
virtual void ControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
uint32 time = B_NOW);
virtual void ControlChange(uchar channel,
uchar controlNumber,
uchar controlValue,
uint32 time = B_NOW);
virtual void ProgramChange(
uchar channel, uchar programNumber, uint32 time = B_NOW);
virtual void ProgramChange(uchar channel,
uchar programNumber,
uint32 time = B_NOW);
virtual void ChannelPressure(
uchar channel, uchar pressure, uint32 time = B_NOW);
virtual void ChannelPressure(uchar channel,
uchar pressure,
uint32 time = B_NOW);
virtual void PitchBend(
uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW);
virtual void PitchBend(uchar channel,
uchar lsb,
uchar msb,
uint32 time = B_NOW);
virtual void SystemExclusive(
void* data, size_t dataLength, uint32 time = B_NOW);
virtual void SystemExclusive(void* data,
size_t dataLength,
uint32 time = B_NOW);
virtual void SystemCommon(
uchar status, uchar data1, uchar data2, uint32 time = B_NOW);
virtual void SystemCommon(uchar statusByte,
uchar data1,
uchar data2,
uint32 time = B_NOW);
virtual void SystemRealTime(uchar status, uint32 time = B_NOW);
virtual void SystemRealTime(uchar statusByte, uint32 time = B_NOW);
virtual void TempoChange(int32 beatsPerMinute, uint32 time = B_NOW);
virtual void TempoChange(int32 bpm, uint32 time = B_NOW);
virtual void AllNotesOff(bool justChannel = true, uint32 time = B_NOW);
status_t Import(const entry_ref *ref);
status_t Export(const entry_ref *ref, int32 format);
status_t Import(const entry_ref* ref);
status_t Export(const entry_ref* ref, int32 format);
void SortEvents(bool force=false);
uint32 CountEvents() const;
void SortEvents(bool force = false);
uint32 CountEvents() const;
uint32 CurrentEvent() const;
void SetCurrentEvent(uint32 eventNumber);
uint32 CurrentEvent() const;
void SetCurrentEvent(uint32 eventNumber);
uint32 DeltaOfEvent(uint32 eventNumber) const;
uint32 EventAtDelta(uint32 time) const;
uint32 DeltaOfEvent(uint32 eventNumber) const;
uint32 EventAtDelta(uint32 time) const;
uint32 BeginTime() const;
void SetTempo(int32 beatsPerMinute);
int32 Tempo() const;
uint32 BeginTime() const;
void SetTempo(int32 bpm);
int32 Tempo() const;
private:
virtual void _ReservedMidiStore1();
virtual void _ReservedMidiStore2();
virtual void _ReservedMidiStore1();
virtual void _ReservedMidiStore2();
virtual void _ReservedMidiStore3();
virtual void Run();
virtual void Run();
BMidiEvent* EventAt(uint32 index) const;
void AddEvent(uint32 time,
bool inMS,
uchar type,
uchar data1 = 0,
uchar data2 = 0,
uchar data3 = 0,
uchar data4 = 0);
static int CompareEvents(const void* event1, const void* event2);
void AddSystemExclusive(void* data, size_t dataLength);
status_t ReadHeader();
bool ReadMT(char*);
int32 Read32Bit();
int32 EGetC();
int32 To32Bit(int32, int32, int32, int32);
int32 Read16Bit();
int32 To16Bit(int32, int32);
bool ReadTrack();
int32 ReadVariNum();
void ChannelMessage(int32, int32, int32);
void MsgInit();
void MsgAdd(int32);
void BiggerMsg();
void MetaEvent(int32);
int32 MsgLength();
uchar* Msg();
void BadByte(int32);
int32 PutC(int32 c);
bool WriteTrack(int32 track);
void WriteTempoTrack();
bool WriteTrackChunk(int32 whichTrack);
void WriteHeaderChunk(int32 format);
bool WriteMidiEvent(uint32 deltaTime,
uint32 type,
uint32 channel,
uchar* data,
uint32 size);
bool WriteMetaEvent(uint32 deltaTime,
uint32 type,
uchar* data,
uint32 size);
bool WriteSystemExclusiveEvent(uint32 deltaTime,
uchar* data,
uint32 size);
void WriteTempo(uint32 deltaTime, int32 tempo);
void WriteVarLen(uint32 value);
void Write32Bit(uint32 data);
void Write16Bit(ushort data);
int32 EPutC(uchar c);
uint32 TicksToMilliseconds(uint32 ticks) const;
uint32 MillisecondsToTicks(uint32 ms) const;
void ReadFileHeader();
void ReadTrackHeader();
void ReadTrack();
int32 Read32Bit();
int16 Read16Bit();
void ReadData(uint8* data, size_t size);
BList *events;
// uint32 fNumEvents;
// uint32 fEventsSize;
uint32 fCurrEvent;
bool fNeedsSorting;
// bool fResetTimer;
uint32 fStartTime;
BFile* fFile;
short fDivision;
float fDivisionFactor;
int32 fTempo;
int32 fCurrTime;
int32 fCurrTrack;
int32 fNumTracks;
// int32 fToBeRead;
// int32 fMsgIndex;
// int32 fMsgSize;
// uchar* fMsgBuff;
int32 fNumBytesWritten;
BList* events;
uint32 tempo;
uint32 curEvent;
uint32 startTime;
uint32 ticksPerBeat;
BFile* file;
int32 numTracks;
int32 trackSize;
int16 division;
uint16 _reserved1;
uint32 _reserved2[17];
uchar* fFileBuffer;
int32 fFileBufferMax;
int32 fFileBufferSize;
int32 fFileBufferIndex;
uint32 _reserved[4];
};
#endif // _MIDI_STORE_H
/*------------------------------------------------------------*/
#endif
+169 -148
View File
@@ -8,128 +8,170 @@
#include <List.h>
#include "debug.h"
#include "Midi.h"
#include "debug.h"
#include "MidiEvent.h"
#define MSG_CODE_PROCESS_EVENT 1
#define MSG_CODE_TERMINATE_THREAD 0
#define DEBUG
//------------------------------------------------------------------------------
//-----------------------------------------------
#define MSG_CODE_PROCESS_EVENT 1
#define MSG_CODE_TERMINATE_THREAD 0
//-----------------------------------------------
//-----------------------------------------------------------------------------
// Initialization Stuff
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);
fConnectionList = new BList();
fIsRunning = false;
fInflowPort = create_port(1, "Inflow Port");
fInflowTask = spawn_thread(
_inflow_task_, "BMidi Inflow Thread",
B_REAL_TIME_PRIORITY, (void *)this);
fInflowAlive = resume_thread(fInflowTask) == B_OK;
}
//------------------------------------------------------------------------------
BMidi::~BMidi()
{
write_port(inflowPort, MSG_CODE_TERMINATE_THREAD, NULL, 0);
write_port(fInflowPort, MSG_CODE_TERMINATE_THREAD, NULL, 0);
status_t exitValue;
wait_for_thread(inflowThread, &exitValue);
status_t exit_value;
wait_for_thread(fInflowTask, &exit_value);
delete_port(inflowPort);
delete connections;
delete_port(fInflowPort);
delete fConnectionList;
}
//------------------------------------------------------------------------------
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) { }
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// 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()
{
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;
fRunTask = spawn_thread(_run_thread_,
"BMidi Run Thread", B_REAL_TIME_PRIORITY, (void *)this);
fIsRunning = true;
status_t ret = resume_thread(fRunTask);
if(ret != B_OK)
{
fIsRunning = false;
}
return ret;
return B_OK;
}
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void BMidi::Stop()
{
status_t exitValue;
wait_for_thread(runThread, &exitValue);
isRunning = false;
status_t exit_value;
status_t ret;
fIsRunning = false;
ret = wait_for_thread(fRunTask, &exit_value);
}
//------------------------------------------------------------------------------
bool BMidi::IsRunning() const
{
return isRunning;
thread_info info;
get_thread_info(fRunTask,&info);
if(find_thread("BMidi Run Thread") == fRunTask)
return true;
return false;
}
//------------------------------------------------------------------------------
void BMidi::Connect(BMidi* toObject)
void BMidi::Connect(BMidi *to_object)
{
connections->AddItem(toObject);
fConnectionList->AddItem((void *)to_object);
}
//------------------------------------------------------------------------------
void BMidi::Disconnect(BMidi* fromObject)
void BMidi::Disconnect(BMidi *from_object)
{
connections->RemoveItem(fromObject);
fConnectionList->RemoveItem((void *)from_object);
}
//------------------------------------------------------------------------------
bool BMidi::IsConnected(BMidi* toObject) const
bool BMidi::IsConnected(BMidi * to_object) const
{
return connections->HasItem(toObject);
return fConnectionList->HasItem((void *)to_object);
}
//------------------------------------------------------------------------------
BList* BMidi::Connections() const
BList * BMidi::Connections() const
{
return connections;
return fConnectionList;
}
//------------------------------------------------------------------------------
void BMidi::SnoozeUntil(uint32 time) const
{
snooze_until((uint64) time * 1000, B_SYSTEM_TIMEBASE);
snooze_until((uint64)time*1000, B_SYSTEM_TIMEBASE);
}
//------------------------------------------------------------------------------
bool BMidi::KeepRunning()
{
return fIsRunning;
}
void BMidi::Run()
{
while(KeepRunning())
snooze(50000);
}
//-----------------------------------------------------------------------------
// Spray Functions
void BMidi::SprayMidiEvent(BMidiEvent *e) const
{
// TRACE(("Hello"))
int32 num_connections = fConnectionList->CountItems();
BMidi *m;
for(int32 i = 0; i < num_connections; i++)
{
m = (BMidi *)fConnectionList->ItemAt(i);
write_port(m->fInflowPort, MSG_CODE_PROCESS_EVENT, e, sizeof(BMidiEvent));
}
}
//----------------------
void BMidi::SprayNoteOff(
uchar channel, uchar note, uchar velocity, uint32 time) const
@@ -143,7 +185,7 @@ void BMidi::SprayNoteOff(
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
//----------------------
void BMidi::SprayNoteOn(
uchar channel, uchar note, uchar velocity, uint32 time) const
@@ -157,7 +199,7 @@ void BMidi::SprayNoteOn(
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
//----------------------
void BMidi::SprayKeyPressure(
uchar channel, uchar note, uchar pressure, uint32 time) const
@@ -171,7 +213,7 @@ void BMidi::SprayKeyPressure(
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
//----------------------
void BMidi::SprayControlChange(
uchar channel, uchar controlNumber, uchar controlValue,
@@ -186,7 +228,7 @@ void BMidi::SprayControlChange(
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
//----------------------
void BMidi::SprayProgramChange(
uchar channel, uchar programNumber, uint32 time) const
@@ -199,7 +241,7 @@ void BMidi::SprayProgramChange(
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
//----------------------
void BMidi::SprayChannelPressure(
uchar channel, uchar pressure, uint32 time) const
@@ -212,7 +254,7 @@ void BMidi::SprayChannelPressure(
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
//----------------------
void BMidi::SprayPitchBend(
uchar channel, uchar lsb, uchar msb, uint32 time) const
@@ -226,22 +268,22 @@ void BMidi::SprayPitchBend(
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
//----------------------
void BMidi::SpraySystemExclusive(
void* data, size_t dataLength, uint32 time) const
void * data, size_t dataLength, uint32 time) const
{
//TODO: Should this data be duplicated!!??
// Should this data be duplicated!!?? I think Yes.
BMidiEvent event;
event.time = time;
event.opcode = BMidiEvent::OP_SYSTEM_EXCLUSIVE;
event.systemExclusive.data = (uint8*) data;
event.systemExclusive.data = new uint8[dataLength];
memcpy(event.systemExclusive.data, data, dataLength);
event.systemExclusive.dataLength = dataLength;
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
//----------------------
void BMidi::SpraySystemCommon(
uchar status, uchar data1, uchar data2, uint32 time) const
@@ -255,7 +297,7 @@ void BMidi::SpraySystemCommon(
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
//----------------------
void BMidi::SpraySystemRealTime(uchar status, uint32 time) const
{
@@ -266,7 +308,7 @@ void BMidi::SpraySystemRealTime(uchar status, uint32 time) const
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
//----------------------
void BMidi::SprayTempoChange(int32 beatsPerMinute, uint32 time) const
{
@@ -277,44 +319,20 @@ void BMidi::SprayTempoChange(int32 beatsPerMinute, uint32 time) const
SprayMidiEvent(&event);
}
//------------------------------------------------------------------------------
bool BMidi::KeepRunning()
{
return isRunning;
}
//------------------------------------------------------------------------------
void BMidi::_ReservedMidi1() { }
void BMidi::_ReservedMidi2() { }
void BMidi::_ReservedMidi3() { }
//------------------------------------------------------------------------------
void BMidi::Run()
{
while (KeepRunning())
{
snooze(50000);
}
}
//------------------------------------------------------------------------------
void BMidi::Inflow()
//-----------------------------------------------------------------------------
// The Inflow Thread
void BMidi::InflowTask()
{
BMidiEvent event;
int32 code;
size_t len;
while (true)
while(true)
{
len = read_port(inflowPort, &code, &event, sizeof(event));
len = read_port(fInflowPort, &code, &event, sizeof(BMidiEvent));
if (code == MSG_CODE_TERMINATE_THREAD) { return; }
if (len != sizeof(event)) { continue; } // ignore errors
if (len != sizeof(BMidiEvent)) { continue; } //ignore errors
switch (event.opcode)
{
@@ -332,7 +350,7 @@ void BMidi::Inflow()
break;
case BMidiEvent::OP_NOTE_ON:
NoteOff(
NoteOn(
event.noteOn.channel,
event.noteOn.note,
event.noteOn.velocity,
@@ -409,38 +427,41 @@ void BMidi::Inflow()
}
}
//------------------------------------------------------------------------------
//----------------------
//----------------------
//----------------------
//----------------------
//----------------------
//----------------------
//----------------------
//----------------------
void BMidi::SprayMidiEvent(BMidiEvent* event) const
void BMidi::_ReservedMidi1() {}
void BMidi::_ReservedMidi2() {}
void BMidi::_ReservedMidi3() {}
//----------------------
status_t _run_thread_(void *data)
{
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();
((BMidi*)data)->Run();
return 0;
}
//------------------------------------------------------------------------------
//----------------------
int32 BMidi::InflowThread(void* data)
status_t _inflow_task_(void * data)
{
((BMidi*) data)->Inflow();
((BMidi*)data)->InflowTask();
return 0;
}
//------------------------------------------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
//-----------------------------------------------
+2
View File
@@ -18,6 +18,8 @@ BMidiEvent::BMidiEvent()
BMidiEvent::~BMidiEvent()
{
if (opcode == OP_SYSTEM_EXCLUSIVE)
delete systemExclusive.data;
}
//------------------------------------------------------------------------------
+2 -2
View File
@@ -140,7 +140,7 @@ return fName;
void BMidiPort::NoteOff(
uchar channel, uchar note, uchar velocity, uint32 time)
{
local_source->SprayNoteOff(channel, note, velocity, 0);
local_source->SprayNoteOff(channel, note, velocity, time);
}
//------------------------------------------------------------------------------
@@ -148,7 +148,7 @@ void BMidiPort::NoteOff(
void BMidiPort::NoteOn(
uchar channel, uchar note, uchar velocity, uint32 time)
{
local_source->SprayNoteOn(channel, note, velocity, 0);
local_source->SprayNoteOn(channel, note, velocity, time);
}
//------------------------------------------------------------------------------
+1 -1
View File
@@ -6,7 +6,7 @@
//----------------------------------------
#include <MidiPortConsumer.h>
#include "MidiPortConsumer.h"
//----------------------------------------
File diff suppressed because it is too large Load Diff
@@ -74,8 +74,8 @@ void Activity::Pulse(void)
void Activity::NoteOn(uchar channel, uchar note,
uchar velocity, uint32 time = B_NOW)
{//This function just update the variable
fActivity[channel - 1] = system_time();
BMidi::NoteOn(channel, note, velocity, time);
fActivity[channel] = system_time();
SprayNoteOn(channel, note, velocity, time);
}
//----------------------------------------------------------