lilypond-user
[Top][All Lists]
Advanced

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

Re: music patterns and octave


From: Thomas Morley
Subject: Re: music patterns and octave
Date: Tue, 8 Mar 2016 22:19:22 +0100



2016-03-08 17:45 GMT+01:00 Gianmaria Lari <address@hidden>:
Suppose you have this:

Inline image 2

This is something like 

\fragment d d
\fragment c e
\fragment e c

So, more precisely I would write:

\version "2.19.35"

pattern =
{
   c16 d e f g a b c
}

\relative c' 
{
  \pattern d4 d4
  \pattern c4 e4
  \pattern e4 c4
}

But the previous code generate:
 
Inline image 1

So I played a bit with "\absolute" and at the end I have been able to fix the issue. Here it is the code:

\version "2.19.35"

pattern = \absolute
{
   c'16 d' e' f' g' a' b' c''
}

\relative c'' 
{
  \pattern d4 d4
  \pattern c4 e4
  \pattern e4 c4
}

Unfortunately this solution does not work well with "\changePitch" (that I need). I also tried setting the pattern in the following way:

pattern = \relative c'
{
   c16 d e f g a b c
}

but it also does not work because the scope of "\relative " ends at the end of the _expression_ (if I understood correctly).

Any suggestion?

(1)
Please don't use inline-images, I'm not the only one always filtering them, please attach them.

(2)
I've no idea about changePitch, it's not in the source. Please post (read: attach) the code or a link to it.

(3)
You may be looking for make-relative, for an example see:
http://lsr.di.unimi.it/LSR/Item?id=465

In your use-case maybe:

\version "2.19.36"

pat = \relative c' {
   c16 d e f g a b c
}

pattern =
#(define-music-function (m) (ly:music?)
  (make-relative (pat) pat m))

\relative c  {
  \pattern \pat  d'4 d4
  \pattern \pat  c4 e4
  \pattern \pat  e4 c4
}

Can't be sure, without clue what you actually want to achieve, though.
 
does exist any command to simply set the octave of the next note?

Maybe below, setting octave up or down:

\version "2.19.36"

setOtherPitchOctave =
#(define-music-function (oct-change m)(integer? ly:music?)
(if (music-is-of-type? m 'note-event)
    (let* ((p (ly:music-property m 'pitch)))
    #{
      \withMusicProperty #'pitch
        #(ly:make-pitch
           (+ oct-change (ly:pitch-octave p))
           (ly:pitch-notename p)
           (ly:pitch-alteration p))
      $m
    #})
    m))
  
  
\relative c' {
    c'' d e f
    \setOtherPitchOctave -1
    g a b c
}


Cheers,
  Harm
 


reply via email to

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