Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Cmd.Integrate

Description

Cmd-level support for integration. These cmds interpret the output of the calls in Derive.Call.Integrate to create score from deriver output and merge it back into the current score.

An example of track integration:

  • Add " | <" to a note track title, which causes damage and a rederive.
  • The integrate call < collects events and puts them into derive results, which go into DeriveComplete, which winds up at integrate_tracks.
  • integrate_tracks finds no existing derived tracks, so it merges into [], which creates new tracks, and damages the whole block.
  • Then it sets Cmd.derive_immediately on the block, which removes the usual derive wait.
  • Derive once again emits integrate results, which winds up at integrate_tracks again, but since there are no changes this time, there is no further damage, and derivation stops. This additional integration just to find out there were no changes is inefficient, but not a big deal since it only happens the first time.

Modify source track:

  • Track damage causes a rederive, which causes the < call to collect integrated events.
  • integrate_tracks merges the changes into the destination track (or tracks), which damages them.
  • This time when the derive happens, since there was no damage on the source track, it gets cached. The cache intentionally doesn't retain integrated events, so < is skipped and I don't get a second derivation.

Block integration is similar, except that I don't get a double derivation when the first new block is created, since the damage is separated to a different block.

It might be a little more orthogonal to omit the thing where I automatically create an integrated block or track if there are none, but it's convenient in practice. It does, however, make it tricky to undo past the integrate, since if you undo the block/track creation, the integrate call is still there and just creates another. Be quick!

This also implements score integration, which is a higher level form of integration that simply copies score events directly, without the intervening derive step.

Synopsis

Documentation

cmd_integrate :: Cmd.M m => Msg.Msg -> m Cmd.Status Source #

Derive integrate takes the result of a derivation and merges it into blocks or tracks which are marked as integrate destinations. A special derive call captures events and saves them in Msg.perf_integrated.

score_integrate :: [Update.UiUpdate] -> Ui.State -> Either.Either Ui.Error ([Log.Msg], Ui.State, Update.UiDamage) Source #

For each block with Block.TrackDestinations, figure out if their sources have damage, and if so, re-integrate.

manual_integrate Source #

Arguments

:: Ui.M m 
=> Block.SourceKey 
-> Convert.Track

note track

-> [Convert.Track]

dependent control tracks

-> m () 

Find blocks with the source key, and merge the given tracks into them.

If you are creating a new track, you need to have already done that and put an empty destination in it. Otherwise, this will find no existing destinations and do nothing.