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:
parent
3e9e6a58c8
commit
bafde775b9
@ -116,7 +116,6 @@ private:
|
||||
volatile thread_id threadId;
|
||||
volatile bool isRunning;
|
||||
|
||||
uint8 _reserved1[3];
|
||||
uint32 _reserved2[5];
|
||||
};
|
||||
|
||||
|
@ -83,8 +83,6 @@ private:
|
||||
bigtime_t creationTime;
|
||||
int16 transpose;
|
||||
bool inputEnabled;
|
||||
|
||||
uint32 _reserved;
|
||||
};
|
||||
|
||||
#endif // _MIDI_SYNTH_H
|
||||
|
@ -69,7 +69,7 @@ private:
|
||||
int32 fId;
|
||||
BString fName;
|
||||
int32 fRefCount;
|
||||
BMessage* fProperties;
|
||||
BMessage *fProperties;
|
||||
bool fIsLocal;
|
||||
bool fIsConsumer;
|
||||
bool fIsRegistered;
|
||||
|
@ -45,10 +45,10 @@ private:
|
||||
bool LockProducer() const;
|
||||
void UnlockProducer() const;
|
||||
|
||||
BList *fConnections;
|
||||
mutable BLocker fLocker;
|
||||
BList fConnections;
|
||||
|
||||
uint32 _reserved[10];
|
||||
|
||||
uint32 _reserved[2];
|
||||
};
|
||||
|
||||
class BMidiLocalProducer : public BMidiProducer
|
||||
|
@ -76,7 +76,7 @@ private:
|
||||
status_t SendRequest(BMessage*, BMessage*);
|
||||
|
||||
BPrivate::BMidiRosterLooper* fLooper;
|
||||
BMessenger fServer;
|
||||
BMessenger *fServer;
|
||||
|
||||
uint32 _reserved[16];
|
||||
};
|
||||
|
@ -58,8 +58,7 @@ status_t BMidiSynth::EnableInput(bool enable, bool loadInstruments)
|
||||
status_t err = B_OK;
|
||||
inputEnabled = enable;
|
||||
|
||||
if (loadInstruments)
|
||||
{
|
||||
if (loadInstruments) {
|
||||
err = be_synth->synth->LoadAllInstruments();
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,6 @@ BSoftSynth::BSoftSynth()
|
||||
fLimiterThreshold = 7;
|
||||
fReverbEnabled = true;
|
||||
fReverbMode = B_REVERB_BALLROOM;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
@ -63,13 +61,14 @@ BSoftSynth::~BSoftSynth()
|
||||
// didn't release our endpoints.
|
||||
|
||||
Unload();
|
||||
Done();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BSoftSynth::InitCheck(void) const
|
||||
BSoftSynth::InitCheck()
|
||||
{
|
||||
if (!fSynth)
|
||||
Init();
|
||||
return fInitCheck;
|
||||
}
|
||||
|
||||
@ -77,8 +76,7 @@ BSoftSynth::InitCheck(void) const
|
||||
void
|
||||
BSoftSynth::Unload(void)
|
||||
{
|
||||
/* TODO: purge samples from memory */
|
||||
|
||||
Done();
|
||||
free(fInstrumentsFile);
|
||||
fInstrumentsFile = NULL;
|
||||
}
|
||||
@ -121,9 +119,7 @@ BSoftSynth::SetInstrumentsFile(const char* path)
|
||||
status_t
|
||||
BSoftSynth::LoadAllInstruments()
|
||||
{
|
||||
/* TODO: Should load all of the instruments from the sample bank. */
|
||||
|
||||
UNIMPLEMENTED
|
||||
InitCheck();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -182,7 +178,6 @@ BSoftSynth::SetSamplingRate(int32 rate)
|
||||
{
|
||||
if (rate == 22050 || rate == 44100 || rate == 48000) {
|
||||
fSampleRate = rate;
|
||||
Init();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -250,7 +245,6 @@ BSoftSynth::SetMaxVoices(int32 max)
|
||||
{
|
||||
if (max > 0 && max <= 4096) {
|
||||
fMaxVoices = max;
|
||||
Init();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -439,6 +433,7 @@ BSoftSynth::AllNotesOff(bool justChannel, uint32 time)
|
||||
void
|
||||
BSoftSynth::Init()
|
||||
{
|
||||
status_t err;
|
||||
fInitCheck = false;
|
||||
|
||||
Done();
|
||||
@ -448,6 +443,12 @@ BSoftSynth::Init()
|
||||
fluid_settings_setint(fSettings, "synth.polyphony", fMaxVoices);
|
||||
|
||||
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;
|
||||
format.channel_count = 2;
|
||||
@ -455,7 +456,7 @@ BSoftSynth::Init()
|
||||
format.format = media_raw_audio_format::B_AUDIO_FLOAT;
|
||||
|
||||
fSoundPlayer = new BSoundPlayer(&format, "Soft Synth", &PlayBuffer, NULL, this);
|
||||
status_t err = fSoundPlayer->InitCheck();
|
||||
err = fSoundPlayer->InitCheck();
|
||||
if (err != B_OK)
|
||||
return;
|
||||
|
||||
@ -473,11 +474,16 @@ BSoftSynth::Done()
|
||||
fSoundPlayer->SetHasData(false);
|
||||
fSoundPlayer->Stop();
|
||||
delete fSoundPlayer;
|
||||
fSoundPlayer = NULL;
|
||||
}
|
||||
if (fSynth)
|
||||
if (fSynth) {
|
||||
delete_fluid_synth(fSynth);
|
||||
if (fSettings)
|
||||
fSynth = NULL;
|
||||
}
|
||||
if (fSettings) {
|
||||
delete_fluid_settings(fSettings);
|
||||
fSettings = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@ class BSoftSynth
|
||||
{
|
||||
public:
|
||||
|
||||
bool InitCheck() const;
|
||||
bool InitCheck();
|
||||
|
||||
void Unload();
|
||||
bool IsLoaded() const;
|
||||
|
@ -24,7 +24,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include "Synth.h"
|
||||
#include <Path.h>
|
||||
#include <Synth.h>
|
||||
#include "SoftSynth.h"
|
||||
|
||||
BSynth* be_synth = NULL;
|
||||
@ -58,12 +59,15 @@ BSynth::~BSynth()
|
||||
|
||||
status_t BSynth::LoadSynthData(entry_ref* instrumentsFile)
|
||||
{
|
||||
if (instrumentsFile == NULL)
|
||||
{
|
||||
if (instrumentsFile == NULL) {
|
||||
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;
|
||||
fIsRegistered = false;
|
||||
fIsAlive = true;
|
||||
|
||||
fProperties = new BMessage;
|
||||
|
||||
fProperties = new BMessage();
|
||||
}
|
||||
|
||||
|
||||
@ -257,7 +257,6 @@ BMidiEndpoint::~BMidiEndpoint()
|
||||
"you should use Release() to dispose of endpoints; "
|
||||
"do not \"delete\" them or allocate them on the stack!");
|
||||
}
|
||||
|
||||
delete fProperties;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ BMidiProducer::IsConnected(BMidiConsumer* cons) const
|
||||
|
||||
if (cons != NULL) {
|
||||
if (LockProducer()) {
|
||||
isConnected = fConnections.HasItem(cons);
|
||||
isConnected = fConnections->HasItem(cons);
|
||||
UnlockProducer();
|
||||
}
|
||||
}
|
||||
@ -79,15 +79,16 @@ BMidiProducer::Connections() const
|
||||
|
||||
BMidiProducer::BMidiProducer(const char* name)
|
||||
: BMidiEndpoint(name),
|
||||
fLocker("MidiProducerLock"),
|
||||
fConnections()
|
||||
fLocker("MidiProducerLock")
|
||||
{
|
||||
fIsConsumer = false;
|
||||
fConnections = new BList();
|
||||
}
|
||||
|
||||
|
||||
BMidiProducer::~BMidiProducer()
|
||||
{
|
||||
delete fConnections;
|
||||
}
|
||||
|
||||
|
||||
@ -146,12 +147,13 @@ BMidiProducer::SendConnectRequest(
|
||||
void
|
||||
BMidiProducer::ConnectionMade(BMidiConsumer* consumer)
|
||||
{
|
||||
ASSERT(consumer != NULL)
|
||||
if (consumer == NULL)
|
||||
return;
|
||||
|
||||
if (LockProducer()) {
|
||||
ASSERT(!fConnections.HasItem(consumer))
|
||||
ASSERT(!fConnections->HasItem(consumer))
|
||||
|
||||
fConnections.AddItem(consumer);
|
||||
fConnections->AddItem(consumer);
|
||||
UnlockProducer();
|
||||
}
|
||||
|
||||
@ -164,12 +166,13 @@ BMidiProducer::ConnectionMade(BMidiConsumer* consumer)
|
||||
bool
|
||||
BMidiProducer::ConnectionBroken(BMidiConsumer* consumer)
|
||||
{
|
||||
ASSERT(consumer != NULL)
|
||||
|
||||
if (consumer == NULL)
|
||||
return false;
|
||||
|
||||
bool wasConnected = false;
|
||||
|
||||
if (LockProducer()) {
|
||||
wasConnected = fConnections.RemoveItem(consumer);
|
||||
wasConnected = fConnections->RemoveItem(consumer);
|
||||
UnlockProducer();
|
||||
}
|
||||
|
||||
@ -184,7 +187,7 @@ BMidiProducer::ConnectionBroken(BMidiConsumer* consumer)
|
||||
int32
|
||||
BMidiProducer::CountConsumers() const
|
||||
{
|
||||
return fConnections.CountItems();
|
||||
return fConnections->CountItems();
|
||||
}
|
||||
|
||||
|
||||
@ -193,7 +196,7 @@ BMidiProducer::ConsumerAt(int32 index) const
|
||||
{
|
||||
ASSERT(index >= 0 && index < CountConsumers())
|
||||
|
||||
return (BMidiConsumer*) fConnections.ItemAt(index);
|
||||
return (BMidiConsumer*) fConnections->ItemAt(index);
|
||||
}
|
||||
|
||||
|
||||
|
@ -213,7 +213,6 @@ BMidiRoster::MidiRoster()
|
||||
|
||||
|
||||
BMidiRoster::BMidiRoster()
|
||||
: fServer(MIDI_SERVER_SIGNATURE)
|
||||
{
|
||||
TRACE(("BMidiRoster::BMidiRoster"))
|
||||
|
||||
@ -232,8 +231,9 @@ BMidiRoster::BMidiRoster()
|
||||
BMessage msg;
|
||||
msg.what = MSG_REGISTER_APP;
|
||||
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");
|
||||
return;
|
||||
}
|
||||
@ -256,6 +256,7 @@ BMidiRoster::~BMidiRoster()
|
||||
fLooper->Lock();
|
||||
fLooper->Quit();
|
||||
}
|
||||
delete fServer;
|
||||
}
|
||||
|
||||
|
||||
@ -336,7 +337,7 @@ BMidiRoster::DeleteLocal(BMidiEndpoint* endp)
|
||||
// a reply from the server. If something went wrong, the
|
||||
// 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
|
||||
// it from the list of endpoints. If creation failed, then
|
||||
@ -358,7 +359,7 @@ BMidiRoster::SendRequest(BMessage* msg, BMessage* reply)
|
||||
ASSERT(msg != 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) {
|
||||
WARN("Cannot send request to midi_server");
|
||||
|
@ -1,5 +1,7 @@
|
||||
SubDir HAIKU_TOP src servers midi ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
UsePrivateHeaders midi ;
|
||||
|
||||
AddResources midi_server :
|
||||
|
Loading…
Reference in New Issue
Block a user