Skip to content

Buses#686

Open
dpwe wants to merge 9 commits intomainfrom
buses
Open

Buses#686
dpwe wants to merge 9 commits intomainfrom
buses

Conversation

@dpwe
Copy link
Copy Markdown
Collaborator

@dpwe dpwe commented Apr 18, 2026

Implements most of #114

This adds a new "bus" field to amy_event and struct synthinfo. amy_global now has an array of bus_state_t *bus[AMY_NUM_BUSES] each of which holds params (and pointers to private buffers) for EQ, reverb, chorus, and echo.

amy_render looks at the bus field of the "lead osc" for each note, and calls render_osc_wave with a pointer to the bus-specific buffer, thus collecting the output for each bus separately (we now have AMY_NUM_BUSES * AMY_MAX_CORES buffers).

amy_fill_buffer executes EQ, Chorus, Echo and Reverb separately for each active bus, then sums the results across buses, scaled by amy_global.volume[bus], before converting to the final output samples. So, volume=<bus0_level>,<bus1_level>,...'` is now a list.

Apart from converting all the global buffers for the FX into resources managed by a struct, the weirdest thing I had to do was to hijack the d->osc field in structure delta to hold the value of the bus (instead of the osc) for commands that are setting the params of a bus - otherwise, there's no way to combine both the parameter value with the bus to which it is meant to apply in a delta. So there's a big explicit conditional in amy_event_to_deltas_queue that treats all the EQ, echo, chorus, and reverb commands as a special-case. It's a bit clumsy, but not a bad solution. Maybe we should rename d->osc to be d->target since it's not always an osc now, but that's just to avoid misdirecting readers of the code.

This went so much more smoothly than I expected. One 4 hour session to move all the FX state into structures so they could be multiply-allocated, then another 4 hour session to actually implement the per-bus processing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant