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
Transpose italian chords
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!
Transpose x steps (-12 <= x <= 12) chords written as lyrics in a string. To be used with AccordiMio.ly. <lilypond version="2.24.0"> %Transpose x steps (-12 <= x <= 12) chords written as lyrics in a string. %To be used with AccordiMio.ly \language "italiano" #(begin ;variabili globali (define semitoni-global 0) ) TrasportaMio = #(define-music-function (semitoni stringa-in) (number? ly:music?) (define stringa-out "") ;controlla che semitoni stia fra -12 e 12 (cond ((and (<= semitoni 12) (>= semitoni -12)) (begin (set! semitoni-global semitoni) (set! stringa-out (music-map elabora-trasposizione stringa-in)) stringa-out ) ) (else (begin (ly:parser-error "I semitoni devono essere compresi fra -12 e 12.") stringa-in ) ) ) ) #(define (elabora-trasposizione stringa-in) (define stringa-out "") (define elemento "") (define p-nota 0) (define p-alterazione 0) (define nome-nota #("do" "re" "mi" "fa" "sol" "la" "si")) (define num-nota #( 0 2 4 5 7 9 11 )) (define nome-alterazione #("bb" "dd" "b" "d" "")) ;ordino dalle stringhe più lunghe alle più corte (define num-alterazione #( -2 2 -1 1 0)) (define nome-nota-sostituita #("do" "reb" "re" "mib" "mi" "fa" "fad" "sol" "lab" "la" "sib" "si")) ;sostituisco con l'omologo che ha meno alterazioni in chiave ;imposto l'uscita uguale all'ingresso (nel caso non debba modificare nulla) (set! stringa-out stringa-in) ;quando la stringa-in è al livello di LyricEvent... (when (eq? (ly:music-property stringa-in 'name) 'LyricEvent) ;ricavo la stringa con tutti gli accordi (set! elemento (ly:music-property stringa-in 'text)) ;sostituisco dalle parole più lunghe a quelle più brevi ;sostituisco le stringhe semidim e dim con un segnaposto (semidim contiene all'interno MI che potrebbe essere interpretato come una nota, dim comincia per D che potrebbe essere interpretato come diesis) (set! elemento (ly:string-substitute "semidim" "<100>" elemento)) (set! elemento (ly:string-substitute "dim" "<200>" elemento)) ;sostituisco alla nota il suo valore numerico trasportato (do ((p-nota 0 (+ p-nota 1))) ((>= p-nota 7)) (do ((p-alterazione 0 (+ p-alterazione 1))) ((>= p-alterazione 5)) (set! elemento (ly:string-substitute (string-append (vector-ref nome-nota p-nota) (vector-ref nome-alterazione p-alterazione)) (string-append "<" (number->string (modulo (+ (vector-ref num-nota p-nota) (vector-ref num-alterazione p-alterazione) semitoni-global) 12)) ">") elemento)) ) ) ;sostituisco al valore numerico trasportato la nota con l'alterazione più utilizzata (do ((p-nota 0 (+ p-nota 1))) ((>= p-nota 12)) (set! elemento (ly:string-substitute (string-append "<" (number->string p-nota) ">") (vector-ref nome-nota-sostituita p-nota) elemento)) ) ;sostituisco i segnaposto con le stringhe semidim e dim (set! elemento (ly:string-substitute "<100>" "semidim" elemento)) (set! elemento (ly:string-substitute "<200>" "dim" elemento)) ;sostituisco 'elements con la stringa trasposta (ly:music-set-property! stringa-out 'text elemento) ) stringa-out ) musica = \new Staff { \new Voice \relative do' { do4 re mi fa sol la si do } } accordi = \new Lyrics \lyricmode { "dobb.4 redim mi fasemidim" } << \musica \TrasportaMio 1 \accordi >> </lilypond>
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
Transpose italian chords
Add topic