lilypond-user
[Top][All Lists]
Advanced

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

Re: Expanding bowed arpeggios


From: David Kastrup
Subject: Re: Expanding bowed arpeggios
Date: Thu, 17 Jan 2013 14:56:46 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

shutterfreak <address@hidden> writes:

> shutterfreak wrote
>> On Sat, Nov 24, 2012 at 1:26 PM, Olivier Biot &lt;
>
>> olivier.biot@
>
>> &gt;wrote:
>> 
>> Dear all,
>> 
>> Following up on my own request, I stumbled upon an insightful article
>> featuring Bach's prelude for piano (BWV 846):
>> http://news.lilynet.net/?The-LilyPond-Report-23#feature_story_prelude_1_in_scheme
>> 
>> Based on this example I managed to create a first version, which however
>> only works with *absolute* pitches (see measure 1).
>> 
>> How can I make it work with *relative* pitches (see measure 2)?
>> 
>> %%% BEGIN Snippet
>> \version "2.16.1"
>> 
>> arpeggiate = #(define-music-function (parser location d p1 p2 p3 p4)
>>                 (ly:duration? ly:pitch? ly:pitch? ly:pitch? ly:pitch?)
>>                 "Arpeggiate each of the 4 notes note with a duration of
>> d."
>>                 #{
>>                   $p1 $d ( $p2 $d $p3 $d $p4 $d )
>>                   $p4 $d ( $p3 $d $p2 $d $p1 $d )
>>                 #})
>> 
>> theMusic = {
>>   \arpeggiate 8 g d' a' e''
>>   \relative g {
>>     \arpeggiate 8 g d' a' e'
>>   }
>> }

Try something like (planning to commit this macro soonish)
#(defmacro-public make-relative (pitches last-pitch music)
  "The list of pitch-carrying variables in @var{pitches} is used as a
sequence for creating relativable music from @var{music}.
The variables in @var{pitches} are, when considered inside of
@code{\\relative}, all considered to be specifications to the preceding
variable.  The first variable is relative to the preceding musical
context, and @var{last-pitch} specifies the pitch passed as relative
base onto the following musical context."

  ;; pitch and music generator might be stored instead in music
  ;; properties, and it might make sense to create a music type of its
  ;; own for this kind of construct rather than using
  ;; RelativeOctaveMusic
  (define ((make-relative::to-relative-callback pitches p->m p->p) music pitch)
    (let* ((chord (make-event-chord
                   (map
                    (lambda (p)
                      (make-music 'NoteEvent
                                  'pitch p))
                    pitches)))
           (pitchout (begin
                       (ly:make-music-relative! chord pitch)
                       (event-chord-pitches chord))))
      (set! (ly:music-property music 'element)
            (apply p->m pitchout))
      (apply p->p pitchout)))
  `(make-music 'RelativeOctaveMusic
               'to-relative-callback
               (,make-relative::to-relative-callback
                (list ,@pitches)
                (lambda ,pitches ,music)
                (lambda ,pitches ,last-pitch))
               'element ,music))


arpeggiate =
#(define-music-function (parser location d p1 p2 p3 p4)
   (ly:duration? ly:pitch? ly:pitch? ly:pitch? ly:pitch?)
   "Arpeggiate each of the 4 notes note with a duration of d."
   (make-relative (p1 p2 p3 p4) p1
                #{
                  $p1 $d ( $p2 $d $p3 $d $p4 $d )
                  $p4 $d ( $p3 $d $p2 $d $p1 $d )
                #}))

This is based on the assumption that you want the next relative pitch be
based on the _first_ note of the arpeggio.  If you want it based on the
last instead, write
   (make-relative (p1 p2 p3 p4) p4
in the respective line.

> So far I didn't find a way to make my arpeggio expansion work with
> notes in *relative pitch*. My bet is that I need to do some magic on
> "ly:pitch?" to get it to work, but I am clueless since I don't know
> what I should type as search keywords to get that information. Is
> there for example a relative-pitch-to-absolute-pitch checker routine
> that I could use?

Sorry for taking so long.  Designing a "user interface" and actually
coding this was not exactly trivial.  Note that arpeggiate will work
fine _both_ when using \relative and when not using it.

-- 
David Kastrup



reply via email to

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