Repository navigation
Firmware Add An Engine
This page is the recipe for a sixth synth engine. It tells you where the engine's sound is made, every place that names the engines, how to test it, and the traps.
An engine is the source of a voice's signal chain. Read Sound Engine first: it shows the chain and what the five engines do with the knobs A and B. Words like carrier, modulator, FM index and control step are in the Glossary.
Before you start, get a clean run of every suite (Running The Tests): then a failure later is yours.
- No format changes. The engine is one byte of the patch (byte 1), so a patch stays 28 bytes and the patch format stays 2.
-
But older devices refuse it.
sfx_patch_unpackrefuses an engine number it does not know. A firmware up to 1.7.2 refuses engine 5, so a sound that uses it cannot go to an older firmware. -
The identity changes by itself. Byte 14 of the identity's 18 bytes, counted from 0 as the table on
Link Protocol counts them, is
SFX_ENGINE_COUNT(ident_pumpinfw_link.h). It will say 6, and the tests that hold the identity's bytes must follow. That byte is also how a game knows whether a device takes the new engine.
| Where | What |
|---|---|
core/sfx_core.h |
the entry in sfx_engine, its branch in sfx__control, its branch in sfx_voice_render, the comments that say "five" |
sfx-forge/fw_sounds.h |
ENGINE_NAME, ENGINE_SHORT, ENGINE_RGB, a factory sound that uses it |
sfx-forge/fw_draw_parts.h |
param_name, param_text: what A and B are called and how their values read |
sfx-forge/fw_draw_sound.h |
the picture of the sound |
other parts that name SFX_ENGINE_...
|
fw_pages.h, fw_softkeys.h, fw_draw.h, fw_events.h, fw_link.h, fw_stage_draw.h, fw_stage_input.h
|
native/ |
nothing to write; rebuild the DLL |
C#, Runtime/Core
|
SfxPatch.cs (SfxEngine, EngineCount, EngineNames, Label), SfxGenerator.cs (Recipes), SfxProfile.cs
|
C#, Editor/UI
|
SfxUnits.cs (EngineNames, ParamName), SfxKit.cs (SfxColors.Engines) |
| tests and documents | the identity's bytes; README, the manual, the cheat sheet |
flowchart TB
eng["sfx_engine<br/>core/sfx_core.h"]
control["sfx__control<br/>what A and B do, the pitch, the filter"]
render["sfx_voice_render<br/>the source, the drive"]
fwnames["ENGINE_NAME, ENGINE_SHORT, ENGINE_RGB<br/>fw_sounds.h"]
fwtext["param_name, param_text<br/>fw_draw_parts.h"]
ident["ident_pump: the identity says the count<br/>fw_link.h"]
dll["sfxforge.dll<br/>sh native/build.sh"]
cs["SfxEngine, EngineCount, SfxProfile, SfxUnits<br/>the Unity package"]
eng --> control
eng --> render
eng --> fwnames
eng --> fwtext
eng --> ident
control --> dll
render --> dll
dll --> cs
ident --> cs
The engine has two branches: one in the control step (every 16 samples), one in the sample loop (every sample). Everything around them is shared by all engines and needs no change.
| Branch | It may read | It must leave | Done for you after it |
|---|---|---|---|
in sfx__control
|
p[SFX_P_FM_RATIO] (A) and p[SFX_P_FM_DEPTH] (B), 0 to 127; oct (the pitch, octaves above 20 Hz), sweep (the pitch envelope now), cut_oct (the filter), timbre (telemetry and the LFO) |
v->idx and v->mdt: 0 when there is no FM, as the three named branches set them. It may add to oct or cut_oct
|
v->dt (the phase step) from oct + sweep, the filter's coefficients, v->lvl
|
in sfx_voice_render
|
v->phase, 0 to 1, one cycle of the pitch |
x: this sample of the source, about -1 to 1 |
v->phase moves on by v->dt; noise, filter, drive, bitcrush, loudness |
The smallest engine that follows this, to show the form (a plain sine; SFX_ENGINE_NEW is your entry's name; this
sketch was not built):
/* in sfx__control, before the last else */
} else if (eng == SFX_ENGINE_NEW) {
/* A and B would become numbers here */
v->idx = 0.0f;
v->mdt = 0.0f;
} else {
/* in sfx_voice_render, before the last else */
} else if (eng == SFX_ENGINE_NEW) {
x = SFX_SIN(v->phase); /* SFX_SIN takes turns: 1.0 is a full circle */
} else {If the engine needs memory of its own (as arp_t is UI BLIP's and gr_t is FOLEY's): add the field to sfx_voice
(section 3), set it in sfx_voice_trigger, which fills every field of a voice, and work out anything that depends
only on the patch in sfx_voice_set_patch (as v->unison is). Nothing may allocate. A bigger sfx_voice needs no
other change: C# asks the DLL for the sizes (sfxn_voice_size, sfxn_player_size).
-
Name it. In
core/sfx_core.h, section 2, add the entry tosfx_enginebeforeSFX_ENGINE_COUNT. Write what its knobs A and B do into the comment over theSFX_P_*list.sfx_patch_init,sfx_patch_pack,sfx_patch_unpackandsfx_patch_randomfollowSFX_ENGINE_COUNTby themselves. -
The control step. In
sfx__control, add a branch of its own in the chain ofifs over the engines. This is where A and B become numbers the sample loop uses. Look also at the two lines under the chain: the carrier's frequency (FOLEY leaves the pitch envelope out of it) and the modulator's step (set for IMPACT and SCI-FI FM only). -
The sample loop. In
sfx_voice_render, add its branch in the chain that makes the source. Look at thedriveline at the top and at the filter's output (FOLEY takes the band-pass, the others the low-pass). -
The prose that says "five". The header of
sfx_core.h, the comment oversfx_engine, and "0..4" in section 6. -
The firmware. Run this and read every hit:
grep -n SFX_ENGINE_ sfx-forge/*.hAt the least: a sixth entry in each of
ENGINE_NAME,ENGINE_SHORTandENGINE_RGBinfw_sounds.h(the arrays haveSFX_ENGINE_COUNTplaces, and a place left out is a null name), the names and texts of A and B infw_draw_parts.h, and the picture infw_draw_sound.h. Several hits ask "is this a WAVETABLE sound?" (the WAVE page is for a wavetable only): decide what each means for your engine. -
A factory sound. Add a row at the end of
PRESETSinfw_sounds.h. The rows after the first 16 are the MUSIC kit's named sounds, so you hear it with F1 PRESET while the MUSIC kit is chosen. -
The native library. Run
sh native/build.sh. You see the DLL'sls -lline. -
C#. Nothing here follows the C by itself: the package has its own copy of the list.
-
Runtime/Core/SfxPatch.cs: the member ofSfxEngine,EngineCount(6),EngineNames, and the names of A and B inLabel. -
Runtime/Core/SfxProfile.cs:VibeFm1takes its count fromEngineCount; add a profile for the firmware before, with 5, asVibeFm15is one for 1.5. -
Runtime/Core/SfxGenerator.cs:Recipes, if a kind of the NEW generator should use the engine. -
Editor/UI/SfxUnits.cs:EngineNamesandParamName.Editor/UI/SfxKit.cs: a sixth colour inSfxColors.Engines.
-
-
Documents. README,
docs/MANUAL.md(sections 6, 7 and 20), the cheat sheet (docs/figures.py).
| Step | Command | What you see |
|---|---|---|
| the firmware builds and nothing else broke | sh build.sh |
lines that say PASSED; the identity check fails until you update its expected bytes |
| the identity's bytes | in tests/check-identity.mjs: the 5 after the 16 in WANT, and 05 in the hex string under it |
identity PASSED |
| the identities in C# |
tests/dotnet/IdentityTests.cs holds the answers of firmware 1.4.0 and 1.6.0 as bytes, with 5 engines (1.7.2 is made from the second). They stay as they are; give those devices the profile for the firmware before, and add the new firmware's answer |
its ok lines about the identity |
| the engine through the DLL | dotnet run -c Release --project tests/dotnet -- . |
the last line is PASSED
|
| the inspectors | the EditMode tests of tests/unity-inspectors
|
all tests pass |
A new engine has no check of its own until you write one. The nearest models are the bakes in
tests/dotnet/EngineTests.cs: they render a patch through the DLL and read the samples. Commands and counts:
Running The Tests.
Then listen to it. No test hears a timbre.
-
The silent fallback. In both chains,
sfx__controlandsfx_voice_render, the lastelseis IMPACT and SCI-FI FM. An engine without a branch of its own lands there and becomes an FM engine without a word. The same holds fordrive: an engine not named gets 1.3. -
C# packs the engine modulo
EngineCount.SfxPatch.Packwritesengine % EngineCountandTryUnpackrefuses a number at or above it. With the enum extended andEngineCountstill 5, your engine is saved as IMPACT and a patch from the device is refused. -
An old DLL passes tests it should fail.
tests/dotnetuses the committedsfxforge.dll. After a change incore/, rebuild it before the .NET run. -
RANDOM will use it.
sfx_patch_randompicks any engine belowSFX_ENGINE_COUNT, with value ranges made for the five. Check that random patches of your engine stay audible. -
The factory kits are compared. The MUSIC kit's 16 pads hold rows 16 to 31 of
PRESETS(factoryinfw_factory.h). They are part of what SEND gives, andcheck-song-export.mjscompares that byte for byte with the Unity demo's song file. A row put before them moves them: add yours at the end, or regenerate the song files. -
Give it its own knob meanings.
SFX_P_TABLEandSFX_P_SPREADare read by WAVETABLE only. A new engine may read them, but check that no factory sound has a value there that now changes how it sounds.
- Sound Engine: the chain your branch plugs into.
- Patch Format: why the patch itself does not change.
- Running The Tests and Release Checklist.
- Unity Extending: the package's side of a change.
- The maintainer's guide, Add an engine and Change the identity
-
core/sfx_core.h:
sfx_engine,sfx__control,sfx_voice_render - fw_sounds.h, fw_draw_parts.h, fw_draw_sound.h, fw_link.h
- SfxPatch.cs, SfxProfile.cs, SfxGenerator.cs, SfxUnits.cs, SfxKit.cs
- tests/check-identity.mjs, tests/dotnet/IdentityTests.cs, tests/dotnet/EngineTests.cs
SFX FORGE, firmware 1.7.2 · Home · Glossary · What Is Tested · the pages are kept in the repository's wiki/ folder: Editing This Wiki
Start
Device
- Quick Start
- Controls And Pages
- Make A Sound
- The Five Engines
- Make A Beat
- Recording
- Finer Grids
- Time Signatures
- Perform
- Song And Arrangement
- Layers And Intensity
- Automation
- Mixer And Effects
- The Stage
- Saving And Reset
- Cheat Sheet
Unity: first steps
- Install
- Quick Start
- Concepts
- Choosing A Route
- One Shots
- Live Voices
- Held Sounds
- Variations
- Presets And Patches
Unity: music
Unity: link and tools
Unity: in practice
- Recipes
- Recipes: Music
- Recipes: Link
- Showcase Walkthrough
- Copy The Showcase Pattern
- Troubleshooting
- Testing Your Audio
Unity: reference and extending
Internals
- Architecture Overview
- Repository Map
- Sound Engine
- Patch Format
- Song Format
- Link Protocol
- Firmware Internals
- Add A Page Or Key
- Add An Engine
- Add A Setting
- Building From Source
- Running The Tests
- Release Checklist
About this wiki