diff --git a/.github/workflows/builtin-fx-preset-native.yml b/.github/workflows/builtin-fx-preset-native.yml index 44f981fa5..bfa359c04 100644 --- a/.github/workflows/builtin-fx-preset-native.yml +++ b/.github/workflows/builtin-fx-preset-native.yml @@ -5,6 +5,13 @@ on: paths: - 'src/BuiltInFxUserPresetStore.h' - 'tests/builtin_fx_user_preset_store_test.cpp' + - 'src/BuiltInFxAcceptedSnapshot.h' + - 'tests/builtin_fx_accepted_snapshot_test.cpp' + - 'engine/builtin_fx/ChannelEq.h' + - 'engine/builtin_fx/ChannelEqProcessor.h' + - 'engine/builtin_fx/ChannelCompressorProcessor.h' + - 'engine/builtin_fx/ChannelHarmonyProcessor.h' + - 'engine/builtin_fx/VocalThrowProcessor.h' - '.github/workflows/builtin-fx-preset-native.yml' - 'CMakeLists.txt' @@ -16,8 +23,45 @@ concurrency: cancel-in-progress: true jobs: + scope: + name: Verify tip commit actually changed native preset sources + runs-on: ubuntu-latest + outputs: + build: ${{ steps.diff.outputs.build }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 2 + - name: Check current tip delta, not entire historical PR + id: diff + shell: bash + env: + PR_ACTION: ${{ github.event.action }} + run: | + if [[ "$PR_ACTION" != "synchronize" ]] || ! git rev-parse --verify HEAD^ >/dev/null 2>&1; then + echo 'build=true' >> "$GITHUB_OUTPUT" + elif git diff --name-only HEAD^ HEAD -- \ + CMakeLists.txt src/BuiltInFxUserPresetStore.h \ + src/BuiltInFxAcceptedSnapshot.h \ + tests/builtin_fx_user_preset_store_test.cpp \ + tests/builtin_fx_accepted_snapshot_test.cpp \ + engine/builtin_fx/ChannelEq.h \ + engine/builtin_fx/ChannelEqProcessor.h \ + engine/builtin_fx/ChannelCompressorProcessor.h \ + engine/builtin_fx/ChannelHarmonyProcessor.h \ + engine/builtin_fx/VocalThrowProcessor.h \ + .github/workflows/builtin-fx-preset-native.yml | grep -q .; then + echo 'build=true' >> "$GITHUB_OUTPUT" + else + echo 'build=false' >> "$GITHUB_OUTPUT" + echo 'No native preset target changes at HEAD; Windows CTest already qualified earlier' + fi + native-preset: - name: Windows MSVC single-target actual disk CTest (Release) + name: Windows MSVC two-target disk + accepted DSP CTest (Release) + needs: scope + if: ${{ needs.scope.outputs.build == 'true' }} runs-on: windows-2022 timeout-minutes: 22 steps: @@ -56,19 +100,20 @@ jobs: $catalogText = & ctest --test-dir build -C Release --show-only=json-v1 if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $catalog = ($catalogText | Out-String | ConvertFrom-Json) - if ('BuiltInFxUserPresetNativePortableSaveAndRecovery' -notin - @($catalog.tests | ForEach-Object { $_.name })) { - throw 'PRESET_CTEST_MISSING_EXACT_SOURCE' + $names = @($catalog.tests | ForEach-Object { $_.name }) + foreach ($required in @('BuiltInFxUserPresetNativePortableSaveAndRecovery', + 'BuiltInFxUserPresetFourRealJuceAdaptersAndColdReopen')) { + if ($required -notin $names) { throw "PRESET_CTEST_MISSING:$required" } } - - name: Compile only native preset store test (not the whole mixer) + - name: Compile only two native preset targets (not the mixer) shell: pwsh run: | - cmake --build build --config Release --parallel 2 --target ARMixBuiltInFxPresetStoreTests + cmake --build build --config Release --parallel 2 --target ARMixBuiltInFxPresetStoreTests ARMixBuiltInFxAcceptedSnapshotTests if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - name: Run immutable-source Release CTest (assertions always enabled) shell: pwsh run: | ctest --test-dir build -C Release --output-on-failure ` - -R '^BuiltInFxUserPresetNativePortableSaveAndRecovery$' + -R '^BuiltInFxUserPreset(NativePortableSaveAndRecovery|FourRealJuceAdaptersAndColdReopen)$' if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - Write-Host 'PRESET_NATIVE_MSVC_TARGET_AND_DISK_ROUNDTRIP=PASS' + Write-Host 'PRESET_NATIVE_TWO_TARGETS_STORE_AND_ACCEPTED_PCM_SNAPSHOT=PASS' diff --git a/.github/workflows/harmony-fast-dsp.yml b/.github/workflows/harmony-fast-dsp.yml index cf4324086..a0c4e1168 100644 --- a/.github/workflows/harmony-fast-dsp.yml +++ b/.github/workflows/harmony-fast-dsp.yml @@ -5,6 +5,7 @@ on: paths: - 'engine/builtin_fx/Harmony*.h' - 'tests/harmony*.cpp' + - 'tools/harmony_offline_ab.cpp' - 'CMakeLists.txt' - '.github/workflows/harmony-fast-dsp.yml' permissions: diff --git a/.github/workflows/ui-smoke.yml b/.github/workflows/ui-smoke.yml index 74f4417a6..401350a39 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -293,6 +293,8 @@ jobs: run: python tests/approved_native_peq_smoke.py - name: Native Compressor real Chromium FX, transfer curve, ACK and responsive editor run: python tests/approved_native_compressor_smoke.py + - name: Native Vocal Throw portable My Presets, audio ACK and responsive editor + run: python tests/approved_native_vocal_throw_smoke.py - name: Native Harmony effective-key LCD, Music/Manual ACK, slow readback and geometry run: python tests/approved_native_harmony_smoke.py - name: Cold start first WIRE and original-channel VST3 picker editor diff --git a/CMakeLists.txt b/CMakeLists.txt index b866ca05b..5ba82034e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,6 +151,21 @@ if(BUILD_TESTING) juce::juce_core juce::juce_cryptography juce::juce_recommended_config_flags) target_compile_features(ARMixBuiltInFxPresetStoreTests PRIVATE cxx_std_20) add_test(NAME BuiltInFxUserPresetNativePortableSaveAndRecovery COMMAND ARMixBuiltInFxPresetStoreTests) + # Real JUCE adapters for all four built-in FX: capture ONLY accepted + # settings, validate portable types and re-open .armixfx in another store. + # Never serialize from a published callback or an offline browser fake. + juce_add_console_app(ARMixBuiltInFxAcceptedSnapshotTests PRODUCT_NAME + "ArSonMix Native Built-in FX Accepted Preset Snapshot Tests") + target_sources(ARMixBuiltInFxAcceptedSnapshotTests PRIVATE + tests/builtin_fx_accepted_snapshot_test.cpp + src/BuiltInFxAcceptedSnapshot.h) + target_link_libraries(ARMixBuiltInFxAcceptedSnapshotTests PRIVATE + juce::juce_audio_processors juce::juce_cryptography + juce::juce_recommended_config_flags) + target_compile_features(ARMixBuiltInFxAcceptedSnapshotTests PRIVATE cxx_std_20) + add_test(NAME BuiltInFxUserPresetFourRealJuceAdaptersAndColdReopen + COMMAND ARMixBuiltInFxAcceptedSnapshotTests) + add_executable(ARMixFxStructuralHandoffTests tests/live_fx_structural_handoff_test.cpp) target_compile_features(ARMixFxStructuralHandoffTests PRIVATE cxx_std_20) add_test(NAME R0BStructuralFxAckAndControlThreadRetirement COMMAND ARMixFxStructuralHandoffTests) diff --git a/engine/builtin_fx/ChannelHarmonyProcessor.h b/engine/builtin_fx/ChannelHarmonyProcessor.h index b54cea5cc..641d4fcff 100644 --- a/engine/builtin_fx/ChannelHarmonyProcessor.h +++ b/engine/builtin_fx/ChannelHarmonyProcessor.h @@ -165,7 +165,7 @@ class ChannelHarmonyProcessor final : public juce::AudioProcessor, void getStateInformation(juce::MemoryBlock& out) override { juce::MemoryOutputStream stream(out,false); stream.writeInt(0x41484d31); // AHM1 - stream.writeInt(2); + stream.writeInt(3); stream.writeInt(accepted_.key); stream.writeInt(accepted_.scale); stream.writeInt(accepted_.voices); @@ -176,29 +176,32 @@ class ChannelHarmonyProcessor final : public juce::AudioProcessor, stream.writeFloat(accepted_.gainDb); stream.writeInt(accepted_.guideMode); stream.writeInt64(static_cast(accepted_.guideChannelId)); + stream.writeInt(accepted_.voiceMode); } bool restoreUnpublishedState(const void* bytes,int len) { if(published_||!bytes||len<=0||len>128)return false; juce::MemoryInputStream stream(bytes,static_cast(len),false); if(stream.readInt()!=0x41484d31)return false; const int version=stream.readInt(); - if(version!=1&&version!=2)return false; + if(version!=1&&version!=2&&version!=3)return false; armix::harmony::Settings incoming{}; incoming.key=stream.readInt();incoming.scale=stream.readInt(); incoming.voices=stream.readInt();incoming.correction=stream.readBool(); incoming.wet=stream.readFloat();incoming.space=stream.readFloat(); incoming.color=stream.readFloat();incoming.gainDb=stream.readFloat(); - if(version==2){ + if(version>=2){ incoming.guideMode=stream.readInt(); const auto guide=stream.readInt64(); if(guide<0)return false; incoming.guideChannelId=static_cast(guide); } + if(version==3)incoming.voiceMode=stream.readInt(); + // v1/v2 lacked an explicit Doubler; they stay pitched Harmony. if(stream.getPosition()!=stream.getTotalLength()|| !armix::harmony::valid(incoming))return false; if(ready_&&!dsp_.setSettings(incoming))return false; // NativeMixerSessionFxRestore restores AFTER prepareToPlay. An accepted - // v2 ChannelId must become the actual AUDIO guide source, not merely a + // v2/v3 ChannelId must become the actual AUDIO guide source, not merely a // saved GUI value. This is unpublished/control-thread only. if(ready_) { guide_.reset(); diff --git a/engine/builtin_fx/HarmonyDsp.h b/engine/builtin_fx/HarmonyDsp.h index e1d60272c..f7ecb0a75 100644 --- a/engine/builtin_fx/HarmonyDsp.h +++ b/engine/builtin_fx/HarmonyDsp.h @@ -12,12 +12,16 @@ #include "HarmonyRoomFocus.h" #include "HarmonyStageSpatial.h" #include "HarmonyPitchSynchronous.h" +#include "HarmonyPeriodContinuity.h" +#include "HarmonyLeadTune.h" +#include "HarmonyVoicePlanner.h" // Deterministic, allocation-free vocal harmony DSP. No JUCE or GUI dependency. // Grain shifting is a functioning prototype, not formant-accurate synthesis. namespace armix::harmony { struct Settings { int key=0, scale=0, voices=3; // C=0..B=11; 0=major, 1=natural minor; 2..5 voices + int voiceMode=0; // 0=pitched harmony (2-5), 1=true unison doubler (one wet take) bool correction=false; // Manual is always the trusted fallback. Music follows another accepted // ChannelId only after stable chroma confidence (never a PCM route). @@ -27,6 +31,7 @@ struct Settings { }; inline bool valid(const Settings& s) noexcept { return s.key>=0&&s.key<12&&s.scale>=0&&s.scale<=1&& + s.voiceMode>=0&&s.voiceMode<=1&& s.guideMode>=0&&s.guideMode<=1&& (s.guideMode==0?s.guideChannelId==0:s.guideChannelId>0)&& s.voices>=2&&s.voices<=5&&std::isfinite(s.wet)&&s.wet>=0&&s.wet<=1&& @@ -68,6 +73,7 @@ inline float smoothGrainBlend(float phase) noexcept { class Engine final { public: static constexpr int maxVoices=5; + static_assert(singers.size()==maxVoices); static constexpr int maxPitchLagsPerSlice=8; // fewer burst MACs per sample // Maximum 192 kHz grain is 3072 frames: 2*grain latency + 3*grain // history = 15360, so 16384 frames retain the full rate/ratio budget. @@ -92,7 +98,6 @@ class Engine final { left_.fill(0.f);right_.fill(0.f);mono_.fill(0.f);decimated_.fill(0.f); filtered_.fill(0.f);phase_.fill(0.f);ratio_.fill(1.f);targetRatio_.fill(1.f); // Independent grain clocks avoid five identical backing-singer seams. - // Lead correction keeps its neutral original phase. for(int v=0;v(v)]=.157f*static_cast(v); // Low-pass before downsampling: raw 12 kHz decimation aliases vocal sibilants @@ -103,13 +108,23 @@ class Engine final { !stage_.prepare(rate)||!roomFocus_.prepare(rate))return false; pitchIntervals_.prepare(); pitchSync_.reset(); + leadShifter_.reset(); + leadTune_.prepare(detectEvery_/rate); + leadRatio_=1.f;leadBlend_=0.f;leadPeriod_=0.f; + leadRendering_=false;voicePlanner_.reset(); pitchSyncBlend_.fill(0.f);pitchSyncFiltered_.fill(0.f); + pitchSyncValid_.fill(0.f); + periodContinuity_.reset(); sourcePeriodSamples_=0.f;sourceConfidence_=0.f;sampleClock_=0; + uncertainPitchHops_=0;weakSyncHops_=0;pitchSyncStable_=false; pitchSyncReferenceEnabled_=true; stageDepthReferenceEnabled_=true; roomFocusReferenceEnabled_=true; presenceReferenceEnabled_=true; - pitchSyncAlpha_=static_cast(1.-std::exp(-1./(rate*.012))); + // Both renderer choice and missing-epoch recovery are time-domain + // crossfades. Never hard-switch their independent source phases. + pitchSyncAlpha_=static_cast(1.-std::exp(-1./(rate*.030))); + pitchSyncValidAlpha_=static_cast(1.-std::exp(-1./(rate*.005))); const float cutoff=1800.f; decimationAlpha_=static_cast(1.-std::exp(-2.*3.141592653589793*cutoff/rate)); write_=0;downWrite_=0;downSeen_=0;downCounter_=0; @@ -118,11 +133,19 @@ class Engine final { peakPitchLagWork_=0;completedPitchAnalyses_=0;abandonedPitchAnalyses_=0; noteHold_=0;currentNote_=-1;candidateNote_=-1; guideKey_=-1;guideScale_=-1;tonalTransitionPending_=false; - voiced_=false;voicedGain_=0.f;settings_=Settings{}; + voiced_=false;voicedGain_=0.f;renderersReleased_=true; + settings_=Settings{}; smoothingAlpha_=static_cast(1.-std::exp(-1./(rate*0.005))); // 5 ms control ramp // Preserve the established 48k envelope while keeping durations // constant at 32-192k. Exponents computed off the callback. - voicedGateAlpha_=static_cast(1.-std::pow(1.-0.002,48000./rate)); + // Sustain a noisy, vibrato-heavy sung vowel without 2ms square-like + // envelope edges; real silence is still detected immediately. + voicedGateAlpha_=static_cast(1.-std::exp(-1./(rate*.008))); + // A released pitch estimate must not gate the wet singer with the + // same 8ms attack constant. 18ms release covers transient uncertainty + // without sustaining unvoiced backing indefinitely. Dry lead is + // unaffected; this is a release envelope, not a voice generator. + voicedReleaseAlpha_=static_cast(1.-std::exp(-1./(rate*.018))); ratioAlpha_=static_cast(1.-std::pow(1.-0.00045,48000./rate)); processed_=false;settings_=Settings{}; return setSettings(settings_); @@ -150,15 +173,38 @@ class Engine final { prepared.settings=next; prepared.gain=std::pow(10.f,next.gainDb/20.f); constexpr float pi=3.14159265358979323846f; + if(next.voiceMode==1){ + // Real unison double, NOT 2 pitched harmony voices. One + // independently windowed take follows source F0 at unity ratio. + // A tiny prepared left-back offset plus the existing shared + // room/detune/arrival give a second-take character. + const float pan=-.40f*next.space; + const float angle=(pan+1.f)*pi*.25f; + const float amount=next.wet*(.77f+.38f*next.wet)*.74f; + prepared.mixL[0]=amount*std::cos(angle); + prepared.mixR[0]=amount*std::sin(angle); + out=prepared; + return true; + } + float profileEnergy=0.f; + for(const auto& singer:singers) + if(singerActive(singer.role,next.voices)) + profileEnergy+=singer.presence*singer.presence; const float amplitude=normalizedBackingWetAmplitude( - next.wet,next.voices,enhancedPresence); - for(int v=0;v(v)/(next.voices-1)-1.f); - const float angle=(pan+1.f)*pi*0.25f; - prepared.mixL[v]=amplitude*std::cos(angle); - prepared.mixR[v]=amplitude*std::sin(angle); + next.wet,next.voices,enhancedPresence)* + std::sqrt(static_cast(next.voices)/profileEnergy); + for(std::size_t v=0;v