From 50c4b5cdab8be8f11fc5214a6aebb7cc26fe637a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 7 Sep 2019 06:21:07 -0400 Subject: [PATCH 01/17] General: Amend clamp parameter order Batch replace on switching to standardized variants assumed common ordering, which evidently wasn't the case --- include/amuse/EffectChorus.hpp | 6 +- include/amuse/EffectDelay.hpp | 18 +++--- include/amuse/EffectReverb.hpp | 12 ++-- include/amuse/Emitter.hpp | 2 +- include/amuse/Listener.hpp | 4 +- lib/EffectChorus.cpp | 6 +- lib/EffectDelay.cpp | 12 ++-- lib/EffectReverb.cpp | 12 ++-- lib/Emitter.cpp | 18 +++--- lib/Engine.cpp | 4 +- lib/Envelope.cpp | 30 ++++++---- lib/SongConverter.cpp | 4 +- lib/SongState.cpp | 4 +- lib/SoundMacroState.cpp | 8 +-- lib/Voice.cpp | 101 ++++++++++++++++++--------------- lib/VolumeTable.cpp | 26 +++++---- 16 files changed, 144 insertions(+), 123 deletions(-) diff --git a/include/amuse/EffectChorus.hpp b/include/amuse/EffectChorus.hpp index 648489e..239065a 100644 --- a/include/amuse/EffectChorus.hpp +++ b/include/amuse/EffectChorus.hpp @@ -38,21 +38,21 @@ public: using ImpType = EffectChorusImp; void setBaseDelay(uint32_t baseDelay) { - baseDelay = std::clamp(5u, baseDelay, 15u); + baseDelay = std::clamp(baseDelay, 5u, 15u); x90_baseDelay = baseDelay; m_dirty = true; } uint32_t getBaseDelay() const { return x90_baseDelay; } void setVariation(uint32_t variation) { - variation = std::clamp(0u, variation, 5u); + variation = std::clamp(variation, 0u, 5u); x94_variation = variation; m_dirty = true; } uint32_t getVariation() const { return x94_variation; } void setPeriod(uint32_t period) { - period = std::clamp(500u, period, 10000u); + period = std::clamp(period, 500u, 10000u); x98_period = period; m_dirty = true; } diff --git a/include/amuse/EffectDelay.hpp b/include/amuse/EffectDelay.hpp index c511d2d..a4f377c 100644 --- a/include/amuse/EffectDelay.hpp +++ b/include/amuse/EffectDelay.hpp @@ -51,41 +51,41 @@ public: using ImpType = EffectDelayImp; void setDelay(uint32_t delay) { - delay = std::clamp(10u, delay, 5000u); + delay = std::clamp(delay, 10u, 5000u); for (int i = 0; i < 8; ++i) x3c_delay[i] = delay; m_dirty = true; } void setChanDelay(int chanIdx, uint32_t delay) { - delay = std::clamp(10u, delay, 5000u); + delay = std::clamp(delay, 10u, 5000u); x3c_delay[chanIdx] = delay; m_dirty = true; } uint32_t getChanDelay(int chanIdx) const { return x3c_delay[chanIdx]; } void setFeedback(uint32_t feedback) { - feedback = std::clamp(0u, feedback, 100u); + feedback = std::clamp(feedback, 0u, 100u); for (int i = 0; i < 8; ++i) x48_feedback[i] = feedback; m_dirty = true; } void setChanFeedback(int chanIdx, uint32_t feedback) { - feedback = std::clamp(0u, feedback, 100u); + feedback = std::clamp(feedback, 0u, 100u); x48_feedback[chanIdx] = feedback; m_dirty = true; } uint32_t getChanFeedback(int chanIdx) const { return x48_feedback[chanIdx]; } void setOutput(uint32_t output) { - output = std::clamp(0u, output, 100u); + output = std::clamp(output, 0u, 100u); for (int i = 0; i < 8; ++i) x54_output[i] = output; m_dirty = true; } void setChanOutput(int chanIdx, uint32_t output) { - output = std::clamp(0u, output, 100u); + output = std::clamp(output, 0u, 100u); x54_output[chanIdx] = output; m_dirty = true; } @@ -93,9 +93,9 @@ public: void setParams(const EffectDelayInfo& info) { for (int i = 0; i < 8; ++i) { - x3c_delay[i] = std::clamp(10u, info.delay[i], 5000u); - x48_feedback[i] = std::clamp(0u, info.feedback[i], 100u); - x54_output[i] = std::clamp(0u, info.output[i], 100u); + x3c_delay[i] = std::clamp(info.delay[i], 10u, 5000u); + x48_feedback[i] = std::clamp(info.feedback[i], 0u, 100u); + x54_output[i] = std::clamp(info.output[i], 0u, 100u); } m_dirty = true; } diff --git a/include/amuse/EffectReverb.hpp b/include/amuse/EffectReverb.hpp index ec980fb..ea9337c 100644 --- a/include/amuse/EffectReverb.hpp +++ b/include/amuse/EffectReverb.hpp @@ -75,31 +75,31 @@ public: using ImpType = EffectReverbStdImp; void setColoration(float coloration) { - x140_x1c8_coloration = std::clamp(0.f, coloration, 1.f); + x140_x1c8_coloration = std::clamp(coloration, 0.f, 1.f); m_dirty = true; } float getColoration() const { return x140_x1c8_coloration; } void setMix(float mix) { - x144_x1cc_mix = std::clamp(0.f, mix, 1.f); + x144_x1cc_mix = std::clamp(mix, 0.f, 1.f); m_dirty = true; } float getMix() const { return x144_x1cc_mix; } void setTime(float time) { - x148_x1d0_time = std::clamp(0.01f, time, 10.f); + x148_x1d0_time = std::clamp(time, 0.01f, 10.f); m_dirty = true; } float getTime() const { return x148_x1d0_time; } void setDamping(float damping) { - x14c_x1d4_damping = std::clamp(0.f, damping, 1.f); + x14c_x1d4_damping = std::clamp(damping, 0.f, 1.f); m_dirty = true; } float getDamping() const { return x14c_x1d4_damping; } void setPreDelay(float preDelay) { - x150_x1d8_preDelay = std::clamp(0.f, preDelay, 0.1f); + x150_x1d8_preDelay = std::clamp(preDelay, 0.f, 0.1f); m_dirty = true; } float getPreDelay() const { return x150_x1d8_preDelay; } @@ -126,7 +126,7 @@ public: using ImpType = EffectReverbHiImp; void setCrosstalk(float crosstalk) { - x1dc_crosstalk = std::clamp(0.f, crosstalk, 1.f); + x1dc_crosstalk = std::clamp(crosstalk, 0.f, 1.f); m_dirty = true; } float getCrosstalk() const { return x1dc_crosstalk; } diff --git a/include/amuse/Emitter.hpp b/include/amuse/Emitter.hpp index c337bc6..6499dc9 100644 --- a/include/amuse/Emitter.hpp +++ b/include/amuse/Emitter.hpp @@ -56,7 +56,7 @@ public: void setVectors(const float* pos, const float* dir); void setMaxVol(float maxVol) { - m_maxVol = std::clamp(0.f, maxVol, 1.f); + m_maxVol = std::clamp(maxVol, 0.f, 1.f); m_dirty = true; } diff --git a/include/amuse/Listener.hpp b/include/amuse/Listener.hpp index da715f3..6a98da7 100644 --- a/include/amuse/Listener.hpp +++ b/include/amuse/Listener.hpp @@ -19,10 +19,10 @@ class Listener { public: Listener(float volume, float frontDiff, float backDiff, float soundSpeed) - : m_volume(std::clamp(0.f, volume, 1.f)), m_frontDiff(frontDiff), m_backDiff(backDiff), m_soundSpeed(soundSpeed) {} + : m_volume(std::clamp(volume, 0.f, 1.f)), m_frontDiff(frontDiff), m_backDiff(backDiff), m_soundSpeed(soundSpeed) {} void setVectors(const float* pos, const float* dir, const float* heading, const float* up); void setVolume(float vol) { - m_volume = std::clamp(0.f, vol, 1.f); + m_volume = std::clamp(vol, 0.f, 1.f); m_dirty = true; } }; diff --git a/lib/EffectChorus.cpp b/lib/EffectChorus.cpp index 548a586..67d5160 100644 --- a/lib/EffectChorus.cpp +++ b/lib/EffectChorus.cpp @@ -143,9 +143,9 @@ static const float rsmpTab12khz[] = /* clang-format on */ EffectChorus::EffectChorus(uint32_t baseDelay, uint32_t variation, uint32_t period) -: x90_baseDelay(std::clamp(5u, baseDelay, 15u)) -, x94_variation(std::clamp(0u, variation, 5u)) -, x98_period(std::clamp(500u, period, 10000u)) {} +: x90_baseDelay(std::clamp(baseDelay, 5u, 15u)) +, x94_variation(std::clamp(variation, 0u, 5u)) +, x98_period(std::clamp(period, 500u, 10000u)) {} template EffectChorusImp::EffectChorusImp(uint32_t baseDelay, uint32_t variation, uint32_t period, double sampleRate) diff --git a/lib/EffectDelay.cpp b/lib/EffectDelay.cpp index 0c6450d..1975763 100644 --- a/lib/EffectDelay.cpp +++ b/lib/EffectDelay.cpp @@ -10,9 +10,9 @@ namespace amuse { template EffectDelayImp::EffectDelayImp(uint32_t initDelay, uint32_t initFeedback, uint32_t initOutput, double sampleRate) { - initDelay = std::clamp(10u, initDelay, 5000u); - initFeedback = std::clamp(0u, initFeedback, 100u); - initOutput = std::clamp(0u, initOutput, 100u); + initDelay = std::clamp(initDelay, 10u, 5000u); + initFeedback = std::clamp(initFeedback, 0u, 100u); + initOutput = std::clamp(initOutput, 0u, 100u); for (int i = 0; i < 8; ++i) { x3c_delay[i] = initDelay; @@ -26,9 +26,9 @@ EffectDelayImp::EffectDelayImp(uint32_t initDelay, uint32_t initFeedback, uin template EffectDelayImp::EffectDelayImp(const EffectDelayInfo& info, double sampleRate) { for (int i = 0; i < 8; ++i) { - x3c_delay[i] = std::clamp(10u, info.delay[i], 5000u); - x48_feedback[i] = std::clamp(0u, info.feedback[i], 100u); - x54_output[i] = std::clamp(0u, info.output[i], 100u); + x3c_delay[i] = std::clamp(info.delay[i], 10u, 5000u); + x48_feedback[i] = std::clamp(info.feedback[i], 0u, 100u); + x54_output[i] = std::clamp(info.output[i], 0u, 100u); } _setup(sampleRate); diff --git a/lib/EffectReverb.cpp b/lib/EffectReverb.cpp index 5b25dca..19e8b69 100644 --- a/lib/EffectReverb.cpp +++ b/lib/EffectReverb.cpp @@ -57,14 +57,14 @@ void ReverbDelayLine::setdelay(int32_t delay) { } EffectReverbStd::EffectReverbStd(float coloration, float mix, float time, float damping, float preDelay) -: x140_x1c8_coloration(std::clamp(0.f, coloration, 1.f)) -, x144_x1cc_mix(std::clamp(0.f, mix, 1.f)) -, x148_x1d0_time(std::clamp(0.01f, time, 10.f)) -, x14c_x1d4_damping(std::clamp(0.f, damping, 1.f)) -, x150_x1d8_preDelay(std::clamp(0.f, preDelay, 0.1f)) {} +: x140_x1c8_coloration(std::clamp(coloration, 0.f, 1.f)) +, x144_x1cc_mix(std::clamp(mix, 0.f, 1.f)) +, x148_x1d0_time(std::clamp(time, 0.01f, 10.f)) +, x14c_x1d4_damping(std::clamp(damping, 0.f, 1.f)) +, x150_x1d8_preDelay(std::clamp(preDelay, 0.f, 0.1f)) {} EffectReverbHi::EffectReverbHi(float coloration, float mix, float time, float damping, float preDelay, float crosstalk) -: EffectReverbStd(coloration, mix, time, damping, preDelay), x1dc_crosstalk(std::clamp(0.f, crosstalk, 1.0f)) {} +: EffectReverbStd(coloration, mix, time, damping, preDelay), x1dc_crosstalk(std::clamp(crosstalk, 0.f, 1.0f)) {} template EffectReverbStdImp::EffectReverbStdImp(float coloration, float mix, float time, float damping, float preDelay, diff --git a/lib/Emitter.cpp b/lib/Emitter.cpp index 45ad01c..f189d7c 100644 --- a/lib/Emitter.cpp +++ b/lib/Emitter.cpp @@ -19,8 +19,8 @@ Emitter::Emitter(Engine& engine, const AudioGroup& group, ObjToken vox, f : Entity(engine, group, vox->getGroupId(), vox->getObjectId()) , m_vox(vox) , m_maxDist(maxDist) -, m_minVol(std::clamp(0.f, minVol, 1.f)) -, m_falloff(std::clamp(-1.f, falloff, 1.f)) +, m_minVol(std::clamp(minVol, 0.f, 1.f)) +, m_falloff(std::clamp(falloff, -1.f, 1.f)) , m_doppler(doppler) {} void Emitter::_destroy() { @@ -60,13 +60,13 @@ void Emitter::_update() { for (auto& listener : m_engine.m_activeListeners) { Vector3f listenerToEmitter; Delta(listenerToEmitter, m_pos, listener->m_pos); - float dist = Length(listenerToEmitter); - float panDist = Dot(listenerToEmitter, listener->m_right); - float frontPan = std::clamp(-1.f, panDist / listener->m_frontDiff, 1.f); - float backPan = std::clamp(-1.f, panDist / listener->m_backDiff, 1.f); - float spanDist = -Dot(listenerToEmitter, listener->m_heading); - float span = - std::clamp(-1.f, spanDist > 0.f ? spanDist / listener->m_backDiff : spanDist / listener->m_frontDiff, 1.f); + const float dist = Length(listenerToEmitter); + const float panDist = Dot(listenerToEmitter, listener->m_right); + const float frontPan = std::clamp(panDist / listener->m_frontDiff, -1.f, 1.f); + const float backPan = std::clamp(panDist / listener->m_backDiff, -1.f, 1.f); + const float spanDist = -Dot(listenerToEmitter, listener->m_heading); + const float span = + std::clamp(spanDist > 0.f ? spanDist / listener->m_backDiff : spanDist / listener->m_frontDiff, -1.f, 1.f); /* Calculate attenuation */ float att = _attenuationCurve(dist); diff --git a/lib/Engine.cpp b/lib/Engine.cpp index fd35d35..5828454 100644 --- a/lib/Engine.cpp +++ b/lib/Engine.cpp @@ -251,7 +251,7 @@ ObjToken Engine::fxStart(SFXId sfxId, float vol, float pan, ObjTokensetVolume(vol); float evalPan = pan != 0.f ? pan : ((entry->panning - 64.f) / 63.f); - evalPan = std::clamp(-1.f, evalPan, 1.f); + evalPan = std::clamp(evalPan, -1.f, 1.f); (*ret)->setPan(evalPan); return *ret; } @@ -273,7 +273,7 @@ ObjToken Engine::fxStart(const AudioGroup* group, GroupId groupId, SFXId (*ret)->setVolume(vol); float evalPan = pan != 0.f ? pan : ((entry.panning - 64.f) / 63.f); - evalPan = std::clamp(-1.f, evalPan, 1.f); + evalPan = std::clamp(evalPan, -1.f, 1.f); (*ret)->setPan(evalPan); return *ret; } diff --git a/lib/Envelope.cpp b/lib/Envelope.cpp index 6b3b2e5..152a762 100644 --- a/lib/Envelope.cpp +++ b/lib/Envelope.cpp @@ -42,8 +42,9 @@ void Envelope::reset(const ADSRDLS* adsr, int8_t note, int8_t vel) { void Envelope::keyOff(const Voice& vox) { double releaseTime = m_releaseTime; - if (vox.m_state.m_useAdsrControllers) - releaseTime = MIDItoTIME[std::clamp(0, int(vox.getCtrlValue(vox.m_state.m_midiRelease)), 103)] / 1000.0; + if (vox.m_state.m_useAdsrControllers) { + releaseTime = MIDItoTIME[std::clamp(int(vox.getCtrlValue(vox.m_state.m_midiRelease)), 0, 103)] / 1000.0; + } m_phase = (releaseTime != 0.0) ? State::Release : State::Complete; m_curTime = 0.0; @@ -64,8 +65,9 @@ float Envelope::advance(double dt, const Voice& vox) { switch (m_phase) { case State::Attack: { double attackTime = m_attackTime; - if (vox.m_state.m_useAdsrControllers) - attackTime = MIDItoTIME[std::clamp(0, int(vox.getCtrlValue(vox.m_state.m_midiAttack)), 103)] / 1000.0; + if (vox.m_state.m_useAdsrControllers) { + attackTime = MIDItoTIME[std::clamp(int(vox.getCtrlValue(vox.m_state.m_midiAttack)), 0, 103)] / 1000.0; + } if (attackTime == 0.0) { m_phase = State::Decay; @@ -85,12 +87,14 @@ float Envelope::advance(double dt, const Voice& vox) { } case State::Decay: { double decayTime = m_decayTime; - if (vox.m_state.m_useAdsrControllers) - decayTime = MIDItoTIME[std::clamp(0, int(vox.getCtrlValue(vox.m_state.m_midiDecay)), 103)] / 1000.0; + if (vox.m_state.m_useAdsrControllers) { + decayTime = MIDItoTIME[std::clamp(int(vox.getCtrlValue(vox.m_state.m_midiDecay)), 0, 103)] / 1000.0; + } double sustainFactor = m_sustainFactor; - if (vox.m_state.m_useAdsrControllers) - sustainFactor = std::clamp(0, int(vox.getCtrlValue(vox.m_state.m_midiSustain)), 127) / 127.0; + if (vox.m_state.m_useAdsrControllers) { + sustainFactor = std::clamp(int(vox.getCtrlValue(vox.m_state.m_midiSustain)), 0, 127) / 127.0; + } if (decayTime == 0.0) { m_phase = State::Sustain; @@ -110,15 +114,17 @@ float Envelope::advance(double dt, const Voice& vox) { } case State::Sustain: { double sustainFactor = m_sustainFactor; - if (vox.m_state.m_useAdsrControllers) - sustainFactor = std::clamp(0, int(vox.getCtrlValue(vox.m_state.m_midiSustain)), 127) / 127.0; + if (vox.m_state.m_useAdsrControllers) { + sustainFactor = std::clamp(int(vox.getCtrlValue(vox.m_state.m_midiSustain)), 0, 127) / 127.0; + } return sustainFactor; } case State::Release: { double releaseTime = m_releaseTime; - if (vox.m_state.m_useAdsrControllers) - releaseTime = MIDItoTIME[std::clamp(0, int(vox.getCtrlValue(vox.m_state.m_midiRelease)), 103)] / 1000.0; + if (vox.m_state.m_useAdsrControllers) { + releaseTime = MIDItoTIME[std::clamp(int(vox.getCtrlValue(vox.m_state.m_midiRelease)), 0, 103)] / 1000.0; + } if (releaseTime == 0.0) { m_phase = State::Complete; diff --git a/lib/SongConverter.cpp b/lib/SongConverter.cpp index a104b62..e68d004 100644 --- a/lib/SongConverter.cpp +++ b/lib/SongConverter.cpp @@ -683,7 +683,7 @@ std::vector SongConverter::SongToMIDI(const unsigned char* data, int& v /* Update pitch */ trk.m_pitchVal += trk.m_nextPitchDelta; events.emplace(regStart + trk.m_nextPitchTick, - Event{PitchEvent{}, trk.m_midiChan, std::clamp(0, trk.m_pitchVal + 0x2000, 0x4000)}); + Event{PitchEvent{}, trk.m_midiChan, std::clamp(trk.m_pitchVal + 0x2000, 0, 0x4000)}); if (trk.m_pitchWheelData[0] != 0x80 || trk.m_pitchWheelData[1] != 0x00) { auto delta = DecodeDelta(trk.m_pitchWheelData); trk.m_nextPitchTick += delta.first; @@ -700,7 +700,7 @@ std::vector SongConverter::SongToMIDI(const unsigned char* data, int& v /* Update modulation */ trk.m_modVal += trk.m_nextModDelta; events.emplace(regStart + trk.m_nextModTick, - Event{CtrlEvent{}, trk.m_midiChan, 1, uint8_t(std::clamp(0, trk.m_modVal / 128, 127)), 0}); + Event{CtrlEvent{}, trk.m_midiChan, 1, uint8_t(std::clamp(trk.m_modVal / 128, 0, 127)), 0}); if (trk.m_modWheelData[0] != 0x80 || trk.m_modWheelData[1] != 0x00) { auto delta = DecodeDelta(trk.m_modWheelData); trk.m_nextModTick += delta.first; diff --git a/lib/SongState.cpp b/lib/SongState.cpp index bca2d95..13fe123 100644 --- a/lib/SongState.cpp +++ b/lib/SongState.cpp @@ -443,7 +443,7 @@ bool SongState::Track::advance(Sequencer& seq, double dt) { if (pitchTick + remPitchTicks > nextTick) { /* Update pitch */ m_pitchVal += m_nextPitchDelta; - seq.setPitchWheel(m_midiChan, std::clamp(-1.f, m_pitchVal / 8191.f, 1.f)); + seq.setPitchWheel(m_midiChan, std::clamp(m_pitchVal / 8191.f, -1.f, 1.f)); if (m_pitchWheelData[0] != 0x80 || m_pitchWheelData[1] != 0x00) { auto delta = DecodeDelta(m_pitchWheelData); m_nextPitchTick += delta.first; @@ -467,7 +467,7 @@ bool SongState::Track::advance(Sequencer& seq, double dt) { if (modTick + remModTicks > nextTick) { /* Update modulation */ m_modVal += m_nextModDelta; - seq.setCtrlValue(m_midiChan, 1, int8_t(std::clamp(0, m_modVal / 127, 127))); + seq.setCtrlValue(m_midiChan, 1, int8_t(std::clamp(m_modVal / 127, 0, 127))); if (m_modWheelData[0] != 0x80 || m_modWheelData[1] != 0x00) { auto delta = DecodeDelta(m_modWheelData); m_nextModTick += delta.first; diff --git a/lib/SoundMacroState.cpp b/lib/SoundMacroState.cpp index e82cb7a..fd8b86d 100644 --- a/lib/SoundMacroState.cpp +++ b/lib/SoundMacroState.cpp @@ -67,7 +67,7 @@ float SoundMacroState::Evaluator::evaluate(double time, const Voice& vox, const break; case 135: /* Time since macro-start (ms) */ - thisValue = std::clamp(0.f, float(st.m_execTime * 1000.f), 16383.f); + thisValue = std::clamp(float(st.m_execTime * 1000.f), 0.f, 16383.f); break; default: thisValue = vox.getCtrlValue(comp.m_midiCtrl); @@ -462,7 +462,7 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdScaleVolume::Introspective = { {FIELD_HEAD(SoundMacro::CmdScaleVolume, originalVol), "Original Vol"sv, 0, 1, 1}}}; bool SoundMacro::CmdScaleVolume::Do(SoundMacroState& st, Voice& vox) const { int32_t eval = int32_t(originalVol ? st.m_initVel : st.m_curVel) * scale / 127 + add; - eval = std::clamp(0, eval, 127); + eval = std::clamp(eval, 0, 127); if (table.id != 0) { const Curve* curveData = vox.getAudioGroup().getPool().tableAsCurves(table.id); @@ -504,7 +504,7 @@ bool SoundMacro::CmdEnvelope::Do(SoundMacroState& st, Voice& vox) const { double secTime = ticksOrMs / q; int32_t eval = int32_t(st.m_curVel) * scale / 127 + add; - eval = std::clamp(0, eval, 127); + eval = std::clamp(eval, 0, 127); const Curve* curveData; if (table.id != 0) @@ -601,7 +601,7 @@ bool SoundMacro::CmdFadeIn::Do(SoundMacroState& st, Voice& vox) const { float secTime = ticksOrMs / q; int32_t eval = int32_t(st.m_curVel) * scale / 127 + add; - eval = std::clamp(0, eval, 127); + eval = std::clamp(eval, 0, 127); const Curve* curveData; if (table.id != 0) diff --git a/lib/Voice.cpp b/lib/Voice.cpp index ee9bb00..2a80088 100644 --- a/lib/Voice.cpp +++ b/lib/Voice.cpp @@ -114,8 +114,8 @@ void Voice::_doKeyOff() { void Voice::_setTotalPitch(int32_t cents, bool slew) { // fprintf(stderr, "PITCH %d %d \n", cents, slew); - int32_t interval = std::clamp(0, cents, 12700) - m_curSample->getPitch() * 100; - double ratio = std::exp2(interval / 1200.0) * m_dopplerRatio; + const int32_t interval = std::clamp(cents, 0, 12700) - m_curSample->getPitch() * 100; + const double ratio = std::exp2(interval / 1200.0) * m_dopplerRatio; m_sampleRate = m_curSample->m_sampleRate * ratio; m_backendVoice->setPitchRatio(ratio, slew); } @@ -200,8 +200,8 @@ void Voice::_procSamplePre(int16_t& samp) { dt = m_sampleRate * 160; if (rem != 0) { /* Lerp within 160-sample block */ - float t = rem / 160.f; - float l = std::clamp(0.f, m_lastLevel * (1.f - t) + m_nextLevel * t, 1.f); + const float t = rem / 160.f; + const float l = std::clamp(m_lastLevel * (1.f - t) + m_nextLevel * t, 0.f, 1.f); /* Apply total volume to sample using decibel scale */ samp = ApplyVolume(m_lerpedCache.getVolume(l * m_engine.m_masterVolume, m_dlsVol), samp); @@ -218,12 +218,13 @@ void Voice::_procSamplePre(int16_t& samp) { /* Process active envelope */ if (m_envelopeTime >= 0.0) { m_envelopeTime += dt; - float start = m_envelopeStart; - float end = m_envelopeEnd; - float t = std::clamp(0.f, float(m_envelopeTime / m_envelopeDur), 1.f); - if (m_envelopeCurve && m_envelopeCurve->data.size() >= 128) + const float start = m_envelopeStart; + const float end = m_envelopeEnd; + float t = std::clamp(float(m_envelopeTime / m_envelopeDur), 0.f, 1.f); + if (m_envelopeCurve && m_envelopeCurve->data.size() >= 128) { t = m_envelopeCurve->data[t * 127.f] / 127.f; - m_envelopeVol = std::clamp(0.f, (start * (1.0f - t)) + (end * t), 1.f); + } + m_envelopeVol = std::clamp((start * (1.0f - t)) + (end * t), 0.f, 1.f); // printf("%d %f\n", m_vid, m_envelopeVol); @@ -280,7 +281,7 @@ void Voice::_procSamplePre(int16_t& samp) { } } - m_nextLevel = std::clamp(0.f, m_nextLevel, 1.f); + m_nextLevel = std::clamp(m_nextLevel, 0.f, 1.f); /* Apply total volume to sample using decibel scale */ samp = ApplyVolume(m_nextLevelCache.getVolume(m_nextLevel * m_engine.m_masterVolume, m_dlsVol), samp); @@ -288,8 +289,8 @@ void Voice::_procSamplePre(int16_t& samp) { template T Voice::_procSampleMaster(double time, T samp) { - float evalVol = m_state.m_volumeSel ? (m_state.m_volumeSel.evaluate(time, *this, m_state) / 127.f) : 1.f; - return ApplyVolume(m_masterCache.getVolume(std::clamp(0.f, evalVol, 1.f), m_dlsVol), samp); + const float evalVol = m_state.m_volumeSel ? (m_state.m_volumeSel.evaluate(time, *this, m_state) / 127.f) : 1.f; + return ApplyVolume(m_masterCache.getVolume(std::clamp(evalVol, 0.f, 1.f), m_dlsVol), samp); } template @@ -297,7 +298,7 @@ T Voice::_procSampleAuxA(double time, T samp) { float evalVol = m_state.m_volumeSel ? (m_state.m_volumeSel.evaluate(time, *this, m_state) / 127.f) : 1.f; evalVol *= m_state.m_reverbSel ? (m_state.m_reverbSel.evaluate(time, *this, m_state) / 127.f) : m_curReverbVol; evalVol += m_state.m_preAuxASel ? (m_state.m_preAuxASel.evaluate(time, *this, m_state) / 127.f) : 0.f; - return ApplyVolume(m_auxACache.getVolume(std::clamp(0.f, evalVol, 1.f), m_dlsVol), samp); + return ApplyVolume(m_auxACache.getVolume(std::clamp(evalVol, 0.f, 1.f), m_dlsVol), samp); } template @@ -305,7 +306,7 @@ T Voice::_procSampleAuxB(double time, T samp) { float evalVol = m_state.m_volumeSel ? (m_state.m_volumeSel.evaluate(time, *this, m_state) / 127.f) : 1.f; evalVol *= m_state.m_postAuxB ? (m_state.m_postAuxB.evaluate(time, *this, m_state) / 127.f) : m_curAuxBVol; evalVol += m_state.m_preAuxBSel ? (m_state.m_preAuxBSel.evaluate(time, *this, m_state) / 127.f) : 0.f; - return ApplyVolume(m_auxBCache.getVolume(std::clamp(0.f, evalVol, 1.f), m_dlsVol), samp); + return ApplyVolume(m_auxBCache.getVolume(std::clamp(evalVol, 0.f, 1.f), m_dlsVol), samp); } uint32_t Voice::_GetBlockSampleCount(SampleFormat fmt) { @@ -343,7 +344,7 @@ void Voice::preSupplyAudio(double dt) { bool panDirty = false; if (m_state.m_panSel) { float evalPan = (m_state.m_panSel.evaluate(m_voiceTime, *this, m_state) - 64.f) / 63.f; - evalPan = std::clamp(-1.f, evalPan, 1.f); + evalPan = std::clamp(evalPan, -1.f, 1.f); if (evalPan != m_curPan) { m_curPan = evalPan; panDirty = true; @@ -351,7 +352,7 @@ void Voice::preSupplyAudio(double dt) { } if (m_state.m_spanSel) { float evalSpan = (m_state.m_spanSel.evaluate(m_voiceTime, *this, m_state) - 64.f) / 63.f; - evalSpan = std::clamp(-1.f, evalSpan, 1.f); + evalSpan = std::clamp(evalSpan, -1.f, 1.f); if (evalSpan != m_curSpan) { m_curSpan = evalSpan; panDirty = true; @@ -361,8 +362,8 @@ void Voice::preSupplyAudio(double dt) { _setPan(m_curPan); if (m_state.m_pitchWheelSel) { - float evalPWheel = (m_state.m_pitchWheelSel.evaluate(m_voiceTime, *this, m_state) - 64.f) / 63.f; - _setPitchWheel(std::clamp(-1.f, evalPWheel, 1.f)); + const float evalPWheel = (m_state.m_pitchWheelSel.evaluate(m_voiceTime, *this, m_state) - 64.f) / 63.f; + _setPitchWheel(std::clamp(evalPWheel, -1.f, 1.f)); } /* Process active pan-sweep */ @@ -370,9 +371,9 @@ void Voice::preSupplyAudio(double dt) { if (!m_panningQueue.empty()) { Panning& p = m_panningQueue.front(); p.m_time += dt; - double start = (p.m_pos - 64) / 64.0; - double end = (p.m_pos + p.m_width - 64) / 64.0; - double t = std::clamp(0.0, p.m_time / p.m_dur, 1.0); + const double start = (p.m_pos - 64) / 64.0; + const double end = (p.m_pos + p.m_width - 64) / 64.0; + const double t = std::clamp(p.m_time / p.m_dur, 0.0, 1.0); _setPan(float((start * (1.0 - t)) + (end * t))); refresh = true; @@ -385,9 +386,9 @@ void Voice::preSupplyAudio(double dt) { if (!m_spanningQueue.empty()) { Panning& s = m_spanningQueue.front(); s.m_time += dt; - double start = (s.m_pos - 64) / 64.0; - double end = (s.m_pos + s.m_width - 64) / 64.0; - double t = std::clamp(0.0, s.m_time / s.m_dur, 1.0); + const double start = (s.m_pos - 64) / 64.0; + const double end = (s.m_pos + s.m_width - 64) / 64.0; + const double t = std::clamp(s.m_time / s.m_dur, 0.0, 1.0); _setSurroundPan(float((start * (1.0 - t)) + (end * t))); refresh = true; @@ -402,7 +403,7 @@ void Voice::preSupplyAudio(double dt) { m_pitchDirty = false; if (m_portamentoTime >= 0.f) { m_portamentoTime += dt; - float t = std::clamp(0.f, m_portamentoTime / m_state.m_portamentoTime, 1.f); + const float t = std::clamp(m_portamentoTime / m_state.m_portamentoTime, 0.f, 1.f); newPitch = (m_curPitch * (1.0f - t)) + (m_portamentoTarget * t); refresh = true; @@ -849,14 +850,15 @@ void Voice::startSample(SampleId sampId, int32_t offset) { m_backendVoice->resetSampleRate(m_curSample->m_sampleRate); m_needsSlew = false; - int32_t numSamples = m_curSample->getNumSamples(); + const int32_t numSamples = m_curSample->getNumSamples(); if (offset) { if (m_curSample->isLooped()) { if (offset > int32_t(m_curSample->m_loopStartSample)) offset = ((offset - m_curSample->m_loopStartSample) % m_curSample->m_loopLengthSamples) + m_curSample->m_loopStartSample; - } else - offset = std::clamp(0, offset, numSamples); + } else { + offset = std::clamp(offset, 0, numSamples); + } } m_curSamplePos = offset; m_prev1 = 0; @@ -895,7 +897,7 @@ void Voice::setVolume(float vol) { if (m_destroyed) return; - m_targetUserVol = std::clamp(0.f, vol, 1.f); + m_targetUserVol = std::clamp(vol, 0.f, 1.f); for (ObjToken& vox : m_childVoices) vox->setVolume(vol); } @@ -1011,12 +1013,13 @@ void Voice::_panLaw(float coefs[8], float frontPan, float backPan, float totalSp } void Voice::_setPan(float pan) { - if (m_destroyed || m_emitter) + if (m_destroyed || m_emitter) { return; + } - m_curPan = std::clamp(-1.f, pan, 1.f); - float totalPan = std::clamp(-1.f, m_curPan, 1.f); - float totalSpan = std::clamp(-1.f, m_curSpan, 1.f); + m_curPan = std::clamp(pan, -1.f, 1.f); + const float totalPan = std::clamp(m_curPan, -1.f, 1.f); + const float totalSpan = std::clamp(m_curSpan, -1.f, 1.f); float coefs[8] = {}; _panLaw(coefs, totalPan, totalPan, totalSpan); _setChannelCoefs(coefs); @@ -1032,7 +1035,7 @@ void Voice::setPan(float pan) { } void Voice::_setSurroundPan(float span) { - m_curSpan = std::clamp(-1.f, span, 1.f); + m_curSpan = std::clamp(span, -1.f, 1.f); _setPan(m_curPan); } @@ -1063,8 +1066,8 @@ void Voice::setChannelCoefs(const float coefs[8]) { void Voice::startEnvelope(double dur, float vol, const Curve* envCurve) { m_envelopeTime = 0.f; m_envelopeDur = dur; - m_envelopeStart = std::clamp(0.f, m_envelopeVol, 1.f); - m_envelopeEnd = std::clamp(0.f, vol, 1.f); + m_envelopeStart = std::clamp(m_envelopeVol, 0.f, 1.f); + m_envelopeEnd = std::clamp(vol, 0.f, 1.f); m_envelopeCurve = envCurve; } @@ -1072,7 +1075,7 @@ void Voice::startFadeIn(double dur, float vol, const Curve* envCurve) { m_envelopeTime = 0.f; m_envelopeDur = dur; m_envelopeStart = 0.f; - m_envelopeEnd = std::clamp(0.f, vol, 1.f); + m_envelopeEnd = std::clamp(vol, 0.f, 1.f); m_envelopeCurve = envCurve; } @@ -1134,21 +1137,25 @@ void Voice::setPitchSweep2(uint8_t times, int16_t add) { } void Voice::setReverbVol(float rvol) { - if (m_destroyed) + if (m_destroyed) { return; + } - m_curReverbVol = std::clamp(0.f, rvol, 1.f); - for (ObjToken& vox : m_childVoices) + m_curReverbVol = std::clamp(rvol, 0.f, 1.f); + for (ObjToken& vox : m_childVoices) { vox->setReverbVol(rvol); + } } void Voice::setAuxBVol(float bvol) { - if (m_destroyed) + if (m_destroyed) { return; + } - m_curAuxBVol = std::clamp(0.f, bvol, 1.f); - for (ObjToken& vox : m_childVoices) + m_curAuxBVol = std::clamp(bvol, 0.f, 1.f); + for (ObjToken& vox : m_childVoices) { vox->setAuxBVol(bvol); + } } void Voice::setAdsr(ObjectId adsrId, bool dls) { @@ -1207,14 +1214,16 @@ void Voice::_setPitchWheel(float pitchWheel) { } void Voice::setPitchWheel(float pitchWheel) { - if (m_destroyed) + if (m_destroyed) { return; + } - m_curPitchWheel = std::clamp(-1.f, pitchWheel, 1.f); + m_curPitchWheel = std::clamp(pitchWheel, -1.f, 1.f); _setPitchWheel(m_curPitchWheel); - for (ObjToken& vox : m_childVoices) + for (ObjToken& vox : m_childVoices) { vox->setPitchWheel(pitchWheel); + } } void Voice::setPitchWheelRange(int8_t up, int8_t down) { diff --git a/lib/VolumeTable.cpp b/lib/VolumeTable.cpp index 1b3f094..4776923 100644 --- a/lib/VolumeTable.cpp +++ b/lib/VolumeTable.cpp @@ -37,22 +37,28 @@ static const float DLSVolumeTable[] = { 0.892802f, 0.907744f, 0.922810f, 0.938000f, 0.953314f, 0.968752f, 0.984314f, 1.000000f, 1.000000f}; float LookupVolume(float vol) { - vol = std::clamp(0.f, vol * 127.f, 127.f); - float f = std::floor(vol); - float c = std::ceil(vol); - if (f == c) + vol = std::clamp(vol * 127.f, 0.f, 127.f); + const float f = std::floor(vol); + const float c = std::ceil(vol); + + if (f == c) { return VolumeTable[int(f)]; - float t = vol - f; + } + + const float t = vol - f; return (1.f - t) * VolumeTable[int(f)] + t * VolumeTable[int(c)]; } float LookupDLSVolume(float vol) { - vol = std::clamp(0.f, vol * 127.f, 127.f); - float f = std::floor(vol); - float c = std::ceil(vol); - if (f == c) + vol = std::clamp(vol * 127.f, 0.f, 127.f); + const float f = std::floor(vol); + const float c = std::ceil(vol); + + if (f == c) { return DLSVolumeTable[int(f)]; - float t = vol - f; + } + + const float t = vol - f; return (1.f - t) * DLSVolumeTable[int(f)] + t * DLSVolumeTable[int(c)]; } From 7600f8ad27d745eef0dd3e5343607de49485dfb2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 7 Sep 2019 11:20:14 -0400 Subject: [PATCH 02/17] General: Make operator bool() instances explicit Prevents error-prone implicit conversions to bool. --- include/amuse/AudioGroup.hpp | 2 +- include/amuse/AudioGroupData.hpp | 4 +++- include/amuse/Common.hpp | 2 +- include/amuse/DirectoryEnumerator.hpp | 2 +- include/amuse/Sequencer.hpp | 2 +- include/amuse/SongState.hpp | 2 +- include/amuse/SoundMacroState.hpp | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/amuse/AudioGroup.hpp b/include/amuse/AudioGroup.hpp index cd0d079..75ab8e9 100644 --- a/include/amuse/AudioGroup.hpp +++ b/include/amuse/AudioGroup.hpp @@ -26,7 +26,7 @@ protected: public: SystemString getSampleBasePath(SampleId sfxId) const; - operator bool() const { return m_valid; } + explicit operator bool() const { return m_valid; } AudioGroup() = default; explicit AudioGroup(const AudioGroupData& data) { assign(data); } explicit AudioGroup(SystemStringView groupPath) { assign(groupPath); } diff --git a/include/amuse/AudioGroupData.hpp b/include/amuse/AudioGroupData.hpp index d25da96..4c91284 100644 --- a/include/amuse/AudioGroupData.hpp +++ b/include/amuse/AudioGroupData.hpp @@ -89,7 +89,9 @@ public: size_t getSdirSize() const { return m_sdirSz; } size_t getSampSize() const { return m_sampSz; } - operator bool() const { return m_proj != nullptr && m_pool != nullptr && m_sdir != nullptr && m_samp != nullptr; } + explicit operator bool() const { + return m_proj != nullptr && m_pool != nullptr && m_sdir != nullptr && m_samp != nullptr; + } DataFormat getDataFormat() const { return m_fmt; } bool getAbsoluteProjOffsets() const { return m_absOffs; } diff --git a/include/amuse/Common.hpp b/include/amuse/Common.hpp index 185a3b2..5f6c558 100644 --- a/include/amuse/Common.hpp +++ b/include/amuse/Common.hpp @@ -216,7 +216,7 @@ public: bool operator!=(const ObjTokenBase& other) const noexcept { return !operator==(other); } bool operator<(const ObjTokenBase& other) const noexcept { return m_obj < other.m_obj; } bool operator>(const ObjTokenBase& other) const noexcept { return m_obj > other.m_obj; } - operator bool() const noexcept { return m_obj != nullptr; } + explicit operator bool() const noexcept { return m_obj != nullptr; } void reset() noexcept { if (m_obj) { m_obj->decrement(); diff --git a/include/amuse/DirectoryEnumerator.hpp b/include/amuse/DirectoryEnumerator.hpp index 98c5194..46dc31c 100644 --- a/include/amuse/DirectoryEnumerator.hpp +++ b/include/amuse/DirectoryEnumerator.hpp @@ -48,7 +48,7 @@ public: DirectoryEnumerator(SystemStringView path, Mode mode = Mode::DirsThenFilesSorted, bool sizeSort = false, bool reverse = false, bool noHidden = false); - operator bool() const { return m_entries.size() != 0; } + explicit operator bool() const { return m_entries.size() != 0; } size_t size() const { return m_entries.size(); } std::vector::const_iterator begin() const { return m_entries.cbegin(); } std::vector::const_iterator end() const { return m_entries.cend(); } diff --git a/include/amuse/Sequencer.hpp b/include/amuse/Sequencer.hpp index f935650..a035080 100644 --- a/include/amuse/Sequencer.hpp +++ b/include/amuse/Sequencer.hpp @@ -51,7 +51,7 @@ class Sequencer : public Entity { ~ChannelState(); ChannelState() = default; ChannelState(Sequencer& parent, uint8_t chanId); - operator bool() const { return m_parent != nullptr; } + explicit operator bool() const { return m_parent != nullptr; } /** Voices corresponding to currently-pressed keys in channel */ std::unordered_map> m_chanVoxs; diff --git a/include/amuse/SongState.hpp b/include/amuse/SongState.hpp index 92ffb3d..0775549 100644 --- a/include/amuse/SongState.hpp +++ b/include/amuse/SongState.hpp @@ -94,7 +94,7 @@ class SongState { Track() = default; Track(SongState& parent, uint8_t midiChan, uint32_t loopStart, const TrackRegion* regions, uint32_t tempo); - operator bool() const { return m_parent != nullptr; } + explicit operator bool() const { return m_parent != nullptr; } void setRegion(const TrackRegion* region); void advanceRegion(); bool advance(Sequencer& seq, double dt); diff --git a/include/amuse/SoundMacroState.hpp b/include/amuse/SoundMacroState.hpp index 1c968c7..a031ccb 100644 --- a/include/amuse/SoundMacroState.hpp +++ b/include/amuse/SoundMacroState.hpp @@ -78,7 +78,7 @@ struct SoundMacroState { float evaluate(double time, const Voice& vox, const SoundMacroState& st) const; /** Determine if able to use */ - operator bool() const { return m_comps.size() != 0; } + explicit operator bool() const { return m_comps.size() != 0; } }; Evaluator m_volumeSel; From 29e7d8bc1e980be3ae0240021b978ef090acd5d3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 7 Sep 2019 20:19:47 -0400 Subject: [PATCH 03/17] Emitter: Use std::array where applicable Makes the data more strongly-typed and prevents implicit array->pointer decay --- include/amuse/BooBackend.hpp | 3 ++- include/amuse/Emitter.hpp | 21 ++++++++++--------- include/amuse/IBackendVoice.hpp | 4 +++- include/amuse/Voice.hpp | 9 +++++---- lib/BooBackend.cpp | 6 +++--- lib/Emitter.cpp | 36 ++++++++++++++------------------- lib/Engine.cpp | 4 +++- lib/Listener.cpp | 18 ++++++++--------- lib/Voice.cpp | 20 ++++++++++-------- 9 files changed, 63 insertions(+), 58 deletions(-) diff --git a/include/amuse/BooBackend.hpp b/include/amuse/BooBackend.hpp index 6ceb3cf..2b09676 100644 --- a/include/amuse/BooBackend.hpp +++ b/include/amuse/BooBackend.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -39,7 +40,7 @@ public: void resetSampleRate(double sampleRate) override; void resetChannelLevels() override; - void setChannelLevels(IBackendSubmix* submix, const float coefs[8], bool slew) override; + void setChannelLevels(IBackendSubmix* submix, const std::array& coefs, bool slew) override; void setPitchRatio(double ratio, bool slew) override; void start() override; void stop() override; diff --git a/include/amuse/Emitter.hpp b/include/amuse/Emitter.hpp index 6499dc9..ac10e05 100644 --- a/include/amuse/Emitter.hpp +++ b/include/amuse/Emitter.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -10,9 +11,9 @@ namespace amuse { class Listener; -using Vector3f = float[3]; +using Vector3f = std::array; -inline float Dot(const Vector3f& a, const Vector3f& b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } +constexpr float Dot(const Vector3f& a, const Vector3f& b) { return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } inline float Length(const Vector3f& a) { if (std::fabs(a[0]) <= FLT_EPSILON && std::fabs(a[1]) <= FLT_EPSILON && std::fabs(a[2]) <= FLT_EPSILON) @@ -20,14 +21,14 @@ inline float Length(const Vector3f& a) { return std::sqrt(Dot(a, a)); } -inline float Normalize(Vector3f& out) { - float dist = Length(out); - if (dist == 0.f) - return 0.f; - out[0] /= dist; - out[1] /= dist; - out[2] /= dist; - return dist; +inline Vector3f Normalize(const Vector3f& in) { + const float dist = Length(in); + + if (dist == 0.f) { + return {}; + } + + return {in[0] / dist, in[1] / dist, in[2] / dist}; } /** Voice wrapper with positional-3D level control */ diff --git a/include/amuse/IBackendVoice.hpp b/include/amuse/IBackendVoice.hpp index 02df76c..a18c30b 100644 --- a/include/amuse/IBackendVoice.hpp +++ b/include/amuse/IBackendVoice.hpp @@ -1,5 +1,7 @@ #pragma once +#include + namespace amuse { class IBackendSubmix; @@ -34,7 +36,7 @@ public: virtual void resetChannelLevels() = 0; /** Set channel-gains for audio source (AudioChannel enum for array index) */ - virtual void setChannelLevels(IBackendSubmix* submix, const float coefs[8], bool slew) = 0; + virtual void setChannelLevels(IBackendSubmix* submix, const std::array& coefs, bool slew) = 0; /** Called by client to dynamically adjust the pitch of voices with dynamic pitch enabled */ virtual void setPitchRatio(double ratio, bool slew) = 0; diff --git a/include/amuse/Voice.hpp b/include/amuse/Voice.hpp index ebdfb27..f3b035e 100644 --- a/include/amuse/Voice.hpp +++ b/include/amuse/Voice.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -146,7 +147,7 @@ class Voice : public Entity { float m_tremoloScale = 0.f; /**< minimum volume factor produced via LFO */ float m_tremoloModScale = 0.f; /**< minimum volume factor produced via LFO, scaled via mod wheel */ - float m_lfoPeriods[2] = {}; /**< time-periods for LFO1 and LFO2 */ + std::array m_lfoPeriods{}; /**< time-periods for LFO1 and LFO2 */ std::unique_ptr m_ctrlValsSelf; /**< Self-owned MIDI Controller values */ int8_t* m_extCtrlVals = nullptr; /**< MIDI Controller values (external storage) */ @@ -186,10 +187,10 @@ class Voice : public Entity { ObjToken _startChildMacro(ObjectId macroId, int macroStep, double ticksPerSec, uint8_t midiKey, uint8_t midiVel, uint8_t midiMod, bool pushPc = false); - void _panLaw(float coefsOut[8], float frontPan, float backPan, float totalSpan) const; + std::array _panLaw(float frontPan, float backPan, float totalSpan) const; void _setPan(float pan); void _setSurroundPan(float span); - void _setChannelCoefs(const float coefs[8]); + void _setChannelCoefs(const std::array& coefs); void _setPitchWheel(float pitchWheel); void _notifyCtrlChange(uint8_t ctrl, int8_t val); @@ -261,7 +262,7 @@ public: void setSurroundPan(float span); /** Set current voice channel coefficients immediately */ - void setChannelCoefs(const float coefs[8]); + void setChannelCoefs(const std::array& coefs); /** Start volume envelope to specified level */ void startEnvelope(double dur, float vol, const Curve* envCurve); diff --git a/lib/BooBackend.cpp b/lib/BooBackend.cpp index 54e5132..14e3833 100644 --- a/lib/BooBackend.cpp +++ b/lib/BooBackend.cpp @@ -36,9 +36,9 @@ void BooBackendVoice::resetSampleRate(double sampleRate) { m_booVoice->resetSamp void BooBackendVoice::resetChannelLevels() { m_booVoice->resetChannelLevels(); } -void BooBackendVoice::setChannelLevels(IBackendSubmix* submix, const float coefs[8], bool slew) { - BooBackendSubmix& smx = *reinterpret_cast(submix); - m_booVoice->setMonoChannelLevels(smx.m_booSubmix.get(), coefs, slew); +void BooBackendVoice::setChannelLevels(IBackendSubmix* submix, const std::array& coefs, bool slew) { + auto& smx = *static_cast(submix); + m_booVoice->setMonoChannelLevels(smx.m_booSubmix.get(), coefs.data(), slew); } void BooBackendVoice::setPitchRatio(double ratio, bool slew) { m_booVoice->setPitchRatio(ratio, slew); } diff --git a/lib/Emitter.cpp b/lib/Emitter.cpp index f189d7c..a07fff8 100644 --- a/lib/Emitter.cpp +++ b/lib/Emitter.cpp @@ -5,14 +5,11 @@ #include "amuse/Voice.hpp" namespace amuse { - -static void Delta(Vector3f& out, const Vector3f& a, const Vector3f& b) { - out[0] = a[0] - b[0]; - out[1] = a[1] - b[1]; - out[2] = a[2] - b[2]; +static constexpr Vector3f Delta(const Vector3f& a, const Vector3f& b) { + return {a[0] - b[0], a[1] - b[1], a[2] - b[2]}; } -Emitter::~Emitter() {} +Emitter::~Emitter() = default; Emitter::Emitter(Engine& engine, const AudioGroup& group, ObjToken vox, float maxDist, float minVol, float falloff, bool doppler) @@ -54,12 +51,11 @@ void Emitter::_update() { return; } - float coefs[8] = {}; + std::array coefs{}; double avgDopplerRatio = 0.0; for (auto& listener : m_engine.m_activeListeners) { - Vector3f listenerToEmitter; - Delta(listenerToEmitter, m_pos, listener->m_pos); + const Vector3f listenerToEmitter = Delta(m_pos, listener->m_pos); const float dist = Length(listenerToEmitter); const float panDist = Dot(listenerToEmitter, listener->m_right); const float frontPan = std::clamp(panDist / listener->m_frontDiff, -1.f, 1.f); @@ -74,27 +70,25 @@ void Emitter::_update() { att = m_attCache.getVolume(att, false); if (att > FLT_EPSILON) { /* Apply pan law */ - float thisCoefs[8] = {}; - m_vox->_panLaw(thisCoefs, frontPan, backPan, span); + const std::array thisCoefs = m_vox->_panLaw(frontPan, backPan, span); /* Take maximum coefficient across listeners */ - for (int i = 0; i < 8; ++i) + for (size_t i = 0; i < coefs.size(); ++i) { coefs[i] = std::max(coefs[i], thisCoefs[i] * att * listener->m_volume); + } } /* Calculate doppler */ if (m_doppler) { /* Positive values indicate emitter and listener closing in */ - Vector3f dirDelta; - Delta(dirDelta, m_dir, listener->m_dir); - Vector3f posDelta; - Delta(posDelta, listener->m_pos, m_pos); - Normalize(posDelta); - float deltaSpeed = Dot(dirDelta, posDelta); - if (listener->m_soundSpeed != 0.f) + const Vector3f dirDelta = Delta(m_dir, listener->m_dir); + const Vector3f posDelta = Normalize(Delta(listener->m_pos, m_pos)); + const float deltaSpeed = Dot(dirDelta, posDelta); + if (listener->m_soundSpeed != 0.f) { avgDopplerRatio += 1.0 + deltaSpeed / listener->m_soundSpeed; - else + } else { avgDopplerRatio += 1.0; + } } } @@ -110,7 +104,7 @@ void Emitter::_update() { } void Emitter::setVectors(const float* pos, const float* dir) { - for (int i = 0; i < 3; ++i) { + for (size_t i = 0; i < m_pos.size(); ++i) { m_pos[i] = pos[i]; m_dir[i] = dir[i]; } diff --git a/lib/Engine.cpp b/lib/Engine.cpp index 5828454..1165f61 100644 --- a/lib/Engine.cpp +++ b/lib/Engine.cpp @@ -1,5 +1,7 @@ #include "amuse/Engine.hpp" +#include + #include "amuse/AudioGroup.hpp" #include "amuse/AudioGroupData.hpp" #include "amuse/Common.hpp" @@ -11,7 +13,7 @@ namespace amuse { -static const float FullLevels[8] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; +constexpr std::array FullLevels{1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f}; Engine::~Engine() { m_backend.setCallbackInterface(nullptr); diff --git a/lib/Listener.cpp b/lib/Listener.cpp index 7507f5a..c948837 100644 --- a/lib/Listener.cpp +++ b/lib/Listener.cpp @@ -2,10 +2,12 @@ namespace amuse { -static void Cross(Vector3f& out, const Vector3f& a, const Vector3f& b) { - out[0] = a[1] * b[2] - a[2] * b[1]; - out[1] = a[2] * b[0] - a[0] * b[2]; - out[2] = a[0] * b[1] - a[1] * b[0]; +static constexpr Vector3f Cross(const Vector3f& a, const Vector3f& b) { + return { + a[1] * b[2] - a[2] * b[1], + a[2] * b[0] - a[0] * b[2], + a[0] * b[1] - a[1] * b[0], + }; } void Listener::setVectors(const float* pos, const float* dir, const float* heading, const float* up) { @@ -16,11 +18,9 @@ void Listener::setVectors(const float* pos, const float* dir, const float* headi m_up[i] = up[i]; } - Normalize(m_heading); - Normalize(m_up); - Cross(m_right, m_heading, m_up); - Normalize(m_right); - + m_heading = Normalize(m_heading); + m_up = Normalize(m_up); + m_right = Normalize(Cross(m_heading, m_up)); m_dirty = true; } diff --git a/lib/Voice.cpp b/lib/Voice.cpp index 2a80088..6e2febc 100644 --- a/lib/Voice.cpp +++ b/lib/Voice.cpp @@ -155,10 +155,11 @@ ObjToken Voice::_findVoice(int vid, ObjToken thisPtr) { } std::unique_ptr& Voice::_ensureCtrlVals() { - if (m_ctrlValsSelf) + if (m_ctrlValsSelf) { return m_ctrlValsSelf; - m_ctrlValsSelf.reset(new int8_t[128]); - memset(m_ctrlValsSelf.get(), 0, 128); + } + + m_ctrlValsSelf = std::make_unique(128); return m_ctrlValsSelf; } @@ -902,7 +903,9 @@ void Voice::setVolume(float vol) { vox->setVolume(vol); } -void Voice::_panLaw(float coefs[8], float frontPan, float backPan, float totalSpan) const { +std::array Voice::_panLaw(float frontPan, float backPan, float totalSpan) const { + std::array coefs{}; + /* -3dB panning law for various channel configs */ switch (m_engine.m_channelSet) { case AudioChannelSet::Stereo: @@ -1010,6 +1013,8 @@ void Voice::_panLaw(float coefs[8], float frontPan, float backPan, float totalSp break; } + + return coefs; } void Voice::_setPan(float pan) { @@ -1020,8 +1025,7 @@ void Voice::_setPan(float pan) { m_curPan = std::clamp(pan, -1.f, 1.f); const float totalPan = std::clamp(m_curPan, -1.f, 1.f); const float totalSpan = std::clamp(m_curSpan, -1.f, 1.f); - float coefs[8] = {}; - _panLaw(coefs, totalPan, totalPan, totalSpan); + const auto coefs = _panLaw(totalPan, totalPan, totalSpan); _setChannelCoefs(coefs); } @@ -1048,13 +1052,13 @@ void Voice::setSurroundPan(float span) { vox->setSurroundPan(span); } -void Voice::_setChannelCoefs(const float coefs[8]) { +void Voice::_setChannelCoefs(const std::array& coefs) { m_backendVoice->setChannelLevels(m_studio->getMaster().m_backendSubmix.get(), coefs, true); m_backendVoice->setChannelLevels(m_studio->getAuxA().m_backendSubmix.get(), coefs, true); m_backendVoice->setChannelLevels(m_studio->getAuxB().m_backendSubmix.get(), coefs, true); } -void Voice::setChannelCoefs(const float coefs[8]) { +void Voice::setChannelCoefs(const std::array& coefs) { if (m_destroyed) return; From d10a0ac7f1ea64099ab6ca6d49a1cdc3fe4b45f6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 8 Sep 2019 16:52:55 -0400 Subject: [PATCH 04/17] General: Be explicit about athena's SeekOrigin type Allows the code to still compile if the enum is turned into an enum class. --- include/amuse/AudioGroupPool.hpp | 8 +- include/amuse/AudioGroupProject.hpp | 8 +- include/amuse/AudioGroupSampleDirectory.hpp | 10 +- lib/AudioGroupPool.cpp | 36 +-- lib/AudioGroupProject.cpp | 233 +++++++++++--------- lib/AudioGroupSampleDirectory.cpp | 22 +- 6 files changed, 170 insertions(+), 147 deletions(-) diff --git a/include/amuse/AudioGroupPool.hpp b/include/amuse/AudioGroupPool.hpp index aae27a9..20bd954 100644 --- a/include/amuse/AudioGroupPool.hpp +++ b/include/amuse/AudioGroupPool.hpp @@ -36,7 +36,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) ObjectHe AT_DECL_DNA Value size; ObjectIdDNA objectId; - Seek<2, athena::Current> pad; + Seek<2, athena::SeekOrigin::Current> pad; }; struct SoundMacro { @@ -908,7 +908,7 @@ struct SoundMacro { static const CmdIntrospection Introspective; Value varCtrlA; Value a; - Seek<1, athena::Current> pad; + Seek<1, athena::SeekOrigin::Current> pad; Value imm; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::SetVar; } @@ -1100,7 +1100,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) KeymapDN Value transpose; Value pan; /* -128 for surround-channel only */ Value prioOffset; - Seek<3, athena::Current> pad; + Seek<3, athena::SeekOrigin::Current> pad; }; struct Keymap : BigDNA { AT_DECL_DNA_YAML @@ -1142,7 +1142,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) LayerMap Value prioOffset; Value span; Value pan; - Seek<3, athena::Current> pad; + Seek<3, athena::SeekOrigin::Current> pad; }; struct LayerMapping : BigDNA { AT_DECL_DNA_YAML diff --git a/include/amuse/AudioGroupProject.hpp b/include/amuse/AudioGroupProject.hpp index 4594c26..b3c92e1 100644 --- a/include/amuse/AudioGroupProject.hpp +++ b/include/amuse/AudioGroupProject.hpp @@ -46,7 +46,7 @@ struct SongGroupIndex : AudioGroupIndex { Value priority; Value maxVoices; Value programNo; - Seek<1, athena::Current> pad; + Seek<1, athena::SeekOrigin::Current> pad; }; template struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) MusyX1PageEntryDNA : BigDNA { @@ -56,7 +56,7 @@ struct SongGroupIndex : AudioGroupIndex { Value maxVoices; Value unk; Value programNo; - Seek<2, athena::Current> pad; + Seek<2, athena::SeekOrigin::Current> pad; }; struct PageEntry : BigDNA { AT_DECL_DNA_YAML @@ -94,7 +94,7 @@ struct SongGroupIndex : AudioGroupIndex { Value panning; Value reverb; Value chorus; - Seek<3, athena::Current> pad; + Seek<3, athena::SeekOrigin::Current> pad; }; struct MIDISetup : BigDNA { AT_DECL_DNA_YAML @@ -130,7 +130,7 @@ struct SFXGroupIndex : AudioGroupIndex { Value defVel; Value panning; Value defKey; - Seek<1, athena::Current> pad; + Seek<1, athena::SeekOrigin::Current> pad; }; struct SFXEntry : BigDNA { AT_DECL_DNA_YAML diff --git a/include/amuse/AudioGroupSampleDirectory.hpp b/include/amuse/AudioGroupSampleDirectory.hpp index a849e55..7900e2d 100644 --- a/include/amuse/AudioGroupSampleDirectory.hpp +++ b/include/amuse/AudioGroupSampleDirectory.hpp @@ -31,7 +31,7 @@ struct DSPADPCMHeader : BigDNA { Value x46_loop_hist1 = 0; Value x48_loop_hist2 = 0; Value m_pitch = 0; // Stash this in the padding - Seek<21, athena::Current> pad; + Seek<21, athena::SeekOrigin::Current> pad; }; struct VADPCMHeader : BigDNA { @@ -156,11 +156,11 @@ public: struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) EntryDNA : BigDNA { AT_DECL_DNA SampleIdDNA m_sfxId; - Seek<2, athena::Current> pad; + Seek<2, athena::SeekOrigin::Current> pad; Value m_sampleOff; Value m_unk; Value m_pitch; - Seek<1, athena::Current> pad2; + Seek<1, athena::SeekOrigin::Current> pad2; Value m_sampleRate; Value m_numSamples; // Top 8 bits is SampleFormat Value m_loopStartSample; @@ -177,7 +177,7 @@ public: struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) MusyX1SdirEntry : BigDNA { AT_DECL_DNA SampleIdDNA m_sfxId; - Seek<2, athena::Current> pad; + Seek<2, athena::SeekOrigin::Current> pad; Value m_sampleOff; Value m_pitchSampleRate; Value m_numSamples; @@ -188,7 +188,7 @@ public: struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) MusyX1AbsSdirEntry : BigDNA { AT_DECL_DNA SampleIdDNA m_sfxId; - Seek<2, athena::Current> pad; + Seek<2, athena::SeekOrigin::Current> pad; Value m_sampleOff; Value m_unk; Value m_pitchSampleRate; diff --git a/lib/AudioGroupPool.cpp b/lib/AudioGroupPool.cpp index 7e5f4dc..574a523 100644 --- a/lib/AudioGroupPool.cpp +++ b/lib/AudioGroupPool.cpp @@ -88,7 +88,7 @@ struct IntrospectCmdOp { static bool AtEnd(athena::io::IStreamReader& r) { uint32_t v = r.readUint32Big(); - r.seek(-4, athena::Current); + r.seek(-4, athena::SeekOrigin::Current); return v == 0xffffffff; } @@ -100,7 +100,7 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { head.read(r); if (head.soundMacrosOffset) { - r.seek(head.soundMacrosOffset, athena::Begin); + r.seek(head.soundMacrosOffset, athena::SeekOrigin::Begin); while (!AtEnd(r)) { ObjectHeader objHead; atInt64 startPos = r.position(); @@ -111,12 +111,12 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { auto& macro = ret.m_soundMacros[objHead.objectId.id]; macro = MakeObj(); macro->template readCmds(r, objHead.size - 8); - r.seek(startPos + objHead.size, athena::Begin); + r.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } } if (head.tablesOffset) { - r.seek(head.tablesOffset, athena::Begin); + r.seek(head.tablesOffset, athena::SeekOrigin::Begin); while (!AtEnd(r)) { ObjectHeader objHead; atInt64 startPos = r.position(); @@ -139,12 +139,12 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { r.readUBytesToBuf(&static_cast(**ptr).data[0], objHead.size - 8); break; } - r.seek(startPos + objHead.size, athena::Begin); + r.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } } if (head.keymapsOffset) { - r.seek(head.keymapsOffset, athena::Begin); + r.seek(head.keymapsOffset, athena::SeekOrigin::Begin); while (!AtEnd(r)) { ObjectHeader objHead; atInt64 startPos = r.position(); @@ -159,12 +159,12 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { kmData.read(r); (*km)[i] = kmData; } - r.seek(startPos + objHead.size, athena::Begin); + r.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } } if (head.layersOffset) { - r.seek(head.layersOffset, athena::Begin); + r.seek(head.layersOffset, athena::SeekOrigin::Begin); while (!AtEnd(r)) { ObjectHeader objHead; atInt64 startPos = r.position(); @@ -182,7 +182,7 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { lmData.read(r); lm->push_back(lmData); } - r.seek(startPos + objHead.size, athena::Begin); + r.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } } @@ -1019,9 +1019,9 @@ std::vector AudioGroupPool::toData() const { p.second->template writeCmds(fo); objHead.size = fo.position() - startPos; objHead.objectId = p.first; - fo.seek(startPos, athena::Begin); + fo.seek(startPos, athena::SeekOrigin::Begin); objHead.write(fo); - fo.seek(startPos + objHead.size, athena::Begin); + fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } athena::io::Write::Do({}, term, fo); } @@ -1049,9 +1049,9 @@ std::vector AudioGroupPool::toData() const { } objHead.size = fo.position() - startPos; objHead.objectId = p.first; - fo.seek(startPos, athena::Begin); + fo.seek(startPos, athena::SeekOrigin::Begin); objHead.write(fo); - fo.seek(startPos + objHead.size, athena::Begin); + fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } athena::io::Write::Do({}, term, fo); } @@ -1068,9 +1068,9 @@ std::vector AudioGroupPool::toData() const { } objHead.size = fo.position() - startPos; objHead.objectId = p.first; - fo.seek(startPos, athena::Begin); + fo.seek(startPos, athena::SeekOrigin::Begin); objHead.write(fo); - fo.seek(startPos + objHead.size, athena::Begin); + fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } athena::io::Write::Do({}, term, fo); } @@ -1089,14 +1089,14 @@ std::vector AudioGroupPool::toData() const { } objHead.size = fo.position() - startPos; objHead.objectId = p.first; - fo.seek(startPos, athena::Begin); + fo.seek(startPos, athena::SeekOrigin::Begin); objHead.write(fo); - fo.seek(startPos + objHead.size, athena::Begin); + fo.seek(startPos + objHead.size, athena::SeekOrigin::Begin); } athena::io::Write::Do({}, term, fo); } - fo.seek(0, athena::Begin); + fo.seek(0, athena::SeekOrigin::Begin); head.write(fo); return fo.data(); diff --git a/lib/AudioGroupProject.cpp b/lib/AudioGroupProject.cpp index e7a28a2..21fd65f 100644 --- a/lib/AudioGroupProject.cpp +++ b/lib/AudioGroupProject.cpp @@ -13,19 +13,19 @@ namespace amuse { static bool AtEnd64(athena::io::IStreamReader& r) { uint64_t v = r.readUint64Big(); - r.seek(-8, athena::Current); + r.seek(-8, athena::SeekOrigin::Current); return v == 0xffffffffffffffff; } static bool AtEnd32(athena::io::IStreamReader& r) { uint32_t v = r.readUint32Big(); - r.seek(-4, athena::Current); + r.seek(-4, athena::SeekOrigin::Current); return v == 0xffffffff; } static bool AtEnd16(athena::io::IStreamReader& r) { uint16_t v = r.readUint16Big(); - r.seek(-2, athena::Current); + r.seek(-2, athena::SeekOrigin::Current); return v == 0xffff; } @@ -89,30 +89,35 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId); #if 0 - /* Sound Macros */ - r.seek(header.soundMacroIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + /* Sound Macros */ + r.seek(header.soundMacroIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + } - /* Samples */ - r.seek(header.samplIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + /* Samples */ + r.seek(header.samplIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + } - /* Tables */ - r.seek(header.tableIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + /* Tables */ + r.seek(header.tableIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + } - /* Keymaps */ - r.seek(header.keymapIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + /* Keymaps */ + r.seek(header.keymapIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + } - /* Layers */ - r.seek(header.layerIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + /* Layers */ + r.seek(header.layerIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + } #endif if (header.type == GroupType::Song) { @@ -120,7 +125,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { idx = MakeObj(); /* Normal pages */ - r.seek(header.pageTableOff, athena::Begin); + r.seek(header.pageTableOff, athena::SeekOrigin::Begin); while (!AtEnd64(r)) { SongGroupIndex::PageEntryDNA entry; entry.read(r); @@ -128,7 +133,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { } /* Drum pages */ - r.seek(header.drumTableOff, athena::Begin); + r.seek(header.drumTableOff, athena::SeekOrigin::Begin); while (!AtEnd64(r)) { SongGroupIndex::PageEntryDNA entry; entry.read(r); @@ -136,24 +141,26 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { } /* MIDI setups */ - r.seek(header.midiSetupsOff, athena::Begin); + r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin); while (r.position() < header.groupEndOff) { uint16_t songId = r.readUint16Big(); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); std::array& setup = idx->m_midiSetups[songId]; - for (int i = 0; i < 16; ++i) + for (int i = 0; i < 16; ++i) { setup[i].read(r); - if (SongId::CurNameDB) + } + if (SongId::CurNameDB) { SongId::CurNameDB->registerPair(NameDB::generateName(songId, NameDB::Type::Song), songId); + } } } else if (header.type == GroupType::SFX) { auto& idx = m_sfxGroups[header.groupId]; idx = MakeObj(); /* SFX entries */ - r.seek(header.pageTableOff, athena::Begin); + r.seek(header.pageTableOff, athena::SeekOrigin::Begin); uint16_t count = r.readUint16Big(); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); idx->m_sfxEntries.reserve(count); for (int i = 0; i < count; ++i) { SFXGroupIndex::SFXEntryDNA entry; @@ -164,7 +171,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { } } - r.seek(header.groupEndOff, athena::Begin); + r.seek(header.groupEndOff, athena::SeekOrigin::Begin); } } @@ -181,30 +188,35 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId); #if 0 - /* Sound Macros */ - r.seek(subDataOff + header.soundMacroIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + /* Sound Macros */ + r.seek(subDataOff + header.soundMacroIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + } - /* Samples */ - r.seek(subDataOff + header.samplIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + /* Samples */ + r.seek(subDataOff + header.samplIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + } - /* Tables */ - r.seek(subDataOff + header.tableIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + /* Tables */ + r.seek(subDataOff + header.tableIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + } - /* Keymaps */ - r.seek(subDataOff + header.keymapIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + /* Keymaps */ + r.seek(subDataOff + header.keymapIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + } - /* Layers */ - r.seek(subDataOff + header.layerIdsOff, athena::Begin); - while (!AtEnd16(r)) - ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + /* Layers */ + r.seek(subDataOff + header.layerIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { + ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + } #endif if (header.type == GroupType::Song) { @@ -213,7 +225,7 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade if (absOffs) { /* Normal pages */ - r.seek(header.pageTableOff, athena::Begin); + r.seek(header.pageTableOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { SongGroupIndex::PageEntryDNA entry; entry.read(r); @@ -221,7 +233,7 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade } /* Drum pages */ - r.seek(header.drumTableOff, athena::Begin); + r.seek(header.drumTableOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { SongGroupIndex::PageEntryDNA entry; entry.read(r); @@ -229,19 +241,20 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade } /* MIDI setups */ - r.seek(header.midiSetupsOff, athena::Begin); + r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin); while (r.position() < header.groupEndOff) { uint16_t songId; athena::io::Read::Do({}, songId, r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); std::array& setup = idx->m_midiSetups[songId]; - for (int i = 0; i < 16; ++i) + for (int i = 0; i < 16; ++i) { setup[i].read(r); + } SongId::CurNameDB->registerPair(NameDB::generateName(songId, NameDB::Type::Song), songId); } } else { /* Normal pages */ - r.seek(subDataOff + header.pageTableOff, athena::Begin); + r.seek(subDataOff + header.pageTableOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { SongGroupIndex::MusyX1PageEntryDNA entry; entry.read(r); @@ -249,7 +262,7 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade } /* Drum pages */ - r.seek(subDataOff + header.drumTableOff, athena::Begin); + r.seek(subDataOff + header.drumTableOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { SongGroupIndex::MusyX1PageEntryDNA entry; entry.read(r); @@ -257,11 +270,11 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade } /* MIDI setups */ - r.seek(subDataOff + header.midiSetupsOff, athena::Begin); + r.seek(subDataOff + header.midiSetupsOff, athena::SeekOrigin::Begin); while (atInt64(r.position() + 4) < groupBegin + header.groupEndOff) { uint16_t songId; athena::io::Read::Do({}, songId, r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); std::array& setup = idx->m_midiSetups[songId]; for (int i = 0; i < 16; ++i) { SongGroupIndex::MusyX1MIDISetup ent; @@ -276,24 +289,24 @@ AudioGroupProject AudioGroupProject::_AudioGroupProject(athena::io::IStreamReade idx = MakeObj(); /* SFX entries */ - r.seek(subDataOff + header.pageTableOff, athena::Begin); + r.seek(subDataOff + header.pageTableOff, athena::SeekOrigin::Begin); uint16_t count; athena::io::Read::Do({}, count, r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); idx->m_sfxEntries.reserve(count); for (int i = 0; i < count; ++i) { SFXGroupIndex::SFXEntryDNA entry; entry.read(r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); idx->m_sfxEntries[entry.sfxId.id] = entry; SFXId::CurNameDB->registerPair(NameDB::generateName(entry.sfxId.id, NameDB::Type::SFX), entry.sfxId.id); } } if (absOffs) - r.seek(header.groupEndOff, athena::Begin); + r.seek(header.groupEndOff, athena::SeekOrigin::Begin); else - r.seek(groupBegin + header.groupEndOff, athena::Begin); + r.seek(groupBegin + header.groupEndOff, athena::SeekOrigin::Begin); } return ret; @@ -452,43 +465,47 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, GCNData GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId); /* Sound Macros */ - r.seek(header.soundMacroIdsOff, athena::Begin); + r.seek(header.soundMacroIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); /* Samples */ - r.seek(header.samplIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(header.samplIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + } /* Tables */ - r.seek(header.tableIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(header.tableIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + } /* Keymaps */ - r.seek(header.keymapIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(header.keymapIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + } /* Layers */ - r.seek(header.layerIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(header.layerIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + } if (header.type == GroupType::Song) { /* MIDI setups */ - r.seek(header.midiSetupsOff, athena::Begin); + r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin); while (r.position() < header.groupEndOff) { uint16_t id = r.readUint16Big(); SongId::CurNameDB->registerPair(NameDB::generateName(id, NameDB::Type::Song), id); - r.seek(2 + 5 * 16, athena::Current); + r.seek(2 + 5 * 16, athena::SeekOrigin::Current); } } else if (header.type == GroupType::SFX) { /* SFX entries */ - r.seek(header.pageTableOff, athena::Begin); + r.seek(header.pageTableOff, athena::SeekOrigin::Begin); uint16_t count = r.readUint16Big(); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); for (int i = 0; i < count; ++i) { SFXGroupIndex::SFXEntryDNA entry; entry.read(r); @@ -496,7 +513,7 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, GCNData } } - r.seek(header.groupEndOff, athena::Begin); + r.seek(header.groupEndOff, athena::SeekOrigin::Begin); } } @@ -511,67 +528,73 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, bool ab GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId); /* Sound Macros */ - r.seek(subDataOff + header.soundMacroIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(subDataOff + header.soundMacroIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + } /* Samples */ - r.seek(subDataOff + header.samplIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(subDataOff + header.samplIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + } /* Tables */ - r.seek(subDataOff + header.tableIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(subDataOff + header.tableIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + } /* Keymaps */ - r.seek(subDataOff + header.keymapIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(subDataOff + header.keymapIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + } /* Layers */ - r.seek(subDataOff + header.layerIdsOff, athena::Begin); - while (!AtEnd16(r)) + r.seek(subDataOff + header.layerIdsOff, athena::SeekOrigin::Begin); + while (!AtEnd16(r)) { ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + } if (header.type == GroupType::Song) { /* MIDI setups */ if (absOffs) { - r.seek(header.midiSetupsOff, athena::Begin); + r.seek(header.midiSetupsOff, athena::SeekOrigin::Begin); while (r.position() < header.groupEndOff) { uint16_t id; athena::io::Read::Do({}, id, r); SongId::CurNameDB->registerPair(NameDB::generateName(id, NameDB::Type::Song), id); - r.seek(2 + 5 * 16, athena::Current); + r.seek(2 + 5 * 16, athena::SeekOrigin::Current); } } else { - r.seek(subDataOff + header.midiSetupsOff, athena::Begin); + r.seek(subDataOff + header.midiSetupsOff, athena::SeekOrigin::Begin); while (atInt64(r.position()) < groupBegin + header.groupEndOff) { uint16_t id; athena::io::Read::Do({}, id, r); SongId::CurNameDB->registerPair(NameDB::generateName(id, NameDB::Type::Song), id); - r.seek(2 + 8 * 16, athena::Current); + r.seek(2 + 8 * 16, athena::SeekOrigin::Current); } } } else if (header.type == GroupType::SFX) { /* SFX entries */ - r.seek(subDataOff + header.pageTableOff, athena::Begin); + r.seek(subDataOff + header.pageTableOff, athena::SeekOrigin::Begin); uint16_t count; athena::io::Read::Do({}, count, r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); for (int i = 0; i < count; ++i) { SFXGroupIndex::SFXEntryDNA entry; entry.read(r); - r.seek(2, athena::Current); + r.seek(2, athena::SeekOrigin::Current); SFXId::CurNameDB->registerPair(NameDB::generateName(entry.sfxId.id, NameDB::Type::SFX), entry.sfxId.id); } } - if (absOffs) - r.seek(header.groupEndOff, athena::Begin); - else - r.seek(groupBegin + header.groupEndOff, athena::Begin); + if (absOffs) { + r.seek(header.groupEndOff, athena::SeekOrigin::Begin); + } else { + r.seek(groupBegin + header.groupEndOff, athena::SeekOrigin::Begin); + } } } @@ -861,9 +884,9 @@ std::vector AudioGroupProject::toGCNData(const AudioGroupPool& pool, } header.groupEndOff = fo.position(); - fo.seek(groupStart, athena::Begin); + fo.seek(groupStart, athena::SeekOrigin::Begin); header.write(fo); - fo.seek(header.groupEndOff, athena::Begin); + fo.seek(header.groupEndOff, athena::SeekOrigin::Begin); } else { auto search2 = m_sfxGroups.find(id); if (search2 != m_sfxGroups.end()) { @@ -897,9 +920,9 @@ std::vector AudioGroupProject::toGCNData(const AudioGroupPool& pool, } header.groupEndOff = fo.position(); - fo.seek(groupStart, athena::Begin); + fo.seek(groupStart, athena::SeekOrigin::Begin); header.write(fo); - fo.seek(header.groupEndOff, athena::Begin); + fo.seek(header.groupEndOff, athena::SeekOrigin::Begin); } } } diff --git a/lib/AudioGroupSampleDirectory.cpp b/lib/AudioGroupSampleDirectory.cpp index 099833d..6f904a3 100644 --- a/lib/AudioGroupSampleDirectory.cpp +++ b/lib/AudioGroupSampleDirectory.cpp @@ -24,7 +24,7 @@ namespace amuse { static bool AtEnd32(athena::io::IStreamReader& r) { uint32_t v = r.readUint32Big(); - r.seek(-4, athena::Current); + r.seek(-4, athena::SeekOrigin::Current); return v == 0xffffffff; } @@ -55,7 +55,7 @@ AudioGroupSampleDirectory::AudioGroupSampleDirectory(athena::io::IStreamReader& for (auto& p : m_entries) { if (p.second->m_data->m_adpcmParmOffset) { - r.seek(p.second->m_data->m_adpcmParmOffset, athena::Begin); + r.seek(p.second->m_data->m_adpcmParmOffset, athena::SeekOrigin::Begin); r.readUBytesToBuf(&p.second->m_data->m_ADPCMParms, sizeof(ADPCMParms::DSPParms)); p.second->m_data->m_ADPCMParms.swapBigDSP(); } @@ -237,7 +237,7 @@ void AudioGroupSampleDirectory::EntryData::loadLooseWAV(SystemStringView wavPath m_looseData.reset(new uint8_t[chunkSize]); r.readUBytesToBuf(m_looseData.get(), chunkSize); } - r.seek(startPos + chunkSize, athena::Begin); + r.seek(startPos + chunkSize, athena::SeekOrigin::Begin); } } } @@ -388,7 +388,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataDSP(SystemStringView dsp athena::io::FileWriter w(dspPath, false); if (!w.hasError()) { - w.seek(0, athena::Begin); + w.seek(0, athena::SeekOrigin::Begin); head.write(w); } } @@ -397,7 +397,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataDSP(SystemStringView dsp void AudioGroupSampleDirectory::EntryData::patchMetadataVADPCM(SystemStringView vadpcmPath) { athena::io::FileWriter w(vadpcmPath, false); if (!w.hasError()) { - w.seek(0, athena::Begin); + w.seek(0, athena::SeekOrigin::Begin); VADPCMHeader header; header.m_pitchSampleRate = m_pitch << 24; header.m_pitchSampleRate |= m_sampleRate & 0xffff; @@ -434,12 +434,12 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav loopOffset = startPos + 36; ++readSec; } - r.seek(startPos + chunkSize, athena::Begin); + r.seek(startPos + chunkSize, athena::SeekOrigin::Begin); } if (smplOffset == -1 || loopOffset == -1) { /* Complete rewrite of RIFF layout - new smpl chunk */ - r.seek(12, athena::Begin); + r.seek(12, athena::SeekOrigin::Begin); athena::io::FileWriter w(wavPath); if (!w.hasError()) { w.writeUint32Little(SBIG('RIFF')); @@ -470,7 +470,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav loop.end = getLoopEndSample(); loop.write(w); if (chunkMagic == SBIG('smpl')) { - r.seek(chunkSize, athena::Current); + r.seek(chunkSize, athena::SeekOrigin::Current); continue; } } @@ -480,7 +480,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav } atUint64 wavLen = w.position(); - w.seek(4, athena::Begin); + w.seek(4, athena::SeekOrigin::Begin); w.writeUint32Little(wavLen - 8); } r.close(); @@ -489,7 +489,7 @@ void AudioGroupSampleDirectory::EntryData::patchMetadataWAV(SystemStringView wav r.close(); athena::io::FileWriter w(wavPath, false); if (!w.hasError()) { - w.seek(smplOffset, athena::Begin); + w.seek(smplOffset, athena::SeekOrigin::Begin); WAVSampleChunk smpl; smpl.smplPeriod = 1000000000 / fmt.sampleRate; smpl.midiNote = m_pitch; @@ -810,7 +810,7 @@ void AudioGroupSampleDirectory::_extractCompressed(SampleId id, const EntryData& samps += sampleCount; } - w.seek(0, athena::Begin); + w.seek(0, athena::SeekOrigin::Begin); header.write(w); } else { return; From b6f0201fbb018e1fb01c513abbc49a4ae1fb86af Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 8 Sep 2019 17:02:36 -0400 Subject: [PATCH 05/17] General: Be explicit about athena's Endian type Allows this code to still compile if the enum is ever changed into an enum class. --- Editor/ProjectModel.cpp | 16 ++++--- Editor/SoundMacroEditor.cpp | 13 +++--- include/amuse/AudioGroupPool.hpp | 56 +++++++++++----------- include/amuse/AudioGroupProject.hpp | 4 +- include/amuse/Common.hpp | 8 ++-- lib/AudioGroupPool.cpp | 22 ++++----- lib/AudioGroupProject.cpp | 42 ++++++++--------- lib/AudioGroupSampleDirectory.cpp | 12 ++--- lib/Common.cpp | 72 ++++++++++++++--------------- lib/SoundMacroState.cpp | 8 ++-- 10 files changed, 129 insertions(+), 124 deletions(-) diff --git a/Editor/ProjectModel.cpp b/Editor/ProjectModel.cpp index 8d0a733..804128e 100644 --- a/Editor/ProjectModel.cpp +++ b/Editor/ProjectModel.cpp @@ -67,18 +67,22 @@ static void VisitObjectFields(ProjectModel::SoundMacroNode* n, break; switch (field.m_tp) { case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroId: - if (!func(amuse::AccessField>(p.get(), field).id, - amuse::SoundMacroId::CurNameDB)) + if (!func(amuse::AccessField>(p.get(), field).id, + amuse::SoundMacroId::CurNameDB)) { return; + } break; case amuse::SoundMacro::CmdIntrospection::Field::Type::TableId: - if (!func(amuse::AccessField>(p.get(), field).id, amuse::TableId::CurNameDB)) + if (!func(amuse::AccessField>(p.get(), field).id, + amuse::TableId::CurNameDB)) { return; + } break; case amuse::SoundMacro::CmdIntrospection::Field::Type::SampleId: - if (!func(amuse::AccessField>(p.get(), field).id, - amuse::SampleId::CurNameDB)) + if (!func(amuse::AccessField>(p.get(), field).id, + amuse::SampleId::CurNameDB)) { return; + } break; default: break; @@ -720,7 +724,7 @@ bool ProjectModel::exportGroup(const QString& path, const QString& groupName, UI fo.writeUBytes(proj.data(), proj.size()); } { - auto pool = group.getPool().toData(); + auto pool = group.getPool().toData(); athena::io::FileWriter fo(QStringToSysString(basePath + QStringLiteral(".pool"))); if (fo.hasError()) { messenger.critical(tr("Export Error"), tr("Unable to export %1.pool").arg(groupName)); diff --git a/Editor/SoundMacroEditor.cpp b/Editor/SoundMacroEditor.cpp index d99f4fa..97c0e3f 100644 --- a/Editor/SoundMacroEditor.cpp +++ b/Editor/SoundMacroEditor.cpp @@ -219,8 +219,8 @@ CommandWidget::CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd, amus nf = new FieldProjectNode(collection, this); nf->setProperty("fieldIndex", f); nf->setProperty("fieldName", fieldName); - int index = - collection->indexOfId(amuse::AccessField>(m_cmd, field).id); + const int index = collection->indexOfId( + amuse::AccessField>(m_cmd, field).id); nf->setCurrentIndex(index < 0 ? 0 : index + 1); connect(nf, &FieldProjectNode::currentIndexChanged, this, &CommandWidget::nodeChanged); layout->addWidget(nf, 1, f); @@ -231,7 +231,8 @@ CommandWidget::CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd, amus sb->setFixedHeight(30); sb->setProperty("fieldIndex", f); sb->setProperty("fieldName", fieldName); - sb->m_spinBox.setValue(amuse::AccessField>(m_cmd, field).step); + sb->m_spinBox.setValue( + amuse::AccessField>(m_cmd, field).step); connect(sb, &FieldSoundMacroStep::valueChanged, this, &CommandWidget::numChanged); layout->addWidget(sb, 1, f); m_stepField = sb; @@ -315,7 +316,7 @@ public: case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroStep: case amuse::SoundMacro::CmdIntrospection::Field::Type::TableId: case amuse::SoundMacro::CmdIntrospection::Field::Type::SampleId: - amuse::AccessField>(m_cmd, m_field).id = uint16_t(m_undoVal); + amuse::AccessField>(m_cmd, m_field).id = uint16_t(m_undoVal); break; default: break; @@ -357,8 +358,8 @@ public: case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroStep: case amuse::SoundMacro::CmdIntrospection::Field::Type::TableId: case amuse::SoundMacro::CmdIntrospection::Field::Type::SampleId: - m_undoVal = amuse::AccessField>(m_cmd, m_field).id.id; - amuse::AccessField>(m_cmd, m_field).id = uint16_t(m_redoVal); + m_undoVal = amuse::AccessField>(m_cmd, m_field).id.id; + amuse::AccessField>(m_cmd, m_field).id = uint16_t(m_redoVal); break; default: break; diff --git a/include/amuse/AudioGroupPool.hpp b/include/amuse/AudioGroupPool.hpp index 20bd954..74374ba 100644 --- a/include/amuse/AudioGroupPool.hpp +++ b/include/amuse/AudioGroupPool.hpp @@ -180,8 +180,8 @@ struct SoundMacro { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; Value key; - SoundMacroIdDNA macro; - SoundMacroStepDNA macroStep; + SoundMacroIdDNA macro; + SoundMacroStepDNA macroStep; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::SplitKey; } }; @@ -189,8 +189,8 @@ struct SoundMacro { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; Value velocity; - SoundMacroIdDNA macro; - SoundMacroStepDNA macroStep; + SoundMacroIdDNA macro; + SoundMacroStepDNA macroStep; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::SplitVel; } }; @@ -212,7 +212,7 @@ struct SoundMacro { Value keyOff; Value random; Value sampleEnd; - SoundMacroStepDNA macroStep; + SoundMacroStepDNA macroStep; Value times; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::Loop; } @@ -221,8 +221,8 @@ struct SoundMacro { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; Seek<1, athena::SeekOrigin::Current> dummy; - SoundMacroIdDNA macro; - SoundMacroStepDNA macroStep; + SoundMacroIdDNA macro; + SoundMacroStepDNA macroStep; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::Goto; } }; @@ -242,8 +242,8 @@ struct SoundMacro { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; Value addNote; - SoundMacroIdDNA macro; - SoundMacroStepDNA macroStep; + SoundMacroIdDNA macro; + SoundMacroStepDNA macroStep; Value priority; Value maxVoices; bool Do(SoundMacroState& st, Voice& vox) const override; @@ -261,8 +261,8 @@ struct SoundMacro { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; Value modValue; - SoundMacroIdDNA macro; - SoundMacroStepDNA macroStep; + SoundMacroIdDNA macro; + SoundMacroStepDNA macroStep; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::SplitMod; } }; @@ -278,7 +278,7 @@ struct SoundMacro { struct CmdSetAdsr : ICmd { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; - TableIdDNA table; + TableIdDNA table; Value dlsMode; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::SetAdsr; } @@ -288,7 +288,7 @@ struct SoundMacro { static const CmdIntrospection Introspective; Value scale; Value add; - TableIdDNA table; + TableIdDNA table; Value originalVol; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::ScaleVolume; } @@ -307,7 +307,7 @@ struct SoundMacro { static const CmdIntrospection Introspective; Value scale; Value add; - TableIdDNA table; + TableIdDNA table; Value msSwitch; Value ticksOrMs; bool Do(SoundMacroState& st, Voice& vox) const override; @@ -317,7 +317,7 @@ struct SoundMacro { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; enum class Mode : atInt8 { NoScale = 0, Negative = 1, Positive = 2 }; - SampleIdDNA sample; + SampleIdDNA sample; Value mode; Value offset; bool Do(SoundMacroState& st, Voice& vox) const override; @@ -339,8 +339,8 @@ struct SoundMacro { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; Value rnd; - SoundMacroIdDNA macro; - SoundMacroStepDNA macroStep; + SoundMacroIdDNA macro; + SoundMacroStepDNA macroStep; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::SplitRnd; } }; @@ -349,7 +349,7 @@ struct SoundMacro { static const CmdIntrospection Introspective; Value scale; Value add; - TableIdDNA table; + TableIdDNA table; Value msSwitch; Value ticksOrMs; bool Do(SoundMacroState& st, Voice& vox) const override; @@ -477,7 +477,7 @@ struct SoundMacro { struct CmdSetPitchAdsr : ICmd { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; - TableIdDNA table; + TableIdDNA table; Seek<1, athena::SeekOrigin::Current> seek; Value keys; Value cents; @@ -519,8 +519,8 @@ struct SoundMacro { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; Seek<1, athena::SeekOrigin::Current> seek; - SoundMacroIdDNA macro; - SoundMacroStepDNA macroStep; + SoundMacroIdDNA macro; + SoundMacroStepDNA macroStep; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::GoSub; } }; @@ -529,8 +529,8 @@ struct SoundMacro { static const CmdIntrospection Introspective; enum class EventType : atInt8 { KeyOff, SampleEnd, MessageRecv }; Value event; - SoundMacroIdDNA macro; - SoundMacroStepDNA macroStep; + SoundMacroIdDNA macro; + SoundMacroStepDNA macroStep; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::TrapEvent; } }; @@ -545,7 +545,7 @@ struct SoundMacro { AT_DECL_DNA_YAMLV static const CmdIntrospection Introspective; Value isVar; - SoundMacroIdDNA macro; + SoundMacroIdDNA macro; Value voiceVar; Value valueVar; bool Do(SoundMacroState& st, Voice& vox) const override; @@ -921,7 +921,7 @@ struct SoundMacro { Value varCtrlB; Value b; Value notEq; - SoundMacroStepDNA macroStep; + SoundMacroStepDNA macroStep; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::IfEqual; } }; @@ -933,7 +933,7 @@ struct SoundMacro { Value varCtrlB; Value b; Value notLt; - SoundMacroStepDNA macroStep; + SoundMacroStepDNA macroStep; bool Do(SoundMacroState& st, Voice& vox) const override; CmdOp Isa() const override { return CmdOp::IfLess; } }; @@ -1104,7 +1104,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) KeymapDN }; struct Keymap : BigDNA { AT_DECL_DNA_YAML - SoundMacroIdDNA macro; + SoundMacroIdDNA macro; Value transpose = 0; Value pan = 64; /* -128 for surround-channel only */ Value prioOffset = 0; @@ -1146,7 +1146,7 @@ struct AT_SPECIALIZE_PARMS(athena::Endian::Big, athena::Endian::Little) LayerMap }; struct LayerMapping : BigDNA { AT_DECL_DNA_YAML - SoundMacroIdDNA macro; + SoundMacroIdDNA macro; Value keyLo = 0; Value keyHi = 127; Value transpose = 0; diff --git a/include/amuse/AudioGroupProject.hpp b/include/amuse/AudioGroupProject.hpp index b3c92e1..5ebac8a 100644 --- a/include/amuse/AudioGroupProject.hpp +++ b/include/amuse/AudioGroupProject.hpp @@ -60,7 +60,7 @@ struct SongGroupIndex : AudioGroupIndex { }; struct PageEntry : BigDNA { AT_DECL_DNA_YAML - PageObjectIdDNA objId; + PageObjectIdDNA objId; Value priority = 0; Value maxVoices = 255; @@ -134,7 +134,7 @@ struct SFXGroupIndex : AudioGroupIndex { }; struct SFXEntry : BigDNA { AT_DECL_DNA_YAML - PageObjectIdDNA objId; + PageObjectIdDNA objId; Value priority = 0; Value maxVoices = 255; Value defVel = 127; diff --git a/include/amuse/Common.hpp b/include/amuse/Common.hpp index 5f6c558..3ac13a3 100644 --- a/include/amuse/Common.hpp +++ b/include/amuse/Common.hpp @@ -38,10 +38,10 @@ constexpr float NativeSampleRate = 32000.0f; namespace amuse { struct NameDB; -using BigDNA = athena::io::DNA; -using LittleDNA = athena::io::DNA; -using BigDNAV = athena::io::DNAVYaml; -using LittleDNAV = athena::io::DNAVYaml; +using BigDNA = athena::io::DNA; +using LittleDNA = athena::io::DNA; +using BigDNAV = athena::io::DNAVYaml; +using LittleDNAV = athena::io::DNAVYaml; /** Common ID structure statically tagging * SoundMacros, Tables, Keymaps, Layers, Samples, SFX, Songs */ diff --git a/lib/AudioGroupPool.cpp b/lib/AudioGroupPool.cpp index 574a523..4860fdd 100644 --- a/lib/AudioGroupPool.cpp +++ b/lib/AudioGroupPool.cpp @@ -67,7 +67,7 @@ struct MakeDefaultCmdOp { case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroStep: case amuse::SoundMacro::CmdIntrospection::Field::Type::TableId: case amuse::SoundMacro::CmdIntrospection::Field::Type::SampleId: - AccessField>(ret.get(), field).id = uint16_t(field.m_default); + AccessField>(ret.get(), field).id = uint16_t(field.m_default); break; default: break; @@ -188,8 +188,8 @@ AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r) { return ret; } -template AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r); -template AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r); +template AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r); +template AudioGroupPool AudioGroupPool::_AudioGroupPool(athena::io::IStreamReader& r); AudioGroupPool AudioGroupPool::CreateAudioGroupPool(const AudioGroupData& data) { if (data.getPoolSize() < 16) @@ -197,9 +197,9 @@ AudioGroupPool AudioGroupPool::CreateAudioGroupPool(const AudioGroupData& data) athena::io::MemoryReader r(data.getPool(), data.getPoolSize()); switch (data.getDataFormat()) { case DataFormat::PC: - return _AudioGroupPool(r); + return _AudioGroupPool(r); default: - return _AudioGroupPool(r); + return _AudioGroupPool(r); } } @@ -339,8 +339,8 @@ void SoundMacro::readCmds(athena::io::IStreamReader& r, uint32_t size) { m_cmds.push_back(CmdDo>(mr)); } } -template void SoundMacro::readCmds(athena::io::IStreamReader& r, uint32_t size); -template void SoundMacro::readCmds(athena::io::IStreamReader& r, uint32_t size); +template void SoundMacro::readCmds(athena::io::IStreamReader& r, uint32_t size); +template void SoundMacro::readCmds(athena::io::IStreamReader& r, uint32_t size); template void SoundMacro::writeCmds(athena::io::IStreamWriter& w) const { @@ -352,8 +352,8 @@ void SoundMacro::writeCmds(athena::io::IStreamWriter& w) const { athena::io::Write::Do({}, data, w); } } -template void SoundMacro::writeCmds(athena::io::IStreamWriter& w) const; -template void SoundMacro::writeCmds(athena::io::IStreamWriter& w) const; +template void SoundMacro::writeCmds(athena::io::IStreamWriter& w) const; +template void SoundMacro::writeCmds(athena::io::IStreamWriter& w) const; void SoundMacro::buildFromPrototype(const SoundMacro& other) { m_cmds.reserve(other.m_cmds.size()); @@ -1101,8 +1101,8 @@ std::vector AudioGroupPool::toData() const { return fo.data(); } -template std::vector AudioGroupPool::toData() const; -template std::vector AudioGroupPool::toData() const; +template std::vector AudioGroupPool::toData() const; +template std::vector AudioGroupPool::toData() const; template <> void amuse::Curve::Enumerate(athena::io::IStreamReader& r) { diff --git a/lib/AudioGroupProject.cpp b/lib/AudioGroupProject.cpp index 21fd65f..dc29261 100644 --- a/lib/AudioGroupProject.cpp +++ b/lib/AudioGroupProject.cpp @@ -82,7 +82,7 @@ static void WriteRangedObjectIds(athena::io::IStreamWriter& w, const T& list) { AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { while (!AtEnd32(r)) { - GroupHeader header; + GroupHeader header; header.read(r); if (GroupId::CurNameDB) @@ -92,31 +92,31 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { /* Sound Macros */ r.seek(header.soundMacroIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { - ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); } /* Samples */ r.seek(header.samplIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { - ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); } /* Tables */ r.seek(header.tableIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { - ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); } /* Keymaps */ r.seek(header.keymapIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { - ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); } /* Layers */ r.seek(header.layerIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { - ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); } #endif @@ -127,7 +127,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { /* Normal pages */ r.seek(header.pageTableOff, athena::SeekOrigin::Begin); while (!AtEnd64(r)) { - SongGroupIndex::PageEntryDNA entry; + SongGroupIndex::PageEntryDNA entry; entry.read(r); idx->m_normPages[entry.programNo] = entry; } @@ -135,7 +135,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { /* Drum pages */ r.seek(header.drumTableOff, athena::SeekOrigin::Begin); while (!AtEnd64(r)) { - SongGroupIndex::PageEntryDNA entry; + SongGroupIndex::PageEntryDNA entry; entry.read(r); idx->m_drumPages[entry.programNo] = entry; } @@ -163,7 +163,7 @@ AudioGroupProject::AudioGroupProject(athena::io::IStreamReader& r, GCNDataTag) { r.seek(2, athena::SeekOrigin::Current); idx->m_sfxEntries.reserve(count); for (int i = 0; i < count; ++i) { - SFXGroupIndex::SFXEntryDNA entry; + SFXGroupIndex::SFXEntryDNA entry; entry.read(r); idx->m_sfxEntries[entry.sfxId.id] = entry; if (SFXId::CurNameDB) @@ -321,9 +321,9 @@ AudioGroupProject AudioGroupProject::CreateAudioGroupProject(const AudioGroupDat default: return AudioGroupProject(r, GCNDataTag{}); case DataFormat::N64: - return _AudioGroupProject(r, data.getAbsoluteProjOffsets()); + return _AudioGroupProject(r, data.getAbsoluteProjOffsets()); case DataFormat::PC: - return _AudioGroupProject(r, data.getAbsoluteProjOffsets()); + return _AudioGroupProject(r, data.getAbsoluteProjOffsets()); } } @@ -459,7 +459,7 @@ AudioGroupProject AudioGroupProject::CreateAudioGroupProject(const AudioGroupPro void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, GCNDataTag) { while (!AtEnd32(r)) { - GroupHeader header; + GroupHeader header; header.read(r); GroupId::CurNameDB->registerPair(NameDB::generateName(header.groupId, NameDB::Type::Group), header.groupId); @@ -467,30 +467,30 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, GCNData /* Sound Macros */ r.seek(header.soundMacroIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) - ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); + ReadRangedObjectIds(SoundMacroId::CurNameDB, r, NameDB::Type::SoundMacro); /* Samples */ r.seek(header.samplIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { - ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); + ReadRangedObjectIds(SampleId::CurNameDB, r, NameDB::Type::Sample); } /* Tables */ r.seek(header.tableIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { - ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); + ReadRangedObjectIds(TableId::CurNameDB, r, NameDB::Type::Table); } /* Keymaps */ r.seek(header.keymapIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { - ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); + ReadRangedObjectIds(KeymapId::CurNameDB, r, NameDB::Type::Keymap); } /* Layers */ r.seek(header.layerIdsOff, athena::SeekOrigin::Begin); while (!AtEnd16(r)) { - ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); + ReadRangedObjectIds(LayersId::CurNameDB, r, NameDB::Type::Layer); } if (header.type == GroupType::Song) { @@ -507,7 +507,7 @@ void AudioGroupProject::BootstrapObjectIDs(athena::io::IStreamReader& r, GCNData uint16_t count = r.readUint16Big(); r.seek(2, athena::SeekOrigin::Current); for (int i = 0; i < count; ++i) { - SFXGroupIndex::SFXEntryDNA entry; + SFXGroupIndex::SFXEntryDNA entry; entry.read(r); SFXId::CurNameDB->registerPair(NameDB::generateName(entry.sfxId.id, NameDB::Type::SFX), entry.sfxId.id); } @@ -606,10 +606,10 @@ void AudioGroupProject::BootstrapObjectIDs(const AudioGroupData& data) { BootstrapObjectIDs(r, GCNDataTag{}); break; case DataFormat::N64: - BootstrapObjectIDs(r, data.getAbsoluteProjOffsets()); + BootstrapObjectIDs(r, data.getAbsoluteProjOffsets()); break; case DataFormat::PC: - BootstrapObjectIDs(r, data.getAbsoluteProjOffsets()); + BootstrapObjectIDs(r, data.getAbsoluteProjOffsets()); break; } } @@ -820,7 +820,7 @@ struct ObjectIdPool std::vector AudioGroupProject::toGCNData(const AudioGroupPool& pool, const AudioGroupSampleDirectory& sdir) const { - constexpr athena::Endian DNAE = athena::Big; + constexpr athena::Endian DNAE = athena::Endian::Big; athena::io::VectorWriter fo; diff --git a/lib/AudioGroupSampleDirectory.cpp b/lib/AudioGroupSampleDirectory.cpp index 6f904a3..061fbef 100644 --- a/lib/AudioGroupSampleDirectory.cpp +++ b/lib/AudioGroupSampleDirectory.cpp @@ -46,7 +46,7 @@ void AudioGroupSampleDirectory::ADPCMParms::swapBigVADPCM() { AudioGroupSampleDirectory::AudioGroupSampleDirectory(athena::io::IStreamReader& r, GCNDataTag) { while (!AtEnd32(r)) { - EntryDNA ent; + EntryDNA ent; ent.read(r); m_entries[ent.m_sfxId] = MakeObj(ent); if (SampleId::CurNameDB) @@ -66,14 +66,14 @@ AudioGroupSampleDirectory::AudioGroupSampleDirectory(athena::io::IStreamReader& bool absOffs, N64DataTag) { if (absOffs) { while (!AtEnd32(r)) { - MusyX1AbsSdirEntry ent; + MusyX1AbsSdirEntry ent; ent.read(r); m_entries[ent.m_sfxId] = MakeObj(ent); SampleId::CurNameDB->registerPair(NameDB::generateName(ent.m_sfxId, NameDB::Type::Sample), ent.m_sfxId); } } else { while (!AtEnd32(r)) { - MusyX1SdirEntry ent; + MusyX1SdirEntry ent; ent.read(r); m_entries[ent.m_sfxId] = MakeObj(ent); SampleId::CurNameDB->registerPair(NameDB::generateName(ent.m_sfxId, NameDB::Type::Sample), ent.m_sfxId); @@ -89,7 +89,7 @@ AudioGroupSampleDirectory::AudioGroupSampleDirectory(athena::io::IStreamReader& AudioGroupSampleDirectory::AudioGroupSampleDirectory(athena::io::IStreamReader& r, bool absOffs, PCDataTag) { if (absOffs) { while (!AtEnd32(r)) { - MusyX1AbsSdirEntry ent; + MusyX1AbsSdirEntry ent; ent.read(r); auto& store = m_entries[ent.m_sfxId]; store = MakeObj(ent); @@ -98,7 +98,7 @@ AudioGroupSampleDirectory::AudioGroupSampleDirectory(athena::io::IStreamReader& } } else { while (!AtEnd32(r)) { - MusyX1SdirEntry ent; + MusyX1SdirEntry ent; ent.read(r); auto& store = m_entries[ent.m_sfxId]; store = MakeObj(ent); @@ -877,7 +877,7 @@ void AudioGroupSampleDirectory::reloadSampleData(SystemStringView groupPath) { std::pair, std::vector> AudioGroupSampleDirectory::toGCNData(const AudioGroupDatabase& group) const { - constexpr athena::Endian DNAE = athena::Big; + constexpr athena::Endian DNAE = athena::Endian::Big; athena::io::VectorWriter fo; athena::io::VectorWriter sfo; diff --git a/lib/Common.cpp b/lib/Common.cpp index 2822589..172d5ba 100644 --- a/lib/Common.cpp +++ b/lib/Common.cpp @@ -49,52 +49,52 @@ bool Copy(const SystemChar* from, const SystemChar* to) { thread_local NameDB* type::CurNameDB = nullptr; \ template <> \ template <> \ - void type##DNA::Enumerate(athena::io::IStreamReader & reader) { \ + void type##DNA::Enumerate(athena::io::IStreamReader& reader) { \ id = reader.readUint16Little(); \ } \ template <> \ template <> \ - void type##DNA::Enumerate(athena::io::IStreamWriter & writer) { \ + void type##DNA::Enumerate(athena::io::IStreamWriter& writer) { \ writer.writeUint16Little(id.id); \ } \ template <> \ template <> \ - void type##DNA::Enumerate(size_t & sz) { \ + void type##DNA::Enumerate(size_t& sz) { \ sz += 2; \ } \ template <> \ template <> \ - void type##DNA::Enumerate(athena::io::YAMLDocReader & reader) { \ + void type##DNA::Enumerate(athena::io::YAMLDocReader& reader) { \ _read(reader); \ } \ template <> \ template <> \ - void type##DNA::Enumerate(athena::io::YAMLDocWriter & writer) { \ + void type##DNA::Enumerate(athena::io::YAMLDocWriter& writer) { \ _write(writer); \ } \ template <> \ template <> \ - void type##DNA::Enumerate(athena::io::IStreamReader & reader) { \ + void type##DNA::Enumerate(athena::io::IStreamReader& reader) { \ id = reader.readUint16Big(); \ } \ template <> \ template <> \ - void type##DNA::Enumerate(athena::io::IStreamWriter & writer) { \ + void type##DNA::Enumerate(athena::io::IStreamWriter& writer) { \ writer.writeUint16Big(id.id); \ } \ template <> \ template <> \ - void type##DNA::Enumerate(size_t & sz) { \ + void type##DNA::Enumerate(size_t& sz) { \ sz += 2; \ } \ template <> \ template <> \ - void type##DNA::Enumerate(athena::io::YAMLDocReader & reader) { \ + void type##DNA::Enumerate(athena::io::YAMLDocReader& reader) { \ _read(reader); \ } \ template <> \ template <> \ - void type##DNA::Enumerate(athena::io::YAMLDocWriter & writer) { \ + void type##DNA::Enumerate(athena::io::YAMLDocWriter& writer) { \ _write(writer); \ } \ template \ @@ -122,8 +122,8 @@ bool Copy(const SystemChar* from, const SystemChar* to) { const char* type##DNA::DNAType() { \ return "amuse::" #type "DNA"; \ } \ - template struct type##DNA; \ - template struct type##DNA; + template struct type##DNA; \ + template struct type##DNA; DEFINE_ID_TYPE(ObjectId, "object") DEFINE_ID_TYPE(SoundMacroId, "SoundMacro") @@ -137,52 +137,52 @@ DEFINE_ID_TYPE(GroupId, "group") template <> template <> -void PageObjectIdDNA::Enumerate(athena::io::IStreamReader& reader) { +void PageObjectIdDNA::Enumerate(athena::io::IStreamReader& reader) { id = reader.readUint16Little(); } template <> template <> -void PageObjectIdDNA::Enumerate(athena::io::IStreamWriter& writer) { +void PageObjectIdDNA::Enumerate(athena::io::IStreamWriter& writer) { writer.writeUint16Little(id.id); } template <> template <> -void PageObjectIdDNA::Enumerate(size_t& sz) { +void PageObjectIdDNA::Enumerate(size_t& sz) { sz += 2; } template <> template <> -void PageObjectIdDNA::Enumerate(athena::io::YAMLDocReader& reader) { +void PageObjectIdDNA::Enumerate(athena::io::YAMLDocReader& reader) { _read(reader); } template <> template <> -void PageObjectIdDNA::Enumerate(athena::io::YAMLDocWriter& writer) { +void PageObjectIdDNA::Enumerate(athena::io::YAMLDocWriter& writer) { _write(writer); } template <> template <> -void PageObjectIdDNA::Enumerate(athena::io::IStreamReader& reader) { +void PageObjectIdDNA::Enumerate(athena::io::IStreamReader& reader) { id = reader.readUint16Big(); } template <> template <> -void PageObjectIdDNA::Enumerate(athena::io::IStreamWriter& writer) { +void PageObjectIdDNA::Enumerate(athena::io::IStreamWriter& writer) { writer.writeUint16Big(id.id); } template <> template <> -void PageObjectIdDNA::Enumerate(size_t& sz) { +void PageObjectIdDNA::Enumerate(size_t& sz) { sz += 2; } template <> template <> -void PageObjectIdDNA::Enumerate(athena::io::YAMLDocReader& reader) { +void PageObjectIdDNA::Enumerate(athena::io::YAMLDocReader& reader) { _read(reader); } template <> template <> -void PageObjectIdDNA::Enumerate(athena::io::YAMLDocWriter& writer) { +void PageObjectIdDNA::Enumerate(athena::io::YAMLDocWriter& writer) { _write(writer); } template @@ -232,65 +232,65 @@ template const char* PageObjectIdDNA::DNAType() { return "amuse::PageObjectIdDNA"; } -template struct PageObjectIdDNA; -template struct PageObjectIdDNA; +template struct PageObjectIdDNA; +template struct PageObjectIdDNA; template <> template <> -void SoundMacroStepDNA::Enumerate(athena::io::IStreamReader& reader) { +void SoundMacroStepDNA::Enumerate(athena::io::IStreamReader& reader) { step = reader.readUint16Little(); } template <> template <> -void SoundMacroStepDNA::Enumerate(athena::io::IStreamWriter& writer) { +void SoundMacroStepDNA::Enumerate(athena::io::IStreamWriter& writer) { writer.writeUint16Little(step); } template <> template <> -void SoundMacroStepDNA::Enumerate(size_t& sz) { +void SoundMacroStepDNA::Enumerate(size_t& sz) { sz += 2; } template <> template <> -void SoundMacroStepDNA::Enumerate(athena::io::YAMLDocReader& reader) { +void SoundMacroStepDNA::Enumerate(athena::io::YAMLDocReader& reader) { step = reader.readUint16(nullptr); } template <> template <> -void SoundMacroStepDNA::Enumerate(athena::io::YAMLDocWriter& writer) { +void SoundMacroStepDNA::Enumerate(athena::io::YAMLDocWriter& writer) { writer.writeUint16(nullptr, step); } template <> template <> -void SoundMacroStepDNA::Enumerate(athena::io::IStreamReader& reader) { +void SoundMacroStepDNA::Enumerate(athena::io::IStreamReader& reader) { step = reader.readUint16Big(); } template <> template <> -void SoundMacroStepDNA::Enumerate(athena::io::IStreamWriter& writer) { +void SoundMacroStepDNA::Enumerate(athena::io::IStreamWriter& writer) { writer.writeUint16Big(step); } template <> template <> -void SoundMacroStepDNA::Enumerate(size_t& sz) { +void SoundMacroStepDNA::Enumerate(size_t& sz) { sz += 2; } template <> template <> -void SoundMacroStepDNA::Enumerate(athena::io::YAMLDocReader& reader) { +void SoundMacroStepDNA::Enumerate(athena::io::YAMLDocReader& reader) { step = reader.readUint16(nullptr); } template <> template <> -void SoundMacroStepDNA::Enumerate(athena::io::YAMLDocWriter& writer) { +void SoundMacroStepDNA::Enumerate(athena::io::YAMLDocWriter& writer) { writer.writeUint16(nullptr, step); } template const char* SoundMacroStepDNA::DNAType() { return "amuse::SoundMacroStepDNA"; } -template struct SoundMacroStepDNA; -template struct SoundMacroStepDNA; +template struct SoundMacroStepDNA; +template struct SoundMacroStepDNA; ObjectId NameDB::generateId(Type tp) const { uint16_t maxMatch = 0; diff --git a/lib/SoundMacroState.cpp b/lib/SoundMacroState.cpp index fd8b86d..bf31ac3 100644 --- a/lib/SoundMacroState.cpp +++ b/lib/SoundMacroState.cpp @@ -163,19 +163,19 @@ constexpr SoundMacro::CmdIntrospection::Field::Type GetFieldType() { return SoundMacro::CmdIntrospection::Field::Type::UInt32; } template <> -constexpr SoundMacro::CmdIntrospection::Field::Type GetFieldType>() { +constexpr SoundMacro::CmdIntrospection::Field::Type GetFieldType>() { return SoundMacro::CmdIntrospection::Field::Type::SoundMacroId; } template <> -constexpr SoundMacro::CmdIntrospection::Field::Type GetFieldType>() { +constexpr SoundMacro::CmdIntrospection::Field::Type GetFieldType>() { return SoundMacro::CmdIntrospection::Field::Type::SoundMacroStep; } template <> -constexpr SoundMacro::CmdIntrospection::Field::Type GetFieldType>() { +constexpr SoundMacro::CmdIntrospection::Field::Type GetFieldType>() { return SoundMacro::CmdIntrospection::Field::Type::TableId; } template <> -constexpr SoundMacro::CmdIntrospection::Field::Type GetFieldType>() { +constexpr SoundMacro::CmdIntrospection::Field::Type GetFieldType>() { return SoundMacro::CmdIntrospection::Field::Type::SampleId; } From f50d67eff05f41b6f95b16f1a4398e51f144f784 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 19:48:29 -0400 Subject: [PATCH 06/17] Sequencer: Eliminate magic values where applicable Many of them are just representative of the sizes of an array, so we can just query the array instead. --- lib/Sequencer.cpp | 57 +++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/lib/Sequencer.cpp b/lib/Sequencer.cpp index a9ce985..a51bf5a 100644 --- a/lib/Sequencer.cpp +++ b/lib/Sequencer.cpp @@ -246,11 +246,13 @@ ObjToken Sequencer::ChannelState::keyOn(uint8_t note, uint8_t velocity) { } ObjToken Sequencer::keyOn(uint8_t chan, uint8_t note, uint8_t velocity) { - if (chan > 15) + if (chan >= m_chanStates.size()) { return {}; + } - if (!m_chanStates[chan]) + if (!m_chanStates[chan]) { m_chanStates[chan] = ChannelState(*this, chan); + } return m_chanStates[chan].keyOn(note, velocity); } @@ -268,8 +270,9 @@ void Sequencer::ChannelState::keyOff(uint8_t note, uint8_t velocity) { } void Sequencer::keyOff(uint8_t chan, uint8_t note, uint8_t velocity) { - if (chan > 15 || !m_chanStates[chan]) + if (chan >= m_chanStates.size() || !m_chanStates[chan]) { return; + } m_chanStates[chan].keyOff(note, velocity); } @@ -351,8 +354,9 @@ void Sequencer::ChannelState::prevProgram() { } void Sequencer::setCtrlValue(uint8_t chan, uint8_t ctrl, int8_t val) { - if (chan > 15) + if (chan >= m_chanStates.size()) { return; + } if (ctrl == 0x66) { fmt::print(fmt("Loop Start\n")); @@ -360,8 +364,9 @@ void Sequencer::setCtrlValue(uint8_t chan, uint8_t ctrl, int8_t val) { fmt::print(fmt("Loop End\n")); } - if (!m_chanStates[chan]) + if (!m_chanStates[chan]) { m_chanStates[chan] = ChannelState(*this, chan); + } m_chanStates[chan].setCtrlValue(ctrl, val); } @@ -375,11 +380,13 @@ void Sequencer::ChannelState::setPitchWheel(float pitchWheel) { } void Sequencer::setPitchWheel(uint8_t chan, float pitchWheel) { - if (chan > 15) + if (chan >= m_chanStates.size()) { return; + } - if (!m_chanStates[chan]) + if (!m_chanStates[chan]) { m_chanStates[chan] = ChannelState(*this, chan); + } m_chanStates[chan].setPitchWheel(pitchWheel); } @@ -422,18 +429,22 @@ void Sequencer::allOff(bool now) { } void Sequencer::allOff(uint8_t chan, bool now) { - if (chan > 15 || !m_chanStates[chan]) + if (chan >= m_chanStates.size() || !m_chanStates[chan]) { return; + } if (now) { - for (const auto& vox : m_chanStates[chan].m_chanVoxs) + for (const auto& vox : m_chanStates[chan].m_chanVoxs) { vox.second->kill(); - for (const auto& vox : m_chanStates[chan].m_keyoffVoxs) + } + for (const auto& vox : m_chanStates[chan].m_keyoffVoxs) { vox->kill(); + } m_chanStates[chan].m_chanVoxs.clear(); m_chanStates[chan].m_keyoffVoxs.clear(); - } else + } else { m_chanStates[chan].allOff(); + } } void Sequencer::ChannelState::killKeygroup(uint8_t kg, bool now) { @@ -575,12 +586,14 @@ void Sequencer::setVolume(float vol, float fadeTime) { } int8_t Sequencer::getChanProgram(int8_t chanId) const { - if (chanId > 15) + if (static_cast(chanId) >= m_chanStates.size()) { return 0; + } if (!m_chanStates[chanId]) { - if (!m_midiSetup) + if (!m_midiSetup) { return 0; + } return m_midiSetup[chanId].programNo; } @@ -588,31 +601,37 @@ int8_t Sequencer::getChanProgram(int8_t chanId) const { } bool Sequencer::setChanProgram(int8_t chanId, int8_t prog) { - if (chanId > 15) + if (static_cast(chanId) >= m_chanStates.size()) { return false; + } - if (!m_chanStates[chanId]) + if (!m_chanStates[chanId]) { m_chanStates[chanId] = ChannelState(*this, chanId); + } return m_chanStates[chanId].programChange(prog); } void Sequencer::nextChanProgram(int8_t chanId) { - if (chanId > 15) + if (static_cast(chanId) >= m_chanStates.size()) { return; + } - if (!m_chanStates[chanId]) + if (!m_chanStates[chanId]) { m_chanStates[chanId] = ChannelState(*this, chanId); + } return m_chanStates[chanId].nextProgram(); } void Sequencer::prevChanProgram(int8_t chanId) { - if (chanId > 15) + if (static_cast(chanId) >= m_chanStates.size()) { return; + } - if (!m_chanStates[chanId]) + if (!m_chanStates[chanId]) { m_chanStates[chanId] = ChannelState(*this, chanId); + } return m_chanStates[chanId].prevProgram(); } From 5f76f0ecbffc99dffe04e5ea90d674330a7ba37e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 20:03:24 -0400 Subject: [PATCH 07/17] Sequencer: Use std::array for m_ctrlVals This is the only array in the header that isn't using std::array. --- include/amuse/Sequencer.hpp | 16 ++++++++-------- lib/Sequencer.cpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/amuse/Sequencer.hpp b/include/amuse/Sequencer.hpp index a035080..4940e3d 100644 --- a/include/amuse/Sequencer.hpp +++ b/include/amuse/Sequencer.hpp @@ -57,14 +57,14 @@ class Sequencer : public Entity { std::unordered_map> m_chanVoxs; std::unordered_set> m_keyoffVoxs; ObjToken m_lastVoice; - int8_t m_ctrlVals[128] = {}; /**< MIDI controller values */ - float m_curPitchWheel = 0.f; /**< MIDI pitch-wheel */ - int8_t m_pitchWheelRange = -1; /**< Pitch wheel range settable by RPN 0 */ - int8_t m_curProgram = 0; /**< MIDI program number */ - float m_curVol = 1.f; /**< Current volume of channel */ - float m_curPan = 0.f; /**< Current panning of channel */ - uint16_t m_rpn = 0; /**< Current RPN (only pitch-range 0x0000 supported) */ - double m_ticksPerSec = 1000.0; /**< Current ticks per second (tempo) for channel */ + std::array m_ctrlVals{}; /**< MIDI controller values */ + float m_curPitchWheel = 0.f; /**< MIDI pitch-wheel */ + int8_t m_pitchWheelRange = -1; /**< Pitch wheel range settable by RPN 0 */ + int8_t m_curProgram = 0; /**< MIDI program number */ + float m_curVol = 1.f; /**< Current volume of channel */ + float m_curPan = 0.f; /**< Current panning of channel */ + uint16_t m_rpn = 0; /**< Current RPN (only pitch-range 0x0000 supported) */ + double m_ticksPerSec = 1000.0; /**< Current ticks per second (tempo) for channel */ void _bringOutYourDead(); size_t getVoiceCount() const; diff --git a/lib/Sequencer.cpp b/lib/Sequencer.cpp index a51bf5a..094e640 100644 --- a/lib/Sequencer.cpp +++ b/lib/Sequencer.cpp @@ -208,7 +208,7 @@ ObjToken Sequencer::ChannelState::keyOn(uint8_t note, uint8_t velocity) { if (*ret) { (*ret)->m_sequencer = m_parent; m_chanVoxs[note] = *ret; - (*ret)->installCtrlValues(m_ctrlVals); + (*ret)->installCtrlValues(m_ctrlVals.data()); ObjectId oid; bool res; From 9ec78d6b9f779397b777f3cf255382dd7e0aacc6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 20:05:02 -0400 Subject: [PATCH 08/17] Sequencer: Always initialize ChannelState channel ID Provides a deterministic initial state for the default constructor case. --- include/amuse/Sequencer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/amuse/Sequencer.hpp b/include/amuse/Sequencer.hpp index 4940e3d..e0e24d4 100644 --- a/include/amuse/Sequencer.hpp +++ b/include/amuse/Sequencer.hpp @@ -45,7 +45,7 @@ class Sequencer : public Entity { /** State of a single MIDI channel */ struct ChannelState { Sequencer* m_parent = nullptr; - uint8_t m_chanId; + uint8_t m_chanId = 0; const SongGroupIndex::MIDISetup* m_setup = nullptr; /* Channel defaults to program 0 if null */ const SongGroupIndex::PageEntry* m_page = nullptr; ~ChannelState(); From 2c75668e0a32f88ccaa3967674f431865ef56e31 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 20:06:31 -0400 Subject: [PATCH 09/17] Sequencer: Default ChannelState's destructor --- lib/Sequencer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Sequencer.cpp b/lib/Sequencer.cpp index 094e640..c8c289b 100644 --- a/lib/Sequencer.cpp +++ b/lib/Sequencer.cpp @@ -71,7 +71,7 @@ Sequencer::Sequencer(Engine& engine, const AudioGroup& group, GroupId groupId, c m_sfxMappings.push_back(sfx.second); } -Sequencer::ChannelState::~ChannelState() {} +Sequencer::ChannelState::~ChannelState() = default; Sequencer::ChannelState::ChannelState(Sequencer& parent, uint8_t chanId) : m_parent(&parent), m_chanId(chanId) { if (m_parent->m_songGroup) { From 1b37122b12f95b26b86150b069407208a94310ed Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 20:08:36 -0400 Subject: [PATCH 10/17] Sequencer: std::move studio instances in constructor Avoids an unnecessary atomic reference count increment and decrement --- lib/Sequencer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Sequencer.cpp b/lib/Sequencer.cpp index c8c289b..d82ac17 100644 --- a/lib/Sequencer.cpp +++ b/lib/Sequencer.cpp @@ -53,7 +53,7 @@ Sequencer::~Sequencer() { Sequencer::Sequencer(Engine& engine, const AudioGroup& group, GroupId groupId, const SongGroupIndex* songGroup, SongId setupId, ObjToken studio) -: Entity(engine, group, groupId), m_songGroup(songGroup), m_studio(studio) { +: Entity(engine, group, groupId), m_songGroup(songGroup), m_studio(std::move(studio)) { auto it = m_songGroup->m_midiSetups.find(setupId); if (it != m_songGroup->m_midiSetups.cend()) m_midiSetup = it->second.data(); @@ -61,7 +61,7 @@ Sequencer::Sequencer(Engine& engine, const AudioGroup& group, GroupId groupId, c Sequencer::Sequencer(Engine& engine, const AudioGroup& group, GroupId groupId, const SFXGroupIndex* sfxGroup, ObjToken studio) -: Entity(engine, group, groupId), m_sfxGroup(sfxGroup), m_studio(studio) { +: Entity(engine, group, groupId), m_sfxGroup(sfxGroup), m_studio(std::move(studio)) { std::map sortSFX; for (const auto& sfx : sfxGroup->m_sfxEntries) sortSFX[sfx.first] = &sfx.second; From 04fbc328e98b97dab4bdbbf34494dae35b92bbd6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 20:20:17 -0400 Subject: [PATCH 11/17] Studio: Make _cyclicCheck a const member function This doesn't actually modify the internal state of the studio instance, so we can mark it as a const member function. --- include/amuse/Studio.hpp | 2 +- lib/Studio.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/amuse/Studio.hpp b/include/amuse/Studio.hpp index 9f853f7..798fdba 100644 --- a/include/amuse/Studio.hpp +++ b/include/amuse/Studio.hpp @@ -18,7 +18,7 @@ class Studio { std::list m_studiosOut; #ifndef NDEBUG - bool _cyclicCheck(Studio* leaf); + bool _cyclicCheck(const Studio* leaf) const; #endif public: diff --git a/lib/Studio.cpp b/lib/Studio.cpp index c0e03cd..9ed132e 100644 --- a/lib/Studio.cpp +++ b/lib/Studio.cpp @@ -1,16 +1,16 @@ #include "amuse/Studio.hpp" + +#include + #include "amuse/Engine.hpp" namespace amuse { #ifndef NDEBUG -bool Studio::_cyclicCheck(Studio* leaf) { - for (auto it = m_studiosOut.begin(); it != m_studiosOut.end();) { - if (leaf == it->m_targetStudio.get() || it->m_targetStudio->_cyclicCheck(leaf)) - return true; - ++it; - } - return false; +bool Studio::_cyclicCheck(const Studio* leaf) const { + return std::any_of(m_studiosOut.cbegin(), m_studiosOut.cend(), [leaf](const auto& studio) { + return leaf == studio.m_targetStudio.get() || studio.m_targetStudio->_cyclicCheck(leaf); + }); } #endif From b92674e1270098d896b69299dfcd17058563bddf Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 20:23:26 -0400 Subject: [PATCH 12/17] Studio: std::move studio instance in addStudioSend() Avoids an unnecessary atomic reference count increment and decrement --- lib/Studio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Studio.cpp b/lib/Studio.cpp index 9ed132e..f94f3a9 100644 --- a/lib/Studio.cpp +++ b/lib/Studio.cpp @@ -20,7 +20,7 @@ Studio::Studio(Engine& engine, bool mainOut) : m_engine(engine), m_master(engine } void Studio::addStudioSend(ObjToken studio, float dry, float auxA, float auxB) { - m_studiosOut.emplace_back(studio, dry, auxA, auxB); + m_studiosOut.emplace_back(std::move(studio), dry, auxA, auxB); /* Cyclic check */ assert(!_cyclicCheck(this)); From 7bc23b719019672f8cdd7f454c11d8f8b14471b4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 20:27:08 -0400 Subject: [PATCH 13/17] VolumeTable: Remove unnecessary Common include We can just include directly to eliminate an indirect include. --- lib/VolumeTable.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/VolumeTable.cpp b/lib/VolumeTable.cpp index 4776923..5a32c2c 100644 --- a/lib/VolumeTable.cpp +++ b/lib/VolumeTable.cpp @@ -1,9 +1,8 @@ #include "amuse/VolumeTable.hpp" +#include #include -#include "amuse/Common.hpp" - namespace amuse { static const float VolumeTable[] = { From a8c9d555fe55cfc4787a7258545a8b2f8af6e6b9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 20:29:41 -0400 Subject: [PATCH 14/17] VolumeTable: Use std::array where applicable Makes the arrays strongly typed. --- lib/VolumeTable.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/VolumeTable.cpp b/lib/VolumeTable.cpp index 5a32c2c..ae4c8c4 100644 --- a/lib/VolumeTable.cpp +++ b/lib/VolumeTable.cpp @@ -1,11 +1,12 @@ #include "amuse/VolumeTable.hpp" #include +#include #include namespace amuse { -static const float VolumeTable[] = { +constexpr std::array VolumeTable{ 0.000000f, 0.000031f, 0.000153f, 0.000397f, 0.000702f, 0.001129f, 0.001648f, 0.002228f, 0.002930f, 0.003723f, 0.004608f, 0.005585f, 0.006653f, 0.007843f, 0.009125f, 0.010498f, 0.011963f, 0.013550f, 0.015198f, 0.016999f, 0.018860f, 0.020844f, 0.022919f, 0.025117f, 0.027406f, 0.029817f, 0.032319f, 0.034944f, 0.037660f, 0.040468f, @@ -18,9 +19,10 @@ static const float VolumeTable[] = { 0.452864f, 0.464217f, 0.475753f, 0.487442f, 0.499313f, 0.511399f, 0.523606f, 0.536027f, 0.548631f, 0.561419f, 0.574389f, 0.587542f, 0.600879f, 0.614399f, 0.628132f, 0.642018f, 0.656148f, 0.670431f, 0.684927f, 0.699637f, 0.714530f, 0.729637f, 0.744926f, 0.760430f, 0.776147f, 0.792077f, 0.808191f, 0.824549f, 0.841090f, 0.857845f, - 0.874844f, 0.892056f, 0.909452f, 0.927122f, 0.945006f, 0.963073f, 0.981414f, 1.000000f, 1.000000f}; + 0.874844f, 0.892056f, 0.909452f, 0.927122f, 0.945006f, 0.963073f, 0.981414f, 1.000000f, 1.000000f, +}; -static const float DLSVolumeTable[] = { +constexpr std::array DLSVolumeTable{ 0.000000f, 0.000062f, 0.000248f, 0.000558f, 0.000992f, 0.001550f, 0.002232f, 0.003038f, 0.003968f, 0.005022f, 0.006200f, 0.007502f, 0.008928f, 0.010478f, 0.012152f, 0.013950f, 0.015872f, 0.017918f, 0.020088f, 0.022382f, 0.024800f, 0.027342f, 0.030008f, 0.032798f, 0.035712f, 0.038750f, 0.041912f, 0.045198f, 0.048608f, 0.052142f, @@ -33,7 +35,8 @@ static const float DLSVolumeTable[] = { 0.502201f, 0.513423f, 0.524769f, 0.536239f, 0.547833f, 0.559551f, 0.571393f, 0.583359f, 0.595449f, 0.607663f, 0.620001f, 0.632463f, 0.645049f, 0.657759f, 0.670593f, 0.683551f, 0.696633f, 0.709839f, 0.723169f, 0.736623f, 0.750202f, 0.763904f, 0.777730f, 0.791680f, 0.805754f, 0.819952f, 0.834274f, 0.848720f, 0.863290f, 0.877984f, - 0.892802f, 0.907744f, 0.922810f, 0.938000f, 0.953314f, 0.968752f, 0.984314f, 1.000000f, 1.000000f}; + 0.892802f, 0.907744f, 0.922810f, 0.938000f, 0.953314f, 0.968752f, 0.984314f, 1.000000f, 1.000000f, +}; float LookupVolume(float vol) { vol = std::clamp(vol * 127.f, 0.f, 127.f); From 60dad604485e86dfa20ccb6d1afcd1fd84d771ad Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 20:40:24 -0400 Subject: [PATCH 15/17] CMakeLists: Add MSVC standards conformance flags Applies flags to make MSVC's compiler be more standards compliant. --- CMakeLists.txt | 37 +++++++++++++++++++++++++++++++------ Editor/CMakeLists.txt | 19 +++++++++++++++++++ 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2b427f..3341e53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,22 +75,47 @@ add_library(amuse include/amuse/VolumeTable.hpp ) +target_atdna(amuse atdna_AudioGroupPool.cpp include/amuse/AudioGroupPool.hpp) +target_atdna(amuse atdna_AudioGroupProject.cpp include/amuse/AudioGroupProject.hpp) +target_atdna(amuse atdna_AudioGroupSampleDirectory.cpp include/amuse/AudioGroupSampleDirectory.hpp) + +target_include_directories(amuse PUBLIC include) +target_link_libraries(amuse + athena-core + lzokay + ${ZLIB_LIBRARIES} +) + if(NX) target_sources(amuse PRIVATE include/switch_math.hpp) endif() -target_atdna(amuse atdna_AudioGroupPool.cpp include/amuse/AudioGroupPool.hpp) -target_atdna(amuse atdna_AudioGroupProject.cpp include/amuse/AudioGroupProject.hpp) -target_atdna(amuse atdna_AudioGroupSampleDirectory.cpp include/amuse/AudioGroupSampleDirectory.hpp) -target_include_directories(amuse PUBLIC include) -target_link_libraries(amuse athena-core ${ZLIB_LIBRARIES} lzokay) if(TARGET boo) target_sources(amuse PRIVATE lib/BooBackend.cpp include/amuse/BooBackend.hpp) target_link_libraries(amuse boo) endif() -if (NOT MSVC) + +if (MSVC) + target_compile_options(amuse PRIVATE + # Enforce various standards compliant behavior. + /permissive- + + # Enable standard volatile semantics. + /volatile:iso + + # Reports the proper value for the __cplusplus preprocessor macro. + /Zc:__cplusplus + + # Allow constexpr variables to have explicit external linkage. + /Zc:externConstexpr + + # Assume that new throws exceptions, allowing better code generation. + /Zc:throwingNew + ) +else() target_compile_options(amuse PRIVATE -Wno-unknown-pragmas) endif() + if(COMMAND add_sanitizers) add_sanitizers(amuse) endif() diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index f8d0595..9d9b344 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -81,6 +81,25 @@ target_compile_definitions(amuse-gui PRIVATE -DQT_USE_QSTRINGBUILDER ) +if (MSVC) + target_compile_options(amuse-gui PRIVATE + # Enforce various standards compliant behavior. + /permissive- + + # Enable standard volatile semantics. + /volatile:iso + + # Reports the proper value for the __cplusplus preprocessor macro. + /Zc:__cplusplus + + # Allow constexpr variables to have explicit external linkage. + /Zc:externConstexpr + + # Assume that new throws exceptions, allowing better code generation. + /Zc:throwingNew + ) +endif() + if(WIN32) target_sources(amuse-gui PRIVATE platforms/win/amuse-gui.rc From 321a229dfda73096ae3ac092cccfe57f6fc27b6d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 21:00:56 -0400 Subject: [PATCH 16/17] AudioGroupPool: Use std::array where applicable Makes the array types strongly-typed and also allows for size querying. --- Editor/SoundMacroEditor.cpp | 9 ++-- include/amuse/AudioGroupPool.hpp | 4 +- lib/AudioGroupPool.cpp | 71 ++++++++++++++++---------------- 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/Editor/SoundMacroEditor.cpp b/Editor/SoundMacroEditor.cpp index 97c0e3f..f7a830e 100644 --- a/Editor/SoundMacroEditor.cpp +++ b/Editor/SoundMacroEditor.cpp @@ -239,14 +239,15 @@ CommandWidget::CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd, amus break; } case amuse::SoundMacro::CmdIntrospection::Field::Type::Choice: { - FieldComboBox* cb = new FieldComboBox(this); + auto* const cb = new FieldComboBox(this); cb->setFixedHeight(30); cb->setProperty("fieldIndex", f); cb->setProperty("fieldName", fieldName); - for (int j = 0; j < 4; ++j) { - if (field.m_choices[j].empty()) + for (const auto choice : field.m_choices) { + if (choice.empty()) { break; - cb->addItem(tr(field.m_choices[j].data())); + } + cb->addItem(tr(choice.data())); } cb->setCurrentIndex(int(amuse::AccessField(m_cmd, field))); connect(cb, qOverload(&FieldComboBox::currentIndexChanged), this, &CommandWidget::numChanged); diff --git a/include/amuse/AudioGroupPool.hpp b/include/amuse/AudioGroupPool.hpp index 74374ba..0d4c4c1 100644 --- a/include/amuse/AudioGroupPool.hpp +++ b/include/amuse/AudioGroupPool.hpp @@ -150,12 +150,12 @@ struct SoundMacro { size_t m_offset; std::string_view m_name; int64_t m_min, m_max, m_default; - std::string_view m_choices[4]; + std::array m_choices; }; CmdType m_tp; std::string_view m_name; std::string_view m_description; - Field m_fields[7]; + std::array m_fields; }; /** Base command interface. All versions of MusyX encode little-endian parameters */ diff --git a/lib/AudioGroupPool.cpp b/lib/AudioGroupPool.cpp index 4860fdd..0960416 100644 --- a/lib/AudioGroupPool.cpp +++ b/lib/AudioGroupPool.cpp @@ -37,41 +37,42 @@ struct MakeDefaultCmdOp { static std::unique_ptr Do(R& r) { std::unique_ptr ret = std::make_unique(); if (const SoundMacro::CmdIntrospection* introspection = SoundMacro::GetCmdIntrospection(r)) { - for (int f = 0; f < 7; ++f) { - const amuse::SoundMacro::CmdIntrospection::Field& field = introspection->m_fields[f]; - if (!field.m_name.empty()) { - switch (field.m_tp) { - case amuse::SoundMacro::CmdIntrospection::Field::Type::Bool: - AccessField(ret.get(), field) = bool(field.m_default); - break; - case amuse::SoundMacro::CmdIntrospection::Field::Type::Int8: - case amuse::SoundMacro::CmdIntrospection::Field::Type::Choice: - AccessField(ret.get(), field) = int8_t(field.m_default); - break; - case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt8: - AccessField(ret.get(), field) = uint8_t(field.m_default); - break; - case amuse::SoundMacro::CmdIntrospection::Field::Type::Int16: - AccessField(ret.get(), field) = int16_t(field.m_default); - break; - case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt16: - AccessField(ret.get(), field) = uint16_t(field.m_default); - break; - case amuse::SoundMacro::CmdIntrospection::Field::Type::Int32: - AccessField(ret.get(), field) = int32_t(field.m_default); - break; - case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt32: - AccessField(ret.get(), field) = uint32_t(field.m_default); - break; - case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroId: - case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroStep: - case amuse::SoundMacro::CmdIntrospection::Field::Type::TableId: - case amuse::SoundMacro::CmdIntrospection::Field::Type::SampleId: - AccessField>(ret.get(), field).id = uint16_t(field.m_default); - break; - default: - break; - } + for (const auto& field : introspection->m_fields) { + if (field.m_name.empty()) { + continue; + } + + switch (field.m_tp) { + case amuse::SoundMacro::CmdIntrospection::Field::Type::Bool: + AccessField(ret.get(), field) = bool(field.m_default); + break; + case amuse::SoundMacro::CmdIntrospection::Field::Type::Int8: + case amuse::SoundMacro::CmdIntrospection::Field::Type::Choice: + AccessField(ret.get(), field) = int8_t(field.m_default); + break; + case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt8: + AccessField(ret.get(), field) = uint8_t(field.m_default); + break; + case amuse::SoundMacro::CmdIntrospection::Field::Type::Int16: + AccessField(ret.get(), field) = int16_t(field.m_default); + break; + case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt16: + AccessField(ret.get(), field) = uint16_t(field.m_default); + break; + case amuse::SoundMacro::CmdIntrospection::Field::Type::Int32: + AccessField(ret.get(), field) = int32_t(field.m_default); + break; + case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt32: + AccessField(ret.get(), field) = uint32_t(field.m_default); + break; + case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroId: + case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroStep: + case amuse::SoundMacro::CmdIntrospection::Field::Type::TableId: + case amuse::SoundMacro::CmdIntrospection::Field::Type::SampleId: + AccessField>(ret.get(), field).id = uint16_t(field.m_default); + break; + default: + break; } } } From ae26ed2fdace7da1bd46bdc414c507b6f772a92d Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 14 Sep 2019 10:07:52 -0700 Subject: [PATCH 17/17] Compile fixes --- Editor/resources/lang_de.ts | 288 ++++++++++----------- lib/SoundMacroState.cpp | 493 +++++++++++++----------------------- 2 files changed, 324 insertions(+), 457 deletions(-) diff --git a/Editor/resources/lang_de.ts b/Editor/resources/lang_de.ts index b5c4af1..1a4c939 100644 --- a/Editor/resources/lang_de.ts +++ b/Editor/resources/lang_de.ts @@ -125,7 +125,7 @@ CommandWidget - + Change %1 @@ -162,26 +162,26 @@ EffectCatalogue - - + + Reverb Standard - - + + Reverb High - - + + Delay - - + + Chorus @@ -197,47 +197,47 @@ KeymapControls - + SoundMacro - + Transpose - + Offset resulting MIDI note - + Pan - + Set initial pan - + Surround - + Initially play through surround channels - + Prio Offset - + Offset resulting priority @@ -1021,7 +1021,7 @@ ModulationSlider - + Modulation: %1 @@ -1184,17 +1184,17 @@ PageObjectProxyModel - + SoundMacros: - + Keymaps: - + Layers: @@ -1215,7 +1215,7 @@ PaintButton - + Activate brush to apply values to keys @@ -1223,7 +1223,7 @@ PitchSlider - + Pitch: %1 @@ -1231,341 +1231,341 @@ ProjectModel - - - - - - + + + + + + Export Error - - - + + + Unable to find group %1 - + Unable to export %1.proj - + Unable to export %1.pool - + Unable to export %1.sdir - + Unable to export %1.samp - + Import Error - + Export Header Error - + Unable to open %1 for reading - + File Exists - + %1 already exists. Overwrite? - + Sound Macros - + ADSRs - + Curves - + Keymaps - + Layers - + Samples - + Naming Conflict - + %1 already exists in this context - + Rename %1 - + Subproject Conflict - + The subproject %1 is already defined - - - + + + Add Subproject %1 - + Sound Group Conflict - - + + The group %1 is already defined - - - + + + Add Sound Group %1 - + Song Group Conflict - - - + + + Add Song Group %1 - + Sound Macro Conflict - + The macro %1 is already defined - - + + Add Sound Macro %1 - + ADSR Conflict - + The ADSR %1 is already defined - - - + + + Add ADSR %1 - + Curve Conflict - + The Curve %1 is already defined - - - + + + Add Curve %1 - + Keymap Conflict - + The Keymap %1 is already defined - - - + + + Add Keymap %1 - + Layers Conflict - + Layers %1 is already defined - - - + + + Add Layers %1 - - + + -copy - + Add SoundMacro %1 - + Cut SongGroup %1 - + Cut SFXGroup %1 - + Cut SoundMacro %1 - + Cut ADSR %1 - + Cut Curve %1 - + Cut Keymap %1 - + Cut Layers %1 - + Delete Subproject - + <p>The subproject %1 will be permanently deleted from the project. Sample files will be permanently removed from the file system.</p><p><strong>This action cannot be undone!</strong></p><p>Continue?</p> - + Delete SongGroup %1 - + Delete SFXGroup %1 - + Delete SoundMacro %1 - + Delete ADSR %1 - + Delete Curve %1 - + Delete Keymap %1 - + Delete Layers %1 - + Delete Sample - + <p>The sample %1 will be permanently deleted from the file system. <p><strong>This action cannot be undone!</strong></p><p>Continue?</p> @@ -1893,72 +1893,72 @@ SoundMacroCatalogue - + Control - + Pitch - + Sample - + Setup - + Special - + Structure - + Volume - + Commands to control the voice - + Commands to control the voice's pitch - + Commands to control the voice's sample playback - + Commands to setup the voice's mixing process - + Miscellaneous commands - + Commands to control macro branching - + Commands to control the voice's volume @@ -1974,17 +1974,17 @@ SoundMacroListing - + Reorder %1 - + Insert %1 - + Delete %1 @@ -1997,17 +1997,17 @@ - + Aux A send level for all voices - + Aux B send level for all voices - + Master volume level @@ -2015,17 +2015,17 @@ StudioSetupWidget - + Studio Setup - + Aux A - + Aux B @@ -2094,7 +2094,7 @@ Uint32X8Button - + Channels @@ -2102,42 +2102,42 @@ Uint32X8Popup - + Front Left - + Front Right - + Rear Left - + Rear Right - + Front Center - + LFE - + Side Left - + Side Right @@ -2145,7 +2145,7 @@ VelocitySlider - + Velocity: %1 diff --git a/lib/SoundMacroState.cpp b/lib/SoundMacroState.cpp index bf31ac3..59e5f65 100644 --- a/lib/SoundMacroState.cpp +++ b/lib/SoundMacroState.cpp @@ -205,9 +205,9 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSplitKey::Introspective = { CmdType::Structure, "Split Key"sv, "Conditionally branches macro execution based on MIDI key."sv, - {{FIELD_HEAD(SoundMacro::CmdSplitKey, key), "Key"sv, 0, 127, 60}, + {{{FIELD_HEAD(SoundMacro::CmdSplitKey, key), "Key"sv, 0, 127, 60}, {FIELD_HEAD(SoundMacro::CmdSplitKey, macro), "Macro"sv, 0, 65535, 65535}, - {FIELD_HEAD(SoundMacro::CmdSplitKey, macroStep), "Macro Step"sv, 0, 65535, 0}}}; + {FIELD_HEAD(SoundMacro::CmdSplitKey, macroStep), "Macro Step"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdSplitKey::Do(SoundMacroState& st, Voice& vox) const { if (st.m_initKey >= key) { /* Do Branch */ @@ -224,9 +224,9 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSplitVel::Introspective = { CmdType::Structure, "Split Velocity"sv, "Conditionally branches macro execution based on velocity."sv, - {{FIELD_HEAD(SoundMacro::CmdSplitVel, velocity), "Key"sv, 0, 127, 100}, + {{{FIELD_HEAD(SoundMacro::CmdSplitVel, velocity), "Key"sv, 0, 127, 100}, {FIELD_HEAD(SoundMacro::CmdSplitVel, macro), "Macro"sv, 0, 65535, 65535}, - {FIELD_HEAD(SoundMacro::CmdSplitVel, macroStep), "Macro Step"sv, 0, 65535, 0}}}; + {FIELD_HEAD(SoundMacro::CmdSplitVel, macroStep), "Macro Step"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdSplitVel::Do(SoundMacroState& st, Voice& vox) const { if (st.m_curVel >= velocity) { /* Do Branch */ @@ -245,12 +245,12 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdWaitTicks::Introspective = { "Suspend SoundMacro execution for specified length of time. Value of 65535 " "will wait indefinitely, relying on Key Off or Sample End to signal stop. " "Absolute mode waits relative to the start of the SoundMacro."sv, - {{FIELD_HEAD(SoundMacro::CmdWaitTicks, keyOff), "Key Off"sv, 0, 1, 0}, + {{{FIELD_HEAD(SoundMacro::CmdWaitTicks, keyOff), "Key Off"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdWaitTicks, random), "Random"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdWaitTicks, sampleEnd), "Sample End"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdWaitTicks, absolute), "Absolute"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdWaitTicks, msSwitch), "Use Millisec"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdWaitTicks, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 96}}}; + {FIELD_HEAD(SoundMacro::CmdWaitTicks, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 96}}}}; bool SoundMacro::CmdWaitTicks::Do(SoundMacroState& st, Voice& vox) const { /* Set wait state */ if (ticksOrMs != 65535) { @@ -283,11 +283,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdLoop::Introspective = { "Loop"sv, "Branch to specified location in a loop for a specified number of Times. " "65535 will cause an endless loop, relying on Key Off or Sample End to signal stop."sv, - {{FIELD_HEAD(SoundMacro::CmdLoop, keyOff), "Key Off"sv, 0, 1, 0}, + {{{FIELD_HEAD(SoundMacro::CmdLoop, keyOff), "Key Off"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdLoop, random), "Random"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdLoop, sampleEnd), "Sample End"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdLoop, macroStep), "Macro Step"sv, 0, 65535, 0}, - {FIELD_HEAD(SoundMacro::CmdLoop, times), "Times"sv, 0, 65535, 0}}}; + {FIELD_HEAD(SoundMacro::CmdLoop, times), "Times"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdLoop::Do(SoundMacroState& st, Voice& vox) const { if ((keyOff && st.m_keyoff) || (sampleEnd && st.m_sampleEnd)) { /* Break out of loop */ @@ -316,8 +316,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdGoto::Introspective = { CmdType::Structure, "Goto"sv, "Unconditional branch to specified SoundMacro location."sv, - {{FIELD_HEAD(SoundMacro::CmdGoto, macro), "Macro"sv, 0, 65535, 65535}, - {FIELD_HEAD(SoundMacro::CmdGoto, macroStep), "Macro Step"sv, 0, 65535, 0}}}; + {{{FIELD_HEAD(SoundMacro::CmdGoto, macro), "Macro"sv, 0, 65535, 65535}, + {FIELD_HEAD(SoundMacro::CmdGoto, macroStep), "Macro Step"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdGoto::Do(SoundMacroState& st, Voice& vox) const { /* Do Branch */ if (macro.id == std::get<0>(st.m_pc.back())) @@ -334,11 +334,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdWaitMs::Introspective = { "Suspend SoundMacro execution for specified length of time. Value of 65535 " "will wait indefinitely, relying on Key Off or Sample End to signal stop. " "Absolute mode waits relative to the start of the SoundMacro."sv, - {{FIELD_HEAD(SoundMacro::CmdWaitMs, keyOff), "Key Off"sv, 0, 1, 0}, + {{{FIELD_HEAD(SoundMacro::CmdWaitMs, keyOff), "Key Off"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdWaitMs, random), "Random"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdWaitMs, sampleEnd), "Sample End"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdWaitMs, absolute), "Absolute"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdWaitMs, ms), "Millisec"sv, 0, 65535, 96}}}; + {FIELD_HEAD(SoundMacro::CmdWaitMs, ms), "Millisec"sv, 0, 65535, 96}}}}; bool SoundMacro::CmdWaitMs::Do(SoundMacroState& st, Voice& vox) const { /* Set wait state */ if (ms != 65535) { @@ -370,11 +370,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPlayMacro::Introspective = { "Play Macro"sv, "Play a SoundMacro in parallel to this one. Add Note is added to the " "current SoundMacro note to evaluate the new note."sv, - {{FIELD_HEAD(SoundMacro::CmdPlayMacro, addNote), "Add Note"sv, -128, 127, 0}, + {{{FIELD_HEAD(SoundMacro::CmdPlayMacro, addNote), "Add Note"sv, -128, 127, 0}, {FIELD_HEAD(SoundMacro::CmdPlayMacro, macro), "Macro"sv, 0, 65535, 65535}, {FIELD_HEAD(SoundMacro::CmdPlayMacro, macroStep), "Macro Step"sv, 0, 65535, 0}, {FIELD_HEAD(SoundMacro::CmdPlayMacro, priority), "Priority"sv, 0, 127, 50}, - {FIELD_HEAD(SoundMacro::CmdPlayMacro, maxVoices), "Max Voices"sv, 0, 255, 255}}}; + {FIELD_HEAD(SoundMacro::CmdPlayMacro, maxVoices), "Max Voices"sv, 0, 255, 255}}}}; bool SoundMacro::CmdPlayMacro::Do(SoundMacroState& st, Voice& vox) const { ObjToken sibVox = vox.startChildMacro(addNote, macro.id, macroStep.step); if (sibVox) @@ -387,8 +387,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSendKeyOff::Introspective = { CmdType::Structure, "Send Key Off"sv, "Send Key Off to voice specified by VID stored in a variable or the last started voice."sv, - {{FIELD_HEAD(SoundMacro::CmdSendKeyOff, variable), "Variable"sv, 0, 31, 0}, - {FIELD_HEAD(SoundMacro::CmdSendKeyOff, lastStarted), "Last Started"sv, 0, 1, 0}}}; + {{{FIELD_HEAD(SoundMacro::CmdSendKeyOff, variable), "Variable"sv, 0, 31, 0}, + {FIELD_HEAD(SoundMacro::CmdSendKeyOff, lastStarted), "Last Started"sv, 0, 1, 0}}}}; bool SoundMacro::CmdSendKeyOff::Do(SoundMacroState& st, Voice& vox) const { if (lastStarted) { if (st.m_lastPlayMacroVid != -1) { @@ -409,9 +409,9 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSplitMod::Introspective = { CmdType::Structure, "Split Mod"sv, "Conditionally branch if mod wheel is greater than or equal to specified value."sv, - {{FIELD_HEAD(SoundMacro::CmdSplitMod, modValue), "Mod Value"sv, 0, 127, 64}, + {{{FIELD_HEAD(SoundMacro::CmdSplitMod, modValue), "Mod Value"sv, 0, 127, 64}, {FIELD_HEAD(SoundMacro::CmdSplitMod, macro), "Macro"sv, 0, 65535, 65535}, - {FIELD_HEAD(SoundMacro::CmdSplitMod, macroStep), "Macro Step"sv, 0, 65535, 0}}}; + {FIELD_HEAD(SoundMacro::CmdSplitMod, macroStep), "Macro Step"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdSplitMod::Do(SoundMacroState& st, Voice& vox) const { if (st.m_curMod >= modValue) { /* Do Branch */ @@ -429,9 +429,9 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPianoPan::Introspective = { "Piano Pan"sv, "Gives piano-like sounds a natural-sounding stereo spread. The current key delta " "from Center Key is scaled with Scale and biased with Center Pan to evaluate panning."sv, - {{FIELD_HEAD(SoundMacro::CmdPianoPan, scale), "Scale"sv, 0, 127, 127}, + {{{FIELD_HEAD(SoundMacro::CmdPianoPan, scale), "Scale"sv, 0, 127, 127}, {FIELD_HEAD(SoundMacro::CmdPianoPan, centerKey), "Center Key"sv, 0, 127, 36}, - {FIELD_HEAD(SoundMacro::CmdPianoPan, centerPan), "Center Pan"sv, 0, 127, 64}}}; + {FIELD_HEAD(SoundMacro::CmdPianoPan, centerPan), "Center Pan"sv, 0, 127, 64}}}}; bool SoundMacro::CmdPianoPan::Do(SoundMacroState& st, Voice& vox) const { int32_t pan = int32_t(st.m_initKey - centerKey) * scale / 127 + centerPan; pan = std::max(-127, std::min(127, pan)); @@ -444,8 +444,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSetAdsr::Introspective = { CmdType::Volume, "Set ADSR"sv, "Specify ADSR envelope using a pool object. DLS mode must match setting in ADSR."sv, - {{FIELD_HEAD(SoundMacro::CmdSetAdsr, table), "ADSR"sv, 0, 65535, 65535}, - {FIELD_HEAD(SoundMacro::CmdSetAdsr, dlsMode), "DLS Mode"sv, 0, 1, 0}}}; + {{{FIELD_HEAD(SoundMacro::CmdSetAdsr, table), "ADSR"sv, 0, 65535, 65535}, + {FIELD_HEAD(SoundMacro::CmdSetAdsr, dlsMode), "DLS Mode"sv, 0, 1, 0}}}}; bool SoundMacro::CmdSetAdsr::Do(SoundMacroState& st, Voice& vox) const { vox.setAdsr(table.id, dlsMode); return false; @@ -456,10 +456,10 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdScaleVolume::Introspective = { "Scale Volume"sv, "Calculates volume by scaling and biasing velocity. " "The result may be passed through an optional Curve."sv, - {{FIELD_HEAD(SoundMacro::CmdScaleVolume, scale), "Scale"sv, 0, 127, 127}, + {{{FIELD_HEAD(SoundMacro::CmdScaleVolume, scale), "Scale"sv, 0, 127, 127}, {FIELD_HEAD(SoundMacro::CmdScaleVolume, add), "Add"sv, 0, 127, 0}, {FIELD_HEAD(SoundMacro::CmdScaleVolume, table), "Curve"sv, 0, 65535, 65535}, - {FIELD_HEAD(SoundMacro::CmdScaleVolume, originalVol), "Original Vol"sv, 0, 1, 1}}}; + {FIELD_HEAD(SoundMacro::CmdScaleVolume, originalVol), "Original Vol"sv, 0, 1, 1}}}}; bool SoundMacro::CmdScaleVolume::Do(SoundMacroState& st, Voice& vox) const { int32_t eval = int32_t(originalVol ? st.m_initVel : st.m_curVel) * scale / 127 + add; eval = std::clamp(eval, 0, 127); @@ -481,9 +481,9 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPanning::Introspective = { CmdType::Control, "Panning"sv, "Start pan-sweep from Pan Position offset by Width over specified time period."sv, - {{FIELD_HEAD(SoundMacro::CmdPanning, panPosition), "Pan Position"sv, 0, 127, 64}, + {{{FIELD_HEAD(SoundMacro::CmdPanning, panPosition), "Pan Position"sv, 0, 127, 64}, {FIELD_HEAD(SoundMacro::CmdPanning, timeMs), "Time Millisec"sv, 0, 65535, 0}, - {FIELD_HEAD(SoundMacro::CmdPanning, width), "Width"sv, -128, 127, 0}}}; + {FIELD_HEAD(SoundMacro::CmdPanning, width), "Width"sv, -128, 127, 0}}}}; bool SoundMacro::CmdPanning::Do(SoundMacroState& st, Voice& vox) const { vox.startPanning(timeMs / 1000.0, panPosition, width); return false; @@ -494,11 +494,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdEnvelope::Introspective = { "Envelope"sv, "Start a velocity envelope by fading the current velocity to the one " "evaluated by Scale and Add. The result is optionally transformed with a Curve object."sv, - {{FIELD_HEAD(SoundMacro::CmdEnvelope, scale), "Scale"sv, 0, 127, 0}, + {{{FIELD_HEAD(SoundMacro::CmdEnvelope, scale), "Scale"sv, 0, 127, 0}, {FIELD_HEAD(SoundMacro::CmdEnvelope, add), "Add"sv, 0, 127, 0}, {FIELD_HEAD(SoundMacro::CmdEnvelope, table), "Curve"sv, 0, 65535, 65535}, {FIELD_HEAD(SoundMacro::CmdEnvelope, msSwitch), "Use Millisec"sv, 0, 1, 1}, - {FIELD_HEAD(SoundMacro::CmdEnvelope, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 500}}}; + {FIELD_HEAD(SoundMacro::CmdEnvelope, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 500}}}}; bool SoundMacro::CmdEnvelope::Do(SoundMacroState& st, Voice& vox) const { double q = msSwitch ? 1000.0 : st.m_ticksPerSec; double secTime = ticksOrMs / q; @@ -522,14 +522,14 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdStartSample::Introspective = { "Start Sample"sv, "Start a Sample playing on the voice. An Offset in samples may be applied. " "This offset may be scaled with the current velocity."sv, - {{FIELD_HEAD(SoundMacro::CmdStartSample, sample), "Sample"sv, 0, 65535, 0}, + {{{FIELD_HEAD(SoundMacro::CmdStartSample, sample), "Sample"sv, 0, 65535, 0}, {FIELD_HEAD(SoundMacro::CmdStartSample, mode), "Velocity Scale"sv, 0, 2, 0, {"No Scale"sv, "Negative"sv, "Positive"sv}}, - {FIELD_HEAD(SoundMacro::CmdStartSample, offset), "Offset"sv, 0, 0xffffff, 0}}}; + {FIELD_HEAD(SoundMacro::CmdStartSample, offset), "Offset"sv, 0, 0xffffff, 0}}}}; bool SoundMacro::CmdStartSample::Do(SoundMacroState& st, Voice& vox) const { uint32_t useOffset = offset; @@ -569,11 +569,9 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSplitRnd::Introspective = { "Split Rnd"sv, "Conditionally branch if a random value is greater than or equal to RND. " "A lower RND will cause a higher probability of branching."sv, - { - {FIELD_HEAD(SoundMacro::CmdSplitRnd, rnd), "RND"sv, 0, 255, 128}, - {FIELD_HEAD(SoundMacro::CmdSplitRnd, macro), "Macro"sv, 0, 65535, 65535}, - {FIELD_HEAD(SoundMacro::CmdSplitRnd, macroStep), "Macro Step"sv, 0, 65535, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdSplitRnd, rnd), "RND"sv, 0, 255, 128}, + {FIELD_HEAD(SoundMacro::CmdSplitRnd, macro), "Macro"sv, 0, 65535, 65535}, + {FIELD_HEAD(SoundMacro::CmdSplitRnd, macroStep), "Macro Step"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdSplitRnd::Do(SoundMacroState& st, Voice& vox) const { if (rnd <= vox.getEngine().nextRandom() % 256) { /* Do branch */ @@ -591,11 +589,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdFadeIn::Introspective = { "Fade In"sv, "Start a velocity envelope by fading from silence to the velocity " "evaluated by Scale and Add. The result is optionally transformed with a Curve object."sv, - {{FIELD_HEAD(SoundMacro::CmdFadeIn, scale), "Scale"sv, 0, 127, 0}, + {{{FIELD_HEAD(SoundMacro::CmdFadeIn, scale), "Scale"sv, 0, 127, 0}, {FIELD_HEAD(SoundMacro::CmdFadeIn, add), "Add"sv, 0, 127, 0}, {FIELD_HEAD(SoundMacro::CmdFadeIn, table), "Curve"sv, 0, 65535, 65535}, {FIELD_HEAD(SoundMacro::CmdFadeIn, msSwitch), "Use Millisec"sv, 0, 1, 1}, - {FIELD_HEAD(SoundMacro::CmdFadeIn, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 500}}}; + {FIELD_HEAD(SoundMacro::CmdFadeIn, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 500}}}}; bool SoundMacro::CmdFadeIn::Do(SoundMacroState& st, Voice& vox) const { float q = msSwitch ? 1000.f : st.m_ticksPerSec; float secTime = ticksOrMs / q; @@ -618,9 +616,9 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSpanning::Introspective = { CmdType::Control, "Spanning"sv, "Start span-sweep from Span Position offset by Width over specified time period."sv, - {{FIELD_HEAD(SoundMacro::CmdSpanning, spanPosition), "Span Position"sv, 0, 127, 64}, + {{{FIELD_HEAD(SoundMacro::CmdSpanning, spanPosition), "Span Position"sv, 0, 127, 64}, {FIELD_HEAD(SoundMacro::CmdSpanning, timeMs), "Time Millisec"sv, 0, 65535, 0}, - {FIELD_HEAD(SoundMacro::CmdSpanning, width), "Width"sv, -128, 127, 0}}}; + {FIELD_HEAD(SoundMacro::CmdSpanning, width), "Width"sv, -128, 127, 0}}}}; bool SoundMacro::CmdSpanning::Do(SoundMacroState& st, Voice& vox) const { vox.startSpanning(timeMs / 1000.0, spanPosition, width); return false; @@ -630,12 +628,10 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSetAdsrCtrl::Introspective = { CmdType::Volume, "Set ADSR Ctrl"sv, "Bind MIDI controls to ADSR parameters."sv, - { - {FIELD_HEAD(SoundMacro::CmdSetAdsrCtrl, attack), "Attack Ctrl"sv, 0, 127, 0}, - {FIELD_HEAD(SoundMacro::CmdSetAdsrCtrl, decay), "Decay Ctrl"sv, 0, 127, 0}, - {FIELD_HEAD(SoundMacro::CmdSetAdsrCtrl, sustain), "Sustain Ctrl"sv, 0, 127, 0}, - {FIELD_HEAD(SoundMacro::CmdSetAdsrCtrl, release), "Release Ctrl"sv, 0, 127, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdSetAdsrCtrl, attack), "Attack Ctrl"sv, 0, 127, 0}, + {FIELD_HEAD(SoundMacro::CmdSetAdsrCtrl, decay), "Decay Ctrl"sv, 0, 127, 0}, + {FIELD_HEAD(SoundMacro::CmdSetAdsrCtrl, sustain), "Sustain Ctrl"sv, 0, 127, 0}, + {FIELD_HEAD(SoundMacro::CmdSetAdsrCtrl, release), "Release Ctrl"sv, 0, 127, 0}}}}; bool SoundMacro::CmdSetAdsrCtrl::Do(SoundMacroState& st, Voice& vox) const { st.m_useAdsrControllers = true; st.m_midiAttack = attack; @@ -658,11 +654,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdRndNote::Introspective = { "Random Note"sv, "Sets random pitch between Note Lo and Note Hi, biased by Detune in cents. " "If Free is set, the note will not snap to key steps."sv, - {{FIELD_HEAD(SoundMacro::CmdRndNote, noteLo), "Note Lo"sv, -127, 127, 48}, + {{{FIELD_HEAD(SoundMacro::CmdRndNote, noteLo), "Note Lo"sv, -127, 127, 48}, {FIELD_HEAD(SoundMacro::CmdRndNote, detune), "Detune"sv, 0, 99, 0}, {FIELD_HEAD(SoundMacro::CmdRndNote, noteHi), "Note Hi"sv, -127, 127, 72}, {FIELD_HEAD(SoundMacro::CmdRndNote, fixedFree), "Free"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdRndNote, absRel), "Absolute"sv, 0, 1, 0}}}; + {FIELD_HEAD(SoundMacro::CmdRndNote, absRel), "Absolute"sv, 0, 1, 0}}}}; bool SoundMacro::CmdRndNote::Do(SoundMacroState& st, Voice& vox) const { int32_t useNoteLo = noteLo; int32_t useNoteHi = noteHi; @@ -693,11 +689,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdAddNote::Introspective = { "Add Note"sv, "Sets new pitch by adding Add, biased by Detune in cents. " "The time parameters behave like a WAIT command when non-zero."sv, - {{FIELD_HEAD(SoundMacro::CmdAddNote, add), "Add"sv, -128, 127, 0}, + {{{FIELD_HEAD(SoundMacro::CmdAddNote, add), "Add"sv, -128, 127, 0}, {FIELD_HEAD(SoundMacro::CmdAddNote, detune), "Detune"sv, -99, 99, 0}, {FIELD_HEAD(SoundMacro::CmdAddNote, originalKey), "Original Key"sv, 0, 1, 1}, {FIELD_HEAD(SoundMacro::CmdAddNote, msSwitch), "Use Millisec"sv, 0, 1, 1}, - {FIELD_HEAD(SoundMacro::CmdAddNote, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 0}}}; + {FIELD_HEAD(SoundMacro::CmdAddNote, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdAddNote::Do(SoundMacroState& st, Voice& vox) const { st.m_curPitch += add * 100 + detune; @@ -719,10 +715,10 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSetNote::Introspective = { "Set Note"sv, "Sets new pitch to Key, biased by Detune in cents. " "The time parameters behave like a WAIT command when non-zero."sv, - {{FIELD_HEAD(SoundMacro::CmdSetNote, key), "Key"sv, 0, 127, 60}, + {{{FIELD_HEAD(SoundMacro::CmdSetNote, key), "Key"sv, 0, 127, 60}, {FIELD_HEAD(SoundMacro::CmdSetNote, detune), "Detune"sv, -99, 99, 0}, {FIELD_HEAD(SoundMacro::CmdSetNote, msSwitch), "Use Millisec"sv, 0, 1, 1}, - {FIELD_HEAD(SoundMacro::CmdSetNote, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 0}}}; + {FIELD_HEAD(SoundMacro::CmdSetNote, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdSetNote::Do(SoundMacroState& st, Voice& vox) const { st.m_curPitch = key * 100 + detune; @@ -744,10 +740,10 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdLastNote::Introspective = { "Last Note"sv, "Sets new pitch by adding Add to last played MIDI note, biased by Detune in cents. " "The time parameters behave like a WAIT command when non-zero."sv, - {{FIELD_HEAD(SoundMacro::CmdLastNote, add), "Key"sv, -128, 127, 0}, + {{{FIELD_HEAD(SoundMacro::CmdLastNote, add), "Key"sv, -128, 127, 0}, {FIELD_HEAD(SoundMacro::CmdLastNote, detune), "Detune"sv, -99, 99, 0}, {FIELD_HEAD(SoundMacro::CmdLastNote, msSwitch), "Use Millisec"sv, 0, 1, 1}, - {FIELD_HEAD(SoundMacro::CmdLastNote, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 0}}}; + {FIELD_HEAD(SoundMacro::CmdLastNote, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdLastNote::Do(SoundMacroState& st, Voice& vox) const { st.m_curPitch = (add + vox.getLastNote()) * 100 + detune; @@ -768,7 +764,7 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPortamento::Introspective = { CmdType::Setup, "Portamento"sv, "Setup portamento mode for this voice."sv, - {{FIELD_HEAD(SoundMacro::CmdPortamento, portState), + {{{FIELD_HEAD(SoundMacro::CmdPortamento, portState), "Port. State"sv, 0, 2, @@ -776,7 +772,7 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPortamento::Introspective = { {"Enable"sv, "Disable"sv, "MIDI Controlled"sv}}, {FIELD_HEAD(SoundMacro::CmdPortamento, portType), "Port. Type"sv, 0, 1, 0, {"Last Pressed"sv, "Always"sv}}, {FIELD_HEAD(SoundMacro::CmdPortamento, msSwitch), "Use Millisec"sv, 0, 1, 1}, - {FIELD_HEAD(SoundMacro::CmdPortamento, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 0}}}; + {FIELD_HEAD(SoundMacro::CmdPortamento, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdPortamento::Do(SoundMacroState& st, Voice& vox) const { st.m_portamentoMode = portState; st.m_portamentoType = portType; @@ -790,23 +786,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdVibrato::Introspective = { "Vibrato"sv, "Setup vibrato mode for this voice. Voice pitch will be " "modulated using the Level magnitude or the modwheel."sv, - {{ - FIELD_HEAD(SoundMacro::CmdVibrato, levelNote), - "Level Note"sv, - -127, - 127, - 0, - }, - { - FIELD_HEAD(SoundMacro::CmdVibrato, levelFine), - "Level Fine"sv, - -99, - 99, - 15, - }, + {{{FIELD_HEAD(SoundMacro::CmdVibrato, levelNote), "Level Note"sv, -127, 127, 0}, + {FIELD_HEAD(SoundMacro::CmdVibrato, levelFine), "Level Fine"sv, -99, 99, 15}, {FIELD_HEAD(SoundMacro::CmdVibrato, modwheelFlag), "Use Modwheel"sv, 0, 1, 1}, {FIELD_HEAD(SoundMacro::CmdVibrato, msSwitch), "Use Millisec"sv, 0, 1, 1}, - {FIELD_HEAD(SoundMacro::CmdVibrato, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 250}}}; + {FIELD_HEAD(SoundMacro::CmdVibrato, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 250}}}}; bool SoundMacro::CmdVibrato::Do(SoundMacroState& st, Voice& vox) const { float q = msSwitch ? 1000.f : st.m_ticksPerSec; vox.setVibrato(levelNote * 100 + levelFine, modwheelFlag, ticksOrMs / q); @@ -818,22 +802,10 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPitchSweep1::Introspective = { "Pitch Sweep 1"sv, "Setup pitch sweep 1 for this voice. Voice pitch will accumulate Add for Times frames. " "If the time values are non-zero, this command also functions as a WAIT."sv, - {{ - FIELD_HEAD(SoundMacro::CmdPitchSweep1, times), - "Times"sv, - 0, - 127, - 100, - }, - { - FIELD_HEAD(SoundMacro::CmdPitchSweep1, add), - "Add"sv, - -32768, - 32767, - 100, - }, + {{{FIELD_HEAD(SoundMacro::CmdPitchSweep1, times), "Times"sv, 0, 127, 100}, + {FIELD_HEAD(SoundMacro::CmdPitchSweep1, add), "Add"sv, -32768, 32767, 100}, {FIELD_HEAD(SoundMacro::CmdPitchSweep1, msSwitch), "Use Millisec"sv, 0, 1, 1}, - {FIELD_HEAD(SoundMacro::CmdPitchSweep1, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 1000}}}; + {FIELD_HEAD(SoundMacro::CmdPitchSweep1, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 1000}}}}; bool SoundMacro::CmdPitchSweep1::Do(SoundMacroState& st, Voice& vox) const { /* Set wait state */ if (msSwitch) { @@ -853,22 +825,10 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPitchSweep2::Introspective = { "Pitch Sweep 2"sv, "Setup pitch sweep 2 for this voice. Voice pitch will accumulate Add for Times frames. " "If the time values are non-zero, this command also functions as a WAIT."sv, - {{ - FIELD_HEAD(SoundMacro::CmdPitchSweep2, times), - "Times"sv, - 0, - 127, - 100, - }, - { - FIELD_HEAD(SoundMacro::CmdPitchSweep2, add), - "Add"sv, - -32768, - 32767, - 100, - }, + {{{FIELD_HEAD(SoundMacro::CmdPitchSweep2, times), "Times"sv, 0, 127, 100}, + {FIELD_HEAD(SoundMacro::CmdPitchSweep2, add), "Add"sv, -32768, 32767, 100}, {FIELD_HEAD(SoundMacro::CmdPitchSweep2, msSwitch), "Use Millisec"sv, 0, 1, 1}, - {FIELD_HEAD(SoundMacro::CmdPitchSweep2, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 1000}}}; + {FIELD_HEAD(SoundMacro::CmdPitchSweep2, ticksOrMs), "Ticks/Millisec"sv, 0, 65535, 1000}}}}; bool SoundMacro::CmdPitchSweep2::Do(SoundMacroState& st, Voice& vox) const { /* Set wait state */ if (msSwitch) { @@ -887,20 +847,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSetPitch::Introspective = { CmdType::Pitch, "Set Pitch"sv, "Set the playback sample rate directly."sv, - {{ - FIELD_HEAD(SoundMacro::CmdSetPitch, hz.val), - "Hz"sv, - 0, - 0xffffff, - 22050, - }, - { - FIELD_HEAD(SoundMacro::CmdSetPitch, fine), - "Level Fine"sv, - 0, - 65535, - 0, - }}}; + {{{FIELD_HEAD(SoundMacro::CmdSetPitch, hz.val), "Hz"sv, 0, 0xffffff, 22050}, + {FIELD_HEAD(SoundMacro::CmdSetPitch, fine), "Level Fine"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdSetPitch::Do(SoundMacroState& st, Voice& vox) const { vox.setPitchFrequency(hz, fine); return false; @@ -911,27 +859,9 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSetPitchAdsr::Introspective = "Set Pitch ADSR"sv, "Define the pitch ADSR from a DLS ADSR pool object. The pitch range is " "specified using Note and Cents parameters."sv, - {{ - FIELD_HEAD(SoundMacro::CmdSetPitchAdsr, table), - "ADSR"sv, - 0, - 65535, - 65535, - }, - { - FIELD_HEAD(SoundMacro::CmdSetPitchAdsr, keys), - "Note range"sv, - -128, - 127, - 0, - }, - { - FIELD_HEAD(SoundMacro::CmdSetPitchAdsr, cents), - "Cents range"sv, - -99, - 99, - 0, - }}}; + {{{FIELD_HEAD(SoundMacro::CmdSetPitchAdsr, table), "ADSR"sv, 0, 65535, 65535}, + {FIELD_HEAD(SoundMacro::CmdSetPitchAdsr, keys), "Note range"sv, -128, 127, 0}, + {FIELD_HEAD(SoundMacro::CmdSetPitchAdsr, cents), "Cents range"sv, -99, 99, 0}}}}; bool SoundMacro::CmdSetPitchAdsr::Do(SoundMacroState& st, Voice& vox) const { vox.setPitchAdsr(table.id, keys * 100 + cents); return false; @@ -941,20 +871,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdScaleVolumeDLS::Introspective CmdType::Volume, "Scale Volume DLS"sv, "Sets new volume by scaling the velocity. A value of 4096 == 100%."sv, - {{ - FIELD_HEAD(SoundMacro::CmdScaleVolumeDLS, scale), - "Scale"sv, - 0, - 16383, - 4096, - }, - { - FIELD_HEAD(SoundMacro::CmdScaleVolumeDLS, originalVol), - "Original Vol"sv, - 0, - 1, - 1, - }}}; + {{{FIELD_HEAD(SoundMacro::CmdScaleVolumeDLS, scale), "Scale"sv, 0, 16383, 4096}, + {FIELD_HEAD(SoundMacro::CmdScaleVolumeDLS, originalVol), "Original Vol"sv, 0, 1, 1}}}}; bool SoundMacro::CmdScaleVolumeDLS::Do(SoundMacroState& st, Voice& vox) const { vox.m_curVol = int32_t(originalVol ? st.m_initVel : st.m_curVel) * scale / 4096.f / 127.f; return false; @@ -964,20 +882,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdMod2Vibrange::Introspective = CmdType::Pitch, "Mod 2 Vibrange"sv, "Values used to scale the modwheel control for vibrato."sv, - {{ - FIELD_HEAD(SoundMacro::CmdMod2Vibrange, keys), - "Key range"sv, - 0, - 16383, - 4096, - }, - { - FIELD_HEAD(SoundMacro::CmdMod2Vibrange, cents), - "Cent range"sv, - 0, - 1, - 1, - }}}; + {{{FIELD_HEAD(SoundMacro::CmdMod2Vibrange, keys), "Key range"sv, 0, 16383, 4096}, + {FIELD_HEAD(SoundMacro::CmdMod2Vibrange, cents), "Cent range"sv, 0, 1, 1}}}}; bool SoundMacro::CmdMod2Vibrange::Do(SoundMacroState& st, Voice& vox) const { vox.setMod2VibratoRange(keys * 100 + cents); return false; @@ -988,20 +894,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSetupTremolo::Introspective = "Setup Tremolo"sv, "Setup tremolo effect. Must be combined with Tremolo Select to connect " "with a configured LFO. A value of 4096 == 100%."sv, - {{ - FIELD_HEAD(SoundMacro::CmdSetupTremolo, scale), - "Scale"sv, - 0, - 16383, - 8192, - }, - { - FIELD_HEAD(SoundMacro::CmdSetupTremolo, modwAddScale), - "Modw. add scale"sv, - 0, - 16383, - 0, - }}}; + {{{FIELD_HEAD(SoundMacro::CmdSetupTremolo, scale), "Scale"sv, 0, 16383, 8192}, + {FIELD_HEAD(SoundMacro::CmdSetupTremolo, modwAddScale), "Modw. add scale"sv, 0, 16383, 0}}}}; bool SoundMacro::CmdSetupTremolo::Do(SoundMacroState& st, Voice& vox) const { vox.setTremolo(scale / 4096.f, scale / 4096.f); return false; @@ -1021,10 +915,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdGoSub::Introspective = { CmdType::Structure, "Go Subroutine"sv, "Push location onto call stack and branch to specified location."sv, - { - {FIELD_HEAD(SoundMacro::CmdSplitRnd, macro), "Macro"sv, 0, 65535, 65535}, - {FIELD_HEAD(SoundMacro::CmdSplitRnd, macroStep), "Macro Step"sv, 0, 65535, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdSplitRnd, macro), "Macro"sv, 0, 65535, 65535}, + {FIELD_HEAD(SoundMacro::CmdSplitRnd, macroStep), "Macro Step"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdGoSub::Do(SoundMacroState& st, Voice& vox) const { if (macro.id == std::get<0>(st.m_pc.back())) st.m_pc.emplace_back(std::get<0>(st.m_pc.back()), std::get<1>(st.m_pc.back()), @@ -1041,16 +933,9 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdTrapEvent::Introspective = { CmdType::Structure, "Trap Event"sv, "Register event-based branch to a specified location."sv, - { - {FIELD_HEAD(SoundMacro::CmdTrapEvent, event), - "Event"sv, - 0, - 2, - 0, - {"Key Off"sv, "Sample End"sv, "Message Recv"sv}}, - {FIELD_HEAD(SoundMacro::CmdTrapEvent, macro), "Macro"sv, 0, 65535, 65535}, - {FIELD_HEAD(SoundMacro::CmdTrapEvent, macroStep), "Macro Step"sv, 0, 65535, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdTrapEvent, event), "Event"sv, 0, 2, 0, {"Key Off"sv, "Sample End"sv, "Message Recv"sv}}, + {FIELD_HEAD(SoundMacro::CmdTrapEvent, macro), "Macro"sv, 0, 65535, 65535}, + {FIELD_HEAD(SoundMacro::CmdTrapEvent, macroStep), "Macro Step"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdTrapEvent::Do(SoundMacroState& st, Voice& vox) const { switch (event) { case EventType::KeyOff: @@ -1076,12 +961,12 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdUntrapEvent::Introspective = { CmdType::Structure, "Untrap Event"sv, "Unregister event-based branch."sv, - {{FIELD_HEAD(SoundMacro::CmdUntrapEvent, event), + {{{FIELD_HEAD(SoundMacro::CmdUntrapEvent, event), "Event"sv, 0, 2, 0, - {"Key Off"sv, "Sample End"sv, "Message Recv"sv}}}}; + {"Key Off"sv, "Sample End"sv, "Message Recv"sv}}}}}; bool SoundMacro::CmdUntrapEvent::Do(SoundMacroState& st, Voice& vox) const { switch (event) { case CmdTrapEvent::EventType::KeyOff: @@ -1108,12 +993,10 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSendMessage::Introspective = { "Send Message"sv, "Send message to SoundMacro or Voice referenced in a variable. " "The message value is retrieved from a variable."sv, - { - {FIELD_HEAD(SoundMacro::CmdSendMessage, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdSendMessage, macro), "Macro"sv, 1, 65535, 65535}, - {FIELD_HEAD(SoundMacro::CmdSendMessage, voiceVar), "Voice Var"sv, 0, 31, 0}, - {FIELD_HEAD(SoundMacro::CmdSendMessage, valueVar), "Value Var"sv, 0, 31, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdSendMessage, isVar), "Is Var"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdSendMessage, macro), "Macro"sv, 1, 65535, 65535}, + {FIELD_HEAD(SoundMacro::CmdSendMessage, voiceVar), "Voice Var"sv, 0, 31, 0}, + {FIELD_HEAD(SoundMacro::CmdSendMessage, valueVar), "Value Var"sv, 0, 31, 0}}}}; bool SoundMacro::CmdSendMessage::Do(SoundMacroState& st, Voice& vox) const { if (isVar) { ObjToken findVox = vox.getEngine().findVoice(st.m_variables[voiceVar & 0x1f]); @@ -1129,7 +1012,7 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdGetMessage::Introspective = { CmdType::Special, "Get Message"sv, "Get voice's latest received message and store its value in Variable."sv, - {{FIELD_HEAD(SoundMacro::CmdGetMessage, variable), "Variable"sv, 0, 31, 0}}}; + {{{FIELD_HEAD(SoundMacro::CmdGetMessage, variable), "Variable"sv, 0, 31, 0}}}}; bool SoundMacro::CmdGetMessage::Do(SoundMacroState& st, Voice& vox) const { st.m_variables[variable & 0x1f] = vox.m_latestMessage; return false; @@ -1139,8 +1022,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdGetVid::Introspective = { CmdType::Special, "Get VID"sv, "Get ID of current voice or last voice started by Play Macro command and store in Variable."sv, - {{FIELD_HEAD(SoundMacro::CmdGetVid, variable), "Variable"sv, 0, 31, 0}, - {FIELD_HEAD(SoundMacro::CmdGetVid, playMacro), "Play Macro"sv, 0, 1, 1}}}; + {{{FIELD_HEAD(SoundMacro::CmdGetVid, variable), "Variable"sv, 0, 31, 0}, + {FIELD_HEAD(SoundMacro::CmdGetVid, playMacro), "Play Macro"sv, 0, 1, 1}}}}; bool SoundMacro::CmdGetVid::Do(SoundMacroState& st, Voice& vox) const { st.m_variables[variable & 0x1f] = playMacro ? st.m_lastPlayMacroVid : vox.vid(); return false; @@ -1150,22 +1033,22 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdAddAgeCount::Introspective = { CmdType::Special, "Add Age Count"sv, "Adds a value to the current voice's age counter."sv, - {{FIELD_HEAD(SoundMacro::CmdAddAgeCount, add), "Add"sv, -32768, 32767, -30000}}}; + {{{FIELD_HEAD(SoundMacro::CmdAddAgeCount, add), "Add"sv, -32768, 32767, -30000}}}}; bool SoundMacro::CmdAddAgeCount::Do(SoundMacroState& st, Voice& vox) const { return false; } const SoundMacro::CmdIntrospection SoundMacro::CmdSetAgeCount::Introspective = { CmdType::Special, "Set Age Count"sv, "Set a value into the current voice's age counter."sv, - {{FIELD_HEAD(SoundMacro::CmdSetAgeCount, counter), "Counter"sv, 0, 65535, 0}}}; + {{{FIELD_HEAD(SoundMacro::CmdSetAgeCount, counter), "Counter"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdSetAgeCount::Do(SoundMacroState& st, Voice& vox) const { return false; } const SoundMacro::CmdIntrospection SoundMacro::CmdSendFlag::Introspective = { CmdType::Special, "Send Flag"sv, "Send a flag value to the host application."sv, - {{FIELD_HEAD(SoundMacro::CmdSendFlag, flagId), "Flag ID"sv, 0, 15, 0}, - {FIELD_HEAD(SoundMacro::CmdSendFlag, value), "Value"sv, 0, 255, 255}}}; + {{{FIELD_HEAD(SoundMacro::CmdSendFlag, flagId), "Flag ID"sv, 0, 15, 0}, + {FIELD_HEAD(SoundMacro::CmdSendFlag, value), "Value"sv, 0, 255, 255}}}}; bool SoundMacro::CmdSendFlag::Do(SoundMacroState& st, Voice& vox) const { /* TODO: figure out a good API */ return false; @@ -1175,8 +1058,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPitchWheelR::Introspective = { CmdType::Setup, "Pitch Wheel Range"sv, "Specifies the number of note steps for the range of the pitch wheel."sv, - {{FIELD_HEAD(SoundMacro::CmdPitchWheelR, rangeUp), "Range Up"sv, 0, 127, 2}, - {FIELD_HEAD(SoundMacro::CmdPitchWheelR, rangeDown), "Range Down"sv, 0, 127, 2}}}; + {{{FIELD_HEAD(SoundMacro::CmdPitchWheelR, rangeUp), "Range Up"sv, 0, 127, 2}, + {FIELD_HEAD(SoundMacro::CmdPitchWheelR, rangeDown), "Range Down"sv, 0, 127, 2}}}}; bool SoundMacro::CmdPitchWheelR::Do(SoundMacroState& st, Voice& vox) const { vox.setPitchWheelRange(rangeUp, rangeDown); return false; @@ -1186,40 +1069,40 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSetPriority::Introspective = { CmdType::Special, "Set Priority"sv, "Sets the priority of the current voice."sv, - {{FIELD_HEAD(SoundMacro::CmdSetPriority, prio), "Priority"sv, 0, 254, 50}}}; + {{{FIELD_HEAD(SoundMacro::CmdSetPriority, prio), "Priority"sv, 0, 254, 50}}}}; bool SoundMacro::CmdSetPriority::Do(SoundMacroState& st, Voice& vox) const { return false; } const SoundMacro::CmdIntrospection SoundMacro::CmdAddPriority::Introspective = { CmdType::Special, "Add Priority"sv, "Adds to the priority of the current voice."sv, - {{FIELD_HEAD(SoundMacro::CmdAddPriority, prio), "Priority"sv, -255, 255, 1}}}; + {{{FIELD_HEAD(SoundMacro::CmdAddPriority, prio), "Priority"sv, -255, 255, 1}}}}; bool SoundMacro::CmdAddPriority::Do(SoundMacroState& st, Voice& vox) const { return false; } const SoundMacro::CmdIntrospection SoundMacro::CmdAgeCntSpeed::Introspective = { CmdType::Special, "Age Count Speed"sv, "Sets the speed the current voice's age counter is decremented."sv, - {{FIELD_HEAD(SoundMacro::CmdAgeCntSpeed, time), "Millisec"sv, 0, 16777215, 1080000}}}; + {{{FIELD_HEAD(SoundMacro::CmdAgeCntSpeed, time), "Millisec"sv, 0, 16777215, 1080000}}}}; bool SoundMacro::CmdAgeCntSpeed::Do(SoundMacroState& st, Voice& vox) const { return false; } const SoundMacro::CmdIntrospection SoundMacro::CmdAgeCntVel::Introspective = { CmdType::Special, "Age Count Velocity"sv, "Sets the current voice's age counter by scaling the velocity."sv, - {{FIELD_HEAD(SoundMacro::CmdAgeCntVel, ageBase), "Base"sv, 0, 65535, 60000}, - {FIELD_HEAD(SoundMacro::CmdAgeCntVel, ageScale), "Scale"sv, 0, 65535, 127}}}; + {{{FIELD_HEAD(SoundMacro::CmdAgeCntVel, ageBase), "Base"sv, 0, 65535, 60000}, + {FIELD_HEAD(SoundMacro::CmdAgeCntVel, ageScale), "Scale"sv, 0, 65535, 127}}}}; bool SoundMacro::CmdAgeCntVel::Do(SoundMacroState& st, Voice& vox) const { return false; } const SoundMacro::CmdIntrospection SoundMacro::CmdVolSelect::Introspective = { CmdType::Setup, "Volume Select"sv, "Appends an evaluator component for computing the voice's volume."sv, - {{FIELD_HEAD(SoundMacro::CmdVolSelect, midiControl), "MIDI Control"sv, 0, 132, 7}, + {{{FIELD_HEAD(SoundMacro::CmdVolSelect, midiControl), "MIDI Control"sv, 0, 132, 7}, {FIELD_HEAD(SoundMacro::CmdVolSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdVolSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdVolSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdVolSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdVolSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdVolSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_volumeSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), SoundMacroState::Evaluator::VarType(isVar)); @@ -1230,11 +1113,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPanSelect::Introspective = { CmdType::Setup, "Pan Select"sv, "Appends an evaluator component for computing the voice's pan."sv, - {{FIELD_HEAD(SoundMacro::CmdPanSelect, midiControl), "MIDI Control"sv, 0, 132, 10}, + {{{FIELD_HEAD(SoundMacro::CmdPanSelect, midiControl), "MIDI Control"sv, 0, 132, 10}, {FIELD_HEAD(SoundMacro::CmdPanSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdPanSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdPanSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdPanSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdPanSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdPanSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_panSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), SoundMacroState::Evaluator::VarType(isVar)); @@ -1245,11 +1128,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPitchWheelSelect::Introspectiv CmdType::Setup, "Pitch Wheel Select"sv, "Appends an evaluator component for computing the voice's pitch wheel."sv, - {{FIELD_HEAD(SoundMacro::CmdPitchWheelSelect, midiControl), "MIDI Control"sv, 0, 132, 128}, + {{{FIELD_HEAD(SoundMacro::CmdPitchWheelSelect, midiControl), "MIDI Control"sv, 0, 132, 128}, {FIELD_HEAD(SoundMacro::CmdPitchWheelSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdPitchWheelSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdPitchWheelSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdPitchWheelSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdPitchWheelSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdPitchWheelSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_pitchWheelSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), @@ -1261,11 +1144,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdModWheelSelect::Introspective CmdType::Setup, "Mod Wheel Select"sv, "Appends an evaluator component for computing the voice's mod wheel."sv, - {{FIELD_HEAD(SoundMacro::CmdModWheelSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, + {{{FIELD_HEAD(SoundMacro::CmdModWheelSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, {FIELD_HEAD(SoundMacro::CmdModWheelSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdModWheelSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdModWheelSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdModWheelSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdModWheelSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdModWheelSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_modWheelSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), @@ -1277,11 +1160,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPedalSelect::Introspective = { CmdType::Setup, "Pedal Select"sv, "Appends an evaluator component for computing the voice's pedal."sv, - {{FIELD_HEAD(SoundMacro::CmdPedalSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, + {{{FIELD_HEAD(SoundMacro::CmdPedalSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, {FIELD_HEAD(SoundMacro::CmdPedalSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdPedalSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdPedalSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdPedalSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdPedalSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdPedalSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_pedalSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), SoundMacroState::Evaluator::VarType(isVar)); @@ -1292,11 +1175,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPortamentoSelect::Introspectiv CmdType::Setup, "Portamento Select"sv, "Appends an evaluator component for computing the voice's portamento."sv, - {{FIELD_HEAD(SoundMacro::CmdPortamentoSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, + {{{FIELD_HEAD(SoundMacro::CmdPortamentoSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, {FIELD_HEAD(SoundMacro::CmdPortamentoSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdPortamentoSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdPortamentoSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdPortamentoSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdPortamentoSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdPortamentoSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_portamentoSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), @@ -1308,11 +1191,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdReverbSelect::Introspective = CmdType::Setup, "Reverb Select"sv, "Appends an evaluator component for computing the voice's reverb."sv, - {{FIELD_HEAD(SoundMacro::CmdReverbSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, + {{{FIELD_HEAD(SoundMacro::CmdReverbSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, {FIELD_HEAD(SoundMacro::CmdReverbSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdReverbSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdReverbSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdReverbSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdReverbSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdReverbSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_reverbSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), SoundMacroState::Evaluator::VarType(isVar)); @@ -1323,11 +1206,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSpanSelect::Introspective = { CmdType::Setup, "Span Select"sv, "Appends an evaluator component for computing the voice's span."sv, - {{FIELD_HEAD(SoundMacro::CmdSpanSelect, midiControl), "MIDI Control"sv, 0, 132, 19}, + {{{FIELD_HEAD(SoundMacro::CmdSpanSelect, midiControl), "MIDI Control"sv, 0, 132, 19}, {FIELD_HEAD(SoundMacro::CmdSpanSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdSpanSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdSpanSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdSpanSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdSpanSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdSpanSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_spanSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), SoundMacroState::Evaluator::VarType(isVar)); @@ -1338,11 +1221,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdDopplerSelect::Introspective = CmdType::Setup, "Doppler Select"sv, "Appends an evaluator component for computing the voice's doppler."sv, - {{FIELD_HEAD(SoundMacro::CmdDopplerSelect, midiControl), "MIDI Control"sv, 0, 132, 132}, + {{{FIELD_HEAD(SoundMacro::CmdDopplerSelect, midiControl), "MIDI Control"sv, 0, 132, 132}, {FIELD_HEAD(SoundMacro::CmdDopplerSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdDopplerSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdDopplerSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdDopplerSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdDopplerSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdDopplerSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_dopplerSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), @@ -1354,11 +1237,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdTremoloSelect::Introspective = CmdType::Setup, "Tremolo Select"sv, "Appends an evaluator component for computing the voice's tremolo."sv, - {{FIELD_HEAD(SoundMacro::CmdTremoloSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, + {{{FIELD_HEAD(SoundMacro::CmdTremoloSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, {FIELD_HEAD(SoundMacro::CmdTremoloSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdTremoloSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdTremoloSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdTremoloSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdTremoloSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdTremoloSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_tremoloSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), @@ -1370,11 +1253,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPreASelect::Introspective = { CmdType::Setup, "PreA Select"sv, "Appends an evaluator component for computing the voice's pre-AUXA."sv, - {{FIELD_HEAD(SoundMacro::CmdPreASelect, midiControl), "MIDI Control"sv, 0, 132, 1}, + {{{FIELD_HEAD(SoundMacro::CmdPreASelect, midiControl), "MIDI Control"sv, 0, 132, 1}, {FIELD_HEAD(SoundMacro::CmdPreASelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdPreASelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdPreASelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdPreASelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdPreASelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdPreASelect::Do(SoundMacroState& st, Voice& vox) const { st.m_preAuxASel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), @@ -1386,11 +1269,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPreBSelect::Introspective = { CmdType::Setup, "PreB Select"sv, "Appends an evaluator component for computing the voice's pre-AUXB."sv, - {{FIELD_HEAD(SoundMacro::CmdPreBSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, + {{{FIELD_HEAD(SoundMacro::CmdPreBSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, {FIELD_HEAD(SoundMacro::CmdPreBSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdPreBSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdPreBSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdPreBSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdPreBSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdPreBSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_preAuxBSel.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), @@ -1402,11 +1285,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdPostBSelect::Introspective = { CmdType::Setup, "PostB Select"sv, "Appends an evaluator component for computing the voice's post-AUXB."sv, - {{FIELD_HEAD(SoundMacro::CmdPostBSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, + {{{FIELD_HEAD(SoundMacro::CmdPostBSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, {FIELD_HEAD(SoundMacro::CmdPostBSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdPostBSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdPostBSelect, isVar), "Is Var"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdPostBSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}; + {FIELD_HEAD(SoundMacro::CmdPostBSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}}}}; bool SoundMacro::CmdPostBSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_postAuxB.addComponent(midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), SoundMacroState::Evaluator::VarType(isVar)); @@ -1417,12 +1300,12 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdAuxAFXSelect::Introspective = CmdType::Setup, "AuxA FX Select"sv, "Appends an evaluator component for computing the AUXA Parameter."sv, - {{FIELD_HEAD(SoundMacro::CmdAuxAFXSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, + {{{FIELD_HEAD(SoundMacro::CmdAuxAFXSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, {FIELD_HEAD(SoundMacro::CmdAuxAFXSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdAuxAFXSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdAuxAFXSelect, isVar), "Is Var"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdAuxAFXSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}, - {FIELD_HEAD(SoundMacro::CmdAuxAFXSelect, paramIndex), "Param Index"sv, 0, 2, 0}}}; + {FIELD_HEAD(SoundMacro::CmdAuxAFXSelect, paramIndex), "Param Index"sv, 0, 2, 0}}}}; bool SoundMacro::CmdAuxAFXSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_auxAFxSel[std::min(paramIndex, atUint8(3))].addComponent( midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), @@ -1434,12 +1317,12 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdAuxBFXSelect::Introspective = CmdType::Setup, "AuxB FX Select"sv, "Appends an evaluator component for computing the AUXB Parameter."sv, - {{FIELD_HEAD(SoundMacro::CmdAuxBFXSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, + {{{FIELD_HEAD(SoundMacro::CmdAuxBFXSelect, midiControl), "MIDI Control"sv, 0, 132, 1}, {FIELD_HEAD(SoundMacro::CmdAuxBFXSelect, scalingPercentage), "Scale Percentage"sv, -10000, 10000, 100}, {FIELD_HEAD(SoundMacro::CmdAuxBFXSelect, combine), "Combine Mode"sv, 0, 2, 0, {"Set"sv, "Add"sv, "Mult"sv}}, {FIELD_HEAD(SoundMacro::CmdAuxBFXSelect, isVar), "Is Var"sv, 0, 1, 0}, {FIELD_HEAD(SoundMacro::CmdAuxBFXSelect, fineScaling), "Fine Scaling"sv, -100, 100, 0}, - {FIELD_HEAD(SoundMacro::CmdAuxBFXSelect, paramIndex), "Param Index"sv, 0, 2, 0}}}; + {FIELD_HEAD(SoundMacro::CmdAuxBFXSelect, paramIndex), "Param Index"sv, 0, 2, 0}}}}; bool SoundMacro::CmdAuxBFXSelect::Do(SoundMacroState& st, Voice& vox) const { st.m_auxBFxSel[std::min(paramIndex, atUint8(3))].addComponent( midiControl, (scalingPercentage + fineScaling / 100.f) / 100.f, SoundMacroState::Evaluator::Combine(combine), @@ -1451,8 +1334,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSetupLFO::Introspective = { CmdType::Setup, "Setup LFO"sv, "Configures voice's LFO period in milliseconds."sv, - {{FIELD_HEAD(SoundMacro::CmdSetupLFO, lfoNumber), "LFO Number"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdSetupLFO, periodInMs), "Period"sv, -10000, 10000, 100}}}; + {{{FIELD_HEAD(SoundMacro::CmdSetupLFO, lfoNumber), "LFO Number"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdSetupLFO, periodInMs), "Period"sv, -10000, 10000, 100}}}}; bool SoundMacro::CmdSetupLFO::Do(SoundMacroState& st, Voice& vox) const { if (lfoNumber == 0) vox.setLFO1Period(periodInMs / 1000.f); @@ -1465,8 +1348,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdModeSelect::Introspective = { CmdType::Setup, "Mode Select"sv, "Sets operating modes for current voice."sv, - {{FIELD_HEAD(SoundMacro::CmdModeSelect, dlsVol), "DLS Vol"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdModeSelect, itd), "ITD"sv, 0, 1, 0}}}; + {{{FIELD_HEAD(SoundMacro::CmdModeSelect, dlsVol), "DLS Vol"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdModeSelect, itd), "ITD"sv, 0, 1, 0}}}}; bool SoundMacro::CmdModeSelect::Do(SoundMacroState& st, Voice& vox) const { vox.m_dlsVol = dlsVol; return false; @@ -1476,8 +1359,8 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSetKeygroup::Introspective = { CmdType::Setup, "Set Keygroup"sv, "Selects keygroup for current voice."sv, - {{FIELD_HEAD(SoundMacro::CmdSetKeygroup, group), "Group"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdSetKeygroup, killNow), "Kill now"sv, 0, 1, 0}}}; + {{{FIELD_HEAD(SoundMacro::CmdSetKeygroup, group), "Group"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdSetKeygroup, killNow), "Kill now"sv, 0, 1, 0}}}}; bool SoundMacro::CmdSetKeygroup::Do(SoundMacroState& st, Voice& vox) const { vox.setKeygroup(0); if (group) { @@ -1491,30 +1374,28 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSRCmodeSelect::Introspective = CmdType::Setup, "SRC Mode Select"sv, "Sets operating modes for sample rate converter."sv, - {{FIELD_HEAD(SoundMacro::CmdSRCmodeSelect, srcType), "SRC Type"sv, 0, 2, 0}, - {FIELD_HEAD(SoundMacro::CmdSRCmodeSelect, type0SrcFilter), "Type 0 SRC Filter"sv, 0, 2, 1}}}; + {{{FIELD_HEAD(SoundMacro::CmdSRCmodeSelect, srcType), "SRC Type"sv, 0, 2, 0}, + {FIELD_HEAD(SoundMacro::CmdSRCmodeSelect, type0SrcFilter), "Type 0 SRC Filter"sv, 0, 2, 1}}}}; bool SoundMacro::CmdSRCmodeSelect::Do(SoundMacroState& st, Voice& vox) const { return false; } const SoundMacro::CmdIntrospection SoundMacro::CmdWiiUnknown::Introspective = { - CmdType::Setup, "Wii Unknown"sv, "????"sv, {{FIELD_HEAD(SoundMacro::CmdWiiUnknown, flag), "?"sv, 0, 1, 0}}}; + CmdType::Setup, "Wii Unknown"sv, "????"sv, {{{FIELD_HEAD(SoundMacro::CmdWiiUnknown, flag), "?"sv, 0, 1, 0}}}}; bool SoundMacro::CmdWiiUnknown::Do(SoundMacroState& st, Voice& vox) const { return false; } const SoundMacro::CmdIntrospection SoundMacro::CmdWiiUnknown2::Introspective = { - CmdType::Setup, "Wii Unknown 2"sv, "????"sv, {{FIELD_HEAD(SoundMacro::CmdWiiUnknown2, flag), "?"sv, 0, 1, 0}}}; + CmdType::Setup, "Wii Unknown 2"sv, "????"sv, {{{FIELD_HEAD(SoundMacro::CmdWiiUnknown2, flag), "?"sv, 0, 1, 0}}}}; bool SoundMacro::CmdWiiUnknown2::Do(SoundMacroState& st, Voice& vox) const { return false; } const SoundMacro::CmdIntrospection SoundMacro::CmdAddVars::Introspective = { CmdType::Special, "Add Vars"sv, "A = B + C"sv, - { - {FIELD_HEAD(SoundMacro::CmdAddVars, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdAddVars, a), "A"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdAddVars, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdAddVars, b), "B"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdAddVars, varCtrlC), "Use Ctrl C"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdAddVars, c), "C"sv, 0, 255, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdAddVars, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdAddVars, a), "A"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdAddVars, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdAddVars, b), "B"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdAddVars, varCtrlC), "Use Ctrl C"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdAddVars, c), "C"sv, 0, 255, 0}}}}; bool SoundMacro::CmdAddVars::Do(SoundMacroState& st, Voice& vox) const { int32_t useB, useC; @@ -1540,14 +1421,12 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSubVars::Introspective = { CmdType::Special, "Sub Vars"sv, "A = B - C"sv, - { - {FIELD_HEAD(SoundMacro::CmdSubVars, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdSubVars, a), "A"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdSubVars, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdSubVars, b), "B"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdSubVars, varCtrlC), "Use Ctrl C"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdSubVars, c), "C"sv, 0, 255, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdSubVars, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdSubVars, a), "A"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdSubVars, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdSubVars, b), "B"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdSubVars, varCtrlC), "Use Ctrl C"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdSubVars, c), "C"sv, 0, 255, 0}}}}; bool SoundMacro::CmdSubVars::Do(SoundMacroState& st, Voice& vox) const { int32_t useB, useC; @@ -1573,14 +1452,12 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdMulVars::Introspective = { CmdType::Special, "Mul Vars"sv, "A = B * C"sv, - { - {FIELD_HEAD(SoundMacro::CmdMulVars, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdMulVars, a), "A"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdMulVars, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdMulVars, b), "B"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdMulVars, varCtrlC), "Use Ctrl C"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdMulVars, c), "C"sv, 0, 255, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdMulVars, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdMulVars, a), "A"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdMulVars, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdMulVars, b), "B"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdMulVars, varCtrlC), "Use Ctrl C"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdMulVars, c), "C"sv, 0, 255, 0}}}}; bool SoundMacro::CmdMulVars::Do(SoundMacroState& st, Voice& vox) const { int32_t useB, useC; @@ -1606,14 +1483,12 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdDivVars::Introspective = { CmdType::Special, "Div Vars"sv, "A = B / C"sv, - { - {FIELD_HEAD(SoundMacro::CmdDivVars, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdDivVars, a), "A"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdDivVars, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdDivVars, b), "B"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdDivVars, varCtrlC), "Use Ctrl C"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdDivVars, c), "C"sv, 0, 255, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdDivVars, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdDivVars, a), "A"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdDivVars, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdDivVars, b), "B"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdDivVars, varCtrlC), "Use Ctrl C"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdDivVars, c), "C"sv, 0, 255, 0}}}}; bool SoundMacro::CmdDivVars::Do(SoundMacroState& st, Voice& vox) const { int32_t useB, useC; @@ -1639,13 +1514,11 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdAddIVars::Introspective = { CmdType::Special, "Add Imm Vars"sv, "A = B + Immediate"sv, - { - {FIELD_HEAD(SoundMacro::CmdAddIVars, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdAddIVars, a), "A"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdAddIVars, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdAddIVars, b), "B"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdAddIVars, imm), "Immediate"sv, -32768, 32767, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdAddIVars, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdAddIVars, a), "A"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdAddIVars, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdAddIVars, b), "B"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdAddIVars, imm), "Immediate"sv, -32768, 32767, 0}}}}; bool SoundMacro::CmdAddIVars::Do(SoundMacroState& st, Voice& vox) const { int32_t useB; @@ -1666,11 +1539,9 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdSetVar::Introspective = { CmdType::Special, "Set Var"sv, "A = Immediate"sv, - { - {FIELD_HEAD(SoundMacro::CmdSetVar, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdSetVar, a), "A"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdSetVar, imm), "Immediate"sv, -32768, 32767, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdSetVar, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdSetVar, a), "A"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdSetVar, imm), "Immediate"sv, -32768, 32767, 0}}}}; bool SoundMacro::CmdSetVar::Do(SoundMacroState& st, Voice& vox) const { if (varCtrlA) vox.setCtrlValue(a, imm); @@ -1684,14 +1555,12 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdIfEqual::Introspective = { CmdType::Structure, "If Equal"sv, "Branches to specified step if A == B."sv, - { - {FIELD_HEAD(SoundMacro::CmdIfEqual, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdIfEqual, a), "A"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdIfEqual, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdIfEqual, b), "B"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdIfEqual, notEq), "Not"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdIfEqual, macroStep), "Macro Step"sv, 0, 65535, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdIfEqual, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdIfEqual, a), "A"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdIfEqual, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdIfEqual, b), "B"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdIfEqual, notEq), "Not"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdIfEqual, macroStep), "Macro Step"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdIfEqual::Do(SoundMacroState& st, Voice& vox) const { int32_t useA, useB; @@ -1715,14 +1584,12 @@ const SoundMacro::CmdIntrospection SoundMacro::CmdIfLess::Introspective = { CmdType::Structure, "If Less"sv, "Branches to specified step if A < B."sv, - { - {FIELD_HEAD(SoundMacro::CmdIfLess, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdIfLess, a), "A"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdIfLess, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdIfLess, b), "B"sv, 0, 255, 0}, - {FIELD_HEAD(SoundMacro::CmdIfLess, notLt), "Not"sv, 0, 1, 0}, - {FIELD_HEAD(SoundMacro::CmdIfLess, macroStep), "Macro Step"sv, 0, 65535, 0}, - }}; + {{{FIELD_HEAD(SoundMacro::CmdIfLess, varCtrlA), "Use Ctrl A"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdIfLess, a), "A"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdIfLess, varCtrlB), "Use Ctrl B"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdIfLess, b), "B"sv, 0, 255, 0}, + {FIELD_HEAD(SoundMacro::CmdIfLess, notLt), "Not"sv, 0, 1, 0}, + {FIELD_HEAD(SoundMacro::CmdIfLess, macroStep), "Macro Step"sv, 0, 65535, 0}}}}; bool SoundMacro::CmdIfLess::Do(SoundMacroState& st, Voice& vox) const { int32_t useA, useB;