wallabra / matt

MATT (Matrix Tracker) – an experimental matrix-routing tracker format and engine.
MIT License
1 stars 0 forks source link

Routing Matrix Architecture #6

Open polyzium opened 1 year ago

polyzium commented 1 year ago

An experimental architecture, that involves a sparse matrix for routing audio signals between other elements of a song.

This involves the following components:

Routing Matrix

A sparse 2D matrix of values, which represent whether (and how much) audio should be routed between a source and a sink.

Voices

The internal array of state machines that handle notes playing in patterns.

A "voice" is a sink, which can be plugged to a source like a sample, or another pattern, or so on. It contains information to modulate and shape this signal, such as note frequency or volume.

Through these source-sink connections, they can also "backpropagate" MIDI commands, which is useful for both Samplers and Effects.

Unlike other objects, those are not standalone objects — they belong to Patterns (below).

Samplers

A sampler is a source that refers to sample data somewhere, such as the embedded list of samples, or an external sample bank. They contain information such as playback position, loop points, et cetera.

They are used by plugging to a Voice, either directly, or indirectly through effect objects.

Unlike other objects, each Sampler can only route to one sink at a time. This is to prevent bugs arising when different voices reuse the same sample, with different note pitches or volumes or playback offsets.

Effects

An effect object is a source and a sink, which applies some sort of transformation to an audio signal. Some effects don't have an actual source.

There are built-in effects, and plug-in effects.

Patterns

A pattern is a table, containing commands which can drive information in Voices, including note information and MIDI commands.

Each column contains a list of Note and Volume commands, which can dynamically allocate Voices to play new notes.

The maximum number of simultaneous Voices that ever play at once, are kept track of while editing the file. This many Voices are then dynamically allocated during playback, for that given Pattern.

A pattern is also a routable object, with as many sinks as it has Voices. It only has one source, though, which is the mix of all Voices in it.

Master Output

This is the 'primary sink' - all sound routed to here is supposed to be the audio signal of the entire music, the master mix.

polyzium commented 1 year ago

If you ever gonna start working on this, please do so in another branch

wallabra commented 1 year ago

If you ever gonna start working on this, please do so in another branch

It is way too infrastructural, any code on top of your architecture would have to be changed and refactored, and maybe even partially rewritten, to fit this.

Funnily enough, it does not break support with plugin interfaces whatsoever, if you just use the source/sink audio buffers. I just wouldn't be able to prove this 100% because I don't know how to interface with VST.

polyzium commented 1 year ago

Well CLAP/VST outputs 2 channels by default in most cases, separating those into their own voices would be extremely difficult if not impossible

wallabra commented 1 year ago

Maybe we could have 2 channels by default, for each buffer in the sink and source lists. And just mix down to mono if a project requires it. I think the resources and complexity saved by allowing someone to use mono buffers internally are insignificant, anyways.

polyzium commented 1 year ago

See this repo for issues and more details