SpencerPark / MellowD

Programmable music! A compiler and high level language.
https://spencerpark.github.io/mellowd-site/editor.html
12 stars 3 forks source link

Landmarks #13

Open SpencerPark opened 7 years ago

SpencerPark commented 7 years ago

Landmarks are a proposed feature that allow the composer to mark important parts of a song. Landmarks could then be synchronized on to allow for blocks to be defined in separate files and imported. They could also be used by the CLI to start playback at a certain time in the composition.

Proposed Syntax

@chorus
{ "chorus" } => landmark

Syncing would then be done with a regular sync call but using blockName.landmark instead. The landmark is only required for imported blocks and if not given will sync with the start of the block.

SpencerPark commented 7 years ago

The @ notation seems to be the natural syntax but the notion for syncing is a little obscure. Instead of the multi-empty block (which is the most common use) synchronization the landmarks would be a global point in time that all blocks that want to synchronize will block on until everyone catches up.

This means that the landmarks must be a lexical construct to determine at compile time which blocks need to synchronize on the landmark. The generated executable will then be able to block until the last block that should synchronize on the landmark has reached it.

For 3 blocks Piano, Guitar, Drums where Piano and Drums want to sync up on start_kick:

Piano {
    [a, b, c]*<e, e, e>
    @start_kick
    [C]*<w!, w!, w!>
}
Guitar {
    //...
}
Drums {
    @start_kick
    3 * { [bass]*<q, q, q, q> }
}

At compile time it is determined that start_kick is a barrier for the Piano and Drums threads. This way of embedding points has the benefit (and downside) of being named. As naming is sometimes more of a hassle than it's worth the current block level synchronization should remain with this auxiliary method available to augment that.