Re: rhythm fragments in different pitches

2012-09-24 Thread Jan Nieuwenhuizen
David Kastrup writes:

 An rtf file with the error log?  Seriously?

Probably an Emacs user :-P

https://raw.github.com/pusto/rtf-el/master/rtf.el

seems to work nicely...

Jan

-- 
Jan Nieuwenhuizen jann...@gnu.org | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

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


Re: rhythm fragments in different pitches

2012-09-22 Thread eluze
quot;Dr. med. Kai Lautenschlägerquot;-2 wrote
 Hi Everyone,
 
 Although I am positive, that I read about this in the list, I cannot find
 it anymore. So I kindly ask for a pointer in the right direction.
 
 I am trying to code a piece with voices that use the same rhythmical
 fragment over and over again. I would like to write something like:

are you thinking of http://lsr.dsi.unimi.it/LSR/Item?id=654 (I searched the
LSR for pattern)

Eluze



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/rhythm-fragments-in-different-pitches-tp133299p133300.html
Sent from the User mailing list archive at Nabble.com.

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


Re: rhythm fragments in different pitches

2012-09-22 Thread David Kastrup
Dr. med. Kai Lautenschläger kai.lautenschlae...@me.com writes:

 Hi Everyone,

 Although I am positive, that I read about this in the list, I cannot
 find it anymore. So I kindly ask for a pointer in the right direction.

 I am trying to code a piece with voices that use the same rhythmical
 fragment over and over again. I would like to write something like:


 \version 2.17.2

 rhythm = { s8.[ s16] }
 melody = \relative c { a d g f e b}

 \score {
 \new staff 
 \relative c { g2 d8 h e4 f  } 
 \applyRhythm \rhythm \melody
 \relative c { g2 d8 h e4 f  } 

 \layout {  }
 }


It is annoying how many bugs you built into your skeleton.  You should
really try to make them work except for the missing parts.  At any rate,
it would appear that something like

\language deutsch

rhythm = { s8.[ s16] }
melody = \relative c { a d g f e b}

applyRhythm =
#(define-music-function (parser location rhythm melody)
  (ly:music? ly:music?)
  #{ $@(map
(lambda (p da) #{ $p $@da #})
(reverse!
 (fold-some-music
  (lambda (m) (ly:music-property m 'pitch #f))
  (lambda (m l) (cons (ly:music-property m 'pitch) l))
  '()
  melody))
(apply circular-list
 (reverse!
  (fold-some-music
   (lambda (m) (music-is-of-type? m 'skip-event))
   (lambda (m l)
(cons (cons (ly:music-property m 'duration)
   (ly:music-property m 'articulations))
 l))
   '()
   rhythm
  #})

\score {
\new Voice {
\relative c { g2 d8 h e4 f  } 
\applyRhythm \rhythm \melody
\relative c { g2 d8 h e4 f  } 
}
\layout {  }
}

does the trick.

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


Re: rhythm fragments in different pitches

2012-09-22 Thread David Kastrup
Dr. med. Kai Lautenschläger kai.lautenschlae...@me.com writes:

 Thanks eluze,

 That was the one I was searching for. I just didn't come up with the
 keyword pattern. Now I suppose I should safe the snippet in a
 .ly-file and \include it into my code, right? If I do so and don't
 change anything else (meaning I don't actually _use_ the snippet yet)
 I get a whole set of errors when compiling. I attach them
 separately. Did I do something wrong or is it a problem with the
 snippet. I used the snippet for 2.16, using 2.17.2 for compiling.

 Any help is appreciated.

An rtf file with the error log?  Seriously?

-- 
David Kastrup


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


Re: rhythm fragments in different pitches

2012-09-22 Thread Dr. med. Kai Lautenschläger
Hi,

I am seriously sorry, I annoyed you with bugs in the code and lengthy files. It 
was not meant like that and I apologize. Especially since I really continue to 
be amazed by the efficiency of this list and the speed, with which help is 
offered. So I hope you will forgive my obviously mistaken approach. 
Nevertheless I got the help, that I needed - as always. Everything works fine 
with the file, that David posted. Thanks, again. Will work on my questioning 
skills …

Best regards,

Kai


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


Re: rhythm fragments in different pitches

2012-09-22 Thread David Kastrup
Dr. med. Kai Lautenschläger kai.lautenschlae...@me.com writes:

 Hi,

 I am seriously sorry, I annoyed you with bugs in the code and lengthy
 files. It was not meant like that and I apologize. Especially since I
 really continue to be amazed by the efficiency of this list and the
 speed, with which help is offered. So I hope you will forgive my
 obviously mistaken approach.

It's not as much a matter of annoyance than of efficiency.  If people
are willing to spend a few minutes on your problems, you don't want to
have them spend this time on things that don't actually help you.

With regard to the log file in rtf format: this is not going to be
overly useful to most developers.  So if you attach information to mail
to the list, try avoiding a workflow involving Word or other word
processors.  Your mail client should be able to attach files without
needing to involve a word processor.

 Nevertheless I got the help, that I needed - as always. Everything
 works fine with the file, that David posted.

At some point of time, we probably should have a convenience function
for the pattern

(reverse! (fold-some-music [predicate]
   (lambda (l m) (cons ([extractor] m) l))
   '()
   [music]))

The example code I posted uses this twice already.

-- 
David Kastrup


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


Re: rhythm fragments in different pitches

2012-09-22 Thread Kai Lautenschläger
Hi David, 

Thanks for explaining. As for your idea below I would like that feature very 
much, though I do not understand the code because I am illiterate to 
programming languages.

Best regards,
Kai

... von unterwegs gesendet!

Am 22.09.2012 um 12:42 schrieb David Kastrup d...@gnu.org:

 At some point of time, we probably should have a convenience function
 for the pattern
 
 (reverse! (fold-some-music [predicate]
   (lambda (l m) (cons ([extractor] m) l))
   '()
   [music]))
 
 The example code I posted uses this twice already.
 
 -- 
 David Kastrup
 
 
 ___
 lilypond-user mailing list
 lilypond-user@gnu.org
 https://lists.gnu.org/mailman/listinfo/lilypond-user

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


Re: rhythm fragments in different pitches

2012-09-22 Thread David Kastrup
Kai Lautenschläger kai.lautenschlae...@me.com writes:

 Am 22.09.2012 um 12:42 schrieb:

 At some point of time, we probably should have a convenience function
 for the pattern
 
 (reverse! (fold-some-music [predicate]
   (lambda (l m) (cons ([extractor] m) l))
   '()
   [music]))
 
 The example code I posted uses this twice already.


 Thanks for explaining. As for your idea [above] I would like that
 feature very much, though I do not understand the code because I am
 illiterate to programming languages.

It turns out that the ([extractor] m) pattern can be equally well done
separately using map!, so actually every function needed here is already
available, making this somewhat simpler:

\language deutsch

rhythm = { s8.[ s16] }
melody = \relative c { a d g f e b}

applyRhythm =
#(define-music-function (parser location rhythm melody)
   (ly:music? ly:music?)
   #{ $@(map!
 (lambda (p da) #{ $p $@da #})
 (map!
  (lambda (m) (ly:music-property m 'pitch))
  (extract-music melody
 (lambda (m) (ly:music-property m 'pitch #f
 (apply circular-list
(map!
 (lambda (m) (cons (ly:music-property m 'duration)
   (ly:music-property m 'articulations)))
 (extract-typed-music rhythm 'skip-event
   #})

\score {
\new Voice {
\relative c { g2 d8 h e4 f  } 
\applyRhythm \rhythm \melody
\relative c { g2 d8 h e4 f  } 
}
\layout {  }
}


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


Re: rhythm fragments in different pitches

2012-09-22 Thread David Kastrup
David Kastrup d...@gnu.org writes:

 Kai Lautenschläger kai.lautenschlae...@me.com writes:

 Am 22.09.2012 um 12:42 schrieb:

 At some point of time, we probably should have a convenience function
 for the pattern
 
 (reverse! (fold-some-music [predicate]
   (lambda (l m) (cons ([extractor] m) l))
   '()
   [music]))
 
 The example code I posted uses this twice already.


 Thanks for explaining. As for your idea [above] I would like that
 feature very much, though I do not understand the code because I am
 illiterate to programming languages.

 It turns out that the ([extractor] m) pattern can be equally well done
 separately using map!, so actually every function needed here is already
 available, making this somewhat simpler:

And actually, one does not need to nest the #{ #} constructs here, so
the following will do fine:

\language deutsch

rhythm = { s8.[ s16] }
melody = \relative c { a d g f e b}

applyRhythm =
#(define-music-function (parser location rhythm melody)
   (ly:music? ly:music?)
   #{ $@(append-map
 cons
 (map!
  (lambda (m) (ly:music-property m 'pitch))
  (extract-music melody
 (lambda (m) (ly:music-property m 'pitch #f
 (apply circular-list
(map!
 (lambda (m) (cons (ly:music-property m 'duration)
   (ly:music-property m 'articulations)))
 (extract-typed-music rhythm 'skip-event
   #})

\score {
\new Voice {
\relative c { g2 d8 h e4 f  } 
\applyRhythm \rhythm \melody
\relative c { g2 d8 h e4 f  } 
}
\layout {  }
}


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


Re: rhythm fragments in different pitches

2012-09-22 Thread Gilles


I am trying to code a piece with voices that use the same rhythmical  
fragment over and over again. [..]


Perhaps this one :
http://lsr.dsi.unimi.it/LSR/Item?id=654
But LSR gives also other answers with the keyword : rhythm
http://lsr.dsi.unimi.it/LSR/Search?q=rhythm

--
Gilles

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


Re: rhythm fragments in different pitches

2012-09-22 Thread Gilles
Le Sat, 22 Sep 2012 14:44:19 +0200, Gilles gilles.thiba...@free.fr a  
écrit:




I am trying to code a piece with voices that use the same rhythmical  
fragment over and over again. [..]


Perhaps this one :
http://lsr.dsi.unimi.it/LSR/Item?id=654


Oh to bad. When i send my message, i had no answers from anybody to the  
initial message... Sorry


I answer to all messages at one time :
   I get a whole set of errors
At the end of the snippet, there is a link here, to download the *last*  
version of the snippet. Old versions don't work with Lilypond 2.16.

Well, i must admit that i didn't test \changePitch with 2.17

   applyRhythm = #(define-music-function [...]
The code given by David is an example for all of conciseness, but has some  
limitations

  1- Doesn't work with chords
melody = \relative c { a d f g f e b} % error
  2- All articulations in melody will be ignored
melody = \relative c { a\p d- g( f e) b} will gave the same  
result than

melody = \relative c { a d g f e b}
  3- You cannot have rests in the patterns
so you cannot have a pattern like :
rhythm = { c8 r8 r8. c16 }


--
Gilles

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


Re: rhythm fragments in different pitches

2012-09-22 Thread David Kastrup
Gilles gilles.thiba...@free.fr writes:

 Le Sat, 22 Sep 2012 14:44:19 +0200, Gilles gilles.thiba...@free.fr a
 écrit:


 I am trying to code a piece with voices that use the same
 rhythmical fragment over and over again. [..]

 Perhaps this one :
 http://lsr.dsi.unimi.it/LSR/Item?id=654

 Oh to bad. When i send my message, i had no answers from anybody to
 the initial message... Sorry

 I answer to all messages at one time :
I get a whole set of errors
 At the end of the snippet, there is a link here, to download the
 *last* version of the snippet. Old versions don't work with Lilypond
 2.16.
 Well, i must admit that i didn't test \changePitch with 2.17

applyRhythm = #(define-music-function [...]
 The code given by David is an example for all of conciseness, but has
 some limitations

Every code has limitations.  The limitations of this example were
matched to the specs.

   1- Doesn't work with chords
 melody = \relative c { a d f g f e b} % error
   2- All articulations in melody will be ignored
 melody = \relative c { a\p d- g( f e) b} will gave the same
 result than
 melody = \relative c { a d g f e b}
   3- You cannot have rests in the patterns
 so you cannot have a pattern like :
 rhythm = { c8 r8 r8. c16 }

Reality check: the given template used _spacer_ rests to specify the
rhythm.  If I had copied the given melody into _spacer_ rests, the
output would not have been particularly impressive.

At any rate, a version with specs similar to what you now consider
missing has also been recently discussed and posted on the list IIRC.

-- 
David Kastrup


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


Re: rhythm fragments in different pitches

2012-09-22 Thread Gilles


Every code has limitations.

Oh yes, of course. My message was just an information/advertisement for
users looking for a rhythm pattern function.
In a more general way, i really thank you, David, to post all these pieces
of code, because it is very instructive for people trying to learn scheme.
In your last code for example, i learn a util use of the circular-list
that i could not imagine, and well, probably i will have to reconsider
some pieces of my code ...

--
Gilles

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