Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
38 changes: 37 additions & 1 deletion core/AudioEngine/MixerAndFxs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ MixerAndFxs<voicesCount>::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::ChannelId>(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<int voicesCount>
Expand All @@ -39,12 +60,27 @@ AudioMixer<MixerAndFxs<voicesCount>::kSendsInputsCount>* MixerAndFxs<voicesCount
}

template<int voicesCount>
AudioMixer<MixerAndFxs<voicesCount>::kTracksAndSynthVoices>*
AudioMixer<MixerAndFxs<voicesCount>::kTracksMixerInputs>*
MixerAndFxs<voicesCount>::getTracksMixer(MixerAndFxChannelType channel)
{
return &tracksAndSynthMixer[(int)channel];
}

#if FEATURE_REALTIME_FX
template<int voicesCount>
AudioMixer<MixerAndFxs<voicesCount>::kTracksAndSynthVoices>*
MixerAndFxs<voicesCount>::getBusMixer(int bus, MixerAndFxChannelType channel)
{
return &busMixer[bus][(int)channel];
}

template<int voicesCount>
AudioEffectInsert* MixerAndFxs<voicesCount>::getBusInsert(int bus)
{
return &busInsert[bus];
}
#endif

template<int voicesCount>
AudioMixer<MixerAndFxs<voicesCount>::kTrackAndSendsMixerInputs>*
MixerAndFxs<voicesCount>::getTracksAndSendsMixer(MixerAndFxChannelType channel)
Expand Down
22 changes: 20 additions & 2 deletions core/AudioEngine/MixerAndFxs.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef AUDIOENGINE_MIXERANDFXS_H_
#define AUDIOENGINE_MIXERANDFXS_H_
#include "Audio.h"
#include "effect_insert.h"

enum struct MixerAndFxChannelType
{
Expand Down Expand Up @@ -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<kSendsInputsCount>* getPreFxMixer(FxType type);
AudioMixer<kTracksAndSynthVoices>* getTracksMixer(MixerAndFxChannelType channel);
AudioMixer<kTracksMixerInputs>* getTracksMixer(MixerAndFxChannelType channel);
#if FEATURE_REALTIME_FX
// bus-channels: each bus sums the same inputs as the tracks mixer, then runs its insert.
AudioMixer<kTracksAndSynthVoices>* getBusMixer(int bus, MixerAndFxChannelType channel);
AudioEffectInsert* getBusInsert(int bus);
#endif
AudioMixer<kTrackAndSendsMixerInputs>* getTracksAndSendsMixer(MixerAndFxChannelType channel);
AudioEffectShortDelay* getDelay();
AudioEffectPolyverb* getPolyverb();
Expand All @@ -55,8 +68,13 @@ class MixerAndFxs

private:
AudioMixer<kSendsInputsCount> preFxMixer[FxType::kFxCount];
#if FEATURE_REALTIME_FX
// declared before the tracks mixer so they update first in each block
AudioMixer<kTracksAndSynthVoices>
tracksAndSynthMixer[(int)MixerAndFxChannelType::kChannelCount];
busMixer[kBusCount][(int)MixerAndFxChannelType::kChannelCount];
AudioEffectInsert busInsert[kBusCount];
#endif
AudioMixer<kTracksMixerInputs> tracksAndSynthMixer[(int)MixerAndFxChannelType::kChannelCount];
AudioMixer<kTrackAndSendsMixerInputs>
tracksAndSendsMixer[(int)MixerAndFxChannelType::kChannelCount];

Expand Down
82 changes: 76 additions & 6 deletions core/AudioEngine/mtAudioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ void audioEngine::connectVoiceToMixer(AudioVoice* voice, MixerAndFxs<kVoices>* 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),
Expand Down Expand Up @@ -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<kVoices>::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<kVoices>* mixerAndFxs, AudioOutput* output)
{
#if FEATURE_REALTIME_FX
Expand Down Expand Up @@ -642,6 +660,11 @@ void audioEngine::connectSynthToMixer(MixerAndFxs<kVoices>* 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
Expand Down Expand Up @@ -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;
}
Expand All @@ -936,43 +959,90 @@ bool audioEngine::setInsertSlot(int channel, int slot, const strInsertSlot& sett
fx.type = settings.type < insertfx::kTypeCount ? static_cast<insertfx::Type>(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<insertfx::ChannelId>(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<kVoices>::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<MixerAndFxChannelType>(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<kVoices>::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++)
{
insertfx::setSlot(static_cast<insertfx::ChannelId>(channel), slot, off);
}
}
#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
setInsertSlot(channel, slot, stored);
}
}
}
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()
Expand Down
14 changes: 11 additions & 3 deletions core/AudioEngine/mtAudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class audioEngine
void connectVoiceToOutput(AudioVoice* voice, AudioOutput* output, int idx);
void connectInputToOutput(AudioInput* input, AudioOutput* output);
void connectMixerToOutput(MixerAndFxs<kVoices>* 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<kVoices>* mixerAndFxs, SynthVoice* synth);
void connectSynthToExportQueue(SynthVoice* synth, ExportQueues* exportQueues);
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions core/FileManager/fileManagerProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion core/FileManager/mtFileManagerOldVersionRecovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -62,6 +63,7 @@ mtVersionRecovery::mtVersionRecovery()
recoveryProjectFunction[15] = recoveryProjectVersion16;
recoveryProjectFunction[16] = recoveryProjectVersion17;
recoveryProjectFunction[17] = recoveryProjectVersion18;
recoveryProjectFunction[18] = recoveryProjectVersion19;

// INSTRUMENT
recoveryInstrumentFunction[0] = recoveryInstrumentVersion1;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down
Loading
Loading