Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
LilyPond wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Adding automatic octaves to a melody
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
This macro allows you to get octaves from a sequence of single notes (this is particularly useful in piano music). The function takes two arguments: the first one is a number (#1 adds notes an octave above, #-1 an octave below, etc), the second one is the music to deal with. Beware: the function can handle chords, but tends to reverse the intervals. <lilypond version="2.24.0"> %% http://lsr.di.unimi.it/LSR/Item?id=445 %LSR by Jay Anderson. %modyfied by Simon Albrecht on March 2014. %=> http://lilypond.1069038.n5.nabble.com/LSR-445-error-td160662.html #(define (octave-up m t) (let* ((octave (1- t)) (new-note (ly:music-deep-copy m)) (new-pitch (ly:make-pitch octave (ly:pitch-notename (ly:music-property m 'pitch)) (ly:pitch-alteration (ly:music-property m 'pitch))))) (set! (ly:music-property new-note 'pitch) new-pitch) new-note)) #(define (octavize-chord elements t) (cond ((null? elements) elements) ((eq? (ly:music-property (car elements) 'name) 'NoteEvent) (cons (car elements) (cons (octave-up (car elements) t) (octavize-chord (cdr elements) t)))) (else (cons (car elements) (octavize-chord (cdr elements ) t))))) #(define (octavize music t) (if (eq? (ly:music-property music 'name) 'EventChord) (ly:music-set-property! music 'elements (octavize-chord (ly:music-property music 'elements) t))) music) makeOctaves = #(define-music-function (arg mus) (integer? ly:music?) (music-map (lambda (x) (octavize x arg)) (event-chord-wrap! mus))) \relative c' { \time 3/8 \key gis \minor \makeOctaves #1 { dis8( e dis')~ dis8.( cis16 b8} \makeOctaves #-1 { ais' gis dis) cis( dis <dis gis'>) } } </lilypond> [[Category:Pitches]] [[Category:Scheme]] [[Category:Simultaneous notes]] [[Category:Really cool]] [[Category:Keyboards]]
Summary:
Please note that all contributions to LilyPond wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Meta:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Adding automatic octaves to a melody
Add topic