Sound
eff SoundSourceMaking a noise, as an effect.
The rules say what should be heard and never learn how. The runtime interprets this onto a pool of clips, the tests interpret it into a list, and a machine with no sound card interprets it into nothing -- all three running the identical simulation.
Operations
Definitions
Interprets Sound by recording what was played instead of playing it.
Pure: the accumulator lives in a region that is fully discharged here, so this needs
no IO and touches no device. This is what the sound tests use.
Runs f and returns only what it played.
Runs f, returning its result together with everything it played.
Interprets Sound by discarding it.
Deliberately not a @DefaultHandler, for the same reason as Canvas and Input:
a default would not save the callers anything (the effect still has to appear in
every @Test signature) and it would let a forgotten interpretation pass unnoticed.
Lifts a step that makes no sound into one that is allowed to.
The teaching sketches have nothing to play, but the runtime asks for a step that may.
checked_ecast widens the effect without changing behaviour -- the escape hatch the
Flix style guide sanctions for exactly this ("if necessary, effect casts are OK").