<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!-- header_tag --> <html lang="en"> <head> <title>Controlling MIDI dynamics - GNU LilyPond Notation Reference</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="description" content="GNU LilyPond Notation Reference"> <meta name="generator" content="makeinfo 4.11"> <link title="Top" rel="start" href="index.fr.html#Top"> <link rel="up" href="MIDI-output.fr.html#MIDI-output" title="MIDI output"> <link rel="prev" href="Repeats-in-MIDI.fr.html#Repeats-in-MIDI" title="Repeats in MIDI"> <link rel="next" href="Percussion-in-MIDI.fr.html#Percussion-in-MIDI" title="Percussion in MIDI"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1999--2007 by the authors Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections. A copy of the license is included in the section entitled ``GNU Free Documentation License''. --> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } hr { border:0; height:1; color: #000000; background-color: #000000; } /* hr { border: none; height: 1px; color: #666666; background-color: #666666; } body { border-left: 1px solid #666666; border-right: 1px solid #666666; color: #332d28; margin-right: auto; margin-left: auto; width: 60em; list-style-type: square; font-family: Arial,Helvetica,sans-serif; padding-right: 1em; padding-left: 1em; } a { border-bottom: 1px dashed #344242; text-decoration: none; color: #344242; } a:link { text-decoration: none; } a:visited { border-bottom: 1px dashed #666666; color: #666666; } a:active { border-bottom: 1px solid #00cccc; color: #00cccc; } a:hover { border-bottom: 1px solid #1d7b85; color: #1d7b85; } blockquote { border: 1px solid #cccccc; padding: 3px; width: 40em; } .node { border-left: 1px solid #666666; margin: -0.5em 0px 1em; padding: 2px 1px 0px; font-style: italic; } .node a { border: none; text-decoration: underline; font-style: normal; font-weight: bold; } .verbatim { font-family: "Courier New",Courier,monospace; } .unnumberedsubsubsec { font-size: large; color: #1d7b85; } .subsubheading { font-size: large; color: #3b220d; } .contents { border: 1px dashed #339999; margin: 3px 2em; list-style-type: square; padding-right: 1em; width: 40em; background-color: #fcfff9; } .contents a { border-bottom: 1px dashed #423d34; text-decoration: none; color: #423d34; } .contents a:visited { border-bottom: 1px dashed #666666; color: #666666; } .contents a:active { border-bottom: 1px solid #f0d86d; color: #f0d86d; } .contents a:hover { border-bottom: 1px solid #3b220d; color: #3b220d; } .menu { border-left: 1px dashed #339999; margin: 3px 2em 1em; list-style-type: square; padding-left: 1.4em; width: 40em; } .unnumbered { } h2 { font-size: x-large; color: #1d7b85; } */ --></style> </head> <BODY BGCOLOR=WHITE TEXT=BLACK> <div class="node"> <p> <a name="Controlling-MIDI-dynamics"></a> Next: <a rel="next" accesskey="n" href="Percussion-in-MIDI.fr.html#Percussion-in-MIDI">Percussion in MIDI</a>, Previous: <a rel="previous" accesskey="p" href="Repeats-in-MIDI.fr.html#Repeats-in-MIDI">Repeats in MIDI</a>, Up: <a rel="up" accesskey="u" href="MIDI-output.fr.html#MIDI-output">MIDI output</a> <hr> </div> <h4 class="subsection">3.5.5 Controlling MIDI dynamics</h4> <p>MIDI dynamics are implemented by the Dynamic_performer which lives by default in the Voice context. It is possible to control the overall MIDI volume, the relative volume of dynamic markings and the relative volume of different instruments. <h5 class="unnumberedsubsubsec">Dynamic marks</h5> <p>Dynamic marks are translated to a fixed fraction of the available MIDI volume range. The default fractions range from 0.25 for <var>ppppp</var> to 0.95 for <var>fffff</var>. The set of dynamic marks and the associated fractions can be seen in <samp><span class="file">../scm/midi.scm</span></samp>, see <a name="index-Other-sources-of-information-2461"></a><a href="../lilypond-learning/Other-sources-of-information.fr.html#Other-sources-of-information">Other sources of information</a>. This set of fractions may be changed or extended by providing a function which takes a dynamic mark as its argument and returns the required fraction, and setting <code>Score.dynamicAbsoluteVolumeFunction</code> to this function. <p>For example, if a <var>rinforzando</var> dynamic marking, <code>\rfz</code>, is required, this will not by default have any effect on the MIDI volume, as this dynamic marking is not included in the default set. Similarly, if a new dynamic marking has been defined with <code>make-dynamic-script</code> that too will not be included in the default set. The following example shows how the MIDI volume for such dynamic markings might be added. The Scheme function sets the fraction to 0.9 if a dynamic mark of rfz is found, or calls the default function otherwise. <blockquote> <pre class="verbatim"> #(define (myDynamics dynamic) (if (equal? dynamic "rfz") 0.9 (default-dynamic-absolute-volume dynamic))) \score { \new Staff { \set Staff.midiInstrument = "cello" \set Score.dynamicAbsoluteVolumeFunction = #myDynamics \new Voice { \relative c'' { a\pp b c-\rfz } } } \layout {} \midi {} } </pre> <p> <a href="../d7/lily-5a7e93b9.ly"> <img align="middle" border="0" src="../d7/lily-5a7e93b9.png" alt="[image of music]"> </a> </p> </blockquote> <p>Alternatively, if the whole table of fractions needs to be redefined, it would be better to use the <var>default-dynamic-absolute-volume</var> procedure in <samp><span class="file">../scm/midi.scm</span></samp> and the associated table as a model. The final example in this section shows how this might be done. <h5 class="unnumberedsubsubsec">Overall MIDI volume</h5> <p>The minimum and maximum overall volume of MIDI dynamic markings is controlled by setting the properties <code>midiMinimumVolume</code> and <code>midiMaximumVolume</code> at the <code>Score</code> level. These properties have an effect only on dynamic marks, so if they are to apply from the start of the score a dynamic mark must be placed there. The fraction corresponding to each dynamic mark is modified with this formula <pre class="example">midiMinimumVolume + (midiMaximumVolume - midiMinimumVolume) * fraction </pre> <p>In the following example the dynamic range of the overall MIDI volume is limited to the range 0.2 - 0.5. <blockquote> <pre class="verbatim"> \score { << \new Staff { \key g \major \time 2/2 \set Staff.midiInstrument = #"flute" \new Voice \relative c''' { r2 g\mp g fis ~ fis4 g8 fis e2 ~ e4 d8 cis d2 } } \new Staff { \key g \major \set Staff.midiInstrument = #"clarinet" \new Voice \relative c'' { b1\p a2. b8 a g2. fis8 e fis2 r } } >> \layout { } \midi { \context { \Score tempoWholesPerMinute = #(ly:make-moment 72 2) midiMinimumVolume = #0.2 midiMaximumVolume = #0.5 } } } </pre> <p> <a href="../ac/lily-afedcafb.ly"> <img align="middle" border="0" src="../ac/lily-afedcafb.png" alt="[image of music]"> </a> </p> </blockquote> <h5 class="unnumberedsubsubsec">Equalizing different instruments (i)</h5> <p>If the minimum and maximum MIDI volume properties are set in the <code>Staff</code> context the relative volumes of the MIDI instruments can be controlled. This gives a basic instrument equalizer, which can enhance the quality of the MIDI output remarkably. <p>In this example the volume of the clarinet is reduced relative to the volume of the flute. There must be a dynamic mark on the first note of each instrument for this to work correctly. <blockquote> <pre class="verbatim"> \score { << \new Staff { \key g \major \time 2/2 \set Staff.midiInstrument = #"flute" \set Staff.midiMinimumVolume = #0.7 \set Staff.midiMaximumVolume = #0.9 \new Voice \relative c''' { r2 g\mp g fis ~ fis4 g8 fis e2 ~ e4 d8 cis d2 } } \new Staff { \key g \major \set Staff.midiInstrument = #"clarinet" \set Staff.midiMinimumVolume = #0.3 \set Staff.midiMaximumVolume = #0.6 \new Voice \relative c'' { b1\p a2. b8 a g2. fis8 e fis2 r } } >> \layout { } \midi { \context { \Score tempoWholesPerMinute = #(ly:make-moment 72 2) } } } </pre> <p> <a href="../1a/lily-c919bea0.ly"> <img align="middle" border="0" src="../1a/lily-c919bea0.png" alt="[image of music]"> </a> </p> </blockquote> <h5 class="unnumberedsubsubsec">Equalizing different instruments (ii)</h5> <p>If the MIDI minimum and maximum volume properties are not set LilyPond will, by default, apply a small degree of equalization to a few instruments. The instruments and the equalization applied are shown in the table <var>instrument-equalizer-alist</var> in <samp><span class="file">../scm/midi.scm</span></samp>. <p>This basic default equalizer can be replaced by setting <code>instrumentEqualizer</code> in the <code>Score</code> context to a new Scheme procedure which accepts a MIDI instrument name as its only argument and returns a pair of fractions giving the minimum and maximum volumes to be applied to that instrument. This replacement is done in the same way as shown for resetting the <code>dynamicAbsoluteVolumeFunction</code> at the start of this section. The default equalizer, <var>default-instrument-equalizer</var>, in <samp><span class="file">../scm/midi.scm</span></samp> shows how such a procedure might be written. <p>The following example sets the relative flute and clarinet volumes to the same values as the previous example. <blockquote> <pre class="verbatim"> #(define my-instrument-equalizer-alist '()) #(set! my-instrument-equalizer-alist (append '( ("flute" . (0.7 . 0.9)) ("clarinet" . (0.3 . 0.6))) my-instrument-equalizer-alist)) #(define (my-instrument-equalizer s) (let ((entry (assoc s my-instrument-equalizer-alist))) (if entry (cdr entry)))) \score { << \new Staff { \key g \major \time 2/2 \set Score.instrumentEqualizer = #my-instrument-equalizer \set Staff.midiInstrument = #"flute" \new Voice \relative c''' { r2 g\mp g fis ~ fis4 g8 fis e2 ~ e4 d8 cis d2 } } \new Staff { \key g \major \set Staff.midiInstrument = #"clarinet" \new Voice \relative c'' { b1\p a2. b8 a g2. fis8 e fis2 r } } >> \layout { } \midi { \context { \Score tempoWholesPerMinute = #(ly:make-moment 72 2) } } } </pre> <p> <a href="../77/lily-3901e6d4.ly"> <img align="middle" border="0" src="../77/lily-3901e6d4.png" alt="[image of music]"> </a> </p> </blockquote> <!-- footer_tag --><br><hr> <div class="node"> <p> Next: <a rel="next" accesskey="n" href="Percussion-in-MIDI.fr.html#Percussion-in-MIDI">Percussion in MIDI</a>, Previous: <a rel="previous" accesskey="p" href="Repeats-in-MIDI.fr.html#Repeats-in-MIDI">Repeats in MIDI</a>, Up: <a rel="up" accesskey="u" href="MIDI-output.fr.html#MIDI-output">MIDI output</a> </div> <div style="background-color: #e8ffe8; padding: 2; border: #c0ffc0 1px solid;"> <p> <font size="-1"> Cette page documente LilyPond-2.11.57 (branche de développement). <br> <address> Rapportez toute anomalie en français à <a href="mailto:lilypond-user-fr@gnu.org">lilypond-user-fr@gnu.org</a> ou en anglais à <a href="http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs">http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs</a> </address> <br> Vos <a href="http://lilypond.org/web/devel/participating/documentation-adding">suggestions à propos de la documentation</a> sont les bienvenues. </font> </p> </div> </BODY></html>