Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > 3a7b4dfc766af1222d90c7f03a0844e6 > files > 10235

lilypond-doc-2.11.57-1mdv2009.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- header_tag -->
<html lang="en">
<head>
<title>Pitches - LilyPond snippets</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="LilyPond snippets">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="index.html#Top" title="Top">
<link rel="next" href="Rhythms.html#Rhythms" title="Rhythms">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<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="Pitches"></a>
Next:&nbsp;<a rel="next" accesskey="n" href="Rhythms.html#Rhythms">Rhythms</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="index.html#Top">Top</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>

<h2 class="unnumbered">Pitches</h2>

<p>These snippets illustrate the Notation Reference,
section <a href="../../../Documentation/user/lilypond/Pitches.html#Pitches">Pitches</a>.

   <p><a name="adding-ambitus-per-voice.ly"></a>

<h3 class="unnumberedsec">Adding ambitus per voice</h3>

<p>Ambitus can be added per voice. In this case, the ambitus must be moved
manually to prevent collisions.

<pre class="verbatim">
\new Staff &lt;&lt;
  \new Voice \with {
    \consists "Ambitus_engraver"
  } \relative c'' {
    \override Ambitus #'X-offset = #2.0
    \voiceOne
    c4 a d e
    f1
  }
  \new Voice \with {
    \consists "Ambitus_engraver"
  } \relative c' {
    \voiceTwo
    es4 f g as
    b1
  }
>>
</pre>
<p>
 <a href="../4f/lily-6712adbe.ly">
  <img align="middle"
    border="0" src="../4f/lily-6712adbe.png" alt="[image of music]">
 </a>
</p>

   <p><a name="ambitus-with-multiple-voices.ly"></a>

<h3 class="unnumberedsec">Ambitus with multiple voices</h3>

<p>Adding the <code>Ambitus_engraver</code> to the <code>Staff</code> context creates
a single ambitus per staff, even in the case of staves with multiple
voices.

<pre class="verbatim">
\new Staff \with {
  \consists "Ambitus_engraver"
  }
&lt;&lt;
  \new Voice \relative c'' {
    \voiceOne
    c4 a d e
    f1
  }
  \new Voice \relative c' {
    \voiceTwo
    es4 f g as
    b1
  }
>>

</pre>
<p>
 <a href="../f9/lily-1e5f126e.ly">
  <img align="middle"
    border="0" src="../f9/lily-1e5f126e.png" alt="[image of music]">
 </a>
</p>

   <p><a name="applying-note-head-styles-depending-on-the-step-of-the-scale.ly"></a>

<h3 class="unnumberedsec">Applying note head styles depending on the step of the scale</h3>

<p>The <code>shapeNoteStyles</code> property can be used to define various note
head styles for each step of the scale (as set by the key signature or
the "tonic" property). This property requires a set of symbols, which
can be purely arbitrary (geometrical expressions such as
<code>triangle</code>, <code>cross</code>, and <code>xcircle</code> are allowed) or based
on old American engraving tradition (some latin note names are also
allowed).

   <p>That said, to imitate old American song books, there are several
predefined note head styles available through shortcut commands such as
<code>\aikenHeads</code> or <code>\sacredHarpHeads</code>.

   <p>This example shows different ways to obtain shape note heads, and
demonstrates the ability to transpose a melody without losing the
correspondence between harmonic functions and note head styles.

<pre class="verbatim">
fragment = {
  \key c \major
  c2 d
  e2 f
  g2 a
  b2 c
}

\score {
  \new Staff {
    \transpose c d 
    \relative c' {
      \set shapeNoteStyles = #'#(do re mi fa #f la ti)
      \fragment
    }
    
    \relative c' {
      \set shapeNoteStyles  = #'#(cross triangle fa #f mensural xcircle diamond)
      \fragment
    }
  }
}

</pre>
<p>
 <a href="../2e/lily-520cfded.ly">
  <img align="middle"
    border="0" src="../2e/lily-520cfded.png" alt="[image of music]">
 </a>
</p>

   <p><a name="creating-a-sequence-of-notes-on-various-pitches.ly"></a>

<h3 class="unnumberedsec">Creating a sequence of notes on various pitches</h3>

<p>In music that contains many occurrences of the same sequence of notes
at different pitches, the following music function may prove useful. 
It takes a note, of which only the pitch is used.  The supporting
Scheme functions were borrowed from the "Tips and tricks" document in
the manual for version 2.10.   This example creates the rhythm used
throughout Mars, from Gustav Holst's The Planets.

<pre class="verbatim">
#(define (make-note-req p d)
  (make-music 'NoteEvent
   'duration d
   'pitch p))

#(define (make-note p d)
  (make-music 'EventChord
   'elements (list (make-note-req p d))))

#(define (seq-music-list elts)
  (make-music 'SequentialMusic
   'elements elts))

#(define (make-triplet elt)
  (make-music 'TimeScaledMusic
   'denominator 3
   'numerator 2
   'element elt))


rhythm = #(define-music-function (parser location note) (ly:music?)
          "Make the rhythm in Mars (the Planets) at the given note's pitch"
          (let* ((p (ly:music-property
                      (car (ly:music-property note 'elements))
                      'pitch)))
          (seq-music-list (list
            (make-triplet (seq-music-list (list
              (make-note p (ly:make-duration 3 0 2 3))
              (make-note p (ly:make-duration 3 0 2 3))
              (make-note p (ly:make-duration 3 0 2 3))
            )))
            (make-note p (ly:make-duration 2 0))
            (make-note p (ly:make-duration 2 0))
            (make-note p (ly:make-duration 3 0))
            (make-note p (ly:make-duration 3 0))
            (make-note p (ly:make-duration 2 0))
          ))))

\score {
  \new Staff {
    \time 5/4
    \rhythm c'
    \rhythm c''
    \rhythm g
  }
}
</pre>
<p>
 <a href="../e1/lily-fcad03a4.ly">
  <img align="middle"
    border="0" src="../e1/lily-fcad03a4.png" alt="[image of music]">
 </a>
</p>

   <p><a name="dodecaphonic-style-accidentals-for-each-note-including-naturals.ly"></a>

<h3 class="unnumberedsec">Dodecaphonic-style accidentals for each note including naturals</h3>

<p>In early 20th century works, starting with Schoenberg, Berg and Webern
(the "Second" Viennese school), every pitch in the twelve-tone scale
has to be regarded as equal, without any hierarchy such as the
classical (tonal) degrees. Therefore, these composers print one
accidental for each note, even at natural pitches, to emphasize their
new approach to music theory and language.

   <p>This snippet shows how to achieve such notation rules.

<pre class="verbatim">
webernAccidentals = {
  % the 5s are just "a value different from any accidental"
  \set Staff.keySignature = #'((0 . 5) (1 . 5) (2 . 5) (3 . 5)
                               (4 . 5) (5 . 5) (6 . 5))
  \set Staff.extraNatural = ##f
  #(set-accidental-style 'forget)
}

\score {
  {
    \webernAccidentals
    c'4 dis' cis' cis'
    c'4 dis' cis' cis'
    c'4 c' dis' des'
  }
  \layout {
    \context {
    \Staff
    \remove "Key_engraver"
    }
  }
}
</pre>
<p>
 <a href="../55/lily-b8124a15.ly">
  <img align="middle"
    border="0" src="../55/lily-b8124a15.png" alt="[image of music]">
 </a>
</p>

   <p><a name="generating-random-notes.ly"></a>

<h3 class="unnumberedsec">Generating random notes</h3>

<p>This Scheme-based snippet generates 24 random notes (or as many as
required), based on the current time (or any randomish number specified
instead, in order to obtain the same random notes each time): i.e., to
get different random note patterns, just change this number.

<pre class="verbatim">
\score {
  { #(let ((random-state (seed->random-state (current-time))))
    (ly:export
     (make-music 'SequentialMusic 'elements
      (map (lambda x
           (let ((idx (random 12 random-state)))
            (make-music 'EventChord
             'elements (list (make-music 'NoteEvent
                              'duration (ly:make-duration 2 0 1 1)
                              'pitch (ly:make-pitch (quotient idx 7)
                                      (remainder idx 7)
                                      0))))))
       (make-list 24)))))
  }
}
</pre>
<p>
 <a href="../35/lily-cbf7db8d.ly">
  <img align="middle"
    border="0" src="../35/lily-cbf7db8d.png" alt="[image of music]">
 </a>
</p>

   <p><a name="makam.ly"></a>

<h3 class="unnumberedsec">Makam</h3>

<p>Makam is a type of melody from Turkey using 1/9th-tone
microtonal alterations.  Consult the initialization file
<code>makam-init.ly</code> (see the `Learning Manual 2.11.57,
4.6.3 Other sources of information' for the location of this file)
for details of pitch names and alterations.
<pre class="verbatim">
% Initialize makam settings
\include "makam-init.ly"

\relative c' {
  \set Staff.keySignature = #`((3 . ,BAKIYE) (6 . ,(- KOMA)))
  c4 cc db fk
  gbm4 gfc gfb efk
  fk4 db cc c
}
</pre>
<p>
 <a href="../5a/lily-1889f4f6.ly">
  <img align="middle"
    border="0" src="../5a/lily-1889f4f6.png" alt="[image of music]">
 </a>
</p>

   <p><a name="non-traditional-key-signatures.ly"></a>

<h3 class="unnumberedsec">Non-traditional key signatures</h3>

<p>The commonly used <code>\key</code> command sets the <code>keySignature</code>
property, in the <code>Staff</code> context.

   <p>To create non-standard key signatures, set this property directly. The
format of this command is a list:

   <p><code> \set Staff.keySignature = #`(((octave . step) . alter) ((octave
. step) . alter) ...) </code> where, for each element in the list,
<code>octave</code> specifies the octave (0 being the octave from middle C to
the B above), <code>step</code> specifies the note within the octave (0 means
C and 6 means B), and <code>alter</code> is <code>,SHARP ,FLAT ,DOUBLE-SHARP</code>
etc. (Note the leading comma.)

   <p>Alternatively, for each item in the list, using the more concise format
<code>(step . alter)</code> specifies that the same alteration should hold in
all octaves.

   <p>Here is an example of a possible key signature for generating a
whole-tone scale:

<pre class="verbatim">
\relative c' {
  \set Staff.keySignature = #`(((0 .  3) . ,SHARP) ((0 . 5) . ,FLAT) ((0 . 6) . ,FLAT))
  c4 d e fis
  aes4 bes c2
}

</pre>
<p>
 <a href="../02/lily-2e1932b1.ly">
  <img align="middle"
    border="0" src="../02/lily-2e1932b1.png" alt="[image of music]">
 </a>
</p>

   <p><a name="ottava-text.ly"></a>

<h3 class="unnumberedsec">Ottava text</h3>

<p>Internally, the <code>set-octavation</code> function sets the properties
<code>ottavation</code> (for example, to <code>"8va"</code> or <code>"8vb"</code>)
and <code>middleCPosition</code>.  To override the text of the bracket, set
<code>ottavation</code> after invoking <code>set-octavation</code>.

<pre class="verbatim">
{
  \ottava #1
  \set Staff.ottavation = #"8"
  c''1
  \ottava #0
  c'1
  \ottava #1
  \set Staff.ottavation = #"Text"
  c''1
}
</pre>
<p>
 <a href="../f1/lily-d72a333b.ly">
  <img align="middle"
    border="0" src="../f1/lily-d72a333b.png" alt="[image of music]">
 </a>
</p>

   <p><a name="preventing-extra-naturals-from-being-automatically-added.ly"></a>

<h3 class="unnumberedsec">Preventing extra naturals from being automatically added</h3>

<p>In accordance with standard typesetting rules, a natural sign is
printed before a sharp or flat if a previous accidental on the same
note needs to be canceled.  To change this behavior, set the
<code>extraNatural</code> property to "false" in the <code>Staff</code> context.

<pre class="verbatim">
\relative c'' {
  aeses4 aes ais a
  \set Staff.extraNatural = ##f
  aeses4 aes ais a
}
</pre>
<p>
 <a href="../a8/lily-0ff700ea.ly">
  <img align="middle"
    border="0" src="../a8/lily-0ff700ea.png" alt="[image of music]">
 </a>
</p>

   <p><a name="preventing-natural-signs-from-being-printed-when-the-key-signature-changes.ly"></a>

<h3 class="unnumberedsec">Preventing natural signs from being printed when the key signature changes</h3>

<p>When the key signature changes, natural signs are automatically printed
to cancel any accidentals from previous key signatures.  This may be
prevented by setting to "false" the <code>printKeyCancellation</code>
property in the <code>Staff</code> context.

<pre class="verbatim">
\relative c' {
  \key d \major
  a4 b cis d
  \key g \minor
  a4 bes c d
  \set Staff.printKeyCancellation = ##f
  \key d \major
  a4 b cis d
  \key g \minor
  a4 bes c d
}
</pre>
<p>
 <a href="../56/lily-148684fe.ly">
  <img align="middle"
    border="0" src="../56/lily-148684fe.png" alt="[image of music]">
 </a>
</p>

   <p><a name="quoting-another-voice-with-transposition.ly"></a>

<h3 class="unnumberedsec">Quoting another voice with transposition</h3>

<p>Quotations take into account the transposition of both
source and target.  In this example, all instruments play sounding
middle C; the target is an instrument in F.  The target part may be
transposed using <code>\transpose</code>.  In this case, all the pitches
(including the quoted ones) are transposed.

<pre class="verbatim">
\addQuote clarinet {
  \transposition bes
  \repeat unfold 8 { d'16 d' d'8 }
}

\addQuote sax {
  \transposition es'
  \repeat unfold 16 { a8 }
}

quoteTest = {
  % french horn
  \transposition f
  g'4
  &lt;&lt; \quoteDuring #"clarinet" { \skip 4 } s4^"clar." >>
  &lt;&lt; \quoteDuring #"sax" { \skip 4 } s4^"sax." >>
  g'4
}

{
  \set Staff.instrumentName = \markup \center-column { Horn \line { in F } }
  \quoteTest
  \transpose c' d' &lt;&lt; \quoteTest s4_"up a tone" >>
}
</pre>
<p>
 <a href="../9f/lily-2747fcc3.ly">
  <img align="middle"
    border="0" src="../9f/lily-2747fcc3.png" alt="[image of music]">
 </a>
</p>

   <p><a name="transposing-pitches-with-minimum-accidentals-smart-transpose.ly"></a>

<h3 class="unnumberedsec">Transposing music with minimum accidentals</h3>

<p>This example uses some Scheme code to enforce enharmonic
modifications for notes in order to have the minimum number of
accidentals.  In this case, the following rules apply:

     <ul>
<li>Double accidentals should be removed

     <li>B sharp -&gt; C

     <li>E sharp -&gt; F

     <li>C flat -&gt; B

     <li>F flat -&gt; E

   </ul>

   <p>In this manner, the most natural enharmonic notes are chosen.

<pre class="verbatim">
#(define  (naturalize-pitch p)
  (let* ((o (ly:pitch-octave p))
         (a (* 4 (ly:pitch-alteration p)))
    ; alteration, a, in quarter tone steps, for historical reasons
         (n (ly:pitch-notename p)))
    (cond
     ((and (> a 1) (or (eq? n 6) (eq? n 2)))
      (set! a (- a 2))
      (set! n (+ n 1)))
     ((and (&lt; a -1) (or (eq? n 0) (eq? n 3)))
      (set! a (+ a 2))
      (set! n (- n 1))))
    (cond
     ((> a 2) (set! a (- a 4)) (set! n (+ n 1)))
     ((&lt; a -2) (set! a (+ a 4)) (set! n (- n 1))))
    (if (&lt; n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
    (if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
    (ly:make-pitch o n (/ a 4))))

#(define (naturalize music)
  (let* ((es (ly:music-property music 'elements))
         (e (ly:music-property music 'element))
         (p (ly:music-property music 'pitch)))
    (if (pair? es)
        (ly:music-set-property!
         music 'elements
         (map (lambda (x) (naturalize x)) es)))
    (if (ly:music? e)
        (ly:music-set-property!
         music 'element
         (naturalize e)))
    (if (ly:pitch? p)
        (begin
          (set! p (naturalize-pitch p))
          (ly:music-set-property! music 'pitch p)))
    music))

naturalizeMusic =
#(define-music-function (parser location m)
					(ly:music?)
			(naturalize m))

music = \relative c' { c4 d e g }

\score {
  \new Staff {
    \transpose c ais \music
    \naturalizeMusic \transpose c ais \music
    \transpose c deses \music
    \naturalizeMusic \transpose c deses \music
  }
  \layout { }
}
</pre>
<p>
 <a href="../47/lily-7f4c521f.ly">
  <img align="middle"
    border="0" src="../47/lily-7f4c521f.png" alt="[image of music]">
 </a>
</p>

   <p><a name="tweaking-clef-properties.ly"></a>

<h3 class="unnumberedsec">Tweaking clef properties</h3>

<p>The command <code>\clef "treble_8"</code> is equivalent to setting
<code>clefGlyph</code>, <code>clefPosition</code> (which controls the vertical
position of the clef), <code>middleCPosition</code> and
<code>clefOctavation</code>. A clef is printed when any of the properties
except <code>middleCPosition</code> are changed.

   <p>Note that changing the glyph, the position of the clef, or the
octavation does not in itself change the position of subsequent notes
on the staff: the position of middle C must also be specified to do
this. The positional parameters are relative to the staff center line,
positive numbers displacing upwards, counting one for each line and
space. The <code>clefOctavation</code> value would normally be set to 7, -7,
15 or -15, but other values are valid.

   <p>When a clef change takes place at a line break the new clef symbol is
printed at both the end of the previous line and the beginning of the
new line by default. If the warning clef at the end of the previous
line is not required it can be suppressed by setting the <code>Staff</code>
property <code>explicitClefVisibility</code> to the value
<code>end-of-line-invisible</code>. The default behavior can be recovered
with  <code>\unset Staff.explicitClefVisibility</code>.

   <p>The following examples show the possibilities when setting these
properties manually. On the first line, the manual changes preserve the
standard relative positioning of clefs and notes, whereas on the second
line, they do not.

<pre class="verbatim">
{
  % The default treble clef
  c'1
  % The standard bass clef
  \set Staff.clefGlyph = #"clefs.F"
  \set Staff.clefPosition = #2
  \set Staff.middleCPosition = #6
  c'1
  % The baritone clef
  \set Staff.clefGlyph = #"clefs.C"
  \set Staff.clefPosition = #4
  \set Staff.middleCPosition = #4
  c'1
  % The standard choral tenor clef
  \set Staff.clefGlyph = #"clefs.G"
  \set Staff.clefPosition = #-2
  \set Staff.clefOctavation = #-7
  \set Staff.middleCPosition = #1
  c'1
  % A non-standard clef
  \set Staff.clefPosition = #0
  \set Staff.clefOctavation = #0
  \set Staff.middleCPosition = #-4
  c'1 \break

  % The following clef changes do not preserve
  % the normal relationship between notes and clefs:

  \set Staff.clefGlyph = #"clefs.F"
  \set Staff.clefPosition = #2
  c'1
  \set Staff.clefGlyph = #"clefs.G"
  c'1
  \set Staff.clefGlyph = #"clefs.C"
  c'1
  \set Staff.clefOctavation = #7
  c'1
  \set Staff.clefOctavation = #0
  \set Staff.clefPosition = #0
  c'1
  
  % Here we go back to the normal clef:

  \set Staff.middleCPosition = #0
  c'1
}
</pre>
<p>
 <a href="../60/lily-919dc097.ly">
  <img align="middle"
    border="0" src="../60/lily-919dc097.png" alt="[image of music]">
 </a>
</p>

   <!-- footer_tag --><br><hr>
<div class="node">
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Rhythms.html#Rhythms">Rhythms</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="index.html#Top">Top</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
</div>

<div style="background-color: #e8ffe8; padding: 2; border: #c0ffc0 1px solid;">
<p>
<font size="-1">
This page is for LilyPond-2.11.57 (development-branch).
<br>
<address>
Report errors to <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>
Your <a href="http://lilypond.org/web/devel/participating/documentation-adding">suggestions for the documentation</a> are welcome.
</font>
</p>
</div>

</BODY></html>