<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.lilypond.community/index.php?action=history&amp;feed=atom&amp;title=Extracting_notes_inside_chords_into_separate_staves</id>
	<title>Extracting notes inside chords into separate staves - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.lilypond.community/index.php?action=history&amp;feed=atom&amp;title=Extracting_notes_inside_chords_into_separate_staves"/>
	<link rel="alternate" type="text/html" href="https://wiki.lilypond.community/index.php?title=Extracting_notes_inside_chords_into_separate_staves&amp;action=history"/>
	<updated>2026-05-04T19:04:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.lilypond.community/index.php?title=Extracting_notes_inside_chords_into_separate_staves&amp;diff=4434&amp;oldid=prev</id>
		<title>Lemzwerg: New category</title>
		<link rel="alternate" type="text/html" href="https://wiki.lilypond.community/index.php?title=Extracting_notes_inside_chords_into_separate_staves&amp;diff=4434&amp;oldid=prev"/>
		<updated>2025-11-21T23:22:57Z</updated>

		<summary type="html">&lt;p&gt;New category&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 23:22, 21 November 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l330&quot;&gt;Line 330:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 330:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Preparing parts]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Preparing parts]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Scheme]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Scheme]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Really cool]][[Category:Snippet]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Really cool]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Snippet]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lemzwerg</name></author>
	</entry>
	<entry>
		<id>https://wiki.lilypond.community/index.php?title=Extracting_notes_inside_chords_into_separate_staves&amp;diff=3471&amp;oldid=prev</id>
		<title>Lemzwerg at 22:52, 21 November 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.lilypond.community/index.php?title=Extracting_notes_inside_chords_into_separate_staves&amp;diff=3471&amp;oldid=prev"/>
		<updated>2025-11-21T22:52:39Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:52, 21 November 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l330&quot;&gt;Line 330:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 330:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Preparing parts]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Preparing parts]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Scheme]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Scheme]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Really cool]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Really cool&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]][[Category:Snippet&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lemzwerg</name></author>
	</entry>
	<entry>
		<id>https://wiki.lilypond.community/index.php?title=Extracting_notes_inside_chords_into_separate_staves&amp;diff=2221&amp;oldid=prev</id>
		<title>Jean Abou Samra: Replace version=&quot;2.24.0&quot; with version=&quot;2.24&quot; now that the LilyWiki extension supports auto-selecting the latest release in a stable series</title>
		<link rel="alternate" type="text/html" href="https://wiki.lilypond.community/index.php?title=Extracting_notes_inside_chords_into_separate_staves&amp;diff=2221&amp;oldid=prev"/>
		<updated>2025-11-16T18:47:01Z</updated>

		<summary type="html">&lt;p&gt;Replace version=&amp;quot;2.24.0&amp;quot; with version=&amp;quot;2.24&amp;quot; now that the LilyWiki extension supports auto-selecting the latest release in a stable series&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:47, 16 November 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l13&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;code&amp;gt;\extractNote #1 \music &amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;code&amp;gt;\extractNote #1 \music &amp;lt;/code&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;lilypond version=&quot;2.24&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.0&lt;/del&gt;&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;lilypond version=&quot;2.24&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;%% http://lsr.di.unimi.it/LSR/Item?u=1&amp;amp;id=545&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;%% http://lsr.di.unimi.it/LSR/Item?u=1&amp;amp;id=545&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;%% see also http://lsr.di.unimi.it/LSR/Item?u=1&amp;amp;id=761&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;%% see also http://lsr.di.unimi.it/LSR/Item?u=1&amp;amp;id=761&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jean Abou Samra</name></author>
	</entry>
	<entry>
		<id>https://wiki.lilypond.community/index.php?title=Extracting_notes_inside_chords_into_separate_staves&amp;diff=520&amp;oldid=prev</id>
		<title>Jean Abou Samra: Import snippet from LSR</title>
		<link rel="alternate" type="text/html" href="https://wiki.lilypond.community/index.php?title=Extracting_notes_inside_chords_into_separate_staves&amp;diff=520&amp;oldid=prev"/>
		<updated>2025-10-26T22:43:28Z</updated>

		<summary type="html">&lt;p&gt;Import snippet from LSR&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This snippet create a new function to allow the transformation of a polyphonic instrument into several monaural instruments.&lt;br /&gt;
&lt;br /&gt;
The syntax of this function is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; \extractNote #position music &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In, for example, &amp;lt;code&amp;gt; &amp;amp;lt;c e g&amp;amp;gt; &amp;lt;/code&amp;gt; ,&amp;lt;code&amp;gt; c &amp;lt;/code&amp;gt; is in position 1, &amp;lt;code&amp;gt; e &amp;lt;/code&amp;gt; in position 2, and &amp;lt;code&amp;gt; g &amp;lt;/code&amp;gt; in 3.&lt;br /&gt;
&lt;br /&gt;
In the example below, the first staff is the original music, and the three others have been made with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;\extractNote #3 \music&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;\extractNote #2 \music&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;\extractNote #1 \music &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;lilypond version=&amp;quot;2.24.0&amp;quot;&amp;gt;&lt;br /&gt;
%% http://lsr.di.unimi.it/LSR/Item?u=1&amp;amp;id=545&lt;br /&gt;
%% see also http://lsr.di.unimi.it/LSR/Item?u=1&amp;amp;id=761&lt;br /&gt;
&lt;br /&gt;
%% version 2014/03/24&lt;br /&gt;
%% see for snippet upgrade http://gillesth.free.fr/Lilypond/chord/&lt;br /&gt;
%% A little doc is also provided !&lt;br /&gt;
&lt;br /&gt;
#(define (noteEvent? music)&lt;br /&gt;
(eq? (ly:music-property music &amp;#039;name) &amp;#039;NoteEvent))&lt;br /&gt;
&lt;br /&gt;
#(define (no-duration? music)&lt;br /&gt;
(not (ly:duration? (ly:music-property music &amp;#039;duration))))&lt;br /&gt;
&lt;br /&gt;
#(define (expand-q-chords music); for q chords : see chord-repetition-init.ly&lt;br /&gt;
(expand-repeat-chords! (list &amp;#039;rhythmic-event) music))&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%  extractNote  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
#(define tagNotExtractNote (gensym))&lt;br /&gt;
#(use-modules (ice-9 receive)) %% for the use of receive&lt;br /&gt;
&lt;br /&gt;
#(define (chord-&amp;gt;note chord n . args)&lt;br /&gt;
&amp;quot;Return either the note n of chord chord, keeping articulations or if other&lt;br /&gt;
numbers are specified in args, a chord with the matching notes.&amp;quot;&lt;br /&gt;
(receive (notes others)&lt;br /&gt;
 (partition noteEvent? (ly:music-property chord &amp;#039;elements))&lt;br /&gt;
 (if (null? notes)&lt;br /&gt;
   chord&lt;br /&gt;
   (let* ((len (length notes))&lt;br /&gt;
          (res (filter-map&lt;br /&gt;
            (lambda(i)&lt;br /&gt;
              (and (integer? i)&lt;br /&gt;
                   (&amp;lt;= i len)&lt;br /&gt;
                   (&amp;gt; i 0)&lt;br /&gt;
                   (list-ref notes (1- i)))) ; list-ref is zero-based&lt;br /&gt;
            (cons n args)))&lt;br /&gt;
           (one-note (cond &lt;br /&gt;
             ((null? res) (list-ref notes (1- len)))&lt;br /&gt;
             ((null? (cdr res))(car res))&lt;br /&gt;
             (else #f))))&lt;br /&gt;
      (if one-note&lt;br /&gt;
        (begin&lt;br /&gt;
          (ly:music-set-property! one-note &amp;#039;articulations &lt;br /&gt;
            (append (ly:music-property one-note &amp;#039;articulations) others))&lt;br /&gt;
          one-note)&lt;br /&gt;
        (make-event-chord (append res others)))))))&lt;br /&gt;
         &lt;br /&gt;
#(define (extract-note music n . args)&lt;br /&gt;
&amp;quot;Extract the note n of each chords in music, keeping articulations.&lt;br /&gt;
If other numbers are given in args, the function returns a chord build with all&lt;br /&gt;
matching notes. If no note matches, returns the last note of the chord.&amp;quot;&lt;br /&gt;
 (map-some-music &lt;br /&gt;
   (lambda (evt)&lt;br /&gt;
      (cond &lt;br /&gt;
        ((eq? &amp;#039;EventChord (ly:music-property evt &amp;#039;name))&lt;br /&gt;
           (let ((tags (ly:music-property evt &amp;#039;tags)))&lt;br /&gt;
              (if (memq tagNotExtractNote tags)&lt;br /&gt;
                 (ly:music-set-property! evt &amp;#039;tags ; only remove the tag&lt;br /&gt;
                     (delq tagNotExtractNote tags))&lt;br /&gt;
                 (set! evt (apply chord-&amp;gt;note evt n args)))&lt;br /&gt;
              evt))&lt;br /&gt;
        (else (and (ly:music-property evt &amp;#039;duration #f) evt))))&lt;br /&gt;
   (expand-q-chords music)))&lt;br /&gt;
&lt;br /&gt;
extractNote = #(define-music-function (n music )&lt;br /&gt;
                                                            (number? ly:music?)&lt;br /&gt;
 (extract-note music n))&lt;br /&gt;
&lt;br /&gt;
% usefull for notExtractNote&lt;br /&gt;
tagify = #(define-music-function (tag music)(symbol? ly:music?)&lt;br /&gt;
&amp;quot;Add `tag in the tags property of all chords&amp;quot;&lt;br /&gt;
(music-map&lt;br /&gt;
	(lambda (evt)&lt;br /&gt;
    (if (eq? &amp;#039;EventChord (ly:music-property evt &amp;#039;name))&lt;br /&gt;
       (ly:music-set-property! evt &amp;#039;tags&lt;br /&gt;
             (cons tag (ly:music-property evt &amp;#039;tags))))&lt;br /&gt;
		evt)&lt;br /&gt;
	music))&lt;br /&gt;
notExtractNote = #(define-music-function (music)(ly:music?)&lt;br /&gt;
&amp;quot;Avoids music to be extracted by \\extractNote.&amp;quot;&lt;br /&gt;
#{&lt;br /&gt;
  \tagify #tagNotExtractNote $music&lt;br /&gt;
#})&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%  extractVoice  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
#(define tagNotExtractVoice (gensym))&lt;br /&gt;
&lt;br /&gt;
#(define (extract-voice music d deeper-level?) ;; d as a decimal number&lt;br /&gt;
   (define (nth-voice voices n)&lt;br /&gt;
    (let ((len (length voices)))&lt;br /&gt;
     (list-ref voices (1-   ; list-ref is zero-based !&lt;br /&gt;
      (if (&amp;lt;= n len) n len)))))&lt;br /&gt;
   &lt;br /&gt;
   (define (not-extract? x)&lt;br /&gt;
     (let ((tags (ly:music-property x &amp;#039;tags)))&lt;br /&gt;
        (and (memq tagNotExtractVoice tags)    ; don&amp;#039;t extract anything&lt;br /&gt;
             (begin &lt;br /&gt;
               (ly:music-set-property! x &amp;#039;tags &lt;br /&gt;
                   (delq tagNotExtractVoice tags)) ; only remove the tag&lt;br /&gt;
               x))))&lt;br /&gt;
   &lt;br /&gt;
   (define (myfilter x)&lt;br /&gt;
     (or (not-extract? x)&lt;br /&gt;
         (case (ly:music-property x &amp;#039;name #f)&lt;br /&gt;
           ((SimultaneousMusic EventChord) x)&lt;br /&gt;
           ((OverrideProperty PropertySet VoiceSeparator) #f)&lt;br /&gt;
           ((ContextSpeccedMusic)&lt;br /&gt;
              (if (eq? (ly:music-property x &amp;#039;context-type) &amp;#039;Voice)&lt;br /&gt;
                (set! x (myfilter (ly:music-property x &amp;#039;element #f))))&lt;br /&gt;
              x)&lt;br /&gt;
           (else (if (ly:music-property x &amp;#039;duration #f)&lt;br /&gt;
             x&lt;br /&gt;
             (let ((e (ly:music-property x &amp;#039;element #f))&lt;br /&gt;
                      (es (ly:music-property x &amp;#039;elements #f)))&lt;br /&gt;
               (if e (ly:music-set-property! x &amp;#039;element (myfilter e)))&lt;br /&gt;
               (if (pair? es)(ly:music-set-property! x &amp;#039;elements&lt;br /&gt;
                                (filter myfilter es)))&lt;br /&gt;
               x))))))&lt;br /&gt;
(map-some-music &lt;br /&gt;
 (lambda(evt)&lt;br /&gt;
   (case (ly:music-property evt &amp;#039;name)&lt;br /&gt;
     ((EventChord) evt)&lt;br /&gt;
     ((SimultaneousMusic)&lt;br /&gt;
        (or (not-extract? evt)&lt;br /&gt;
            (let* ((save-d d)                      ; if d = 4.321, we&amp;#039;ll get :&lt;br /&gt;
                   (n (truncate d))                ; n = 4 (the integer part)&lt;br /&gt;
                   (next-d (- (* 10  d)(* 10 n)))  ; next-d = 43.21 - 40 = 3.21&lt;br /&gt;
                   (voices (filter myfilter (ly:music-property evt &amp;#039;elements))))     &lt;br /&gt;
              (set! evt (if (or (null? voices)(&amp;lt; n 1))&lt;br /&gt;
                 &amp;#039;()&lt;br /&gt;
                 (nth-voice voices (inexact-&amp;gt;exact n))))&lt;br /&gt;
              (if deeper-level? (begin                                   &lt;br /&gt;
                (set! d (if (&amp;lt; next-d 1) n next-d))        ; keep n if (truncate next-d) = 0&lt;br /&gt;
                (set! evt (extract-voice evt d deeper-level?)))) ; SimultaneousMusic inside?&lt;br /&gt;
              (set! d save-d)&lt;br /&gt;
              evt)))&lt;br /&gt;
     (else (and (ly:music-property evt &amp;#039;duration #f)&lt;br /&gt;
                evt))))&lt;br /&gt;
 music))&lt;br /&gt;
&lt;br /&gt;
extractVoice = #(define-music-function (n music )&lt;br /&gt;
                                                            (integer? ly:music?)&lt;br /&gt;
&amp;quot;Extract in music, the n-th voice of simultaneous music of the same level, keeping &lt;br /&gt;
only basic music events (no more \\Voicexxx or \\new Voice). A Voice separator&lt;br /&gt;
doesn&amp;#039;t count as a voice.&amp;quot;&lt;br /&gt;
(extract-voice music n #f))&lt;br /&gt;
&lt;br /&gt;
deepExtractVoice = #(define-music-function (x music )&lt;br /&gt;
                                                            (number? ly:music?)&lt;br /&gt;
&amp;quot;Behaves like extractVoice, taking first the integer part of x as n argument, but&lt;br /&gt;
goes deeper in each simultaneous music, extracting voice of other potential&lt;br /&gt;
simultaneous music, taking now as n argument the first digit of the decimal part&lt;br /&gt;
of x, then continues always deeper with second digit and so on.&lt;br /&gt;
Notes that a digit of 0, means taking previous value of n, so 2 is equivalent to 2,222...&lt;br /&gt;
and 2,3 to 2,333...&amp;quot;&lt;br /&gt;
(extract-voice music x #t))&lt;br /&gt;
&lt;br /&gt;
notExtractVoice = #(define-music-function (music)(ly:music?)&lt;br /&gt;
&amp;quot;Inside an \\extractVoice section, avoids that a part of this section (called&lt;br /&gt;
here `music) to be extracted.&amp;quot;&lt;br /&gt;
#{ \tag #tagNotExtractVoice $music #})&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% derivated functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
%% If you have enter &amp;lt;&amp;lt; &amp;lt;c e g&amp;gt; \\ &amp;lt;ais cis fis&amp;gt; &amp;gt;&amp;gt;, the first function will&lt;br /&gt;
%% give you c, the second fis&lt;br /&gt;
extractPartUpper = #(define-music-function (music )(ly:music?)&lt;br /&gt;
 #{ \extractNote #1000 \extractVoice #1 $music #})&lt;br /&gt;
&lt;br /&gt;
extractPartLower = #(define-music-function (music )(ly:music?)&lt;br /&gt;
 #{ \extractNote #1 \extractVoice #1000 $music #})&lt;br /&gt;
                          %%%%%% shortcuts %%%%%%%&lt;br /&gt;
#(define ePU extractPartUpper)&lt;br /&gt;
#(define ePL extractPartLower)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%% addNote&lt;br /&gt;
&lt;br /&gt;
#(define (add-note music notes-to-add)                ; music and notes-to-add as music&lt;br /&gt;
  (define (note-&amp;gt;chords-arti note)                    ; note as a NoteEvent&lt;br /&gt;
    (receive (note-arti chord-arti)&lt;br /&gt;
      (partition      ; separates arti for NoteEvent from arti for EventChord&lt;br /&gt;
        (lambda (evt)(memq (ly:music-property evt &amp;#039;name)&lt;br /&gt;
                       (list &amp;#039;StringNumberEvent &amp;#039;StrokeFingerEvent &amp;#039;FingeringEvent)))&lt;br /&gt;
        (ly:music-property note &amp;#039;articulations))&lt;br /&gt;
      (ly:music-set-property! note &amp;#039;articulations note-arti)&lt;br /&gt;
      chord-arti))&lt;br /&gt;
  (let* ((alist      ; a list of pairs of 2 lists : &amp;#039;(notes . articulations)&lt;br /&gt;
          (reverse (let loop ((m (expand-q-chords notes-to-add)) ; q to chords&lt;br /&gt;
                              (p &amp;#039;())) ; m = music, p previous value of the list&lt;br /&gt;
            (case (ly:music-property m &amp;#039;name)&lt;br /&gt;
              ((or SkipEvent SkipMusic) ; a skip in notes-to-add means : add nothing&lt;br /&gt;
                 (cons #f p))           ; add #f to the list&lt;br /&gt;
              ((NoteEvent) &lt;br /&gt;
                 (acons (list m) (note-&amp;gt;chords-arti m) p))&lt;br /&gt;
              ((EventChord)&lt;br /&gt;
                 (receive (notes arti) ; separates notes from scripts, dynamics etc&lt;br /&gt;
                   (partition noteEvent? (ly:music-property m &amp;#039;elements))&lt;br /&gt;
                   (if (pair? notes)(acons notes arti p) p)))&lt;br /&gt;
              (else (let ((e (ly:music-property m &amp;#039;element)))&lt;br /&gt;
                 (fold loop&lt;br /&gt;
                       (if (ly:music? e)(loop e p) p)&lt;br /&gt;
                       (ly:music-property m &amp;#039;elements))))))))&lt;br /&gt;
        (entry #f)  ; will be (car alist)&lt;br /&gt;
        (entry? (lambda() (and&lt;br /&gt;
                  (pair? alist)&lt;br /&gt;
                  (begin (set! entry (car alist))&lt;br /&gt;
                         (set! alist (cdr alist))&lt;br /&gt;
                         entry))))&lt;br /&gt;
        (do-add (lambda (notes arti)&lt;br /&gt;
                  (let* ((dur (ly:music-property (car notes) &amp;#039;duration))&lt;br /&gt;
                         (new-notes (map            ; fix all durations to dur&lt;br /&gt;
                           (lambda(evt)(ly:music-set-property! evt &amp;#039;duration dur)&lt;br /&gt;
                                       evt)&lt;br /&gt;
                           (car entry)))            ; the list of new notes&lt;br /&gt;
                         (new-arti (cdr entry)))    ; the articulations&lt;br /&gt;
                     (append new-notes notes new-arti arti)))))&lt;br /&gt;
    ;; combine in chords, each element of alist with notes of music  &lt;br /&gt;
   (map-some-music&lt;br /&gt;
     (lambda(x)&lt;br /&gt;
       (case (ly:music-property x &amp;#039;name)&lt;br /&gt;
           ((NoteEvent)(if (entry?)&lt;br /&gt;
              (make-event-chord (do-add (list x) (note-&amp;gt;chords-arti x)))&lt;br /&gt;
              x))&lt;br /&gt;
           ((EventChord)&lt;br /&gt;
              (if (entry?)(receive (notes arti) ; separates notes from scripts, dynamics etc&lt;br /&gt;
                (partition noteEvent? (ly:music-property x &amp;#039;elements))&lt;br /&gt;
                (if (pair? notes)(ly:music-set-property! x &amp;#039;elements (do-add notes arti)))))&lt;br /&gt;
              x)&lt;br /&gt;
           (else (and (ly:music-property x &amp;#039;duration #f) x)))) ; #f means : go deeper&lt;br /&gt;
     (expand-q-chords music))))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
addNote = #(define-music-function (music notes)&lt;br /&gt;
                                                          (ly:music? ly:music?)&lt;br /&gt;
&amp;quot;Merges in a chord, the first note or chord in `music, with the first note or chord&lt;br /&gt;
in `notes, including articulations, then continues to the second one, and so on.&lt;br /&gt;
The duration of notes are taken from `music.&lt;br /&gt;
In `notes, only note or chord events are kept.&amp;quot;&lt;br /&gt;
(add-note #{\relative c&amp;#039; $music  #}   ; the 2 music-parameters will&lt;br /&gt;
          #{\relative c&amp;#039; $notes  #})) % be seen in \relative mode&lt;br /&gt;
          &lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%% addVoice&lt;br /&gt;
%% Traditionnal way&lt;br /&gt;
addVoice = #(define-music-function (music newVoice)&lt;br /&gt;
                                                          (ly:music? ly:music?)&lt;br /&gt;
#{ &amp;lt;&amp;lt; $music \\ $newVoice &amp;gt;&amp;gt; #})&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%% Alternate way&lt;br /&gt;
addVoiceAlt = #(define-music-function (music newVoice)&lt;br /&gt;
                                                          (ly:music? ly:music?)&lt;br /&gt;
#{ &amp;lt;&amp;lt; { \voiceOne $music } \new Voice { \voiceTwo $newVoice } &amp;gt;&amp;gt;&lt;br /&gt;
   \oneVoice #})&lt;br /&gt;
                                                          &lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
deleteDynamics = #(define-music-function (music) (ly:music?)&lt;br /&gt;
(music-filter (lambda (evt)&lt;br /&gt;
                (not (memq (ly:music-property evt &amp;#039;name) (list &lt;br /&gt;
                           &amp;#039;AbsoluteDynamicEvent &amp;#039;CrescendoEvent &amp;#039;DecrescendoEvent))))&lt;br /&gt;
   	      music))&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
absolute = #(define-music-function (music) (ly:music?)&lt;br /&gt;
&amp;quot;A \\relative command will have no effect in the resulting music.&amp;quot;&lt;br /&gt;
(make-music &amp;#039;UnrelativableMusic &amp;#039;element music))&lt;br /&gt;
&lt;br /&gt;
doubleNote = #(define-music-function (music) (ly:music?)&lt;br /&gt;
&amp;quot;Double each note with the note an octave higher.&amp;quot;&lt;br /&gt;
 #{ \addNote \transpose c c&amp;#039; \relative c&amp;#039; { $music } $music #})&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
%% Well \shiftDurations do now the same things ...&lt;br /&gt;
%% depracated functions&lt;br /&gt;
&lt;br /&gt;
doubleDur = #(define-music-function (music)(ly:music?)&lt;br /&gt;
(map-some-music&lt;br /&gt;
 (lambda (evt)&lt;br /&gt;
   (let ((dur (ly:music-property evt &amp;#039;duration #f)))&lt;br /&gt;
     (and dur (begin&lt;br /&gt;
          (ly:music-set-property! evt &amp;#039;duration (ly:make-duration&lt;br /&gt;
            (1- (ly:duration-log dur))&lt;br /&gt;
            (ly:duration-dot-count dur)))&lt;br /&gt;
          evt))))&lt;br /&gt;
 music))&lt;br /&gt;
&lt;br /&gt;
halfDur = #(define-music-function (music)(ly:music?)&lt;br /&gt;
(map-some-music&lt;br /&gt;
 (lambda (evt)&lt;br /&gt;
   (let ((dur (ly:music-property evt &amp;#039;duration #f)))&lt;br /&gt;
     (and dur (begin&lt;br /&gt;
         (ly:music-set-property! evt &amp;#039;duration (ly:make-duration&lt;br /&gt;
            (1+ (ly:duration-log dur))&lt;br /&gt;
            (ly:duration-dot-count dur)))&lt;br /&gt;
         evt))))&lt;br /&gt;
 music))&lt;br /&gt;
 &lt;br /&gt;
	%%%%%%%%%%%%%%%%%%%%%%%%% TESTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
&lt;br /&gt;
music = \relative c&amp;#039; {&lt;br /&gt;
  &amp;lt;c e g&amp;gt;4-&amp;gt; &amp;lt;d f&amp;gt;( &amp;lt;b g&amp;#039; d&amp;#039;&amp;gt;) &amp;lt;c e g&amp;gt;-.&lt;br /&gt;
  g2 c2&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
\score {&lt;br /&gt;
  &amp;lt;&amp;lt;&lt;br /&gt;
    \new Staff \music &lt;br /&gt;
    \new Staff \extractNote #3 \music&lt;br /&gt;
    \new Staff \extractNote #2 \music&lt;br /&gt;
    \new Staff \extractNote #1 \music&lt;br /&gt;
  &amp;gt;&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/lilypond&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Preparing parts]]&lt;br /&gt;
[[Category:Scheme]]&lt;br /&gt;
[[Category:Really cool]]&lt;/div&gt;</summary>
		<author><name>Jean Abou Samra</name></author>
	</entry>
</feed>