Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe HaskellNone

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.CmdUpdate]) Source #

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

manual_integrate :: Ui.M m => Block.SourceKey -> Convert.Track -> [Convert.Track] -> m () Source #

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