made midi server beos compatible
fix binary compatibility for several classes (I missed this before) the soft synth loads by default /boot/beos/etc/synth/big_synth.sy (which I locally linked to a General Midi sf2 bank tested with MidiSynth 1.6 on Haiku git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17864 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -116,7 +116,6 @@ private:
|
|||||||
volatile thread_id threadId;
|
volatile thread_id threadId;
|
||||||
volatile bool isRunning;
|
volatile bool isRunning;
|
||||||
|
|
||||||
uint8 _reserved1[3];
|
|
||||||
uint32 _reserved2[5];
|
uint32 _reserved2[5];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -83,8 +83,6 @@ private:
|
|||||||
bigtime_t creationTime;
|
bigtime_t creationTime;
|
||||||
int16 transpose;
|
int16 transpose;
|
||||||
bool inputEnabled;
|
bool inputEnabled;
|
||||||
|
|
||||||
uint32 _reserved;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _MIDI_SYNTH_H
|
#endif // _MIDI_SYNTH_H
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ private:
|
|||||||
int32 fId;
|
int32 fId;
|
||||||
BString fName;
|
BString fName;
|
||||||
int32 fRefCount;
|
int32 fRefCount;
|
||||||
BMessage* fProperties;
|
BMessage *fProperties;
|
||||||
bool fIsLocal;
|
bool fIsLocal;
|
||||||
bool fIsConsumer;
|
bool fIsConsumer;
|
||||||
bool fIsRegistered;
|
bool fIsRegistered;
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ private:
|
|||||||
bool LockProducer() const;
|
bool LockProducer() const;
|
||||||
void UnlockProducer() const;
|
void UnlockProducer() const;
|
||||||
|
|
||||||
|
BList *fConnections;
|
||||||
mutable BLocker fLocker;
|
mutable BLocker fLocker;
|
||||||
BList fConnections;
|
|
||||||
|
uint32 _reserved[2];
|
||||||
uint32 _reserved[10];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class BMidiLocalProducer : public BMidiProducer
|
class BMidiLocalProducer : public BMidiProducer
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ private:
|
|||||||
status_t SendRequest(BMessage*, BMessage*);
|
status_t SendRequest(BMessage*, BMessage*);
|
||||||
|
|
||||||
BPrivate::BMidiRosterLooper* fLooper;
|
BPrivate::BMidiRosterLooper* fLooper;
|
||||||
BMessenger fServer;
|
BMessenger *fServer;
|
||||||
|
|
||||||
uint32 _reserved[16];
|
uint32 _reserved[16];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -58,8 +58,7 @@ status_t BMidiSynth::EnableInput(bool enable, bool loadInstruments)
|
|||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
inputEnabled = enable;
|
inputEnabled = enable;
|
||||||
|
|
||||||
if (loadInstruments)
|
if (loadInstruments) {
|
||||||
{
|
|
||||||
err = be_synth->synth->LoadAllInstruments();
|
err = be_synth->synth->LoadAllInstruments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-14
@@ -49,8 +49,6 @@ BSoftSynth::BSoftSynth()
|
|||||||
fLimiterThreshold = 7;
|
fLimiterThreshold = 7;
|
||||||
fReverbEnabled = true;
|
fReverbEnabled = true;
|
||||||
fReverbMode = B_REVERB_BALLROOM;
|
fReverbMode = B_REVERB_BALLROOM;
|
||||||
|
|
||||||
Init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -63,13 +61,14 @@ BSoftSynth::~BSoftSynth()
|
|||||||
// didn't release our endpoints.
|
// didn't release our endpoints.
|
||||||
|
|
||||||
Unload();
|
Unload();
|
||||||
Done();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BSoftSynth::InitCheck(void) const
|
BSoftSynth::InitCheck()
|
||||||
{
|
{
|
||||||
|
if (!fSynth)
|
||||||
|
Init();
|
||||||
return fInitCheck;
|
return fInitCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +76,7 @@ BSoftSynth::InitCheck(void) const
|
|||||||
void
|
void
|
||||||
BSoftSynth::Unload(void)
|
BSoftSynth::Unload(void)
|
||||||
{
|
{
|
||||||
/* TODO: purge samples from memory */
|
Done();
|
||||||
|
|
||||||
free(fInstrumentsFile);
|
free(fInstrumentsFile);
|
||||||
fInstrumentsFile = NULL;
|
fInstrumentsFile = NULL;
|
||||||
}
|
}
|
||||||
@@ -121,9 +119,7 @@ BSoftSynth::SetInstrumentsFile(const char* path)
|
|||||||
status_t
|
status_t
|
||||||
BSoftSynth::LoadAllInstruments()
|
BSoftSynth::LoadAllInstruments()
|
||||||
{
|
{
|
||||||
/* TODO: Should load all of the instruments from the sample bank. */
|
InitCheck();
|
||||||
|
|
||||||
UNIMPLEMENTED
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +178,6 @@ BSoftSynth::SetSamplingRate(int32 rate)
|
|||||||
{
|
{
|
||||||
if (rate == 22050 || rate == 44100 || rate == 48000) {
|
if (rate == 22050 || rate == 44100 || rate == 48000) {
|
||||||
fSampleRate = rate;
|
fSampleRate = rate;
|
||||||
Init();
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +245,6 @@ BSoftSynth::SetMaxVoices(int32 max)
|
|||||||
{
|
{
|
||||||
if (max > 0 && max <= 4096) {
|
if (max > 0 && max <= 4096) {
|
||||||
fMaxVoices = max;
|
fMaxVoices = max;
|
||||||
Init();
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,6 +433,7 @@ BSoftSynth::AllNotesOff(bool justChannel, uint32 time)
|
|||||||
void
|
void
|
||||||
BSoftSynth::Init()
|
BSoftSynth::Init()
|
||||||
{
|
{
|
||||||
|
status_t err;
|
||||||
fInitCheck = false;
|
fInitCheck = false;
|
||||||
|
|
||||||
Done();
|
Done();
|
||||||
@@ -448,6 +443,12 @@ BSoftSynth::Init()
|
|||||||
fluid_settings_setint(fSettings, "synth.polyphony", fMaxVoices);
|
fluid_settings_setint(fSettings, "synth.polyphony", fMaxVoices);
|
||||||
|
|
||||||
fSynth = new_fluid_synth(fSettings);
|
fSynth = new_fluid_synth(fSettings);
|
||||||
|
if (!fSynth)
|
||||||
|
return;
|
||||||
|
|
||||||
|
err = fluid_synth_sfload(fSynth, fInstrumentsFile, 1);
|
||||||
|
if (err < B_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
media_raw_audio_format format = media_raw_audio_format::wildcard;
|
media_raw_audio_format format = media_raw_audio_format::wildcard;
|
||||||
format.channel_count = 2;
|
format.channel_count = 2;
|
||||||
@@ -455,7 +456,7 @@ BSoftSynth::Init()
|
|||||||
format.format = media_raw_audio_format::B_AUDIO_FLOAT;
|
format.format = media_raw_audio_format::B_AUDIO_FLOAT;
|
||||||
|
|
||||||
fSoundPlayer = new BSoundPlayer(&format, "Soft Synth", &PlayBuffer, NULL, this);
|
fSoundPlayer = new BSoundPlayer(&format, "Soft Synth", &PlayBuffer, NULL, this);
|
||||||
status_t err = fSoundPlayer->InitCheck();
|
err = fSoundPlayer->InitCheck();
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -473,11 +474,16 @@ BSoftSynth::Done()
|
|||||||
fSoundPlayer->SetHasData(false);
|
fSoundPlayer->SetHasData(false);
|
||||||
fSoundPlayer->Stop();
|
fSoundPlayer->Stop();
|
||||||
delete fSoundPlayer;
|
delete fSoundPlayer;
|
||||||
|
fSoundPlayer = NULL;
|
||||||
}
|
}
|
||||||
if (fSynth)
|
if (fSynth) {
|
||||||
delete_fluid_synth(fSynth);
|
delete_fluid_synth(fSynth);
|
||||||
if (fSettings)
|
fSynth = NULL;
|
||||||
|
}
|
||||||
|
if (fSettings) {
|
||||||
delete_fluid_settings(fSettings);
|
delete_fluid_settings(fSettings);
|
||||||
|
fSettings = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class BSoftSynth
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool InitCheck() const;
|
bool InitCheck();
|
||||||
|
|
||||||
void Unload();
|
void Unload();
|
||||||
bool IsLoaded() const;
|
bool IsLoaded() const;
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "Synth.h"
|
#include <Path.h>
|
||||||
|
#include <Synth.h>
|
||||||
#include "SoftSynth.h"
|
#include "SoftSynth.h"
|
||||||
|
|
||||||
BSynth* be_synth = NULL;
|
BSynth* be_synth = NULL;
|
||||||
@@ -58,12 +59,15 @@ BSynth::~BSynth()
|
|||||||
|
|
||||||
status_t BSynth::LoadSynthData(entry_ref* instrumentsFile)
|
status_t BSynth::LoadSynthData(entry_ref* instrumentsFile)
|
||||||
{
|
{
|
||||||
if (instrumentsFile == NULL)
|
if (instrumentsFile == NULL) {
|
||||||
{
|
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return synth->SetInstrumentsFile(instrumentsFile->name);
|
BPath path(instrumentsFile);
|
||||||
|
status_t err = path.InitCheck();
|
||||||
|
if (err != B_OK)
|
||||||
|
return err;
|
||||||
|
return synth->SetInstrumentsFile(path.Path());
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -243,8 +243,8 @@ BMidiEndpoint::BMidiEndpoint(const char* name_)
|
|||||||
fIsLocal = false;
|
fIsLocal = false;
|
||||||
fIsRegistered = false;
|
fIsRegistered = false;
|
||||||
fIsAlive = true;
|
fIsAlive = true;
|
||||||
|
|
||||||
fProperties = new BMessage;
|
fProperties = new BMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -257,7 +257,6 @@ BMidiEndpoint::~BMidiEndpoint()
|
|||||||
"you should use Release() to dispose of endpoints; "
|
"you should use Release() to dispose of endpoints; "
|
||||||
"do not \"delete\" them or allocate them on the stack!");
|
"do not \"delete\" them or allocate them on the stack!");
|
||||||
}
|
}
|
||||||
|
|
||||||
delete fProperties;
|
delete fProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ BMidiProducer::IsConnected(BMidiConsumer* cons) const
|
|||||||
|
|
||||||
if (cons != NULL) {
|
if (cons != NULL) {
|
||||||
if (LockProducer()) {
|
if (LockProducer()) {
|
||||||
isConnected = fConnections.HasItem(cons);
|
isConnected = fConnections->HasItem(cons);
|
||||||
UnlockProducer();
|
UnlockProducer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,15 +79,16 @@ BMidiProducer::Connections() const
|
|||||||
|
|
||||||
BMidiProducer::BMidiProducer(const char* name)
|
BMidiProducer::BMidiProducer(const char* name)
|
||||||
: BMidiEndpoint(name),
|
: BMidiEndpoint(name),
|
||||||
fLocker("MidiProducerLock"),
|
fLocker("MidiProducerLock")
|
||||||
fConnections()
|
|
||||||
{
|
{
|
||||||
fIsConsumer = false;
|
fIsConsumer = false;
|
||||||
|
fConnections = new BList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BMidiProducer::~BMidiProducer()
|
BMidiProducer::~BMidiProducer()
|
||||||
{
|
{
|
||||||
|
delete fConnections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -146,12 +147,13 @@ BMidiProducer::SendConnectRequest(
|
|||||||
void
|
void
|
||||||
BMidiProducer::ConnectionMade(BMidiConsumer* consumer)
|
BMidiProducer::ConnectionMade(BMidiConsumer* consumer)
|
||||||
{
|
{
|
||||||
ASSERT(consumer != NULL)
|
if (consumer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (LockProducer()) {
|
if (LockProducer()) {
|
||||||
ASSERT(!fConnections.HasItem(consumer))
|
ASSERT(!fConnections->HasItem(consumer))
|
||||||
|
|
||||||
fConnections.AddItem(consumer);
|
fConnections->AddItem(consumer);
|
||||||
UnlockProducer();
|
UnlockProducer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,12 +166,13 @@ BMidiProducer::ConnectionMade(BMidiConsumer* consumer)
|
|||||||
bool
|
bool
|
||||||
BMidiProducer::ConnectionBroken(BMidiConsumer* consumer)
|
BMidiProducer::ConnectionBroken(BMidiConsumer* consumer)
|
||||||
{
|
{
|
||||||
ASSERT(consumer != NULL)
|
if (consumer == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
bool wasConnected = false;
|
bool wasConnected = false;
|
||||||
|
|
||||||
if (LockProducer()) {
|
if (LockProducer()) {
|
||||||
wasConnected = fConnections.RemoveItem(consumer);
|
wasConnected = fConnections->RemoveItem(consumer);
|
||||||
UnlockProducer();
|
UnlockProducer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +187,7 @@ BMidiProducer::ConnectionBroken(BMidiConsumer* consumer)
|
|||||||
int32
|
int32
|
||||||
BMidiProducer::CountConsumers() const
|
BMidiProducer::CountConsumers() const
|
||||||
{
|
{
|
||||||
return fConnections.CountItems();
|
return fConnections->CountItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -193,7 +196,7 @@ BMidiProducer::ConsumerAt(int32 index) const
|
|||||||
{
|
{
|
||||||
ASSERT(index >= 0 && index < CountConsumers())
|
ASSERT(index >= 0 && index < CountConsumers())
|
||||||
|
|
||||||
return (BMidiConsumer*) fConnections.ItemAt(index);
|
return (BMidiConsumer*) fConnections->ItemAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -213,7 +213,6 @@ BMidiRoster::MidiRoster()
|
|||||||
|
|
||||||
|
|
||||||
BMidiRoster::BMidiRoster()
|
BMidiRoster::BMidiRoster()
|
||||||
: fServer(MIDI_SERVER_SIGNATURE)
|
|
||||||
{
|
{
|
||||||
TRACE(("BMidiRoster::BMidiRoster"))
|
TRACE(("BMidiRoster::BMidiRoster"))
|
||||||
|
|
||||||
@@ -232,8 +231,9 @@ BMidiRoster::BMidiRoster()
|
|||||||
BMessage msg;
|
BMessage msg;
|
||||||
msg.what = MSG_REGISTER_APP;
|
msg.what = MSG_REGISTER_APP;
|
||||||
msg.AddMessenger("midi:messenger", BMessenger(fLooper));
|
msg.AddMessenger("midi:messenger", BMessenger(fLooper));
|
||||||
|
fServer = new BMessenger(MIDI_SERVER_SIGNATURE);
|
||||||
|
|
||||||
if (fServer.SendMessage(&msg, fLooper, TIMEOUT) != B_OK) {
|
if (fServer->SendMessage(&msg, fLooper, TIMEOUT) != B_OK) {
|
||||||
WARN("Cannot send request to midi_server");
|
WARN("Cannot send request to midi_server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -256,6 +256,7 @@ BMidiRoster::~BMidiRoster()
|
|||||||
fLooper->Lock();
|
fLooper->Lock();
|
||||||
fLooper->Quit();
|
fLooper->Quit();
|
||||||
}
|
}
|
||||||
|
delete fServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -336,7 +337,7 @@ BMidiRoster::DeleteLocal(BMidiEndpoint* endp)
|
|||||||
// a reply from the server. If something went wrong, the
|
// a reply from the server. If something went wrong, the
|
||||||
// object will be destroyed regardless.
|
// object will be destroyed regardless.
|
||||||
|
|
||||||
fServer.SendMessage(&msg, (BHandler*) NULL, TIMEOUT);
|
fServer->SendMessage(&msg, (BHandler*) NULL, TIMEOUT);
|
||||||
|
|
||||||
// If the endpoint was successfully created, we must remove
|
// If the endpoint was successfully created, we must remove
|
||||||
// it from the list of endpoints. If creation failed, then
|
// it from the list of endpoints. If creation failed, then
|
||||||
@@ -358,7 +359,7 @@ BMidiRoster::SendRequest(BMessage* msg, BMessage* reply)
|
|||||||
ASSERT(msg != NULL)
|
ASSERT(msg != NULL)
|
||||||
ASSERT(reply != NULL)
|
ASSERT(reply != NULL)
|
||||||
|
|
||||||
status_t err = fServer.SendMessage(msg, reply, TIMEOUT, TIMEOUT);
|
status_t err = fServer->SendMessage(msg, reply, TIMEOUT, TIMEOUT);
|
||||||
|
|
||||||
if (err != B_OK) {
|
if (err != B_OK) {
|
||||||
WARN("Cannot send request to midi_server");
|
WARN("Cannot send request to midi_server");
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
SubDir HAIKU_TOP src servers midi ;
|
SubDir HAIKU_TOP src servers midi ;
|
||||||
|
|
||||||
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
UsePrivateHeaders midi ;
|
UsePrivateHeaders midi ;
|
||||||
|
|
||||||
AddResources midi_server :
|
AddResources midi_server :
|
||||||
|
|||||||
Reference in New Issue
Block a user