Class OrnamentApplier
- Namespace
- Celeritas.Core.Ornamentation
- Assembly
- Celeritas.dll
Utility class for applying ornaments to note sequences
public static class OrnamentApplier
- Inheritance
-
OrnamentApplier
- Inherited Members
Methods
Apply(NoteEvent[], IReadOnlyDictionary<int, Ornament>)
Apply ornaments to a melody by note index (as used in examples).
public static NoteEvent[] Apply(NoteEvent[] melody, IReadOnlyDictionary<int, Ornament> ornamentMap)
Parameters
melodyNoteEvent[]ornamentMapIReadOnlyDictionary<int, Ornament>
Returns
Remarks
Every note not being ornamented keeps its written offset, so a lengthening articulation (the fermata preset) overlaps the note after it in a single line; see the span overload.
Exceptions
- ArgumentNullException
melodyorornamentMapis null.
Apply(ReadOnlySpan<NoteEvent>, IReadOnlyDictionary<int, Ornament>)
Apply ornaments to a melody by note index (as used in examples).
public static NoteEvent[] Apply(ReadOnlySpan<NoteEvent> melody, IReadOnlyDictionary<int, Ornament> ornamentMap)
Parameters
melodyReadOnlySpan<NoteEvent>ornamentMapIReadOnlyDictionary<int, Ornament>
Returns
Remarks
Each ornament is expanded in place of its note and every other note keeps its written offset. An ornament that subdivides its note fits inside it; an articulation that lengthens it — the fermata preset, or any DurationMultiplier above 1 — is given no room, so in a single line the lengthened note is still sounding at the next onset and overlaps it. Delaying the rest of the line is the caller's to do.
Exceptions
- ArgumentNullException
ornamentMapis null.
ApplyOrnaments(NoteEvent[], Ornament[])
Apply ornaments to a sequence of notes. An ornament is matched to a note by (Offset, Pitch) of its BaseNote, so multiple ornaments may share an offset (e.g. on different notes of a chord). Ornaments that match no note are ignored.
public static NoteEvent[] ApplyOrnaments(NoteEvent[] notes, Ornament[] ornaments)
Parameters
Returns
Remarks
As with Apply(ReadOnlySpan<NoteEvent>, IReadOnlyDictionary<int, Ornament>), the notes around an ornament keep their written offsets: a lengthening articulation (the fermata preset) is given no room and overlaps the note after it in a single line.
Exceptions
- ArgumentNullException
notesorornamentsis null.
CreateAppoggiatura(NoteEvent, AppogiaturaType, int)
Create an appoggiatura ornament
public static Appoggiatura CreateAppoggiatura(NoteEvent baseNote, AppogiaturaType type = AppogiaturaType.Long, int interval = 2)
Parameters
baseNoteNoteEventtypeAppogiaturaTypeintervalint
Returns
Exceptions
- ArgumentOutOfRangeException
typeis not a defined AppogiaturaType value.
CreateMordent(NoteEvent, MordentType, int, int)
Create a mordent ornament
public static Mordent CreateMordent(NoteEvent baseNote, MordentType type = MordentType.Upper, int interval = 2, int alternations = 1)
Parameters
baseNoteNoteEventtypeMordentTypeintervalintalternationsint
Returns
Exceptions
- ArgumentOutOfRangeException
typeis not a defined MordentType value.
CreateTrill(NoteEvent, int, int, bool, bool)
Create a trill ornament
public static Trill CreateTrill(NoteEvent baseNote, int interval = 2, int speed = 8, bool startWithUpper = false, bool endWithTurn = false)
Parameters
Returns
CreateTurn(NoteEvent, TurnType, int, int)
Create a turn ornament
public static Turn CreateTurn(NoteEvent baseNote, TurnType type = TurnType.Normal, int upperInterval = 2, int lowerInterval = 2)
Parameters
Returns
Exceptions
- ArgumentOutOfRangeException
typeis not a defined TurnType value.