Skip to content
Pastellie

Docs · 02

How importing works

The document is the source of truth, and the importer never guesses.


One decision explains most of struDAWl’s behaviour:

The document is the source of truth. Code is generated from it.

Code is not parsed continuously. It is parsed when you import, or when you explicitly apply an edit from the raw-code drawer. Between those moments, the graph is authoritative and the source shown to you is printed from it.

That is what makes the tool safe to point at a file you care about.

Nothing is lost

The importer models a large slice of Strudel, not all of it — and it is honest about the rest:

  • An unknown method becomes a Method node that re-emits its arguments untouched.
  • An unparseable statement becomes a Raw code node that survives verbatim.

Neither is a failure state. Both round-trip.

Nothing is invented

A parsed node’s untouched parameters stay absent. So importing

.room(.25)

emits

.room(.25)

and never grows a .roomsize() you did not write. Defaults are not silently materialised into your file.

Round trip is a test, not a hope

The test suite imports a bundled song, regenerates the source, re-imports it, and asserts the two documents are identical — with zero unmodelled nodes. If a change to the model breaks that equality, the suite fails before the change ships.

Generated source stays plain Strudel: paste it back into strudel.cc and it runs unchanged.

What folds, and why

Consecutive methods of one kind fold into a single node. .attack().decay().sustain().release() becomes one envelope card rather than four nodes, because four nodes for one idea is worse for both reading and editing.

Node kinds live in one table. An entry declares its parameters, the Strudel methods it owns, and optionally a custom editor — code generation, the importer and the parameter UI are all generic over that table, so teaching the tool a new Strudel method is usually one entry and no UI work.

One thing to know about masks

A flat trailing mask — a bare <1 1 0 1> at the end of a layer — is lifted into the arrangement timeline on import, because that is what it means. Anything more complex stays an ordinary node. See the arrangement timeline.