2016-05-03 05:16:37 +00:00
|
|
|
#include "amuse/SoundMacroState.hpp"
|
|
|
|
#include "amuse/Voice.hpp"
|
|
|
|
#include "amuse/Engine.hpp"
|
|
|
|
#include "amuse/Common.hpp"
|
2016-05-06 05:19:19 +00:00
|
|
|
#include "amuse/AudioGroup.hpp"
|
|
|
|
#include "amuse/AudioGroupPool.hpp"
|
2016-05-03 05:16:37 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2016-06-15 00:36:25 +00:00
|
|
|
#undef SendMessage
|
|
|
|
#undef GetMessage
|
|
|
|
|
2016-05-03 05:16:37 +00:00
|
|
|
namespace amuse
|
|
|
|
{
|
|
|
|
|
|
|
|
void SoundMacroState::Header::swapBig()
|
|
|
|
{
|
|
|
|
m_size = SBig(m_size);
|
2016-05-14 22:38:37 +00:00
|
|
|
m_macroId = SBig(m_macroId);
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SoundMacroState::Command::swapBig()
|
|
|
|
{
|
|
|
|
uint32_t* words = reinterpret_cast<uint32_t*>(this);
|
|
|
|
words[0] = SBig(words[0]);
|
|
|
|
words[1] = SBig(words[1]);
|
|
|
|
}
|
|
|
|
|
2016-05-09 07:22:58 +00:00
|
|
|
void SoundMacroState::Evaluator::addComponent(uint8_t midiCtrl, float scale,
|
2016-05-06 05:19:19 +00:00
|
|
|
Combine combine, VarType varType)
|
|
|
|
{
|
|
|
|
m_comps.push_back({midiCtrl, scale, combine, varType});
|
|
|
|
}
|
|
|
|
|
2016-05-14 04:46:39 +00:00
|
|
|
float SoundMacroState::Evaluator::evaluate(const Voice& vox, const SoundMacroState& st) const
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
float value = 0.f;
|
|
|
|
|
|
|
|
/* Iterate each component */
|
|
|
|
for (auto it=m_comps.cbegin() ; it != m_comps.cend() ; ++it)
|
|
|
|
{
|
|
|
|
const Component& comp = *it;
|
|
|
|
float thisValue = 0.f;
|
|
|
|
|
|
|
|
/* Load selected data */
|
|
|
|
if (comp.m_varType == VarType::Ctrl)
|
|
|
|
{
|
|
|
|
switch (comp.m_midiCtrl)
|
|
|
|
{
|
|
|
|
case 128:
|
|
|
|
/* Pitchbend */
|
|
|
|
thisValue = vox.getPitchWheel();
|
|
|
|
break;
|
|
|
|
case 129:
|
|
|
|
/* Aftertouch */
|
2016-06-20 08:08:32 +00:00
|
|
|
thisValue = vox.getAftertouch() * (2.f / 127.f);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
case 130:
|
|
|
|
/* LFO1 */
|
2016-05-11 21:30:45 +00:00
|
|
|
if (vox.m_lfoPeriods[0])
|
2016-06-20 08:08:32 +00:00
|
|
|
thisValue = std::sin(vox.m_voiceTime / vox.m_lfoPeriods[0] * 2.f * M_PIF);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
case 131:
|
|
|
|
/* LFO2 */
|
2016-05-11 21:30:45 +00:00
|
|
|
if (vox.m_lfoPeriods[1])
|
2016-06-20 08:08:32 +00:00
|
|
|
thisValue = std::sin(vox.m_voiceTime / vox.m_lfoPeriods[1] * 2.f * M_PIF);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
case 132:
|
|
|
|
/* Surround panning */
|
2016-06-20 08:08:32 +00:00
|
|
|
thisValue = vox.m_curSpan;
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
case 133:
|
|
|
|
/* Macro-starting key */
|
|
|
|
thisValue = st.m_initKey;
|
|
|
|
break;
|
|
|
|
case 134:
|
|
|
|
/* Macro-starting velocity */
|
|
|
|
thisValue = st.m_initVel;
|
|
|
|
break;
|
|
|
|
case 135:
|
|
|
|
/* Time since macro-start (ms) */
|
2016-06-20 08:08:32 +00:00
|
|
|
thisValue = clamp(0.f, float(st.m_execTime * 1000.f), 16383.f);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
default:
|
2016-06-20 08:08:32 +00:00
|
|
|
if (comp.m_midiCtrl == 10) /* Centered pan computation */
|
|
|
|
thisValue = vox.getCtrlValue(comp.m_midiCtrl) * (2.f / 127.f) - 1.f;
|
|
|
|
else
|
|
|
|
thisValue = vox.getCtrlValue(comp.m_midiCtrl) * (2.f / 127.f);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (comp.m_varType == VarType::Var)
|
|
|
|
thisValue = st.m_variables[std::max(0, std::min(255, int(comp.m_midiCtrl)))];
|
|
|
|
|
|
|
|
/* Apply scale */
|
|
|
|
thisValue *= comp.m_scale;
|
|
|
|
|
|
|
|
/* Combine */
|
|
|
|
if (it != m_comps.cbegin())
|
|
|
|
{
|
|
|
|
switch (comp.m_combine)
|
|
|
|
{
|
|
|
|
case Combine::Add:
|
|
|
|
value += thisValue;
|
|
|
|
break;
|
|
|
|
case Combine::Mult:
|
|
|
|
value *= thisValue;
|
|
|
|
break;
|
2016-05-06 21:22:39 +00:00
|
|
|
default:
|
|
|
|
value = thisValue;
|
|
|
|
break;
|
2016-05-06 05:19:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
value = thisValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2016-05-28 02:28:59 +00:00
|
|
|
void SoundMacroState::initialize(const unsigned char* ptr, int step, bool swapData)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
2016-05-28 02:28:59 +00:00
|
|
|
initialize(ptr, step, 1000.f, 0, 0, 0, swapData);
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
|
2016-05-14 04:46:39 +00:00
|
|
|
void SoundMacroState::initialize(const unsigned char* ptr, int step, double ticksPerSec,
|
2016-05-28 02:28:59 +00:00
|
|
|
uint8_t midiKey, uint8_t midiVel, uint8_t midiMod, bool swapData)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
|
|
|
m_ticksPerSec = ticksPerSec;
|
2016-05-11 21:30:45 +00:00
|
|
|
m_initKey = midiKey;
|
|
|
|
m_initVel = midiVel;
|
|
|
|
m_initMod = midiMod;
|
2016-05-16 02:40:18 +00:00
|
|
|
m_curVel = midiVel;
|
|
|
|
m_curMod = midiMod;
|
|
|
|
m_curPitch = midiKey * 100;
|
2016-05-03 05:16:37 +00:00
|
|
|
m_pc.clear();
|
2016-05-11 21:30:45 +00:00
|
|
|
m_pc.push_back({ptr, step});
|
2016-05-16 02:40:18 +00:00
|
|
|
m_inWait = false;
|
2016-05-03 05:16:37 +00:00
|
|
|
m_execTime = 0.f;
|
|
|
|
m_keyoff = false;
|
|
|
|
m_sampleEnd = false;
|
|
|
|
m_loopCountdown = -1;
|
|
|
|
m_lastPlayMacroVid = -1;
|
2016-05-06 05:19:19 +00:00
|
|
|
m_useAdsrControllers = false;
|
2016-06-01 21:17:16 +00:00
|
|
|
m_portamentoMode = 2;
|
|
|
|
m_portamentoTime = 0.5f;
|
2016-05-04 05:19:13 +00:00
|
|
|
m_header = *reinterpret_cast<const Header*>(ptr);
|
2016-05-28 02:28:59 +00:00
|
|
|
if (swapData)
|
|
|
|
m_header.swapBig();
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
|
2016-05-14 04:46:39 +00:00
|
|
|
bool SoundMacroState::advance(Voice& vox, double dt)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
|
|
|
/* Nothing if uninitialized or finished */
|
2016-05-06 21:22:39 +00:00
|
|
|
if (m_pc.empty() || m_pc.back().first == nullptr || m_pc.back().second == -1)
|
2016-05-03 05:16:37 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
/* Loop through as many commands as we can for this time period */
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
/* Advance wait timer if active, returning if waiting */
|
|
|
|
if (m_inWait)
|
|
|
|
{
|
2016-05-16 02:40:18 +00:00
|
|
|
if (m_keyoffWait && m_keyoff)
|
|
|
|
m_inWait = false;
|
|
|
|
else if (m_sampleEndWait && m_sampleEnd)
|
|
|
|
m_inWait = false;
|
|
|
|
else if (!m_indefiniteWait)
|
2016-05-14 22:38:37 +00:00
|
|
|
{
|
|
|
|
m_waitCountdown -= dt;
|
|
|
|
if (m_waitCountdown < 0.f)
|
|
|
|
m_inWait = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_inWait)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
|
|
|
m_execTime += dt;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Load next command based on counter */
|
2016-05-06 21:22:39 +00:00
|
|
|
const Command* commands = reinterpret_cast<const Command*>(m_pc.back().first + sizeof(Header));
|
|
|
|
Command cmd = commands[m_pc.back().second++];
|
2016-05-28 02:28:59 +00:00
|
|
|
if (vox.getAudioGroup().getDataFormat() != DataFormat::PC)
|
|
|
|
cmd.swapBig();
|
2016-05-03 05:16:37 +00:00
|
|
|
|
|
|
|
/* Perform function of command */
|
|
|
|
switch (cmd.m_op)
|
|
|
|
{
|
|
|
|
case Op::End:
|
|
|
|
case Op::Stop:
|
2016-05-16 02:40:18 +00:00
|
|
|
m_pc.back().second = -1;
|
2016-05-03 05:16:37 +00:00
|
|
|
return true;
|
|
|
|
case Op::SplitKey:
|
|
|
|
{
|
|
|
|
uint8_t keyNumber = cmd.m_data[0];
|
2016-05-06 05:19:19 +00:00
|
|
|
ObjectId macroId = *reinterpret_cast<ObjectId*>(&cmd.m_data[1]);
|
2016-05-03 05:16:37 +00:00
|
|
|
int16_t macroStep = *reinterpret_cast<int16_t*>(&cmd.m_data[3]);
|
|
|
|
|
2016-05-06 05:19:19 +00:00
|
|
|
if (m_initKey >= keyNumber)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
|
|
|
/* Do Branch */
|
|
|
|
if (macroId == m_header.m_macroId)
|
2016-05-06 21:22:39 +00:00
|
|
|
m_pc.back().second = macroStep;
|
2016-05-03 05:16:37 +00:00
|
|
|
else
|
2016-05-15 06:48:26 +00:00
|
|
|
vox.loadSoundObject(macroId, macroStep, m_ticksPerSec,
|
2016-05-16 02:40:18 +00:00
|
|
|
m_initKey, m_initVel, m_initMod);
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Op::SplitVel:
|
|
|
|
{
|
|
|
|
uint8_t velocity = cmd.m_data[0];
|
2016-05-06 05:19:19 +00:00
|
|
|
ObjectId macroId = *reinterpret_cast<ObjectId*>(&cmd.m_data[1]);
|
2016-05-03 05:16:37 +00:00
|
|
|
int16_t macroStep = *reinterpret_cast<int16_t*>(&cmd.m_data[3]);
|
|
|
|
|
2016-05-06 05:19:19 +00:00
|
|
|
if (m_curVel >= velocity)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
|
|
|
/* Do Branch */
|
|
|
|
if (macroId == m_header.m_macroId)
|
2016-05-06 21:22:39 +00:00
|
|
|
m_pc.back().second = macroStep;
|
2016-05-03 05:16:37 +00:00
|
|
|
else
|
2016-05-15 06:48:26 +00:00
|
|
|
vox.loadSoundObject(macroId, macroStep, m_ticksPerSec,
|
2016-06-01 21:32:48 +00:00
|
|
|
m_initKey, m_initVel, m_initMod);
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Op::WaitTicks:
|
|
|
|
{
|
|
|
|
bool keyRelease = cmd.m_data[0];
|
|
|
|
bool random = cmd.m_data[1];
|
|
|
|
bool sampleEnd = cmd.m_data[2];
|
|
|
|
bool absolute = cmd.m_data[3];
|
|
|
|
bool ms = cmd.m_data[4];
|
|
|
|
int16_t time = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
|
|
|
/* Set wait state */
|
2016-05-14 22:38:37 +00:00
|
|
|
if (time >= 0)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
2016-05-14 22:38:37 +00:00
|
|
|
float q = ms ? 1000.f : m_ticksPerSec;
|
|
|
|
float secTime = time / q;
|
|
|
|
if (absolute)
|
|
|
|
{
|
|
|
|
if (secTime <= m_execTime)
|
|
|
|
break;
|
|
|
|
m_waitCountdown = secTime - m_execTime;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_waitCountdown = secTime;
|
|
|
|
|
|
|
|
/* Randomize at the proper resolution */
|
|
|
|
if (random)
|
|
|
|
secTime = std::fmod(vox.getEngine().nextRandom() / q, secTime);
|
|
|
|
|
|
|
|
m_indefiniteWait = false;
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
else
|
2016-05-14 22:38:37 +00:00
|
|
|
m_indefiniteWait = true;
|
2016-05-03 05:16:37 +00:00
|
|
|
|
|
|
|
m_inWait = true;
|
|
|
|
m_keyoffWait = keyRelease;
|
|
|
|
m_sampleEndWait = sampleEnd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Op::Loop:
|
|
|
|
{
|
|
|
|
bool keyRelease = cmd.m_data[0];
|
|
|
|
bool random = cmd.m_data[1];
|
|
|
|
bool sampleEnd = cmd.m_data[2];
|
|
|
|
int16_t step = *reinterpret_cast<int16_t*>(&cmd.m_data[3]);
|
|
|
|
int16_t times = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
|
|
|
if ((keyRelease && m_keyoff) || (sampleEnd && m_sampleEnd))
|
|
|
|
{
|
|
|
|
/* Break out of loop */
|
|
|
|
m_loopCountdown = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (random)
|
2016-05-06 21:22:39 +00:00
|
|
|
times = vox.getEngine().nextRandom() % times;
|
2016-05-03 05:16:37 +00:00
|
|
|
|
|
|
|
if (m_loopCountdown == -1 && times != -1)
|
|
|
|
m_loopCountdown = times;
|
|
|
|
|
|
|
|
if (m_loopCountdown > 0)
|
|
|
|
{
|
|
|
|
/* Loop back to step */
|
|
|
|
--m_loopCountdown;
|
2016-05-06 21:22:39 +00:00
|
|
|
m_pc.back().second = step;
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
else /* Break out of loop */
|
|
|
|
m_loopCountdown = -1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Op::Goto:
|
|
|
|
{
|
2016-05-06 05:19:19 +00:00
|
|
|
ObjectId macroId = *reinterpret_cast<ObjectId*>(&cmd.m_data[1]);
|
2016-05-03 05:16:37 +00:00
|
|
|
int16_t macroStep = *reinterpret_cast<int16_t*>(&cmd.m_data[3]);
|
|
|
|
|
|
|
|
/* Do Branch */
|
|
|
|
if (macroId == m_header.m_macroId)
|
2016-05-06 21:22:39 +00:00
|
|
|
m_pc.back().second = macroStep;
|
2016-05-03 05:16:37 +00:00
|
|
|
else
|
2016-05-15 06:48:26 +00:00
|
|
|
vox.loadSoundObject(macroId, macroStep, m_ticksPerSec,
|
2016-06-01 21:32:48 +00:00
|
|
|
m_initKey, m_initVel, m_initMod);
|
2016-05-03 05:16:37 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Op::WaitMs:
|
|
|
|
{
|
|
|
|
bool keyRelease = cmd.m_data[0];
|
|
|
|
bool random = cmd.m_data[1];
|
|
|
|
bool sampleEnd = cmd.m_data[2];
|
|
|
|
bool absolute = cmd.m_data[3];
|
|
|
|
int16_t time = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
|
|
|
/* Set wait state */
|
2016-05-14 22:38:37 +00:00
|
|
|
if (time >= 0)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
2016-05-14 22:38:37 +00:00
|
|
|
float secTime = time / 1000.f;
|
|
|
|
if (absolute)
|
|
|
|
{
|
|
|
|
if (secTime <= m_execTime)
|
|
|
|
break;
|
|
|
|
m_waitCountdown = secTime - m_execTime;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_waitCountdown = secTime;
|
|
|
|
|
|
|
|
/* Randomize at the proper resolution */
|
|
|
|
if (random)
|
|
|
|
secTime = std::fmod(vox.getEngine().nextRandom() / 1000.f, secTime);
|
|
|
|
|
|
|
|
m_indefiniteWait = false;
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
else
|
2016-05-14 22:38:37 +00:00
|
|
|
m_indefiniteWait = true;
|
2016-05-03 05:16:37 +00:00
|
|
|
|
|
|
|
m_inWait = true;
|
|
|
|
m_keyoffWait = keyRelease;
|
|
|
|
m_sampleEndWait = sampleEnd;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Op::PlayMacro:
|
|
|
|
{
|
|
|
|
int8_t addNote = cmd.m_data[0];
|
2016-05-06 05:19:19 +00:00
|
|
|
ObjectId macroId = *reinterpret_cast<ObjectId*>(&cmd.m_data[1]);
|
2016-05-03 05:16:37 +00:00
|
|
|
int16_t macroStep = *reinterpret_cast<int16_t*>(&cmd.m_data[3]);
|
2016-05-04 05:19:13 +00:00
|
|
|
//int8_t priority = cmd.m_data[5];
|
|
|
|
//int8_t maxVoices = cmd.m_data[6];
|
2016-06-15 00:36:25 +00:00
|
|
|
|
2016-05-14 04:46:39 +00:00
|
|
|
std::shared_ptr<Voice> sibVox = vox.startChildMacro(addNote, macroId, macroStep);
|
2016-05-03 05:16:37 +00:00
|
|
|
if (sibVox)
|
|
|
|
m_lastPlayMacroVid = sibVox->vid();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Op::SendKeyOff:
|
|
|
|
{
|
|
|
|
uint8_t vid = cmd.m_data[0];
|
|
|
|
bool lastStarted = cmd.m_data[1];
|
|
|
|
|
|
|
|
if (lastStarted)
|
|
|
|
{
|
|
|
|
if (m_lastPlayMacroVid != -1)
|
|
|
|
{
|
2016-05-14 04:46:39 +00:00
|
|
|
std::shared_ptr<Voice> otherVox = vox.getEngine().findVoice(m_lastPlayMacroVid);
|
2016-05-04 05:19:13 +00:00
|
|
|
if (otherVox)
|
|
|
|
otherVox->keyOff();
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-14 04:46:39 +00:00
|
|
|
std::shared_ptr<Voice> otherVox = vox.getEngine().findVoice(m_variables[vid]);
|
2016-05-04 05:19:13 +00:00
|
|
|
if (otherVox)
|
|
|
|
otherVox->keyOff();
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Op::SplitMod:
|
|
|
|
{
|
|
|
|
uint8_t mod = cmd.m_data[0];
|
2016-05-06 05:19:19 +00:00
|
|
|
ObjectId macroId = *reinterpret_cast<ObjectId*>(&cmd.m_data[1]);
|
2016-05-03 05:16:37 +00:00
|
|
|
int16_t macroStep = *reinterpret_cast<int16_t*>(&cmd.m_data[3]);
|
|
|
|
|
2016-05-06 05:19:19 +00:00
|
|
|
if (m_curMod >= mod)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
|
|
|
/* Do Branch */
|
|
|
|
if (macroId == m_header.m_macroId)
|
2016-05-06 21:22:39 +00:00
|
|
|
m_pc.back().second = macroStep;
|
2016-05-03 05:16:37 +00:00
|
|
|
else
|
2016-05-15 06:48:26 +00:00
|
|
|
vox.loadSoundObject(macroId, macroStep, m_ticksPerSec,
|
2016-06-01 21:32:48 +00:00
|
|
|
m_initKey, m_initVel, m_initMod);
|
2016-05-03 05:16:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Op::PianoPan:
|
2016-05-05 06:39:18 +00:00
|
|
|
{
|
|
|
|
int8_t scale = cmd.m_data[0];
|
|
|
|
int8_t cenKey = cmd.m_data[1];
|
|
|
|
int8_t cenPan = cmd.m_data[2];
|
|
|
|
|
2016-05-06 05:19:19 +00:00
|
|
|
int32_t pan = int32_t(m_initKey - cenKey) * scale / 127 + cenPan;
|
2016-05-05 06:39:18 +00:00
|
|
|
pan = std::max(-127, std::min(127, pan));
|
2016-05-11 21:30:45 +00:00
|
|
|
vox.setPan(pan / 127.f);
|
2016-05-05 06:39:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SetAdsr:
|
2016-05-05 06:39:18 +00:00
|
|
|
{
|
2016-05-06 05:19:19 +00:00
|
|
|
ObjectId tableId = *reinterpret_cast<ObjectId*>(&cmd.m_data[0]);
|
2016-05-16 20:20:29 +00:00
|
|
|
bool dlsMode = cmd.m_data[2];
|
|
|
|
vox.setAdsr(tableId, dlsMode);
|
2016-05-05 06:39:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::ScaleVolume:
|
2016-05-05 06:39:18 +00:00
|
|
|
{
|
|
|
|
int8_t scale = cmd.m_data[0];
|
|
|
|
int8_t add = cmd.m_data[1];
|
2016-05-06 05:19:19 +00:00
|
|
|
ObjectId curve = *reinterpret_cast<ObjectId*>(&cmd.m_data[2]);
|
2016-05-05 06:39:18 +00:00
|
|
|
bool orgVel = cmd.m_data[4];
|
|
|
|
|
2016-05-06 05:19:19 +00:00
|
|
|
int32_t eval = int32_t(orgVel ? m_initVel : m_curVel) * scale / 127 + add;
|
|
|
|
eval = std::max(0, std::min(127, eval));
|
|
|
|
|
2016-05-11 04:48:08 +00:00
|
|
|
if (curve != 0)
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
const Curve* curveData = vox.getAudioGroup().getPool().tableAsCurves(curve);
|
|
|
|
if (curveData)
|
|
|
|
{
|
2016-05-16 20:20:29 +00:00
|
|
|
vox.m_curVol = (*curveData)[eval] / 127.f;
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-16 20:20:29 +00:00
|
|
|
vox.m_curVol = eval / 127.f;
|
2016-05-05 06:39:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::Panning:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int8_t panPos = cmd.m_data[0];
|
|
|
|
int16_t timeMs = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
|
|
|
int8_t width = cmd.m_data[3];
|
|
|
|
|
2016-05-11 21:30:45 +00:00
|
|
|
vox.startPanning(timeMs / 1000.0, panPos, width);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::Envelope:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int8_t scale = cmd.m_data[0];
|
|
|
|
int8_t add = cmd.m_data[1];
|
|
|
|
ObjectId curve = *reinterpret_cast<ObjectId*>(&cmd.m_data[2]);
|
|
|
|
bool ms = cmd.m_data[4];
|
|
|
|
int16_t fadeTime = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
2016-05-11 21:30:45 +00:00
|
|
|
double q = ms ? 1000.0 : m_ticksPerSec;
|
|
|
|
double secTime = fadeTime / q;
|
2016-05-06 05:19:19 +00:00
|
|
|
|
|
|
|
int32_t eval = int32_t(m_curVel) * scale / 127 + add;
|
|
|
|
eval = std::max(0, std::min(127, eval));
|
|
|
|
|
2016-05-11 21:30:45 +00:00
|
|
|
const Curve* curveData;
|
2016-05-11 04:48:08 +00:00
|
|
|
if (curve != 0)
|
2016-05-11 21:30:45 +00:00
|
|
|
curveData = vox.getAudioGroup().getPool().tableAsCurves(curve);
|
2016-05-06 05:19:19 +00:00
|
|
|
else
|
2016-05-11 21:30:45 +00:00
|
|
|
curveData = nullptr;
|
2016-05-06 05:19:19 +00:00
|
|
|
|
2016-05-11 21:30:45 +00:00
|
|
|
vox.startEnvelope(secTime, eval, curveData);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::StartSample:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int16_t smpId = *reinterpret_cast<int16_t*>(&cmd.m_data[0]);
|
|
|
|
int8_t mode = cmd.m_data[2];
|
|
|
|
int32_t offset = *reinterpret_cast<int32_t*>(&cmd.m_data[3]);
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
offset = offset * (127 - m_curVel) / 127;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
offset = offset * m_curVel / 127;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
vox.startSample(smpId, offset);
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.setPitchKey(m_curPitch);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::StopSample:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
vox.stopSample();
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::KeyOff:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
2016-05-16 02:40:18 +00:00
|
|
|
vox._macroKeyOff();
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SplitRnd:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t rndVal = cmd.m_data[0];
|
|
|
|
ObjectId macroId = *reinterpret_cast<ObjectId*>(&cmd.m_data[1]);
|
|
|
|
int16_t macroStep = *reinterpret_cast<int16_t*>(&cmd.m_data[3]);
|
|
|
|
|
2016-05-06 21:22:39 +00:00
|
|
|
if (rndVal <= vox.getEngine().nextRandom() % 256)
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
/* Do branch */
|
|
|
|
if (macroId == m_header.m_macroId)
|
2016-05-06 21:22:39 +00:00
|
|
|
m_pc.back().second = macroStep;
|
2016-05-06 05:19:19 +00:00
|
|
|
else
|
2016-05-15 06:48:26 +00:00
|
|
|
vox.loadSoundObject(macroId, macroStep, m_ticksPerSec,
|
2016-06-01 21:32:48 +00:00
|
|
|
m_initKey, m_initVel, m_initMod);
|
2016-05-06 05:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::FadeIn:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int8_t scale = cmd.m_data[0];
|
|
|
|
int8_t add = cmd.m_data[1];
|
|
|
|
ObjectId curve = *reinterpret_cast<ObjectId*>(&cmd.m_data[2]);
|
|
|
|
bool ms = cmd.m_data[4];
|
|
|
|
int16_t fadeTime = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
|
|
|
float q = ms ? 1000.f : m_ticksPerSec;
|
|
|
|
float secTime = fadeTime / q;
|
|
|
|
|
|
|
|
int32_t eval = int32_t(m_curVel) * scale / 127 + add;
|
|
|
|
eval = std::max(0, std::min(127, eval));
|
|
|
|
|
2016-05-11 21:30:45 +00:00
|
|
|
const Curve* curveData;
|
2016-05-11 04:48:08 +00:00
|
|
|
if (curve != 0)
|
2016-05-11 21:30:45 +00:00
|
|
|
curveData = vox.getAudioGroup().getPool().tableAsCurves(curve);
|
2016-05-06 05:19:19 +00:00
|
|
|
else
|
2016-05-11 21:30:45 +00:00
|
|
|
curveData = nullptr;
|
2016-05-06 05:19:19 +00:00
|
|
|
|
2016-05-11 21:30:45 +00:00
|
|
|
vox.startFadeIn(secTime, eval, curveData);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::Spanning:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int8_t panPos = cmd.m_data[0];
|
|
|
|
int16_t timeMs = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
|
|
|
int8_t width = cmd.m_data[3];
|
|
|
|
|
2016-05-11 21:30:45 +00:00
|
|
|
vox.startSpanning(timeMs / 1000.0, panPos, width);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SetAdsrCtrl:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
m_useAdsrControllers = true;
|
|
|
|
m_midiAttack = cmd.m_data[0];
|
|
|
|
m_midiDecay = cmd.m_data[1];
|
|
|
|
m_midiSustain = cmd.m_data[2];
|
|
|
|
m_midiRelease = cmd.m_data[3];
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::RndNote:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int32_t noteLo = int32_t(cmd.m_data[0]);
|
|
|
|
int8_t detune = cmd.m_data[1];
|
|
|
|
int32_t noteHi = int32_t(cmd.m_data[2]);
|
|
|
|
int8_t free = cmd.m_data[3];
|
|
|
|
int8_t rel = cmd.m_data[4];
|
|
|
|
|
|
|
|
if (rel)
|
|
|
|
{
|
|
|
|
noteLo = m_initKey - noteLo;
|
|
|
|
noteHi = noteLo + noteHi;
|
|
|
|
}
|
|
|
|
|
|
|
|
noteLo *= 100;
|
|
|
|
noteHi *= 100;
|
|
|
|
|
2016-05-17 00:41:44 +00:00
|
|
|
if (noteHi == noteLo)
|
|
|
|
m_curPitch = noteHi;
|
|
|
|
else
|
|
|
|
m_curPitch = (vox.getEngine().nextRandom() % (noteHi - noteLo)) + noteLo;
|
|
|
|
|
2016-05-06 05:19:19 +00:00
|
|
|
if (!free)
|
2016-05-16 02:40:18 +00:00
|
|
|
m_curPitch = m_curPitch / 100 * 100 + detune;
|
2016-05-06 05:19:19 +00:00
|
|
|
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.setPitchKey(m_curPitch);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::AddNote:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int32_t add = int32_t(cmd.m_data[0]);
|
|
|
|
int8_t detune = cmd.m_data[1];
|
2016-05-06 21:22:39 +00:00
|
|
|
int8_t orgKey = cmd.m_data[2];
|
2016-05-06 05:19:19 +00:00
|
|
|
int8_t ms = cmd.m_data[4];
|
|
|
|
int16_t timeMs = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
2016-05-16 02:40:18 +00:00
|
|
|
m_curPitch = (orgKey ? (m_initKey * 100) : m_curPitch) + add * 100 + detune;
|
2016-05-06 05:19:19 +00:00
|
|
|
|
|
|
|
/* Set wait state */
|
|
|
|
if (timeMs)
|
|
|
|
{
|
|
|
|
float q = ms ? 1000.f : m_ticksPerSec;
|
|
|
|
float secTime = timeMs / q;
|
|
|
|
m_waitCountdown = secTime;
|
|
|
|
m_inWait = true;
|
|
|
|
}
|
|
|
|
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.setPitchKey(m_curPitch);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SetNote:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int32_t key = int32_t(cmd.m_data[0]);
|
|
|
|
int8_t detune = cmd.m_data[1];
|
|
|
|
int8_t ms = cmd.m_data[4];
|
|
|
|
int16_t timeMs = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
2016-05-16 02:40:18 +00:00
|
|
|
m_curPitch = key * 100 + detune;
|
2016-05-06 05:19:19 +00:00
|
|
|
|
|
|
|
/* Set wait state */
|
|
|
|
if (timeMs)
|
|
|
|
{
|
|
|
|
float q = ms ? 1000.f : m_ticksPerSec;
|
|
|
|
float secTime = timeMs / q;
|
|
|
|
m_waitCountdown = secTime;
|
|
|
|
m_inWait = true;
|
|
|
|
}
|
|
|
|
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.setPitchKey(m_curPitch);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::LastNote:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int32_t add = int32_t(cmd.m_data[0]);
|
|
|
|
int8_t detune = cmd.m_data[1];
|
|
|
|
int8_t ms = cmd.m_data[4];
|
|
|
|
int16_t timeMs = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
2016-05-16 02:40:18 +00:00
|
|
|
m_curPitch = (add + vox.getLastNote()) * 100 + detune;
|
2016-05-06 05:19:19 +00:00
|
|
|
|
|
|
|
/* Set wait state */
|
|
|
|
if (timeMs)
|
|
|
|
{
|
|
|
|
float q = ms ? 1000.f : m_ticksPerSec;
|
|
|
|
float secTime = timeMs / q;
|
|
|
|
m_waitCountdown = secTime;
|
|
|
|
m_inWait = true;
|
|
|
|
}
|
|
|
|
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.setPitchKey(m_curPitch);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::Portamento:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
m_portamentoMode = cmd.m_data[0];
|
|
|
|
m_portamentoType = cmd.m_data[1];
|
|
|
|
int8_t ms = cmd.m_data[4];
|
|
|
|
int16_t timeMs = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
|
|
|
float q = ms ? 1000.f : m_ticksPerSec;
|
|
|
|
m_portamentoTime = timeMs / q;
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::Vibrato:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
2016-05-11 21:30:45 +00:00
|
|
|
int32_t level = cmd.m_data[0] * 100 + cmd.m_data[1];
|
|
|
|
int32_t modLevel = cmd.m_data[2];
|
2016-05-06 05:19:19 +00:00
|
|
|
int8_t ms = cmd.m_data[4];
|
|
|
|
int16_t timeMs = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
|
|
|
float q = ms ? 1000.f : m_ticksPerSec;
|
2016-05-11 21:30:45 +00:00
|
|
|
vox.setVibrato(level, modLevel, timeMs / q);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::PitchSweep1:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
2016-05-11 21:30:45 +00:00
|
|
|
int32_t times = int32_t(cmd.m_data[0]);
|
|
|
|
int16_t add = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-06 05:19:19 +00:00
|
|
|
|
|
|
|
int8_t ms = cmd.m_data[4];
|
|
|
|
int16_t timeMs = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
|
|
|
/* Set wait state */
|
|
|
|
if (timeMs)
|
|
|
|
{
|
|
|
|
float q = ms ? 1000.f : m_ticksPerSec;
|
|
|
|
float secTime = timeMs / q;
|
|
|
|
m_waitCountdown = secTime;
|
|
|
|
m_inWait = true;
|
|
|
|
}
|
|
|
|
|
2016-05-11 21:30:45 +00:00
|
|
|
vox.setPitchSweep1(times, add);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::PitchSweep2:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
2016-05-11 21:30:45 +00:00
|
|
|
int32_t times = int32_t(cmd.m_data[0]);
|
|
|
|
int16_t add = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-06 05:19:19 +00:00
|
|
|
|
|
|
|
int8_t ms = cmd.m_data[4];
|
|
|
|
int16_t timeMs = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
|
|
|
/* Set wait state */
|
|
|
|
if (timeMs)
|
|
|
|
{
|
|
|
|
float q = ms ? 1000.f : m_ticksPerSec;
|
|
|
|
float secTime = timeMs / q;
|
|
|
|
m_waitCountdown = secTime;
|
|
|
|
m_inWait = true;
|
|
|
|
}
|
|
|
|
|
2016-05-11 21:30:45 +00:00
|
|
|
vox.setPitchSweep2(times, add);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SetPitch:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint32_t hz = *reinterpret_cast<uint32_t*>(&cmd.m_data[0]) >> 8;
|
|
|
|
uint16_t fine = *reinterpret_cast<uint16_t*>(&cmd.m_data[3]);
|
|
|
|
vox.setPitchFrequency(hz, fine);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SetPitchAdsr:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
ObjectId adsr = *reinterpret_cast<ObjectId*>(&cmd.m_data[0]);
|
|
|
|
int8_t keys = cmd.m_data[3];
|
|
|
|
int8_t cents = cmd.m_data[4];
|
|
|
|
vox.setPitchAdsr(adsr, keys * 100 + cents);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::ScaleVolumeDLS:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int16_t scale = *reinterpret_cast<int16_t*>(&cmd.m_data[0]);
|
|
|
|
bool orgVel = cmd.m_data[2];
|
2016-05-16 20:20:29 +00:00
|
|
|
vox.m_curVol = int32_t(orgVel ? m_initVel : m_curVel) * scale / 4096.f / 127.f;
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::Mod2Vibrange:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int8_t keys = cmd.m_data[0];
|
|
|
|
int8_t cents = cmd.m_data[1];
|
2016-05-11 21:30:45 +00:00
|
|
|
vox.setMod2VibratoRange(keys * 100 + cents);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SetupTremolo:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
int16_t scale = *reinterpret_cast<int16_t*>(&cmd.m_data[0]);
|
|
|
|
int16_t modScale = *reinterpret_cast<int16_t*>(&cmd.m_data[3]);
|
2016-05-11 21:30:45 +00:00
|
|
|
vox.setTremolo(scale / 4096.f, modScale / 4096.f);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::Return:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
if (m_pc.size() > 1)
|
|
|
|
{
|
|
|
|
m_pc.pop_back();
|
|
|
|
m_header = *reinterpret_cast<const Header*>(m_pc.back().first);
|
2016-05-28 02:28:59 +00:00
|
|
|
if (vox.getAudioGroup().getDataFormat() != DataFormat::PC)
|
|
|
|
m_header.swapBig();
|
2016-05-06 21:22:39 +00:00
|
|
|
vox.m_objectId = m_header.m_macroId;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::GoSub:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
ObjectId macroId = *reinterpret_cast<ObjectId*>(&cmd.m_data[1]);
|
|
|
|
int16_t macroStep = *reinterpret_cast<int16_t*>(&cmd.m_data[3]);
|
|
|
|
|
|
|
|
if (macroId == m_header.m_macroId)
|
|
|
|
m_pc.push_back({m_pc.back().first, macroStep});
|
|
|
|
else
|
2016-05-15 06:48:26 +00:00
|
|
|
vox.loadSoundObject(macroId, macroStep, m_ticksPerSec,
|
2016-06-01 21:32:48 +00:00
|
|
|
m_initKey, m_initVel, m_initMod, true);
|
2016-05-06 21:22:39 +00:00
|
|
|
|
|
|
|
m_header = *reinterpret_cast<const Header*>(m_pc.back().first);
|
2016-05-28 02:28:59 +00:00
|
|
|
if (vox.getAudioGroup().getDataFormat() != DataFormat::PC)
|
|
|
|
m_header.swapBig();
|
2016-05-06 21:22:39 +00:00
|
|
|
vox.m_objectId = m_header.m_macroId;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::TrapEvent:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
uint8_t event = cmd.m_data[0];
|
|
|
|
ObjectId macroId = *reinterpret_cast<ObjectId*>(&cmd.m_data[1]);
|
|
|
|
int16_t macroStep = *reinterpret_cast<int16_t*>(&cmd.m_data[3]);
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case 0:
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.m_keyoffTrap.macroId = macroId;
|
|
|
|
vox.m_keyoffTrap.macroStep = macroStep;
|
2016-05-06 21:22:39 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.m_sampleEndTrap.macroId = macroId;
|
|
|
|
vox.m_sampleEndTrap.macroStep = macroStep;
|
2016-05-06 21:22:39 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.m_messageTrap.macroId = macroId;
|
|
|
|
vox.m_messageTrap.macroStep = macroStep;
|
2016-05-06 21:22:39 +00:00
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Op::UntrapEvent:
|
|
|
|
{
|
|
|
|
uint8_t event = cmd.m_data[0];
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case 0:
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.m_keyoffTrap.macroId = 0xffff;
|
|
|
|
vox.m_keyoffTrap.macroStep = -1;
|
2016-05-06 21:22:39 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.m_sampleEndTrap.macroId = 0xffff;
|
|
|
|
vox.m_sampleEndTrap.macroStep = -1;
|
2016-05-06 21:22:39 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2016-05-16 02:40:18 +00:00
|
|
|
vox.m_messageTrap.macroId = 0xffff;
|
|
|
|
vox.m_messageTrap.macroStep = -1;
|
2016-05-06 21:22:39 +00:00
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SendMessage:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
bool isVar = cmd.m_data[0];
|
|
|
|
ObjectId macroId = *reinterpret_cast<ObjectId*>(&cmd.m_data[1]);
|
|
|
|
uint8_t vid = cmd.m_data[3];
|
|
|
|
uint8_t val = cmd.m_data[4];
|
|
|
|
|
|
|
|
if (isVar)
|
|
|
|
{
|
2016-05-14 04:46:39 +00:00
|
|
|
std::shared_ptr<Voice> findVox = vox.getEngine().findVoice(m_variables[vid]);
|
2016-05-06 21:22:39 +00:00
|
|
|
if (findVox)
|
|
|
|
findVox->message(val);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
vox.getEngine().sendMacroMessage(macroId, val);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::GetMessage:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
uint8_t vid = cmd.m_data[0];
|
2016-05-16 02:40:18 +00:00
|
|
|
if (vox.m_messageQueue.size())
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
2016-05-16 02:40:18 +00:00
|
|
|
m_variables[vid] = vox.m_messageQueue.front();
|
|
|
|
vox.m_messageQueue.pop_front();
|
2016-05-06 21:22:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
m_variables[vid] = 0;
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::GetVid:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
uint8_t vid = cmd.m_data[0];
|
|
|
|
bool lastPlayMacro = cmd.m_data[1];
|
|
|
|
m_variables[vid] = lastPlayMacro ? m_lastPlayMacroVid : vox.vid();
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SendFlag:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
int8_t id = cmd.m_data[0];
|
|
|
|
int8_t val = cmd.m_data[1];
|
|
|
|
break; /* TODO: figure out a good API */
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::PitchWheelR:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
int8_t up = cmd.m_data[0];
|
|
|
|
int8_t down = cmd.m_data[1];
|
|
|
|
vox.setPitchWheelRange(up, down);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
2016-05-06 21:22:39 +00:00
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::VolSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_volumeSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::PanSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_panSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::PitchWheelSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_pitchWheelSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::ModWheelSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_modWheelSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::PedalSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_pedalSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-06 21:22:39 +00:00
|
|
|
case Op::PortamentoSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
2016-05-06 21:22:39 +00:00
|
|
|
m_portamentoSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::ReverbSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_reverbSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SpanSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_spanSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::DopplerSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_dopplerSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::TremoloSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_tremoloSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::PreASelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_preAuxASel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::PreBSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_preAuxBSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::PostBSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_postAuxB.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::AuxAFXSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_auxAFxSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::AuxBFXSelect:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t ctrl = cmd.m_data[0];
|
|
|
|
int16_t perc = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-09 07:22:58 +00:00
|
|
|
Evaluator::Combine combine = Evaluator::Combine(cmd.m_data[3]);
|
|
|
|
Evaluator::VarType vtype = Evaluator::VarType(cmd.m_data[4]);
|
2016-05-06 05:19:19 +00:00
|
|
|
uint8_t fine = cmd.m_data[5];
|
|
|
|
m_auxBFxSel.addComponent(ctrl, (perc + fine / 100.f) / 100.f, combine, vtype);
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SetupLFO:
|
2016-05-06 05:19:19 +00:00
|
|
|
{
|
|
|
|
uint8_t number = cmd.m_data[0];
|
|
|
|
int16_t period = *reinterpret_cast<int16_t*>(&cmd.m_data[1]);
|
2016-05-11 21:30:45 +00:00
|
|
|
if (number == 0)
|
|
|
|
vox.setLFO1Period(period / 1000.f);
|
|
|
|
else if (number == 1)
|
|
|
|
vox.setLFO2Period(period / 1000.f);
|
2016-05-06 05:19:19 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SetKeygroup:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
uint8_t id = cmd.m_data[0];
|
|
|
|
uint8_t flag = cmd.m_data[1];
|
|
|
|
|
|
|
|
vox.setKeygroup(0);
|
|
|
|
if (id)
|
|
|
|
{
|
|
|
|
vox.getEngine().killKeygroup(id, flag);
|
|
|
|
vox.setKeygroup(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::AddVars:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
bool aCtrl = cmd.m_data[0];
|
|
|
|
int8_t a = cmd.m_data[1];
|
|
|
|
bool bCtrl = cmd.m_data[2];
|
|
|
|
int8_t b = cmd.m_data[3];
|
|
|
|
bool cCtrl = cmd.m_data[4];
|
|
|
|
int8_t c = cmd.m_data[5];
|
|
|
|
|
|
|
|
if (bCtrl)
|
|
|
|
b = vox.getCtrlValue(b);
|
|
|
|
else
|
|
|
|
b = m_variables[b];
|
|
|
|
|
|
|
|
if (cCtrl)
|
|
|
|
c = vox.getCtrlValue(c);
|
|
|
|
else
|
|
|
|
c = m_variables[c];
|
|
|
|
|
|
|
|
if (aCtrl)
|
|
|
|
vox.setCtrlValue(a, b + c);
|
|
|
|
else
|
|
|
|
m_variables[a] = b + c;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::SubVars:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
bool aCtrl = cmd.m_data[0];
|
|
|
|
int8_t a = cmd.m_data[1];
|
|
|
|
bool bCtrl = cmd.m_data[2];
|
|
|
|
int8_t b = cmd.m_data[3];
|
|
|
|
bool cCtrl = cmd.m_data[4];
|
|
|
|
int8_t c = cmd.m_data[5];
|
|
|
|
|
|
|
|
if (bCtrl)
|
|
|
|
b = vox.getCtrlValue(b);
|
|
|
|
else
|
|
|
|
b = m_variables[b];
|
|
|
|
|
|
|
|
if (cCtrl)
|
|
|
|
c = vox.getCtrlValue(c);
|
|
|
|
else
|
|
|
|
c = m_variables[c];
|
|
|
|
|
|
|
|
if (aCtrl)
|
|
|
|
vox.setCtrlValue(a, b - c);
|
|
|
|
else
|
|
|
|
m_variables[a] = b - c;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::MulVars:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
bool aCtrl = cmd.m_data[0];
|
|
|
|
int8_t a = cmd.m_data[1];
|
|
|
|
bool bCtrl = cmd.m_data[2];
|
|
|
|
int8_t b = cmd.m_data[3];
|
|
|
|
bool cCtrl = cmd.m_data[4];
|
|
|
|
int8_t c = cmd.m_data[5];
|
|
|
|
|
|
|
|
if (bCtrl)
|
|
|
|
b = vox.getCtrlValue(b);
|
|
|
|
else
|
|
|
|
b = m_variables[b];
|
|
|
|
|
|
|
|
if (cCtrl)
|
|
|
|
c = vox.getCtrlValue(c);
|
|
|
|
else
|
|
|
|
c = m_variables[c];
|
|
|
|
|
|
|
|
if (aCtrl)
|
|
|
|
vox.setCtrlValue(a, b * c);
|
|
|
|
else
|
|
|
|
m_variables[a] = b * c;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::DivVars:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
bool aCtrl = cmd.m_data[0];
|
|
|
|
int8_t a = cmd.m_data[1];
|
|
|
|
bool bCtrl = cmd.m_data[2];
|
|
|
|
int8_t b = cmd.m_data[3];
|
|
|
|
bool cCtrl = cmd.m_data[4];
|
|
|
|
int8_t c = cmd.m_data[5];
|
|
|
|
|
|
|
|
if (bCtrl)
|
|
|
|
b = vox.getCtrlValue(b);
|
|
|
|
else
|
|
|
|
b = m_variables[b];
|
|
|
|
|
|
|
|
if (cCtrl)
|
|
|
|
c = vox.getCtrlValue(c);
|
|
|
|
else
|
|
|
|
c = m_variables[c];
|
|
|
|
|
|
|
|
if (aCtrl)
|
|
|
|
vox.setCtrlValue(a, b / c);
|
|
|
|
else
|
|
|
|
m_variables[a] = b / c;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::AddIVars:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
bool aCtrl = cmd.m_data[0];
|
|
|
|
int8_t a = cmd.m_data[1];
|
|
|
|
bool bCtrl = cmd.m_data[2];
|
|
|
|
int8_t b = cmd.m_data[3];
|
|
|
|
int16_t imm = *reinterpret_cast<int16_t*>(&cmd.m_data[4]);
|
|
|
|
|
|
|
|
if (bCtrl)
|
|
|
|
b = vox.getCtrlValue(b);
|
|
|
|
else
|
|
|
|
b = m_variables[b];
|
|
|
|
|
|
|
|
if (aCtrl)
|
|
|
|
vox.setCtrlValue(a, b + imm);
|
|
|
|
else
|
|
|
|
m_variables[a] = b + imm;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::IfEqual:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
bool aCtrl = cmd.m_data[0];
|
|
|
|
int8_t a = cmd.m_data[1];
|
|
|
|
bool bCtrl = cmd.m_data[2];
|
|
|
|
int8_t b = cmd.m_data[3];
|
|
|
|
bool lnot = cmd.m_data[4];
|
|
|
|
int16_t macroStep = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
|
|
|
if (aCtrl)
|
|
|
|
a = vox.getCtrlValue(a);
|
|
|
|
else
|
|
|
|
a = m_variables[a];
|
|
|
|
|
|
|
|
if (bCtrl)
|
|
|
|
b = vox.getCtrlValue(b);
|
|
|
|
else
|
|
|
|
b = m_variables[b];
|
|
|
|
|
|
|
|
if ((a == b) ^ lnot)
|
|
|
|
m_pc.back().second = macroStep;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
case Op::IfLess:
|
2016-05-06 21:22:39 +00:00
|
|
|
{
|
|
|
|
bool aCtrl = cmd.m_data[0];
|
|
|
|
int8_t a = cmd.m_data[1];
|
|
|
|
bool bCtrl = cmd.m_data[2];
|
|
|
|
int8_t b = cmd.m_data[3];
|
|
|
|
bool lnot = cmd.m_data[4];
|
|
|
|
int16_t macroStep = *reinterpret_cast<int16_t*>(&cmd.m_data[5]);
|
|
|
|
|
|
|
|
if (aCtrl)
|
|
|
|
a = vox.getCtrlValue(a);
|
|
|
|
else
|
|
|
|
a = m_variables[a];
|
|
|
|
|
|
|
|
if (bCtrl)
|
|
|
|
b = vox.getCtrlValue(b);
|
|
|
|
else
|
|
|
|
b = m_variables[b];
|
|
|
|
|
|
|
|
if ((a < b) ^ lnot)
|
|
|
|
m_pc.back().second = macroStep;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2016-05-03 05:16:37 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_execTime += dt;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-06 21:22:39 +00:00
|
|
|
void SoundMacroState::keyoffNotify(Voice& vox)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
|
|
|
m_keyoff = true;
|
|
|
|
}
|
|
|
|
|
2016-05-06 21:22:39 +00:00
|
|
|
void SoundMacroState::sampleEndNotify(Voice& vox)
|
2016-05-03 05:16:37 +00:00
|
|
|
{
|
|
|
|
m_sampleEnd = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|