Scheme function for alternate tagged swing stopped working

2014-12-20 Thread Christopher R. Maden
I wrote a function \sw, against LilyPond 2.12, a while back.

It takes music as an argument, and returns two copies of the music, one
tagged 'layout and one tagged 'midi.  The 'midi tagged one has eighth
notes changed to quarter-eighth triplets (i.e., swung).

I’ve run it through convert-ly a couple of times, and now, against
2.16.2, it doesn’t work.  I’m not sure when it stopped working; I was
setting reels fast enough that it was hard to hear the difference.  But
now I’m setting some hornpipes, and the difference is very clear.

The file that defines the swing function can be found at http://crism.maden.org/music/swing.ly >.

Attached is a simple test file and its output.  The first staff should
have the same passage twice, but swung the second time.  The second
staff should be straight, and the third swung.  Instead, you’ll see that
all four copies are identical, and straight.

It seems that the music internals have changed but I can’t put my finger
on how.  Any pointers would be welcome.

Thanks,
Chris
-- 
Chris Maden, text nerd  http://crism.maden.org/ >
Surround hate and force it to surrender.
GnuPG fingerprint: DB08 CF6C 2583 7F55 3BE9  A210 4A51 DBAC 5C5C 3D5E
\version "2.16.2"

\include "english.ly"
\include "swing.ly"

#(set-default-paper-size "letter")

\paper {
  top-margin = 0.5\in
  bottom-margin = 0.5\in
  left-margin = 0.75\in
  line-width = 7.25\in
  right-margin = 0.5\in
}

\header {
  title = "Swing Test"
}

passage = {
  \sw {
\relative c' {
  c4 d8 e f g a b | c4 b8 a g f e d | c1 \bar "|."
}
  }
}

\score {
  <<
\new Staff <<
  \passage
>>
\new Staff <<
  \keepWithTag #'layout {
\passage
  }
>>
\new Staff <<
  \keepWithTag #'midi {
\passage
  }
>>
  >>
  \layout {}
}


swing_test.pdf
Description: Adobe PDF document
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Scheme function for alternate tagged swing stopped working

2014-12-21 Thread Thomas Morley
2014-12-21 8:29 GMT+01:00 Christopher R. Maden :
> I wrote a function \sw, against LilyPond 2.12, a while back.
>
> It takes music as an argument, and returns two copies of the music, one
> tagged 'layout and one tagged 'midi.  The 'midi tagged one has eighth
> notes changed to quarter-eighth triplets (i.e., swung).
>
> I’ve run it through convert-ly a couple of times, and now, against
> 2.16.2, it doesn’t work.  I’m not sure when it stopped working; I was
> setting reels fast enough that it was hard to hear the difference.  But
> now I’m setting some hornpipes, and the difference is very clear.
>
> The file that defines the swing function can be found at  http://crism.maden.org/music/swing.ly >.
>
> Attached is a simple test file and its output.  The first staff should
> have the same passage twice, but swung the second time.  The second
> staff should be straight, and the third swung.  Instead, you’ll see that
> all four copies are identical, and straight.
>
> It seems that the music internals have changed but I can’t put my finger
> on how.  Any pointers would be welcome.

Hi Christopher,

it's due to the changes for 'EventChord. Until 2.15.x (don't remember
the exact version) every single note was wrapped into an 'EventChord.

Look at the output from:

\displayMusic { d8 e }

2.14.2 returns:

(make-music
  'SequentialMusic
  'elements
  (list (make-music
  'EventChord
  'elements
  (list (make-music
  'NoteEvent
  'duration
  (ly:make-duration 3 0 1 1)
  'pitch
  (ly:make-pitch -1 1 0
(make-music
  'EventChord
  'elements
  (list (make-music
  'NoteEvent
  'duration
  (ly:make-duration 3 0 1 1)
  'pitch
  (ly:make-pitch -1 2 0))

2.16.2 and later returns:

(make-music
  'SequentialMusic
  'elements
  (list (make-music
  'NoteEvent
  'duration
  (ly:make-duration 3 0 1)
  'pitch
  (ly:make-pitch -1 1 0))
(make-music
  'NoteEvent
  'duration
  (ly:make-duration 3 0 1)
  'pitch
  (ly:make-pitch -1 2 0

A quick fix would be to wrap the music into EventChords again.

sw = #(define-music-function (parser location notes) (ly:music?)
   (let ((swing (make-music
 'SequentialMusic
 'elements
 (list
  (make-music
   'RelativeOctaveMusic
   'element
   (make-music
'SequentialMusic
'elements
(swing-eighths
 (ly:music-deep-copy
  (ly:music-property
   (ly:music-property
(car (ly:music-property
  (event-chord-wrap! notes)  ;; 
  'elements))
'element)
   'elements))
 '()
 #f)))
#{
  \tag #'layout { $notes }
  \tag #'midi { $swing }
#}
  )
 )


Alternatively rewrite the functions to work with 'NoteEvent and 'EventChord.




HTH,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Scheme function for alternate tagged swing stopped working

2014-12-24 Thread Christopher R. Maden
On 12/21/2014 04:29 AM, Thomas Morley wrote:
> it's due to the changes for 'EventChord. Until 2.15.x (don't
> remember the exact version) every single note was wrapped into an
> 'EventChord.

Thanks, Harm!  That’s the clue I needed.

> A quick fix would be to wrap the music into EventChords again.

I suppose... I may as well take this opportunity to make it work with
anything with a 'duration property, though.

I’m trying to figure out a generic way to do a *shallow* copy of
heterogeneous structures (i.e., to traverse and copy unmodified as a
starting point, before introducing the few small modifications I want to
make).  Searching hasn’t turned up anything other than
ly:music-deep-copy... if anyone has a pointer to a template for this,
I’d be grateful.

Merry Christmas and/or happy Saturnalia to those as appropriate,
Chris
-- 
Chris Maden, text nerd  http://crism.maden.org/ >
Surround hate and force it to surrender.
GnuPG fingerprint: DB08 CF6C 2583 7F55 3BE9  A210 4A51 DBAC 5C5C 3D5E

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Scheme function for alternate tagged swing stopped working

2014-12-25 Thread Christopher R. Maden
On 12/24/2014 11:15 PM, I wrote:
> I’m trying to figure out a generic way to do a *shallow* copy of 
> heterogeneous structures (i.e., to traverse and copy unmodified as a 
> starting point, before introducing the few small modifications I want
> to make).  Searching hasn’t turned up anything other than 
> ly:music-deep-copy... if anyone has a pointer to a template for
> this, I’d be grateful.

OK!

At http://crism.maden.org/music/swing.ly > is an updated version,
which seems to be working.  Comments welcome, as are use and redistribution.

As for the generic shallow copy, the thing I made as a starting point
for this is below, in case anyone else finds it useful for making a
slightly-modified copy of some music.

#(define (my-copy some-music)
   (cond
((ly:music? some-music)
 (let ((elt (ly:music-property some-music 'element))
   (elts (ly:music-property some-music 'elements))
   (new-music (ly:music-deep-copy some-music)))
   (cond
((not (null? elts))
 (ly:music-set-property! new-music 'elements (my-copy elts)))
((not (null? elt))
 (ly:music-set-property! new-music 'element (my-copy elt)))
)
   new-music))
((list? some-music)
 (map my-copy some-music))
(#t
 (ly:music-deep-copy some-music

~Chris
-- 
Chris Maden, text nerd  http://crism.maden.org/ >
Surround hate and force it to surrender.
GnuPG fingerprint: DB08 CF6C 2583 7F55 3BE9  A210 4A51 DBAC 5C5C 3D5E

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user