lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creates a MIDI note length formatter (issue 5576062)


From: mtsolo
Subject: Creates a MIDI note length formatter (issue 5576062)
Date: Sun, 29 Jan 2012 09:35:12 +0000

Reviewers: ,

Message:
The idea here is to create a generic framework that allows for
modifications to note lengths (i.e. swing) in the MIDI without having a
typographical impact on the score.

Description:
Creates a MIDI note length formatter

Please review this at http://codereview.appspot.com/5576062/

Affected files:
  M lily/note-performer.cc
  M scm/define-context-properties.scm


Index: lily/note-performer.cc
diff --git a/lily/note-performer.cc b/lily/note-performer.cc
index 01086620ef5e3f6ea23ce554926c52e7eb8ee338..c22a17199bc2470aa47eeac96ca8623e132aa052 100644
--- a/lily/note-performer.cc
+++ b/lily/note-performer.cc
@@ -53,6 +53,7 @@ Note_performer::process_music ()

   Pitch transposing;
   SCM prop = get_property ("instrumentTransposition");
+  SCM length_formatter = get_property ("midiNoteLengthFormatter");
   if (unsmob_pitch (prop))
     transposing = *unsmob_pitch (prop);

@@ -78,6 +79,13 @@ Note_performer::process_music ()
             }

           Moment len = get_event_length (n, now_mom ());
+          if (ly_is_procedure (length_formatter))
+            {
+              len = *unsmob_moment (scm_call_3 (length_formatter,
+                                                 len.smobbed_copy (),
+ get_property ("measureLength"), + get_property ("measurePosition")));
+            }

           Audio_note *p = new Audio_note (*pitp, len,
tie_event, transposing.negated ());
@@ -129,7 +137,10 @@ ADD_TRANSLATOR (Note_performer,
                 "",

                 /* read */
-                "",
+                "instrumentTransposition "
+                "measureLength "
+                "measurePosition "
+                "midiNoteLengthFormatter ",

                 /* write */
                 ""
Index: scm/define-context-properties.scm
diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index 43079859c638b83acba705060a6eba9413a85d2f..bae534e7a965eb0b4f329fbe8f41313ac00b267f 100644
--- a/scm/define-context-properties.scm
+++ b/scm/define-context-properties.scm
@@ -368,6 +368,7 @@ is used for ottava brackets.")
      (middleCPosition ,number? "The place of the middle C, measured in
 half staff-spaces.  Usually determined by looking at
 @code{middleCClefPosition} and @code{middleCOffset}.")
+ (midiChannelMapping ,symbol? "How to map MIDI channels: per @code{instrument} (default), @code{staff} or @code{voice}.")
      (midiInstrument ,string? "Name of the MIDI instrument to use.")
      (midiMergeUnisons ,boolean? "If true, output only one MIDI note-on
event when notes with the same pitch, in the same MIDI-file track, overlap.") @@ -375,7 +376,10 @@ event when notes with the same pitch, in the same MIDI-file track, overlap.")
 @code{midiMinimumVolume}.")
      (midiMinimumVolume ,number? "Set the minimum loudness for MIDI.
 Ranges from 0 address@hidden")
- (midiChannelMapping ,symbol? "How to map MIDI channels: per @code{instrument} (default), @code{staff} or @code{voice}.")
+     (midiNoteLengthFormatter ,procedure? "A procedure that takes three
+arguments: the length of a note, the length of the measure in which the note +falls, and the position of the note in the measure. The function must return
+a moment that corresponds to the actual length of the note.")
      (minimumFret ,number? "The tablature auto string-selecting
 mechanism selects the highest string with a fret at least
 @code{minimumFret}.")





reply via email to

[Prev in Thread] Current Thread [Next in Thread]