[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pitch argument for transpose function
From: |
Thomas Morley |
Subject: |
Re: pitch argument for transpose function |
Date: |
Thu, 18 Feb 2021 11:46:08 +0100 |
Am Do., 18. Feb. 2021 um 11:12 Uhr schrieb Robert Kubosz
<kubosz.robert@gmail.com>:
>
> Hello!
>
>
> I want to write a piece of code, that would automatically fill-in
> missing voices. Here is a snippet that represents what I want to accomplish:
>
>
> \version "2.22.0"
>
>
> voice-one = {c'}
>
>
> #(define interval "c' b")
>
> %this does not work
> %\transpose function expects pitch as first argument,
> %but unfortunately I have no idea how to provide it
>
> voice-two = \transpose \interval \voice-one
>
> {\voice-two}
>
>
> Of course it throws errors.
>
> Does somebody what to write to make it work?
> I want to keep transpose intervals in scheme variables, because there is
> ~24 voices and I want to keep the code maintainable.
>
>
> Best regards
>
> Robert Kubosz
>
>
Probably:
\version "2.22.0"
#(define interval #{ c' b #})
voice-one = { c' }
transposedMusic =
#(define-music-function (from-to-music music)(ly:music? ly:music?)
(let ((transpose-pitches (event-chord-pitches from-to-music)))
(if (= (length transpose-pitches) 2)
(apply transpose `(,@transpose-pitches ,music))
(begin
(ly:warning
"\\transpose expects two pitches: ~a, ignoring."
transpose-pitches)
music))))
voice-two = \transposedMusic \interval \voice-one
\new Staff \voice-two
Cheers,
Harm