Made correction asked to me
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1957 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -67,11 +67,12 @@ private:
|
||||
virtual void Run();
|
||||
friend class BMidiPortConsumer;
|
||||
|
||||
void Dispatch(
|
||||
const unsigned char* buffer, size_t size, bigtime_t when);
|
||||
//Can I do that?
|
||||
// void Dispatch(
|
||||
// const unsigned char* buffer, size_t size, bigtime_t when);
|
||||
|
||||
ssize_t Read(void* buffer, size_t numBytes) const;
|
||||
ssize_t Write(void* buffer, size_t numBytes, uint32 time) const;
|
||||
// ssize_t Read(void* buffer, size_t numBytes) const;
|
||||
// ssize_t Write(void* buffer, size_t numBytes, uint32 time) const;
|
||||
|
||||
void ScanDevices();
|
||||
|
||||
@@ -84,9 +85,10 @@ private:
|
||||
char* fName;
|
||||
status_t fCStatus;
|
||||
BList* _fDevices;
|
||||
uint8 _m_prev_cmd;
|
||||
bool _m_enhanced;
|
||||
uint8 _m_reserved[2];
|
||||
// uint8 _m_prev_cmd;
|
||||
// bool _m_enhanced;
|
||||
// uint8 _m_reserved[2];
|
||||
uint8 _reserved[4];
|
||||
};
|
||||
|
||||
#endif // _MIDI_PORT_H
|
||||
|
||||
+302
-317
@@ -1,317 +1,302 @@
|
||||
/**
|
||||
* @file MidiPort.cpp
|
||||
*
|
||||
* @author Jerome Leveque
|
||||
*/
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
#include "MidiPortConsumer.cpp"
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
#include <MidiPort.h>
|
||||
#include <MidiRoster.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <MidiProducer.h>
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
//----------------------------------------
|
||||
//Public function
|
||||
|
||||
BMidiPort::BMidiPort(const char *name = NULL)
|
||||
: BMidi(),
|
||||
remote_source(NULL),
|
||||
remote_sink(NULL),
|
||||
fCStatus(B_ERROR),
|
||||
_fDevices(new BList)
|
||||
{
|
||||
local_source = new BMidiLocalProducer("MidiPortGlue(out)");
|
||||
if (local_source != NULL)
|
||||
local_source->Register();
|
||||
local_sink = new BMidiPortConsumer(this, "MidiPortGlue(in)");
|
||||
if (local_sink != NULL)
|
||||
local_sink->Register();
|
||||
|
||||
ScanDevices();
|
||||
Open(name);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
BMidiPort::~BMidiPort()
|
||||
{
|
||||
Close();
|
||||
delete fName;
|
||||
if (local_source)
|
||||
local_source->Release();
|
||||
if (local_sink)
|
||||
local_sink->Release();
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
status_t BMidiPort::InitCheck() const
|
||||
{
|
||||
return fCStatus;
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
status_t BMidiPort::Open(const char *name)
|
||||
{
|
||||
if (name == NULL)
|
||||
return fCStatus = B_ERROR;
|
||||
|
||||
if (remote_source != NULL)
|
||||
{
|
||||
if (local_sink != NULL)
|
||||
{
|
||||
remote_source->Disconnect(local_sink);
|
||||
}
|
||||
remote_source->Release();
|
||||
remote_source = NULL;
|
||||
}
|
||||
if (remote_sink != NULL)
|
||||
{
|
||||
if (local_source != NULL)
|
||||
{
|
||||
local_source->Disconnect(remote_sink);
|
||||
}
|
||||
remote_sink->Release();
|
||||
remote_sink = NULL;
|
||||
}
|
||||
|
||||
int32 id = 0;
|
||||
BMidiRoster *roster = BMidiRoster::MidiRoster();
|
||||
if (roster == NULL)
|
||||
return fCStatus = B_ERROR;
|
||||
BMidiEndpoint *endpt = NULL;
|
||||
while ((endpt = roster->NextEndpoint(&id)) != NULL)
|
||||
{
|
||||
if (strcmp(endpt->Name(), name) == 0)
|
||||
{//An endpoint have the same name as we want
|
||||
fName = new char[strlen(name)];
|
||||
if (fName != NULL)
|
||||
strcpy(fName, name);
|
||||
if (endpt->IsProducer())
|
||||
{
|
||||
remote_source = (BMidiProducer*)endpt;
|
||||
endpt->Acquire(); //Because we always call Release()
|
||||
}
|
||||
if (endpt->IsConsumer())
|
||||
{
|
||||
remote_sink = (BMidiConsumer*)endpt;
|
||||
endpt->Acquire();//Because we always call Release()
|
||||
if (local_source != NULL)
|
||||
local_source->Connect(remote_sink);
|
||||
}
|
||||
}
|
||||
endpt->Release();
|
||||
}
|
||||
return fCStatus = B_OK;
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::Close()
|
||||
{
|
||||
if ((local_sink != NULL) && (remote_source != NULL))
|
||||
{
|
||||
remote_source->Disconnect(local_sink);
|
||||
remote_source->Release();
|
||||
remote_source = NULL;
|
||||
}
|
||||
if ((local_source != NULL) && (remote_sink != NULL))
|
||||
{
|
||||
local_source->Disconnect(remote_sink);
|
||||
remote_sink->Release();
|
||||
remote_sink = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
int32 BMidiPort::CountDevices()
|
||||
{
|
||||
return _fDevices->CountItems();
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
status_t BMidiPort::GetDeviceName(int32 n, char *name, size_t bufSize)
|
||||
{
|
||||
BMidiEndpoint *endpt = (BMidiEndpoint*)_fDevices->ItemAt(n);
|
||||
if (endpt == NULL)
|
||||
return B_BAD_VALUE;
|
||||
size_t size = strlen(endpt->Name());
|
||||
if (size > bufSize)
|
||||
return B_NAME_TOO_LONG;
|
||||
if (strlen(strcpy(name, endpt->Name())) == size)
|
||||
return B_OK;
|
||||
else
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
const char *BMidiPort::PortName() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
void BMidiPort::NoteOff(uchar channel, uchar note, uchar velocity, uint32 time = B_NOW)
|
||||
{
|
||||
local_source->SprayNoteOff(channel, note, velocity, 0);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::NoteOn(uchar channel, uchar note, uchar velocity, uint32 time = B_NOW)
|
||||
{
|
||||
local_source->SprayNoteOn(channel, note, velocity, 0);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::KeyPressure(uchar channel, uchar note, uchar pressure, uint32 time = B_NOW)
|
||||
{
|
||||
local_source->SprayKeyPressure(channel, note, pressure, 0);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::ControlChange(uchar channel, uchar controlNumber, uchar controlValue, uint32 time = B_NOW)
|
||||
{
|
||||
local_source->SprayControlChange(channel, controlNumber, controlValue, 0);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::ProgramChange(uchar channel, uchar programNumber, uint32 time = B_NOW)
|
||||
{
|
||||
local_source->SprayProgramChange(channel, programNumber, 0);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::ChannelPressure(uchar channel, uchar pressure, uint32 time = B_NOW)
|
||||
{
|
||||
local_source->SprayChannelPressure(channel, pressure, 0);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time = B_NOW)
|
||||
{
|
||||
local_source->SprayPitchBend(channel, lsb, msb, 0);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::SystemExclusive(void* data, size_t dataLength, uint32 time = B_NOW)
|
||||
{
|
||||
local_source->SpraySystemExclusive(data, dataLength, 0);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::SystemCommon(uchar statusByte, uchar data1, uchar data2, uint32 time = B_NOW)
|
||||
{
|
||||
local_source->SpraySystemCommon(statusByte, data1, data2, 0);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::SystemRealTime(uchar statusByte, uint32 time = B_NOW)
|
||||
{
|
||||
local_source->SpraySystemRealTime(statusByte, 0);
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
status_t BMidiPort::Start()
|
||||
{
|
||||
if ((local_sink != NULL) && (remote_source != NULL))
|
||||
if ((fCStatus = remote_source->Connect(local_sink)) != B_OK)
|
||||
return fCStatus;
|
||||
else
|
||||
{
|
||||
return BMidi::Start();
|
||||
}
|
||||
else
|
||||
return fCStatus = B_ERROR;
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::Stop()
|
||||
{
|
||||
if ((remote_source != NULL) && (local_sink != NULL))
|
||||
{
|
||||
remote_source->Disconnect(local_sink);
|
||||
}
|
||||
BMidi::Stop();
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
//Private Function
|
||||
|
||||
void BMidiPort::_ReservedMidiPort1() {}
|
||||
void BMidiPort::_ReservedMidiPort2() {}
|
||||
void BMidiPort::_ReservedMidiPort3() {}
|
||||
|
||||
//----------------------------------------
|
||||
//Not Used function
|
||||
|
||||
void BMidiPort::Dispatch(const unsigned char *buffer, size_t size, bigtime_t when) {}
|
||||
ssize_t BMidiPort::Read(void *buffer, size_t numBytes) const { return 0; }
|
||||
ssize_t BMidiPort::Write(void *buffer, size_t numBytes, uint32 time) const { return 0; }
|
||||
|
||||
//-----------------
|
||||
//Used function
|
||||
|
||||
void BMidiPort::Run()
|
||||
{
|
||||
while(KeepRunning())
|
||||
snooze(50000);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPort::ScanDevices()
|
||||
{
|
||||
int32 id = 0;
|
||||
BMidiRoster *roster = BMidiRoster::MidiRoster();
|
||||
if (roster == NULL)
|
||||
return;
|
||||
BMidiEndpoint *endpt = NULL;
|
||||
while ((endpt = roster->NextEndpoint(&id)) != NULL)
|
||||
{
|
||||
bool additem = true;
|
||||
for (int32 i = 0; i < _fDevices->CountItems(); i++)
|
||||
{
|
||||
BMidiEndpoint *endpoint = (BMidiEndpoint*)_fDevices->ItemAt(i);
|
||||
if (strcmp(endpt->Name(), endpoint->Name()) == 0)
|
||||
additem = false;
|
||||
}
|
||||
if (additem)
|
||||
_fDevices->AddItem(endpt);
|
||||
endpt->Release();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
/**
|
||||
* @file MidiPort.cpp
|
||||
*
|
||||
* @author Jerome Leveque
|
||||
* @author Matthijs Hollemans
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "MidiPort.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "MidiPortConsumer.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <MidiRoster.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <MidiProducer.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BMidiPort::BMidiPort(const char* name)
|
||||
: BMidi(),
|
||||
remote_source(NULL),
|
||||
remote_sink(NULL),
|
||||
fName(NULL),
|
||||
fCStatus(B_ERROR),
|
||||
_fDevices(new BList)
|
||||
{
|
||||
local_source = new BMidiLocalProducer("MidiPortGlue(out)");
|
||||
if (local_source != NULL)
|
||||
local_source->Register();
|
||||
local_sink = new BMidiPortConsumer(this, "MidiPortGlue(in)");
|
||||
if (local_sink != NULL)
|
||||
local_sink->Register();
|
||||
|
||||
ScanDevices();
|
||||
Open(name);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
BMidiPort::~BMidiPort()
|
||||
{
|
||||
Close();
|
||||
delete fName;
|
||||
delete _fDevices;
|
||||
if (local_source)
|
||||
local_source->Release();
|
||||
if (local_sink)
|
||||
local_sink->Release();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
status_t BMidiPort::InitCheck() const
|
||||
{
|
||||
return fCStatus;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
status_t BMidiPort::Open(const char* name)
|
||||
{
|
||||
if (name == NULL)
|
||||
return fCStatus = B_ERROR;
|
||||
|
||||
Close();
|
||||
|
||||
int32 id = 0;
|
||||
BMidiRoster *roster = BMidiRoster::MidiRoster();
|
||||
if (roster == NULL)
|
||||
return fCStatus = B_ERROR;
|
||||
BMidiEndpoint *endpt = NULL;
|
||||
while ((endpt = roster->NextEndpoint(&id)) != NULL)
|
||||
{
|
||||
if (strcmp(endpt->Name(), name) == 0)
|
||||
{//An endpoint have the same name as we want
|
||||
delete fName;
|
||||
fName = new char[strlen(name)];
|
||||
if (fName != NULL)
|
||||
strcpy(fName, name);
|
||||
//Can an Endpoint be Consumer AND Producer?
|
||||
if (endpt->IsProducer())
|
||||
{
|
||||
remote_source = (BMidiProducer*)endpt;
|
||||
// endpt->Acquire(); //Because we always call Release()
|
||||
}
|
||||
if (endpt->IsConsumer())
|
||||
{
|
||||
remote_sink = (BMidiConsumer*)endpt;
|
||||
// endpt->Acquire();//Because we always call Release()
|
||||
if (local_source != NULL)
|
||||
local_source->Connect(remote_sink);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
endpt->Release();
|
||||
}
|
||||
}
|
||||
return fCStatus = B_OK;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::Close()
|
||||
{
|
||||
if (remote_source != NULL)
|
||||
{
|
||||
if (local_sink != NULL)
|
||||
{
|
||||
remote_source->Disconnect(local_sink);
|
||||
}
|
||||
remote_source->Release();
|
||||
remote_source = NULL;
|
||||
}
|
||||
if (remote_sink != NULL)
|
||||
{
|
||||
if (local_source != NULL)
|
||||
{
|
||||
local_source->Disconnect(remote_sink);
|
||||
}
|
||||
remote_sink->Release();
|
||||
remote_sink = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const char* BMidiPort::PortName() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::NoteOff(
|
||||
uchar channel, uchar note, uchar velocity, uint32 time)
|
||||
{
|
||||
local_source->SprayNoteOff(channel, note, velocity, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::NoteOn(
|
||||
uchar channel, uchar note, uchar velocity, uint32 time)
|
||||
{
|
||||
local_source->SprayNoteOn(channel, note, velocity, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::KeyPressure(
|
||||
uchar channel, uchar note, uchar pressure, uint32 time)
|
||||
{
|
||||
local_source->SprayKeyPressure(channel, note, pressure, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::ControlChange(
|
||||
uchar channel, uchar controlNumber, uchar controlValue, uint32 time)
|
||||
{
|
||||
local_source->SprayControlChange(channel, controlNumber, controlValue, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::ProgramChange(
|
||||
uchar channel, uchar programNumber, uint32 time)
|
||||
{
|
||||
local_source->SprayProgramChange(channel, programNumber, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::ChannelPressure(uchar channel, uchar pressure, uint32 time)
|
||||
{
|
||||
local_source->SprayChannelPressure(channel, pressure, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::PitchBend(uchar channel, uchar lsb, uchar msb, uint32 time)
|
||||
{
|
||||
local_source->SprayPitchBend(channel, lsb, msb, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::SystemExclusive(void* data, size_t dataLength, uint32 time)
|
||||
{
|
||||
local_source->SpraySystemExclusive(data, dataLength, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::SystemCommon(
|
||||
uchar status, uchar data1, uchar data2, uint32 time)
|
||||
{
|
||||
local_source->SpraySystemCommon(statusByte, data1, data2, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::SystemRealTime(uchar status, uint32 time)
|
||||
{
|
||||
local_source->SpraySystemRealTime(statusByte, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
status_t BMidiPort::Start()
|
||||
{
|
||||
if ((local_sink != NULL) && (remote_source != NULL))
|
||||
if ((fCStatus = remote_source->Connect(local_sink)) != B_OK)
|
||||
return fCStatus;
|
||||
else
|
||||
{
|
||||
return BMidi::Start();
|
||||
}
|
||||
else
|
||||
return fCStatus = B_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::Stop()
|
||||
{
|
||||
if ((remote_source != NULL) && (local_sink != NULL))
|
||||
{
|
||||
remote_source->Disconnect(local_sink);
|
||||
}
|
||||
BMidi::Stop();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
int32 BMidiPort::CountDevices()
|
||||
{
|
||||
return _fDevices->CountItems();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
status_t BMidiPort::GetDeviceName(int32 n, char* name, size_t bufSize)
|
||||
{
|
||||
BMidiEndpoint *endpt = (BMidiEndpoint*)_fDevices->ItemAt(n);
|
||||
if (endpt == NULL)
|
||||
return B_BAD_VALUE;
|
||||
size_t size = strlen(endpt->Name());
|
||||
if (size > bufSize)
|
||||
return B_NAME_TOO_LONG;
|
||||
if (strlen(strcpy(name, endpt->Name())) == size)
|
||||
return B_OK;
|
||||
else
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::_ReservedMidiPort1() { }
|
||||
void BMidiPort::_ReservedMidiPort2() { }
|
||||
void BMidiPort::_ReservedMidiPort3() { }
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::Run()
|
||||
{
|
||||
while(KeepRunning())
|
||||
snooze(50000);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void BMidiPort::ScanDevices()
|
||||
{
|
||||
int32 id = 0;
|
||||
BMidiRoster *roster = BMidiRoster::MidiRoster();
|
||||
if (roster == NULL)
|
||||
return;
|
||||
BMidiEndpoint *endpt = NULL;
|
||||
while ((endpt = roster->NextEndpoint(&id)) != NULL)
|
||||
{
|
||||
bool additem = true;
|
||||
for (int32 i = 0; i < _fDevices->CountItems(); i++)
|
||||
{
|
||||
BMidiEndpoint *endpoint = (BMidiEndpoint*)_fDevices->ItemAt(i);
|
||||
if (strcmp(endpt->Name(), endpoint->Name()) == 0)
|
||||
additem = false;
|
||||
}
|
||||
if (additem)
|
||||
_fDevices->AddItem(endpt);
|
||||
endpt->Release();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -6,69 +6,92 @@
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
#include <MidiConsumer.h>
|
||||
#include <MidiPort.h>
|
||||
#include <MidiPortConsumer.h>
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
class BMidiPortConsumer : public BMidiLocalConsumer
|
||||
BMidiPortConsumer::BMidiPortConsumer(BMidiPort *toPort, const char *name = NULL)
|
||||
: BMidiLocalConsumer(name), port(toPort)
|
||||
{
|
||||
public:
|
||||
BMidiPortConsumer(BMidiPort *toPort, const char *name = NULL)
|
||||
: BMidiLocalConsumer(name), port(toPort) {}
|
||||
}
|
||||
|
||||
void NoteOff(uchar channel, uchar note, uchar velocity, bigtime_t time)
|
||||
{
|
||||
port->SprayNoteOff(channel, note, velocity, B_NOW);
|
||||
}
|
||||
|
||||
void NoteOn(uchar channel, uchar note, uchar velocity, bigtime_t time)
|
||||
{
|
||||
port->SprayNoteOn(channel, note, velocity, B_NOW);
|
||||
}
|
||||
|
||||
void KeyPressure(uchar channel, uchar note, uchar pressure, bigtime_t time)
|
||||
{
|
||||
port->SprayKeyPressure(channel, note, pressure, B_NOW);
|
||||
}
|
||||
|
||||
void ControlChange(uchar channel, uchar controlNumber, uchar controlValue, bigtime_t time)
|
||||
{
|
||||
port->SprayControlChange(channel, controlNumber, controlValue, B_NOW);
|
||||
}
|
||||
|
||||
void ProgramChange(uchar channel, uchar programNumber, bigtime_t time)
|
||||
{
|
||||
port->SprayProgramChange(channel, programNumber, B_NOW);
|
||||
}
|
||||
|
||||
void ChannelPressure(uchar channel, uchar pressure, bigtime_t time)
|
||||
{
|
||||
port->SprayChannelPressure(channel, pressure, B_NOW);
|
||||
}
|
||||
|
||||
void PitchBend(uchar channel, uchar lsb, uchar msb, bigtime_t time)
|
||||
{
|
||||
port->SprayPitchBend(channel, lsb, msb, B_NOW);
|
||||
}
|
||||
|
||||
void SystemExclusive(void *data, size_t dataLength, bigtime_t time)
|
||||
{
|
||||
port->SpraySystemExclusive(data, dataLength, B_NOW);
|
||||
}
|
||||
|
||||
void SystemCommon(uchar statusByte, uchar data1, uchar data2, bigtime_t time)
|
||||
{
|
||||
port->SpraySystemCommon(statusByte, data1, data2, B_NOW);
|
||||
}
|
||||
|
||||
void SystemRealTime(uchar statusByte, bigtime_t time)
|
||||
{
|
||||
port->SpraySystemRealTime(statusByte, B_NOW);
|
||||
}
|
||||
//-----------------
|
||||
|
||||
private:
|
||||
BMidiPort *port;
|
||||
void BMidiPortConsumer::NoteOff(uchar channel, uchar note, uchar velocity, bigtime_t time)
|
||||
{
|
||||
port->SprayNoteOff(channel, note, velocity, B_NOW);
|
||||
}
|
||||
|
||||
};
|
||||
//-----------------
|
||||
|
||||
void BMidiPortConsumer::NoteOn(uchar channel, uchar note, uchar velocity, bigtime_t time)
|
||||
{
|
||||
port->SprayNoteOn(channel, note, velocity, B_NOW);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPortConsumer::KeyPressure(uchar channel, uchar note, uchar pressure, bigtime_t time)
|
||||
{
|
||||
port->SprayKeyPressure(channel, note, pressure, B_NOW);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPortConsumer::ControlChange(uchar channel, uchar controlNumber, uchar controlValue, bigtime_t time)
|
||||
{
|
||||
port->SprayControlChange(channel, controlNumber, controlValue, B_NOW);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPortConsumer::ProgramChange(uchar channel, uchar programNumber, bigtime_t time)
|
||||
{
|
||||
port->SprayProgramChange(channel, programNumber, B_NOW);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPortConsumer::ChannelPressure(uchar channel, uchar pressure, bigtime_t time)
|
||||
{
|
||||
port->SprayChannelPressure(channel, pressure, B_NOW);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPortConsumer::PitchBend(uchar channel, uchar lsb, uchar msb, bigtime_t time)
|
||||
{
|
||||
port->SprayPitchBend(channel, lsb, msb, B_NOW);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPortConsumer::SystemExclusive(void *data, size_t dataLength, bigtime_t time)
|
||||
{
|
||||
port->SpraySystemExclusive(data, dataLength, B_NOW);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPortConsumer::SystemCommon(uchar statusByte, uchar data1, uchar data2, bigtime_t time)
|
||||
{
|
||||
port->SpraySystemCommon(statusByte, data1, data2, B_NOW);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
|
||||
void BMidiPortConsumer::SystemRealTime(uchar statusByte, bigtime_t time)
|
||||
{
|
||||
port->SpraySystemRealTime(statusByte, B_NOW);
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
//----------------------------------------
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file MidiPort.h
|
||||
*
|
||||
* @author Jerome Leveque
|
||||
*/
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
#ifndef _MIDI_PORT_CONSUMER_H
|
||||
#define _MIDI_PORT_CONSUMER_H
|
||||
|
||||
#include <MidiConsumer.h>
|
||||
#include <MidiPort.h>
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
class BMidiPortConsumer : public BMidiLocalConsumer
|
||||
{
|
||||
public:
|
||||
BMidiPortConsumer(BMidiPort *toPort, const char *name = NULL);
|
||||
|
||||
void NoteOff(uchar channel, uchar note, uchar velocity, bigtime_t time);
|
||||
void NoteOn(uchar channel, uchar note, uchar velocity, bigtime_t time);
|
||||
void KeyPressure(uchar channel, uchar note, uchar pressure, bigtime_t time);
|
||||
void ControlChange(uchar channel, uchar controlNumber,
|
||||
uchar controlValue, bigtime_t time);
|
||||
void ProgramChange(uchar channel, uchar programNumber, bigtime_t time);
|
||||
void ChannelPressure(uchar channel, uchar pressure, bigtime_t time);
|
||||
void PitchBend(uchar channel, uchar lsb, uchar msb, bigtime_t time);
|
||||
void SystemExclusive(void *data, size_t dataLength, bigtime_t time);
|
||||
void SystemCommon(uchar statusByte, uchar data1,
|
||||
uchar data2, bigtime_t time);
|
||||
void SystemRealTime(uchar statusByte, bigtime_t time);
|
||||
|
||||
private:
|
||||
BMidiPort *port;
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
#endif _MIDI_PORT_CONSUMER_H
|
||||
@@ -3,7 +3,7 @@ Author: Jerome LEVEQUE
|
||||
Email: [email protected]
|
||||
*/
|
||||
#include "MidiPlayerView.h"
|
||||
#include "Scope.h"
|
||||
//#include "Scope.h"
|
||||
#include "Activity.h"
|
||||
|
||||
#include <StringView.h>
|
||||
@@ -154,12 +154,12 @@ Activity *view = NULL;
|
||||
RemoveAll(fViewBox);
|
||||
break;
|
||||
//--------------
|
||||
case VIEW_CHANGE_TO_SCOPE :
|
||||
/* case VIEW_CHANGE_TO_SCOPE :
|
||||
RemoveAll(fViewBox);
|
||||
fViewBox->AddChild(new Scope(BRect(10, 25, 340, 340)));
|
||||
break;
|
||||
//--------------
|
||||
case VIEW_CHANGE_TO_ACTIVITY :
|
||||
*/ case VIEW_CHANGE_TO_ACTIVITY :
|
||||
RemoveAll(fViewBox);
|
||||
msg->FindPointer("View", (void**)&view);
|
||||
fViewBox->AddChild(view);
|
||||
@@ -229,7 +229,7 @@ BMessage *msg = NULL;
|
||||
BMenuItem *item = NULL;
|
||||
int32 temp = 0;
|
||||
|
||||
Menu = new BPopUpMenu("Sample Rate");
|
||||
/* Menu = new BPopUpMenu("Sample Rate");
|
||||
temp = be_synth->SamplingRate();
|
||||
msg = new BMessage(CHANGE_SAMPLE_RATE_SYNTH);
|
||||
Menu->AddItem(item = new BMenuItem("11025 Hz", msg));
|
||||
@@ -303,7 +303,7 @@ BSlider *slider = new BSlider(BRect(5, 100, 275, 130), NULL, "Volume",
|
||||
slider->SetValue(temp);
|
||||
slider->SetLimitLabels("Min", "Max");
|
||||
aView->AddChild(slider);
|
||||
}
|
||||
*/}
|
||||
|
||||
//----------------------------------------------------------
|
||||
//----------------------------------------------------------
|
||||
|
||||
@@ -17,7 +17,7 @@ Email: [email protected]
|
||||
#include <File.h>
|
||||
#include <MidiStore.h>
|
||||
#include <MidiPort.h>
|
||||
#include <MidiSynth.h>
|
||||
//#include <MidiSynth.h>
|
||||
#include <MidiSynthFile.h>
|
||||
|
||||
//----------------------------------------------------------
|
||||
@@ -210,7 +210,7 @@ entry_ref ref;
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
case OUTPUT_CHANGE_TO_BEOS_SYNTH :
|
||||
/* case OUTPUT_CHANGE_TO_BEOS_SYNTH :
|
||||
if (fOutputType == BEOS_SYNTH)
|
||||
break;
|
||||
fOutputType = BEOS_SYNTH;
|
||||
@@ -244,7 +244,7 @@ entry_ref ref;
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
case OUTPUT_CHANGE_TO_MIDIPORT :
|
||||
*/ case OUTPUT_CHANGE_TO_MIDIPORT :
|
||||
if (fOutputType == MIDIPORT)
|
||||
break;
|
||||
fOutputType = MIDIPORT;
|
||||
@@ -280,14 +280,14 @@ entry_ref ref;
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
case VIEW_CHANGE_TO_SCOPE :
|
||||
/* case VIEW_CHANGE_TO_SCOPE :
|
||||
if (fDisplayType == SCOPE)
|
||||
break;
|
||||
fDisplayType = SCOPE;
|
||||
PostMessage(msg, fStandartView);
|
||||
break;
|
||||
//--------------
|
||||
case VIEW_CHANGE_TO_ACTIVITY :
|
||||
*/ case VIEW_CHANGE_TO_ACTIVITY :
|
||||
if (fDisplayType == ACTIVITY)
|
||||
break;
|
||||
fDisplayType = ACTIVITY;
|
||||
@@ -422,7 +422,7 @@ entry_ref ref;
|
||||
//--------------
|
||||
//Message from the BeOS Synth
|
||||
//--------------
|
||||
case CHANGE_BEOS_SYNTH_FILE:
|
||||
/* case CHANGE_BEOS_SYNTH_FILE:
|
||||
if (fOutputFilePanel)
|
||||
{
|
||||
msg->FindRef("refs", &fOutputFile);
|
||||
@@ -545,7 +545,7 @@ entry_ref ref;
|
||||
//--------------
|
||||
//For the drag and drop function
|
||||
//--------------
|
||||
case B_SIMPLE_DATA : //A file had been dropped into application
|
||||
*/ case B_SIMPLE_DATA : //A file had been dropped into application
|
||||
if (msg->FindRef("refs", &ref) == B_OK)
|
||||
{
|
||||
message = BMessage(INPUT_CHANGE_TO_FILE);
|
||||
|
||||
Reference in New Issue
Block a user