lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trying to make pitch and duration independent


From: Caio Giovaneti de Barros
Subject: Trying to make pitch and duration independent
Date: Wed, 5 Oct 2016 12:32:23 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

I've been experimenting with building a function that can accept different durations/rhythm for given pitches and vice versa. I don't know if that is already possible, but I don't seem to find any reference to it, except:

http://lsr.di.unimi.it/LSR/Item?id=346 (different pitches with same rhythm). This is more or less what I imagine, except I also want to be able to do the opposite, namely, create a variable with some pitches that I can manipulate to change its durations.

There is also:

http://lsr.di.unimi.it/LSR/Item?id=305 (shiftDurations) which is too restrictive with the changes in durations (only multiples).

So far, here is what I got:

%%%%%%%%%%%%%%%%%%

\version "2.19.46"

#(define (lilyListLength ls) (length (ly:music-property ls 'elements)))

#(define (getDuration i ls)
   (ly:music-property
    (list-ref (ly:music-property ls 'elements) i) 'duration))

#(define (setDuration! i ls dur)
   (set!
    (ly:music-property
     (list-ref (ly:music-property ls 'elements) i) 'duration)
    dur))

#(define (mapDurations! pitches durations)
   (let rec ((i 0))
     (if (= i (lilyListLength pitches))
         '()
(begin (rec (1+ i)) (setDuration! i pitches (getDuration i durations))))))

setDurations = #(define-music-function (pitches durations) (ly:music? ly:music?)
                  (begin (mapDurations! pitches durations) pitches))

pitches = { c' d' e' f' g' }

durations = { 8 8 4. 8 4 }

{
  \setDurations #pitches #durations
}

{
  \setDurations { c' b c' d' e' } #durations
}

{
  \setDurations { c' d' e' d' c' } {16 16 8 4. 8 }
}

%%%%%%%%%%%%%%%%%%

This is almost what I want, but doesn't work right:
- Tuplets don't work (maybe some recursive way of getting the 'duration property no matter how deep it is nested?) - If, for instance, I have: \setDurations #pitches { 16 16 8 4. 8 } the first appearance of \pitches will also have these new durations (insert a new line in the code above to see what I mean).

Is there some easier way of getting what I want or fixing the code above? Also, it would be nice to have the option of changing only the octaves of a pitch group. I'm using this to work with 12 tone rows and it is common to repeat the same row many times but with pitches in different octaves. It would make my life easier to automate some manipulations of rows and immediately see the result instead of loosing a lot of time doing it by hand only to find out that it doesn't sound very nice. I believe this would also speed up typing in some situations.

Caio Barros



reply via email to

[Prev in Thread] Current Thread [Next in Thread]