From bbed570341291c3d3ab10873be361ef361b68126 Mon Sep 17 00:00:00 2001 From: llozd Date: Mon, 23 Nov 2026 22:53:38 +0000 Subject: [PATCH 1/5] skip silenced mixer inputs so an unused mixer sends nothing --- core/libs/Audio/mixer.cpp | 13 ++++++++++++- core/libs/Audio/mixer.h | 10 ++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/libs/Audio/mixer.cpp b/core/libs/Audio/mixer.cpp index 4581e6a..2e010f9 100644 --- a/core/libs/Audio/mixer.cpp +++ b/core/libs/Audio/mixer.cpp @@ -37,7 +37,17 @@ AUDIO_CORE_RAM void AudioMixer::update(void) for (int channel = 0; channel < mixerSize; channel++) { - if (nullptr == out) + if (multiplier[channel] == 0 && previousMultiplier[channel] == 0) + { + // Silenced input: drop it, so a mixer with every input silenced sends nothing and + // what follows can sleep (bus-channels routing works by gain). + in = receiveReadOnly(channel); + if (nullptr != in) + { + release(in); + } + } + else if (nullptr == out) { out = receiveWritable(channel); if (out) @@ -77,4 +87,5 @@ template class AudioMixer<10>; template class AudioMixer<18>; template class AudioMixer<11>; template class AudioMixer<21>; +template class AudioMixer<15>; #endif diff --git a/core/libs/Audio/mixer.h b/core/libs/Audio/mixer.h index ff8c1ef..ac6ea77 100644 --- a/core/libs/Audio/mixer.h +++ b/core/libs/Audio/mixer.h @@ -64,6 +64,16 @@ class AudioMixer : public AudioStream multiplier[channel] = gain * kUnityGain; } + // Like gain(), without the ramp from the previous gain. For setting up before audio starts. + void gainImmediate(unsigned int channel, float value) + { + gain(channel, value); + if (channel < mixerSize) + { + previousMultiplier[channel] = multiplier[channel]; + } + } + void setSaturationType(SaturationType type) { saturationType = type; } private: From 0b6e2cafdc0ab9f0153dff29d98bc94aba2420a8 Mon Sep 17 00:00:00 2001 From: llozd Date: Mon, 23 Nov 2026 23:07:49 +0000 Subject: [PATCH 2/5] store bus outputs, volumes and slots in the project file --- core/FileManager/fileManagerProject.cpp | 1 + .../mtFileManagerOldVersionRecovery.cpp | 10 +++++++- core/interface/projectEditor/fProjEdit.cpp | 12 ++++++++++ core/source/mtStructs.cpp | 16 +++++++++++++ core/source/mtStructs.h | 23 ++++++++++++++++++- 5 files changed, 60 insertions(+), 2 deletions(-) diff --git a/core/FileManager/fileManagerProject.cpp b/core/FileManager/fileManagerProject.cpp index 37eace2..cd9ccfd 100644 --- a/core/FileManager/fileManagerProject.cpp +++ b/core/FileManager/fileManagerProject.cpp @@ -380,6 +380,7 @@ void cFileManager::getDefaultValues(struct strMtValues* source) memset(source->synthPart, 0, sizeof(source->synthPart)); source->recorderGainUsb = 0; + source->setDefaultBuses(); } void cFileManager::getCurrentProjectPathWithName(char* path, int maxLen) diff --git a/core/FileManager/mtFileManagerOldVersionRecovery.cpp b/core/FileManager/mtFileManagerOldVersionRecovery.cpp index fb33ad0..d3ffbb3 100644 --- a/core/FileManager/mtFileManagerOldVersionRecovery.cpp +++ b/core/FileManager/mtFileManagerOldVersionRecovery.cpp @@ -28,6 +28,7 @@ static void recoveryProjectVersion15(); static void recoveryProjectVersion16(); static void recoveryProjectVersion17(); static void recoveryProjectVersion18(); +static void recoveryProjectVersion19(); static void recoveryInstrumentVersion1(); static void recoveryInstrumentVersion2(); static void recoveryInstrumentVersion3(); @@ -62,6 +63,7 @@ mtVersionRecovery::mtVersionRecovery() recoveryProjectFunction[15] = recoveryProjectVersion16; recoveryProjectFunction[16] = recoveryProjectVersion17; recoveryProjectFunction[17] = recoveryProjectVersion18; + recoveryProjectFunction[18] = recoveryProjectVersion19; // INSTRUMENT recoveryInstrumentFunction[0] = recoveryInstrumentVersion1; @@ -345,7 +347,7 @@ static void recoveryProjectVersion14() } static_assert(sizeof(strMtProjectRemote) == - 3528); // if assert hits it is most likely you need to do sth here + 3952); // if assert hits it is most likely you need to do sth here static void recoveryProjectVersion15() { strMtProjectRemote* newProject = versionRecovery.getReadedProject(); @@ -402,6 +404,12 @@ void recoveryProjectVersion18() } } +// Buses: every track and synth part to the master, buses empty. +void recoveryProjectVersion19() +{ + versionRecovery.getReadedProject()->values.setDefaultBuses(); +} + //*************************************************************************INSTRUMENT strInstrumentFile* mtVersionRecovery::getReadedInstrument() diff --git a/core/interface/projectEditor/fProjEdit.cpp b/core/interface/projectEditor/fProjEdit.cpp index 4e8cb57..1549a5c 100644 --- a/core/interface/projectEditor/fProjEdit.cpp +++ b/core/interface/projectEditor/fProjEdit.cpp @@ -455,6 +455,18 @@ uint8_t cProjectEditor::loadProjectValues() if (mtProject.values.patternLength > 255) mtProject.values.patternLength = 32; //---------------------------------------------------------------------------------------------------- + // buses + for (uint8_t& output : mtProject.values.channelOutput) + { + if (output > kBusCount) + output = kOutputMaster; + } + for (uint8_t& volume : mtProject.values.busVolume) + { + if (volume > kBusVolumeMax) + volume = kBusVolumeDefault; + } + //---------------------------------------------------------------------------------------------------- // midi instruments for (uint8_t channel = 0; channel < 16; channel++) { diff --git a/core/source/mtStructs.cpp b/core/source/mtStructs.cpp index 27146fb..4b55cda 100644 --- a/core/source/mtStructs.cpp +++ b/core/source/mtStructs.cpp @@ -13,3 +13,19 @@ void strMtValues::setDefaultTrackName(int trackIdx) sprintf(midiTrackNames[trackIdx - kSampleTracks], "Midi %d", trackIdx + 1); } } + +void strMtValues::setDefaultBuses() +{ + for (uint8_t& output : channelOutput) + { + output = kOutputMaster; + } + for (int bus = 0; bus < kBusCount; bus++) + { + busVolume[bus] = kBusVolumeDefault; + for (strInsertSlot& slot : busInsertSlot[bus]) + { + slot = strInsertSlot{}; + } + } +} diff --git a/core/source/mtStructs.h b/core/source/mtStructs.h index 2a2866a..7b6ccf5 100644 --- a/core/source/mtStructs.h +++ b/core/source/mtStructs.h @@ -47,7 +47,7 @@ const char firmwareVersionLabelFormatBeta[] = "%d.%d.%d " FW_EDITION_NAME " rc % const char firmwareVersionLabelFormatBeta[] = "%d.%d.%d " FW_EDITION_NAME " beta %d"; #endif -const uint8_t PROJECT_FILE_VERSION = 19; // wersja struktury pliku projektu +const uint8_t PROJECT_FILE_VERSION = 20; // wersja struktury pliku projektu const uint8_t INSTRUMENT_FILE_VERSION = 9; // wersja struktury pliku instrumentu const uint8_t PATTERN_FILE_VERSION = 8; @@ -135,6 +135,15 @@ struct strInsertSlot uint8_t reserved = 0; int16_t params[kInsertParams] = {}; }; + +// Buses (bus-channels): tracks and synth parts go to the master or to one of 4 buses, each with +// insert slots and a volume. Insert channel ids 12-15 are the buses. +static constexpr int kBusCount = 4; +static constexpr int kBusSources = kInsertChannels - 1; // 8 sample tracks and 3 synth parts +static constexpr int kAllInsertChannels = kInsertChannels + kBusCount; +static constexpr uint8_t kOutputMaster = 0; // channelOutput: 0 master, 1-4 bus 1-4 +static constexpr uint8_t kBusVolumeMax = 100; +static constexpr uint8_t kBusVolumeDefault = 50; // 0 dB (ampLogValues) static constexpr uint8_t kTotalInstrumentsCount = #ifdef FEATURE_SYNTH kSynthInstrumentsCount + @@ -998,7 +1007,19 @@ struct strMtValues uint8_t recorderGainUsb; uint8_t linesPerBeatIndex = kDefaultLinesPerBeatIndex; strInsertSlot insertSlot[kInsertChannels][kInsertSlots]; + uint8_t channelOutput[kBusSources]; + uint8_t busVolume[kBusCount]; + strInsertSlot busInsertSlot[kBusCount][kInsertSlots]; + void setDefaultTrackName(int trackIdx); + // Every source to the master, buses at 0 dB with empty slots. + void setDefaultBuses(); + // channel: 0-11 as insertSlot, 12-15 the buses. + strInsertSlot& insertSlotOf(int channel, int slot) + { + return channel < kInsertChannels ? insertSlot[channel][slot] + : busInsertSlot[channel - kInsertChannels][slot]; + } }; //---------------------------------------------------------------------------------- From 6c459cb3b147a27c27b4aefc477ffce05ace94cc Mon Sep 17 00:00:00 2001 From: llozd Date: Mon, 23 Nov 2026 23:07:49 +0000 Subject: [PATCH 3/5] route tracks and synth parts to four buses with inserts --- core/AudioEngine/MixerAndFxs.cpp | 38 ++++++++++++- core/AudioEngine/MixerAndFxs.h | 22 +++++++- core/AudioEngine/mtAudioEngine.cpp | 82 ++++++++++++++++++++++++++--- core/AudioEngine/mtAudioEngine.h | 14 +++-- core/libs/Audio/fx/insertChannels.h | 5 +- core/source/devCommands.cpp | 11 +++- 6 files changed, 157 insertions(+), 15 deletions(-) diff --git a/core/AudioEngine/MixerAndFxs.cpp b/core/AudioEngine/MixerAndFxs.cpp index b95a9d2..c3ce2f1 100644 --- a/core/AudioEngine/MixerAndFxs.cpp +++ b/core/AudioEngine/MixerAndFxs.cpp @@ -29,6 +29,27 @@ MixerAndFxs::MixerAndFxs() connections.push_back( new AudioConnection(&tracksAndSynthMixer[channel], 0, &dryMixRMS[channel], 0)); } + +#if FEATURE_REALTIME_FX + for (int bus = 0; bus < kBusCount; bus++) + { + busInsert[bus].attach(static_cast(insertfx::kBus0 + bus)); + for (int channel = 0; channel < (int)MixerAndFxChannelType::kChannelCount; channel++) + { + // Nothing is routed to a bus until the project says so. + for (int input = 0; input < kTracksAndSynthVoices; input++) + { + busMixer[bus][channel].gainImmediate(input, 0.0f); + } + connections.push_back( + new AudioConnection(&busMixer[bus][channel], 0, &busInsert[bus], channel)); + connections.push_back(new AudioConnection(&busInsert[bus], + channel, + &tracksAndSynthMixer[channel], + kTracksAndSynthVoices + bus)); + } + } +#endif } template @@ -39,12 +60,27 @@ AudioMixer::kSendsInputsCount>* MixerAndFxs -AudioMixer::kTracksAndSynthVoices>* +AudioMixer::kTracksMixerInputs>* MixerAndFxs::getTracksMixer(MixerAndFxChannelType channel) { return &tracksAndSynthMixer[(int)channel]; } +#if FEATURE_REALTIME_FX +template +AudioMixer::kTracksAndSynthVoices>* +MixerAndFxs::getBusMixer(int bus, MixerAndFxChannelType channel) +{ + return &busMixer[bus][(int)channel]; +} + +template +AudioEffectInsert* MixerAndFxs::getBusInsert(int bus) +{ + return &busInsert[bus]; +} +#endif + template AudioMixer::kTrackAndSendsMixerInputs>* MixerAndFxs::getTracksAndSendsMixer(MixerAndFxChannelType channel) diff --git a/core/AudioEngine/MixerAndFxs.h b/core/AudioEngine/MixerAndFxs.h index 87f77b6..bc92be2 100644 --- a/core/AudioEngine/MixerAndFxs.h +++ b/core/AudioEngine/MixerAndFxs.h @@ -1,6 +1,7 @@ #ifndef AUDIOENGINE_MIXERANDFXS_H_ #define AUDIOENGINE_MIXERANDFXS_H_ #include "Audio.h" +#include "effect_insert.h" enum struct MixerAndFxChannelType { @@ -39,10 +40,22 @@ class MixerAndFxs static constexpr int kTrackAndSendsMixerInputs = kTrackMixerOutputsCount + kExternalInputsCount + FxType::kFxCount; static constexpr int kTracksAndSynthVoices = voicesCount + kSynthParts; +#if FEATURE_REALTIME_FX + static constexpr int kBusCount = insertfx::kBusCount; +#else + static constexpr int kBusCount = 0; +#endif + // The tracks mixer takes the tracks and synth parts, then the buses' returns. + static constexpr int kTracksMixerInputs = kTracksAndSynthVoices + kBusCount; MixerAndFxs(); AudioMixer* getPreFxMixer(FxType type); - AudioMixer* getTracksMixer(MixerAndFxChannelType channel); + AudioMixer* getTracksMixer(MixerAndFxChannelType channel); +#if FEATURE_REALTIME_FX + // bus-channels: each bus sums the same inputs as the tracks mixer, then runs its insert. + AudioMixer* getBusMixer(int bus, MixerAndFxChannelType channel); + AudioEffectInsert* getBusInsert(int bus); +#endif AudioMixer* getTracksAndSendsMixer(MixerAndFxChannelType channel); AudioEffectShortDelay* getDelay(); AudioEffectPolyverb* getPolyverb(); @@ -55,8 +68,13 @@ class MixerAndFxs private: AudioMixer preFxMixer[FxType::kFxCount]; +#if FEATURE_REALTIME_FX + // declared before the tracks mixer so they update first in each block AudioMixer - tracksAndSynthMixer[(int)MixerAndFxChannelType::kChannelCount]; + busMixer[kBusCount][(int)MixerAndFxChannelType::kChannelCount]; + AudioEffectInsert busInsert[kBusCount]; +#endif + AudioMixer tracksAndSynthMixer[(int)MixerAndFxChannelType::kChannelCount]; AudioMixer tracksAndSendsMixer[(int)MixerAndFxChannelType::kChannelCount]; diff --git a/core/AudioEngine/mtAudioEngine.cpp b/core/AudioEngine/mtAudioEngine.cpp index 16dfff1..1aa1a6e 100644 --- a/core/AudioEngine/mtAudioEngine.cpp +++ b/core/AudioEngine/mtAudioEngine.cpp @@ -377,6 +377,11 @@ void audioEngine::connectVoiceToMixer(AudioVoice* voice, MixerAndFxs* m 0, mixerAndFxs->getTracksMixer(MixerAndFxChannelType::kRight), idx)); +#if FEATURE_REALTIME_FX + connectToBuses(voice->getPanningAmplifier(AudioVoice::VoiceChannels::kLeft), + voice->getPanningAmplifier(AudioVoice::VoiceChannels::kRight), + idx); +#endif connections.push_back( new AudioConnection(voice->getPostFilter(AudioVoice::VoiceChannels::kLeft), @@ -545,6 +550,19 @@ void audioEngine::connectInputToOutput(AudioInput* input, AudioOutput* output) } #endif +#if FEATURE_REALTIME_FX +void audioEngine::connectToBuses(AudioStream* left, AudioStream* right, int input) +{ + for (int bus = 0; bus < MixerAndFxs::kBusCount; bus++) + { + connections.push_back(new AudioConnection( + left, 0, mixerAndFxs.getBusMixer(bus, MixerAndFxChannelType::kLeft), input)); + connections.push_back(new AudioConnection( + right, 0, mixerAndFxs.getBusMixer(bus, MixerAndFxChannelType::kRight), input)); + } +} +#endif + void audioEngine::connectMixerToOutput(MixerAndFxs* mixerAndFxs, AudioOutput* output) { #if FEATURE_REALTIME_FX @@ -642,6 +660,11 @@ void audioEngine::connectSynthToMixer(MixerAndFxs* mixerAndFxs, SynthVo 0, mixerAndFxs->getTracksMixer(MixerAndFxChannelType::kRight), kVoices + synthChannel)); +#if FEATURE_REALTIME_FX + connectToBuses(synth->getPanningAmplifier(synthChannel, SynthVoice::Channels::kLeft), + synth->getPanningAmplifier(synthChannel, SynthVoice::Channels::kRight), + kVoices + synthChannel); +#endif connections.push_back( new AudioConnection(synth->getPolySynth(), // UI shows only mono @@ -927,7 +950,7 @@ void audioEngine::refreshDelayVolume() bool audioEngine::setInsertSlot(int channel, int slot, const strInsertSlot& settings) { - if (channel < 0 || channel >= kInsertChannels || slot < 0 || slot >= kInsertSlots) + if (channel < 0 || channel >= kAllInsertChannels || slot < 0 || slot >= kInsertSlots) { return false; } @@ -936,24 +959,63 @@ bool audioEngine::setInsertSlot(int channel, int slot, const strInsertSlot& sett fx.type = settings.type < insertfx::kTypeCount ? static_cast(settings.type) : insertfx::kOff; static_assert(kInsertParams == insertfx::kParams && kInsertSlots == insertfx::kSlots && - kInsertChannels == insertfx::kChannelCount); + kAllInsertChannels == insertfx::kChannelCount && + kInsertChannels == insertfx::kBus0 && kBusCount == insertfx::kBusCount); memcpy(fx.params, settings.params, sizeof(fx.params)); if (!insertfx::setSlot(static_cast(channel), slot, fx)) { return false; } #endif - mtProject.values.insertSlot[channel][slot] = settings; + mtProject.values.insertSlotOf(channel, slot) = settings; return true; } +void audioEngine::setChannelOutput(int source, uint8_t output) +{ + if (source < 0 || source >= kBusSources || output > kBusCount) + { + return; + } + mtProject.values.channelOutput[source] = output; +#if FEATURE_REALTIME_FX + static_assert(kBusSources == MixerAndFxs::kTracksAndSynthVoices); + // All gains change in the same block; each mixer ramps its own over the block. + DISABLE_AUDIO_INTERRUPTS(); + for (int channel = 0; channel < (int)MixerAndFxChannelType::kChannelCount; channel++) + { + const auto type = static_cast(channel); + mixerAndFxs.getTracksMixer(type)->gain(source, output == kOutputMaster ? 1.0f : 0.0f); + for (int bus = 0; bus < kBusCount; bus++) + { + mixerAndFxs.getBusMixer(bus, type)->gain(source, output == bus + 1 ? 1.0f : 0.0f); + } + } + ENABLE_AUDIO_INTERRUPTS(); +#endif +} + +void audioEngine::setBusVolume(int bus, uint8_t volume) +{ + if (bus < 0 || bus >= kBusCount || volume > kBusVolumeMax) + { + return; + } + mtProject.values.busVolume[bus] = volume; +#if FEATURE_REALTIME_FX + const int input = MixerAndFxs::kTracksAndSynthVoices + bus; + mixerAndFxs.getTracksMixer(MixerAndFxChannelType::kLeft)->gain(input, ampLogValues[volume]); + mixerAndFxs.getTracksMixer(MixerAndFxChannelType::kRight)->gain(input, ampLogValues[volume]); +#endif +} + void audioEngine::refreshInserts() { #if FEATURE_REALTIME_FX // Free every reverb first, so the order of the slots does not matter. insertfx::Slot off; insertfx::setDefaults(off, insertfx::kOff); - for (int channel = 0; channel < kInsertChannels; channel++) + for (int channel = 0; channel < kAllInsertChannels; channel++) { for (int slot = 0; slot < kInsertSlots; slot++) { @@ -961,11 +1023,11 @@ void audioEngine::refreshInserts() } } #endif - for (int channel = 0; channel < kInsertChannels; channel++) + for (int channel = 0; channel < kAllInsertChannels; channel++) { for (int slot = 0; slot < kInsertSlots; slot++) { - strInsertSlot& stored = mtProject.values.insertSlot[channel][slot]; + strInsertSlot& stored = mtProject.values.insertSlotOf(channel, slot); if (!setInsertSlot(channel, slot, stored)) { stored = strInsertSlot{}; // no free reverb: the slot loads empty @@ -973,6 +1035,14 @@ void audioEngine::refreshInserts() } } } + for (int source = 0; source < kBusSources; source++) + { + setChannelOutput(source, mtProject.values.channelOutput[source]); + } + for (int bus = 0; bus < kBusCount; bus++) + { + setBusVolume(bus, mtProject.values.busVolume[bus]); + } } void audioEngine::refreshAllSends() diff --git a/core/AudioEngine/mtAudioEngine.h b/core/AudioEngine/mtAudioEngine.h index d638750..7eb5046 100644 --- a/core/AudioEngine/mtAudioEngine.h +++ b/core/AudioEngine/mtAudioEngine.h @@ -51,6 +51,10 @@ class audioEngine void connectVoiceToOutput(AudioVoice* voice, AudioOutput* output, int idx); void connectInputToOutput(AudioInput* input, AudioOutput* output); void connectMixerToOutput(MixerAndFxs* mixerAndFxs, AudioOutput* output); +#if FEATURE_REALTIME_FX + // Feeds a track or synth part (input: its tracks mixer input) to every bus mixer. + void connectToBuses(AudioStream* left, AudioStream* right, int input); +#endif #ifdef FEATURE_SYNTH void connectSynthToMixer(MixerAndFxs* mixerAndFxs, SynthVoice* synth); void connectSynthToExportQueue(SynthVoice* synth, ExportQueues* exportQueues); @@ -69,10 +73,14 @@ class audioEngine void refreshDelayVolume(); void refreshAllSends(); - // Insert effects (realtime-effects). channel: 0-7 tracks, 8-10 synth parts, 11 master. - // Sets the project's slot and the engine's; false (nothing changed) if no reverb is free. + // Insert effects (realtime-effects). channel: 0-7 tracks, 8-10 synth parts, 11 master, + // 12-15 buses. Sets the project's slot and the engine's; false (nothing changed) if no reverb + // is free. bool setInsertSlot(int channel, int slot, const strInsertSlot& settings); - // Loads every slot of the project into the engine (after a project load). + // Buses (bus-channels). source: 0-7 tracks, 8-10 synth parts. output: kOutputMaster or 1-4. + void setChannelOutput(int source, uint8_t output); + void setBusVolume(int bus, uint8_t volume); // 0-kBusVolumeMax, as ampLogValues + // Loads every slot, output and bus volume of the project into the engine (after a load). void refreshInserts(); void forceLineInStreamVolume(uint8_t value); void refreshLineInStreamVolume(); diff --git a/core/libs/Audio/fx/insertChannels.h b/core/libs/Audio/fx/insertChannels.h index 22d0ba9..38a7983 100644 --- a/core/libs/Audio/fx/insertChannels.h +++ b/core/libs/Audio/fx/insertChannels.h @@ -10,12 +10,15 @@ namespace insertfx { +constexpr int kBusCount = 4; // bus-channels + enum ChannelId : uint8_t { kTrack0 = 0, // 8 sample tracks kSynth0 = 8, // 3 synth parts kMaster = 11, - kChannelCount + kBus0 = 12, // 4 buses (bus-channels) + kChannelCount = kBus0 + kBusCount }; struct Channel diff --git a/core/source/devCommands.cpp b/core/source/devCommands.cpp index 3051c56..205aa08 100644 --- a/core/source/devCommands.cpp +++ b/core/source/devCommands.cpp @@ -14,7 +14,7 @@ namespace { #if FEATURE_REALTIME_FX -// t1..t8, s1..s3 or m +// t1..t8, s1..s3, b1..b4 or m bool parseChannel(const char* s, insertfx::ChannelId& id) { const int n = atoi(s + 1); @@ -30,6 +30,11 @@ bool parseChannel(const char* s, insertfx::ChannelId& id) return false; id = static_cast(insertfx::kSynth0 + n - 1); return true; + case 'b': + if (n < 1 || n > insertfx::kBusCount) + return false; + id = static_cast(insertfx::kBus0 + n - 1); + return true; case 'm': id = insertfx::kMaster; return true; default: return false; } @@ -84,7 +89,9 @@ void handleFx(char* argument, char* reply, size_t size) if (count < 3 || !parseChannel(tokens[0], id) || slotIdx < 0 || slotIdx >= insertfx::kSlots || !parseType(tokens[2], type)) { - snprintf(reply, size, "err usage: fx list | fx t1-t8|s1-s3|m [params]"); + snprintf(reply, + size, + "err usage: fx list | fx t1-t8|s1-s3|b1-b4|m [params]"); return; } From 4cd917499e3d0332c5d5a9a70511d343371a6bc4 Mon Sep 17 00:00:00 2001 From: llozd Date: Mon, 23 Nov 2026 23:07:49 +0000 Subject: [PATCH 4/5] add an out slot to the inserts page for bus routing --- core/interface/masterParams/masterInserts.cpp | 204 ++++++++++++++++-- 1 file changed, 190 insertions(+), 14 deletions(-) diff --git a/core/interface/masterParams/masterInserts.cpp b/core/interface/masterParams/masterInserts.cpp index 7c29b91..2e6d9de 100644 --- a/core/interface/masterParams/masterInserts.cpp +++ b/core/interface/masterParams/masterInserts.cpp @@ -70,17 +70,154 @@ int pickerIndexOf(uint8_t type) return 0; } +// Channel picker order: tracks, synth parts, buses, then the master (insert channel ids). +constexpr uint8_t kChannelOrder[kAllInsertChannels] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, insertfx::kBus0, insertfx::kBus0 + 1, insertfx::kBus0 + 2, + insertfx::kBus0 + 3, insertfx::kMaster +}; +static_assert(insertfx::kBusCount == 4 && kAllInsertChannels == insertfx::kChannelCount); + +int channelOrderIndexOf(uint8_t ch) +{ + for (int i = 0; i < kAllInsertChannels; i++) + { + if (kChannelOrder[i] == ch) + return i; + } + return 0; +} + +bool isBus(uint8_t ch) +{ + return ch >= insertfx::kBus0; +} + +bool isBusSource(uint8_t ch) +{ + return ch < kBusSources; +} + +// bus-channels: after the effect slots, an "Out" slot holds the routing: a track or synth part's +// output, or a bus's volume. The master has none. +bool hasOutSlot(uint8_t ch) +{ + return isBusSource(ch) || isBus(ch); +} + +int slotCount(uint8_t ch) +{ + return kInsertSlots + (hasOutSlot(ch) ? 1 : 0); +} + const char* channelName(uint8_t ch, char* buf, size_t size) { if (ch < kSampleTracks) snprintf(buf, size, "Track %d", ch + 1); - else if (ch < kInsertChannels - 1) + else if (ch < insertfx::kMaster) snprintf(buf, size, "Synth %d", ch - kSampleTracks + 1); + else if (isBus(ch)) + snprintf(buf, size, "Bus %d", ch - insertfx::kBus0 + 1); else snprintf(buf, size, "Master"); return buf; } +const char* outputName(uint8_t output, char* buf, size_t size) +{ + if (output == kOutputMaster) + snprintf(buf, size, "Master"); + else + snprintf(buf, size, "Bus %d", output); + return buf; +} + +// As ampLogValues: 50 is 0 dB, 0.48 dB a step. +void formatBusVolume(uint8_t volume, char* buf, size_t size) +{ + if (volume == 0) + snprintf(buf, size, "-inf dB"); + else + snprintf(buf, size, "%+.1f dB", (volume - kBusVolumeDefault) * 0.48f); +} + +int busSourceCount(uint8_t ch) +{ + int n = 0; + for (uint8_t output : mtProject.values.channelOutput) + { + if (output == ch - insertfx::kBus0 + 1) + n++; + } + return n; +} + +// The Out slot has no effect: it reads as an empty slot. +const strInsertSlot& slotAt(uint8_t ch, uint8_t slot) +{ + static const strInsertSlot kNoEffect{}; + return slot < kInsertSlots ? mtProject.values.insertSlotOf(ch, slot) : kNoEffect; +} + +// The Out slot's controls: Output on a track or synth part; Volume and Inputs on a bus. +void outSlotText(uint8_t ch, int control, char* label, char* value, size_t size) +{ + snprintf(label, size, " "); // an empty place shows a space, like an unused parameter + snprintf(value, size, " "); + if (isBusSource(ch) && control == 0) + { + snprintf(label, size, "Output"); + outputName(mtProject.values.channelOutput[ch], value, size); + } + else if (isBus(ch) && control == 0) + { + snprintf(label, size, "Volume"); + formatBusVolume(mtProject.values.busVolume[ch - insertfx::kBus0], value, size); + } + else if (isBus(ch) && control == 1) + { + snprintf(label, size, "Inputs"); + snprintf(value, size, "%d", busSourceCount(ch)); + } +} + +// Changes an Out slot control by value (encoder steps). Returns false when nothing changed. +bool changeOutSlot(uint8_t ch, int control, int16_t value) +{ + if (isBusSource(ch) && control == 0) + { + const int output = mtProject.values.channelOutput[ch] + (value > 0 ? 1 : -1); + if (output < kOutputMaster || output > kBusCount) + return false; + engine.setChannelOutput(ch, static_cast(output)); + return true; + } + if (isBus(ch) && control == 0) + { + const int bus = ch - insertfx::kBus0; + const int volume = + std::clamp(mtProject.values.busVolume[bus] + value, 0, int{ kBusVolumeMax }); + engine.setBusVolume(bus, static_cast(volume)); + return true; + } + return false; +} + +// Delete on an Out slot control: back to the master, or a bus back to 0 dB. +bool resetOutSlot(uint8_t ch, int control) +{ + if (isBusSource(ch) && control == 0) + { + engine.setChannelOutput(ch, kOutputMaster); + return true; + } + if (isBus(ch) && control == 0) + { + engine.setBusVolume(ch - insertfx::kBus0, kBusVolumeDefault); + return true; + } + return false; +} + int pageCount(const insertfx::Desc& d) { return d.count == 0 ? 1 : (d.count + kParamsPerPage - 1) / kParamsPerPage; @@ -167,7 +304,8 @@ void cMasterParams::showInsertsScreen() void cMasterParams::showInsertsValues() { - const strInsertSlot& slot = mtProject.values.insertSlot[insertsChannel][insertsSlot]; + const bool outSlot = insertsSlot >= kInsertSlots; + const strInsertSlot& slot = slotAt(insertsChannel, insertsSlot); const insertfx::Desc& d = insertfx::describe(static_cast(slot.type)); const int pages = pageCount(d); if (insertsPage >= pages) @@ -176,9 +314,12 @@ void cMasterParams::showInsertsValues() snprintf(labelText[kPlaceChannel], sizeof(labelText[0]), "Channel"); channelName(insertsChannel, valueText[kPlaceChannel], sizeof(valueText[0])); snprintf(labelText[kPlaceSlot], sizeof(labelText[0]), "Slot"); - snprintf(valueText[kPlaceSlot], sizeof(valueText[0]), "%d", insertsSlot + 1); + if (outSlot) + snprintf(valueText[kPlaceSlot], sizeof(valueText[0]), "Out"); + else + snprintf(valueText[kPlaceSlot], sizeof(valueText[0]), "%d", insertsSlot + 1); snprintf(labelText[kPlaceEffect], sizeof(labelText[0]), "Effect"); - snprintf(valueText[kPlaceEffect], sizeof(valueText[0]), "%s", d.name); + snprintf(valueText[kPlaceEffect], sizeof(valueText[0]), "%s", outSlot ? "-" : d.name); snprintf(labelText[kPlacePage], sizeof(labelText[0]), "Page"); snprintf(valueText[kPlacePage], sizeof(valueText[0]), "%d/%d", insertsPage + 1, pages); @@ -187,7 +328,11 @@ void cMasterParams::showInsertsValues() const int param = insertsPage * kParamsPerPage + i; char* lt = labelText[kPlaceFirstParam + i]; char* vt = valueText[kPlaceFirstParam + i]; - if (param < d.count) + if (outSlot) + { + outSlotText(insertsChannel, i, lt, vt, sizeof(valueText[0])); + } + else if (param < d.count) { snprintf(lt, sizeof(labelText[0]), "%s", d.p[param].label); formatValue(d.p[param], slot.params[param], vt, sizeof(valueText[0])); @@ -220,13 +365,21 @@ void cMasterParams::showInsertsValues() show = dynamics; else if (i >= kPlaceFirstParam) show = !eq && insertsPage * kParamsPerPage + (i - kPlaceFirstParam) < d.count; + const bool volumeBar = outSlot && isBus(insertsChannel) && i == kPlaceFirstParam; + show = show || volumeBar; display.setControlStyle(barControl[i], (i == kPlaceEffect ? controlStyleReverse_0_100 : controlStyleValue_0_100) | controlStyleBackground | shadow | gradient); barData[i].value = i <= kPlaceSlot ? display.getTheme().green : i == kPlaceEffect ? display.getTheme().cyan : display.getTheme().white; - if (i >= kPlaceFirstParam && show) + if (volumeBar) + { + display.setControlValue(barControl[i], + mtProject.values.busVolume[insertsChannel - insertfx::kBus0] * + 100 / kBusVolumeMax); + } + else if (i >= kPlaceFirstParam && show) { const int param = insertsPage * kParamsPerPage + (i - kPlaceFirstParam); const insertfx::ParamDesc& p = d.p[param]; @@ -292,7 +445,7 @@ void cMasterParams::insertsRefreshMeters() display.setControlValue(barControl[kPlaceSlot], static_cast(outMeter)); display.refreshControl(barControl[kPlaceSlot]); - const strInsertSlot& slot = mtProject.values.insertSlot[insertsChannel][insertsSlot]; + const strInsertSlot& slot = slotAt(insertsChannel, insertsSlot); if (insertfx::isDynamics(static_cast(slot.type))) { const float gr = insertfx::gainReductionDb(id, insertsSlot); @@ -331,29 +484,34 @@ void cMasterParams::insertsMove(int8_t direction) void cMasterParams::insertsChange(int16_t value) { - strInsertSlot slot = mtProject.values.insertSlot[insertsChannel][insertsSlot]; + const bool outSlot = insertsSlot >= kInsertSlots; + strInsertSlot slot = slotAt(insertsChannel, insertsSlot); const insertfx::Desc& d = insertfx::describe(static_cast(slot.type)); switch (selectedPlaceInserts) { case kPlaceChannel: { - const int ch = insertsChannel + (value > 0 ? 1 : -1); - if (ch >= 0 && ch < kInsertChannels) - insertsChannel = static_cast(ch); + const int idx = channelOrderIndexOf(insertsChannel) + (value > 0 ? 1 : -1); + if (idx >= 0 && idx < kAllInsertChannels) + insertsChannel = kChannelOrder[idx]; + if (insertsSlot >= slotCount(insertsChannel)) + insertsSlot = kInsertSlots - 1; // the master has no Out slot insertsPage = 0; break; } case kPlaceSlot: { const int s = insertsSlot + (value > 0 ? 1 : -1); - if (s >= 0 && s < kInsertSlots) + if (s >= 0 && s < slotCount(insertsChannel)) insertsSlot = static_cast(s); insertsPage = 0; break; } case kPlaceEffect: { + if (outSlot) + return; int idx = pickerIndexOf(slot.type) + (value > 0 ? 1 : -1); if (idx < 0 || idx >= insertfx::kTypeCount) break; @@ -381,6 +539,13 @@ void cMasterParams::insertsChange(int16_t value) } default: { + if (outSlot) + { + if (!changeOutSlot(insertsChannel, selectedPlaceInserts - kPlaceFirstParam, value)) + return; + newFileManager.setProjectStructChanged(); + break; + } const int param = insertsPage * kParamsPerPage + (selectedPlaceInserts - kPlaceFirstParam); if (param >= d.count) return; @@ -399,10 +564,21 @@ void cMasterParams::insertsChange(int16_t value) display.synchronizeRefresh(); } -// Delete: on the effect, clears the slot; on a parameter, restores its default. +// Delete: on the effect, clears the slot; on a parameter, restores its default; on an Out slot +// control, routes back to the master or sets the bus to 0 dB. void cMasterParams::insertsClear() { - strInsertSlot slot = mtProject.values.insertSlot[insertsChannel][insertsSlot]; + if (insertsSlot >= kInsertSlots) + { + if (selectedPlaceInserts < kPlaceFirstParam || + !resetOutSlot(insertsChannel, selectedPlaceInserts - kPlaceFirstParam)) + return; + newFileManager.setProjectStructChanged(); + showInsertsValues(); + display.synchronizeRefresh(); + return; + } + strInsertSlot slot = mtProject.values.insertSlotOf(insertsChannel, insertsSlot); if (selectedPlaceInserts == kPlaceEffect) { slot = strInsertSlot{}; From 324fe755044927cd24e597e2e1ce1b3a4b54ba6d Mon Sep 17 00:00:00 2001 From: llozd Date: Tue, 24 Nov 2026 07:52:45 +0000 Subject: [PATCH 5/5] document bus channels --- CHANGELOG.md | 11 ++++++ README.md | 1 + docs/realtime_effects.md | 25 ++++++++++--- openspec/README.md | 1 + openspec/changes/bus-channels/design.md | 37 +++++++++++++++++++ openspec/changes/bus-channels/proposal.md | 25 +++++++++++++ .../changes/bus-channels/specs/buses/spec.md | 37 +++++++++++++++++++ openspec/changes/bus-channels/tasks.md | 12 ++++++ 8 files changed, 143 insertions(+), 6 deletions(-) create mode 100644 openspec/changes/bus-channels/design.md create mode 100644 openspec/changes/bus-channels/proposal.md create mode 100644 openspec/changes/bus-channels/specs/buses/spec.md create mode 100644 openspec/changes/bus-channels/tasks.md diff --git a/CHANGELOG.md b/CHANGELOG.md index ead4301..4aafd18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to the **Polyend Tracker Community Edition (CE)** firmware a --- +## [Unreleased] + +### Added +* **Buses (Tracker+ and Mini)**: 4 buses, each with 3 insert slots and a volume. Send any sample track or synth part to a bus from its **Out** slot on the Inserts page, to share effects such as an EQ and a compressor across channels. See [`docs/realtime_effects.md`](docs/realtime_effects.md#buses). +* **Dev console**: `fx` takes `b1` to `b4` for the buses. + +### Changed +* Project files are version 20. Older projects open with every channel sent to the master. + +--- + ## [ENH 0.1.0 rc 1] - First Tracker Enhanced Release Candidate > **Release candidate.** Most of what is new since beta 1 is not yet tested on hardware. Back up your microSD card before flashing. Projects saved with Tracker Enhanced will not open on stock or Community Edition firmware. diff --git a/README.md b/README.md index 4e91c12..b1d2a20 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Three insert slots on every sample track, synth part and the master, set on the * **Dynamics**: compressor, limiter, glue (bus) compressor and FET compressor. * **Drive and colour**: overdrive, digital clip, bit crush, soft clip, diode drive, tape, tube, transformer, console, saturator and exciter. * **Motion and space**: chorus (makes mono synth parts stereo), flanger, phaser and reverb (up to 4 reverb inserts at once). +* **Buses**: send any track or synth part to one of 4 buses, each with its own 3 insert slots and volume, to share an EQ or compressor across several channels. Not yet tested on hardware, and CPU limits are still to be measured. diff --git a/docs/realtime_effects.md b/docs/realtime_effects.md index ee4ab19..cd364b3 100644 --- a/docs/realtime_effects.md +++ b/docs/realtime_effects.md @@ -1,6 +1,6 @@ # Realtime Insert Effects (Tracker+ and Tracker Mini) -Every audio channel has **3 insert effect slots**: the 8 sample tracks, the 3 synth parts and the master. Effects run live while you play and are saved with the project. MIDI tracks have no audio, so they have no inserts. The Original Tracker does not have inserts. +Every audio channel has **3 insert effect slots**: the 8 sample tracks, the 3 synth parts, the 4 buses and the master. Effects run live while you play and are saved with the project. MIDI tracks have no audio, so they have no inserts. The Original Tracker does not have inserts. --- @@ -10,8 +10,8 @@ Press **Master** to cycle through the Master screen's pages: **Master**, **Mixer | Field | Button | What it does | | :--- | :---: | :--- | -| **Channel** | F1 | Track 1 to 8, Synth 1 to 3, or Master | -| **Slot** | F2 | Slot 1, 2 or 3 of that channel. Slots run in order: slot 1 feeds slot 2, which feeds slot 3 | +| **Channel** | F1 | Track 1 to 8, Synth 1 to 3, Bus 1 to 4, or Master | +| **Slot** | F2 | Slot 1, 2 or 3 of that channel. Slots run in order: slot 1 feeds slot 2, which feeds slot 3. Tracks, synth parts and buses also have an **Out** slot after slot 3 (see [Buses](#buses)) | | **Effect** | F3 | The effect in the slot, or Off | | **Page** | F4 | Which group of 4 parameters the last four fields show | | **Parameters** | F5 to F8 | The effect's parameters, 4 per page | @@ -29,11 +29,24 @@ The bars above the fields show what the channel is doing: --- +## Buses + +The 4 buses group channels, so they can share effects. For example, to put one EQ and one compressor on tracks 1 to 4, send those tracks to Bus 1 and put the effects on Bus 1. + +* **Send a channel to a bus**: pick the track or synth part as the Channel, turn Slot past 3 to **Out**, then set **Output** (F5) to Master or Bus 1 to 4. Delete on Output sends it back to Master. +* **Bus level**: pick the bus as the Channel and go to its **Out** slot. **Volume** (F5) runs from silent to +24 dB, 0 dB by default (Delete resets it). **Inputs** (F6) shows how many channels go to the bus. +* A channel sent to a bus is taken after its own inserts, volume and pan, and plays only through the bus. The bus then goes to the master mix, before the master inserts. +* Delay and reverb sends stay on the channel, so they are not affected by the bus's effects. +* Stems and multi-channel USB audio take each track from before the bus. A song export of the master includes the buses. + +--- + ## Where the inserts sit * **Sample tracks**: after the track's filter, before its volume and pan. The track's delay and reverb sends hear the effect. * **Synth parts**: before the part's sends, so the sends hear the effect. A chorus or reverb makes a mono synth part stereo. -* **Master**: on the whole mix (tracks, sends and inputs), before the limiter. +* **Buses**: on the sum of the channels sent to the bus, before the bus volume. +* **Master**: on the whole mix (tracks, buses, sends and inputs), before the limiter. --- @@ -71,10 +84,10 @@ The drives and colour effects keep quiet signals at the same level and add chara * **Reverb**: up to 4 reverb inserts at once (each needs 64 KB of memory). Picking a fifth shows **No free reverb**. The master reverb send is separate and always available. * **CPU**: many effects on every channel can use a lot of processing power. If audio starts to break up, remove some effects. -* Empty slots cost nothing, and a channel's effects stop working once its input is silent and their tails have died out. +* Empty slots cost nothing, and a channel's effects stop working once its input is silent and their tails have died out. A bus with nothing sent to it costs nothing. --- ## Projects -Insert settings are saved with the project. Projects made before inserts existed open with every slot empty. Projects with inserts open on the Original Tracker too, which keeps the settings but does not play the effects. +Insert settings, bus outputs and bus volumes are saved with the project. Projects made before inserts existed open with every slot empty, and projects made before buses existed open with every channel sent to the master. Projects with inserts open on the Original Tracker too, which keeps the settings but does not play the effects. diff --git a/openspec/README.md b/openspec/README.md index 6f8e8e1..7913997 100644 --- a/openspec/README.md +++ b/openspec/README.md @@ -7,6 +7,7 @@ Change records for Tracker Enhanced, in [OpenSpec](https://github.com/Fission-AI | [lines-per-beat](changes/lines-per-beat/proposal.md) | Complete (PRs #3 to #7), tested on Tracker+ | | [extended-midi-cc](changes/extended-midi-cc/proposal.md) | Planned | | [realtime-effects](changes/realtime-effects/proposal.md) | Implemented, untested on hardware | +| [bus-channels](changes/bus-channels/proposal.md) | Implemented, untested on hardware | | [legato-rolls](changes/legato-rolls/proposal.md) | Implemented, untested on hardware | | [button-hold-release](changes/button-hold-release/proposal.md) | Investigating | | [position-fx-slices](changes/position-fx-slices/proposal.md) | Implemented, untested on hardware | diff --git a/openspec/changes/bus-channels/design.md b/openspec/changes/bus-channels/design.md new file mode 100644 index 0000000..02535f7 --- /dev/null +++ b/openspec/changes/bus-channels/design.md @@ -0,0 +1,37 @@ +# Design + +## Audio graph + +``` +track / synth part panning L/R --+--> tracks mixer (input 0-10, gain 1 or 0) + +--> bus mixer 1-4 (input 0-10, gain 1 or 0) -> bus insert 1-4 --+ + | +tracks mixer (inputs 11-14: bus returns, gain = bus volume) <-------------------------------------+ + -> tracks and sends mixer -> master insert -> limiter +``` + +- `MixerAndFxs` owns `busMixer[4][L/R]` (`AudioMixer<11>`) and `busInsert[4]` (`AudioEffectInsert` on insert channels 12-15). They are declared before the tracks mixer so they update first in each block, with no extra latency. +- The tracks mixer grows from 11 to 15 inputs on the Plus and Mini (`kTracksMixerInputs`). On the Original `kBusCount` is 0, so nothing changes there. +- `audioEngine::connectToBuses` feeds each track's and synth part's panning amplifiers to every bus mixer, at the same input index as the tracks mixer. + +## Routing by gain +- `setChannelOutput` sets the source's gain to 1 in the one mixer it goes to and 0 in the other four, with the audio interrupt off so all of them change in the same block. `AudioMixer` ramps each gain over one block, so a change does not click. +- `AudioMixer::update` now drops an input whose gain is 0 (and was 0 in the previous block) without mixing it. A mixer whose inputs are all silenced sends no block, so an unused bus mixer costs a loop over its inputs, and its insert sleeps. Before this, a 0-gain input still produced a block of zeros, which would have kept every bus insert awake. +- `AudioMixer::gainImmediate` sets a gain without the ramp. The bus mixers start with every input at 0 through it, so the first block does not fade a track into every bus. +- Bus volume is the bus return's gain in the tracks mixer, through `ampLogValues` (0-100, 50 is 0 dB, 0.48 dB a step). + +## Storage +- Appended to `strMtValues`: `uint8_t channelOutput[11]` (0 master, 1-4 bus), `uint8_t busVolume[4]`, `strInsertSlot busInsertSlot[4][3]`. `strMtProjectRemote` grows from 3528 to 3952 B. +- The existing `insertSlot[12][3]` is not reshaped. `strMtValues::insertSlotOf(channel, slot)` maps insert channels 0-11 to it and 12-15 to `busInsertSlot`. +- `PROJECT_FILE_VERSION` 19 to 20. `recoveryProjectVersion19` and `getDefaultValues` call `strMtValues::setDefaultBuses` (everything to the master, buses at 0 dB and empty). `loadProjectValues` sets an out-of-range output to the master and an out-of-range volume to 0 dB. +- `audioEngine::refreshInserts` loads the bus slots with the rest, then every output and bus volume. + +## Memory (Tracker+) +- `EXTERNAL_RAM`: 12 more insert slots (delay lines and state), about 96 KB. +- `SRAM_DTC`: 8 mixers, 4 inserts and 4 more tracks mixer inputs. +- See the PR for the measured linker table. + +## CPU +- No input routed to a bus: the bus mixers send nothing and the bus inserts do nothing. +- A bus with no effects: one mixer pass per side and a pass-through insert. +- A bus's effects cost the same as on any other channel, and share the pool of 4 reverbs. diff --git a/openspec/changes/bus-channels/proposal.md b/openspec/changes/bus-channels/proposal.md new file mode 100644 index 0000000..5393a56 --- /dev/null +++ b/openspec/changes/bus-channels/proposal.md @@ -0,0 +1,25 @@ +# Bus channels + +**Status: implemented**, untested on hardware. CPU cost to be measured with the inserts. + +**Platforms:** Plus and Mini only, built on [realtime-effects](../realtime-effects/proposal.md) and wrapped in `#if FEATURE_REALTIME_FX`. The Original stores the settings and ignores them, so projects stay portable. + +## Why +Shared processing on a group of channels (one EQ and one compressor on tracks 1 to 4, say) needs an effect on every track today, which costs CPU per track and does not compress the group as a whole. + +## What changes +- **4 buses**, each with 3 insert slots (the same effects as every other channel) and a volume. +- **An output per sample track and synth part**: Master (default) or Bus 1 to 4. The channel is taken after its own inserts, volume and pan, and plays only through its bus. +- Buses go into the master mix, before the master inserts and the limiter. +- Delay and reverb sends stay on the channel (tapped before volume, as now), so the bus effects work on the dry signal. +- Stems and multi-channel USB audio still take each track before the bus. The master export includes the buses. + +## UI +On the Master screen's Inserts page, the Channel picker gains Bus 1 to 4 (between the synth parts and the master), and Slot gains an **Out** slot after slot 3 on tracks, synth parts and buses: +- Track or synth part: F5 **Output** (Master, Bus 1 to 4). +- Bus: F5 **Volume** (silent to +24 dB, 0 dB default), F6 **Inputs** (how many channels go to it, read only). +- Delete on these restores Master or 0 dB. + +## Out of scope +- Bus pan and mute, sending a bus to another bus, and sends from a bus. +- A bus stem in the export. diff --git a/openspec/changes/bus-channels/specs/buses/spec.md b/openspec/changes/bus-channels/specs/buses/spec.md new file mode 100644 index 0000000..905bcc0 --- /dev/null +++ b/openspec/changes/bus-channels/specs/buses/spec.md @@ -0,0 +1,37 @@ +## ADDED Requirements + +### Requirement: Channels can be sent to a bus +Each sample track and synth part SHALL have an output of Master or Bus 1 to 4, saved with the project. + +#### Scenario: Group tracks on a bus +- **WHEN** tracks 1 to 4 have Output set to Bus 1, and Bus 1 has an EQ and a compressor +- **THEN** tracks 1 to 4 are heard only through Bus 1's EQ and compressor, at their own volume and pan + +#### Scenario: Changing the output while playing +- **WHEN** a playing track's output changes +- **THEN** the sound moves to the new output without a click + +### Requirement: Buses have inserts and a volume +Each bus SHALL have 3 insert slots and a volume, and SHALL feed the master mix before the master inserts. + +#### Scenario: Bus volume +- **WHEN** a bus's volume is changed +- **THEN** every channel on that bus gets louder or quieter together, after the bus effects + +#### Scenario: Unused bus +- **WHEN** no channel is sent to a bus +- **THEN** the bus adds no sound and no noticeable CPU load + +### Requirement: Sends stay on the channel +Delay and reverb sends SHALL be taken from the channel as before, whatever its output. + +#### Scenario: Reverb send on a bused track +- **WHEN** a track on a bus has a reverb send +- **THEN** the reverb hears the track without the bus effects + +### Requirement: Older projects +Projects saved before buses SHALL open with every channel sent to the master and every bus empty at 0 dB. + +#### Scenario: Open a version 19 project +- **WHEN** a project saved before buses existed is opened +- **THEN** it sounds as it did before diff --git a/openspec/changes/bus-channels/tasks.md b/openspec/changes/bus-channels/tasks.md new file mode 100644 index 0000000..943bb46 --- /dev/null +++ b/openspec/changes/bus-channels/tasks.md @@ -0,0 +1,12 @@ +# Tasks + +- [x] Skip 0-gain inputs in `AudioMixer` so an unused mixer sends nothing +- [x] Insert channels 12-15 for the buses (`insertfx::kBus0`), dev console `fx b1`-`b4` +- [x] Bus mixers and bus inserts in `MixerAndFxs`, returns into the tracks mixer +- [x] Feed tracks and synth parts to the bus mixers, routing by gain (`setChannelOutput`, `setBusVolume`) +- [x] Store outputs, volumes and bus slots (project version 20, upgrade step, defaults, load checks) +- [x] Inserts page: Bus 1-4 channels, Out slot with Output, Volume and Inputs +- [x] Docs: `docs/realtime_effects.md`, README, CHANGELOG +- [ ] Hardware: route tracks to a bus, check the effect, level and no clicks on changing output +- [ ] Hardware: measure the CPU cost of an idle bus and a bus with effects +- [ ] Hardware: open a version 19 project and check every channel plays through the master