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

Derive.Call.Ly

Description

Utilities for calls to cooperate with the lilypond backend.

Synopsis

utils for ly calls

when_lilypond Source #

Arguments

:: Deriver a

Run if this is a lilypond derive.

-> Deriver a

Run if this is a normal derive.

-> Deriver a 

when_lilypond_config Source #

Arguments

:: (Types.Config -> Deriver a)

Run if this is a lilypond derive.

-> Deriver a

Run if this is a normal derive.

-> Deriver a 

only_lilypond :: NoteDeriver -> NoteDeriver Source #

Only emit the deriver if I'm in lilypond mode.

note_code :: Code -> PassedArgs d -> NoteDeriver -> NoteDeriver Source #

When in lilypond mode, generate a note with the given Code.

transformer

add_all :: Code -> NoteDeriver -> NoteDeriver Source #

Add the Code to all the events.

add_first :: Code -> NoteDeriver -> NoteDeriver Source #

Add Code to the first event.

note parent

notes_code :: Code -> PassedArgs d -> NoteDeriver -> NoteDeriver Source #

Replace a note parent with one that derives its sub-events as-is and adds lilypond code to them.

first_note_code :: Code -> PassedArgs d -> NoteDeriver -> NoteDeriver Source #

Like notes_code, but only apply the code to the first event, not all of them.

notes_around :: Code -> Code -> PassedArgs d -> NoteDeriver -> NoteDeriver Source #

This is like notes_code, but the first event in each track gets the start code, and the last event in each track gets the end code.

notes_around_ly :: Code -> Code -> PassedArgs d -> NoteDeriver Source #

Like notes_around, but for use when you already know you're in lilypond mode.

code_around :: FreeCode -> FreeCode -> PassedArgs d -> NoteDeriver Source #

Like notes_around, but when I'm not in lilypond mode just derive the sub events unchanged.

notes_with :: (NoteDeriver -> NoteDeriver) -> PassedArgs d -> NoteDeriver -> NoteDeriver Source #

Transform and evaluate the sub events.

first_last :: (Score.Event -> Score.Event) -> (Score.Event -> Score.Event) -> Stream.Stream Score.Event -> Stream.Stream Score.Event Source #

Apply a function to the first and last Events, which are not is_code0.

code

type Code = (Position Constants.CodePosition, Ly) Source #

Either prepend or append some code to a lilypond note.

data Position pos Source #

Constructors

Position !pos 
SetEnviron !EnvKey.Key

Create a note with the given env value set to the Ly code. This is for directives to the lilypond performer, not to lilypond itself. E.g. Constants.v_subdivision.

type Ly = Text Source #

Fragment of Lilypond code.

type Note = Ly Source #

A lilypond "note", which is just a chunk of text.

code0 :: ScoreTime -> FreeCode -> NoteDeriver Source #

Like code, but for 0 duration code fragments, and can either put them before or after notes that occur at the same time.

code0_event :: RealTime -> FreeCode -> Score.Event -> Score.Event Source #

Make a code0 event directly. Inherit instrument and environ from an existing note. Otherwise, the lilypond backend doesn't know how to group the code event.

TODO aka free_code, maybe rename it?

global :: Deriver a -> Deriver a Source #

Derive with the Constants.ly_global instrument.

is_code0 :: Score.Event -> Bool Source #

Test if an event is a 0 duration lilypond code event.

low level

add_note_code :: Code -> Score.Event -> Score.Event Source #

Add lilypond code to a note. Skip is_code events, since those aren't actual notes.

convert

note_duration :: Types.Config -> RealTime -> Types.NoteDuration Source #

Round the RealTime to the nearest NoteDuration.

is_note_duration :: Types.Config -> RealTime -> Maybe Types.NoteDuration Source #

Like note_duration, but only succeeds if the RealTime is exactly a NoteDuration.