Merge pull request #675 from jpcima/vst-misc
vst: eliminate some string comparisons
This commit is contained in:
commit
4fe2dc99ca
1 changed files with 22 additions and 14 deletions
|
|
@ -33,6 +33,14 @@ enum {
|
|||
static const char* kRingIdMidi = "Mid";
|
||||
static const char* kRingIdOsc = "Osc";
|
||||
|
||||
static const char* kMsgIdSetNumVoices = "SetNumVoices";
|
||||
static const char* kMsgIdSetOversampling = "SetOversampling";
|
||||
static const char* kMsgIdSetPreloadSize = "SetPreloadSize";
|
||||
static const char* kMsgIdCheckShouldReload = "CheckShouldReload";
|
||||
static const char* kMsgIdNotifyPlayState = "NotifyPlayState";
|
||||
static const char* kMsgIdReceiveMessage = "ReceiveMessage";
|
||||
static const char* kMsgIdNoteEvents = "NoteEvents";
|
||||
|
||||
SfizzVstProcessor::SfizzVstProcessor()
|
||||
: _fifoToWorker(64 * 1024), _fifoMessageFromUi(64 * 1024),
|
||||
_oscTemp(new uint8_t[kOscTempSize])
|
||||
|
|
@ -265,7 +273,7 @@ tresult PLUGIN_API SfizzVstProcessor::process(Vst::ProcessData& data)
|
|||
_fileChangeCounter += numFrames;
|
||||
if (_fileChangeCounter > _fileChangePeriod) {
|
||||
_fileChangeCounter %= _fileChangePeriod;
|
||||
if (writeWorkerMessage("CheckShouldReload", nullptr, 0))
|
||||
if (writeWorkerMessage(kMsgIdCheckShouldReload, nullptr, 0))
|
||||
_semaToWorker.post();
|
||||
}
|
||||
|
||||
|
|
@ -279,7 +287,7 @@ tresult PLUGIN_API SfizzVstProcessor::process(Vst::ProcessData& data)
|
|||
playState.regions = synth.getNumRegions();
|
||||
playState.preloadedSamples = synth.getNumPreloadedSamples();
|
||||
playState.activeVoices = synth.getNumActiveVoices();
|
||||
if (writeWorkerMessage("NotifyPlayState", &playState, sizeof(playState)))
|
||||
if (writeWorkerMessage(kMsgIdNotifyPlayState, &playState, sizeof(playState)))
|
||||
_semaToWorker.post();
|
||||
}
|
||||
|
||||
|
|
@ -294,7 +302,7 @@ tresult PLUGIN_API SfizzVstProcessor::process(Vst::ProcessData& data)
|
|||
_noteEventsCurrentCycle[key] = -1.0f;
|
||||
}
|
||||
if (numNoteEvents > 0) {
|
||||
if (writeWorkerMessage("NoteEvents", noteEvents, numNoteEvents * sizeof(noteEvents[0])))
|
||||
if (writeWorkerMessage(kMsgIdNoteEvents, noteEvents, numNoteEvents * sizeof(noteEvents[0])))
|
||||
_semaToWorker.post();
|
||||
}
|
||||
|
||||
|
|
@ -349,7 +357,7 @@ void SfizzVstProcessor::processParameterChanges(Vst::IParameterChanges& pc)
|
|||
if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue) {
|
||||
int32 data = static_cast<int32>(range.denormalize(value));
|
||||
_state.numVoices = data;
|
||||
if (writeWorkerMessage("SetNumVoices", &data, sizeof(data)))
|
||||
if (writeWorkerMessage(kMsgIdSetNumVoices, &data, sizeof(data)))
|
||||
_semaToWorker.post();
|
||||
}
|
||||
break;
|
||||
|
|
@ -357,7 +365,7 @@ void SfizzVstProcessor::processParameterChanges(Vst::IParameterChanges& pc)
|
|||
if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue) {
|
||||
int32 data = static_cast<int32>(range.denormalize(value));
|
||||
_state.oversamplingLog2 = data;
|
||||
if (writeWorkerMessage("SetOversampling", &data, sizeof(data)))
|
||||
if (writeWorkerMessage(kMsgIdSetOversampling, &data, sizeof(data)))
|
||||
_semaToWorker.post();
|
||||
}
|
||||
break;
|
||||
|
|
@ -365,7 +373,7 @@ void SfizzVstProcessor::processParameterChanges(Vst::IParameterChanges& pc)
|
|||
if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue) {
|
||||
int32 data = static_cast<int32>(range.denormalize(value));
|
||||
_state.preloadSize = data;
|
||||
if (writeWorkerMessage("SetPreloadSize", &data, sizeof(data)))
|
||||
if (writeWorkerMessage(kMsgIdSetPreloadSize, &data, sizeof(data)))
|
||||
_semaToWorker.post();
|
||||
}
|
||||
break;
|
||||
|
|
@ -606,7 +614,7 @@ void SfizzVstProcessor::receiveMessage(int delay, const char* path, const char*
|
|||
uint8_t* oscTemp = _oscTemp.get();
|
||||
uint32 oscSize = sfizz_prepare_message(oscTemp, kOscTempSize, path, sig, args);
|
||||
if (oscSize <= kOscTempSize) {
|
||||
if (writeWorkerMessage("ReceiveMessage", oscTemp, oscSize))
|
||||
if (writeWorkerMessage(kMsgIdReceiveMessage, oscTemp, oscSize))
|
||||
_semaToWorker.post();
|
||||
}
|
||||
}
|
||||
|
|
@ -635,22 +643,22 @@ void SfizzVstProcessor::doBackgroundWork()
|
|||
|
||||
const char* id = msg->type;
|
||||
|
||||
if (!std::strcmp(id, "SetNumVoices")) {
|
||||
if (id == kMsgIdSetNumVoices) {
|
||||
int32 value = *msg->payload<int32>();
|
||||
std::lock_guard<SpinMutex> lock(_processMutex);
|
||||
_synth->setNumVoices(value);
|
||||
}
|
||||
else if (!std::strcmp(id, "SetOversampling")) {
|
||||
else if (id == kMsgIdSetOversampling) {
|
||||
int32 value = *msg->payload<int32>();
|
||||
std::lock_guard<SpinMutex> lock(_processMutex);
|
||||
_synth->setOversamplingFactor(1 << value);
|
||||
}
|
||||
else if (!std::strcmp(id, "SetPreloadSize")) {
|
||||
else if (id == kMsgIdSetPreloadSize) {
|
||||
int32 value = *msg->payload<int32>();
|
||||
std::lock_guard<SpinMutex> lock(_processMutex);
|
||||
_synth->setPreloadSize(value);
|
||||
}
|
||||
else if (!std::strcmp(id, "CheckShouldReload")) {
|
||||
else if (id == kMsgIdCheckShouldReload) {
|
||||
if (_synth->shouldReloadFile()) {
|
||||
fprintf(stderr, "[Sfizz] sfz file has changed, reloading\n");
|
||||
std::lock_guard<SpinMutex> lock(_processMutex);
|
||||
|
|
@ -667,20 +675,20 @@ void SfizzVstProcessor::doBackgroundWork()
|
|||
_synth->loadScalaFile(_state.scalaFile);
|
||||
}
|
||||
}
|
||||
else if (!std::strcmp(id, "NotifyPlayState")) {
|
||||
else if (id == kMsgIdNotifyPlayState) {
|
||||
SfizzPlayState playState = *msg->payload<SfizzPlayState>();
|
||||
Steinberg::OPtr<Vst::IMessage> notification { allocateMessage() };
|
||||
notification->setMessageID("NotifiedPlayState");
|
||||
notification->getAttributes()->setBinary("PlayState", &playState, sizeof(playState));
|
||||
sendMessage(notification);
|
||||
}
|
||||
else if (!std::strcmp(id, "ReceiveMessage")) {
|
||||
else if (id == kMsgIdReceiveMessage) {
|
||||
Steinberg::OPtr<Vst::IMessage> notification { allocateMessage() };
|
||||
notification->setMessageID("ReceivedMessage");
|
||||
notification->getAttributes()->setBinary("Message", msg->payload<uint8_t>(), msg->size);
|
||||
sendMessage(notification);
|
||||
}
|
||||
else if (!std::strcmp(id, "NoteEvents")) {
|
||||
else if (id == kMsgIdNoteEvents) {
|
||||
Steinberg::OPtr<Vst::IMessage> notification { allocateMessage() };
|
||||
notification->setMessageID("NoteEvents");
|
||||
notification->getAttributes()->setBinary("Events", msg->payload<uint8_t>(), msg->size);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue