Re: Pattern-generating Scheme function challenge

2013-08-18 Thread Janek Warchoł
Hi Schemers,

2013/7/24 Nicolas Sceaux nicolas.sceaux.l...@gmail.com:
 Le 24 juil. 2013 à 01:09, Thomas Morley thomasmorle...@gmail.com a écrit :
 In a few hours (after sleep) I'll start my vacations, being offline
 for three weeks.
 Perhaps someone else might catch the ball.

 Hi,
 Here is a proposition, with probably still room for improvements!

(sorry for delay) This is excellent!  It would be really awesome to
have this code (maybe even both versions for comparison?) on the blog.
 How much time did it take you both to write it?

best,
Janek

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


Re: Pattern-generating Scheme function challenge

2013-08-18 Thread Urs Liska




Janek Warchoł janek.lilyp...@gmail.com schrieb:

Hi Schemers,

2013/7/24 Nicolas Sceaux nicolas.sceaux.l...@gmail.com:
 Le 24 juil. 2013 à 01:09, Thomas Morley thomasmorle...@gmail.com a
écrit :
 In a few hours (after sleep) I'll start my vacations, being offline
 for three weeks.
 Perhaps someone else might catch the ball.

 Hi,
 Here is a proposition, with probably still room for improvements!

(sorry for delay) This is excellent!  It would be really awesome to
have this code (maybe even both versions for comparison?) on the blog.

Maybe after I'll eventually have managed to write my third part of the series 
(achieving the result with Python and plain LilyPond.

Urs

 How much time did it take you both to write it?

best,
Janek

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Pattern-generating Scheme function challenge

2013-08-18 Thread Urs Liska




Janek Warchoł janek.lilyp...@gmail.com schrieb:

Hi Schemers,

2013/7/24 Nicolas Sceaux nicolas.sceaux.l...@gmail.com:
 Le 24 juil. 2013 à 01:09, Thomas Morley thomasmorle...@gmail.com a
écrit :
 In a few hours (after sleep) I'll start my vacations, being offline
 for three weeks.
 Perhaps someone else might catch the ball.

 Hi,
 Here is a proposition, with probably still room for improvements!

(sorry for delay) This is excellent!  It would be really awesome to
have this code (maybe even both versions for comparison?) on the blog.

Maybe after I'll eventually have managed to write my third part of the series 
(achieving the result with Python and plain LilyPond.

Urs

 How much time did it take you both to write it?

best,
Janek

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.

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


Re: Pattern-generating Scheme function challenge

2013-08-17 Thread Thomas Morley
2013/7/24 Nicolas Sceaux nicolas.sceaux.l...@gmail.com:
 Le 24 juil. 2013 à 01:09, Thomas Morley thomasmorle...@gmail.com a écrit :

 Hi David, Urs,

 I'm sorry I didn't try to improve my recent code with David's proposals.

 In a few hours (after sleep) I'll start my vacations, being offline
 for three weeks.
 Perhaps someone else might catch the ball.


 Hi,

 Here is a proposition, with probably still room for improvements!

 Nicolas

Hi Nicolas,

your code is much more elegant than my last trials.

Thanks a lot!

Best,
  Harm

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


Re: Pattern-generating Scheme function challenge

2013-08-17 Thread Urs Liska
Hi all,

I'm sorry I didn't seem to acknowledge your contributions. But I'll surely look 
into them when I'm at home again.

Urs



Thomas Morley thomasmorle...@gmail.com schrieb:

2013/7/24 Nicolas Sceaux nicolas.sceaux.l...@gmail.com:
 Le 24 juil. 2013 à 01:09, Thomas Morley thomasmorle...@gmail.com a
écrit :

 Hi David, Urs,

 I'm sorry I didn't try to improve my recent code with David's
proposals.

 In a few hours (after sleep) I'll start my vacations, being offline
 for three weeks.
 Perhaps someone else might catch the ball.


 Hi,

 Here is a proposition, with probably still room for improvements!

 Nicolas

Hi Nicolas,

your code is much more elegant than my last trials.

Thanks a lot!

Best,
  Harm

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Pattern-generating Scheme function challenge

2013-07-24 Thread Nicolas Sceaux
Le 24 juil. 2013 à 01:09, Thomas Morley thomasmorle...@gmail.com a écrit :

 Hi David, Urs,
 
 I'm sorry I didn't try to improve my recent code with David's proposals.
 
 In a few hours (after sleep) I'll start my vacations, being offline
 for three weeks.
 Perhaps someone else might catch the ball.


Hi,

Here is a proposition, with probably still room for improvements!

Nicolas



finale-exercise.ly
Description: Binary data
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Pattern-generating Scheme function challenge

2013-07-21 Thread Werner LEMBERG

 %% Why not public?
 
 Not public because it is trivial and not discoverable.  People
 looking through GUILE documentation will find and use
 lset-difference.  There is a lot of cruft in lily-library like that
 which should really be thrown out.  Making it public would be a step
 in the wrong direction since then people may start depending on it.

+1


Werner

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


Re: Pattern-generating Scheme function challenge

2013-07-21 Thread David Kastrup
Urs Liska u...@openlilylib.org writes:

 Hi Harm,

 I did a quick compilation (further investigation to follow) - and
 that's awesome! Thenk you very much.
 Of course it will be hard to 'sell' it with a 'hey, look how easy it
 is to realize that with LilyPond ;-)

Let's see how we can improve on that.

 Am 20.07.2013 23:48, schrieb Thomas Morley:
 \version 2.17.22
 %% While compiling with 2.16.2, a little modification in \layout is
 %% recommended.

 %% Used to get access to integer-list
 %% Though, returns a warning:
 %%   imported module (srfi srfi-60) overrides core binding `bit-count'
 #(use-modules (srfi srfi-60))

 %
 %% definitions, helpers and functions
 %

 %% c/p from lily-library.scm
 %% Why not public?
 #(define (list-minus a b)
Return list of elements in A that are not in B.
(lset-difference eq? a b))

 %% Affects beaming for mixed notes and rests.
 %% For debugging, uncomment modified 'thickness and 'color
 #(define modify-beaming
(lambda (grob)
  (let* ((all-stems
(ly:grob-array-list (ly:grob-object grob 'stems)))
 (visible-stems
(ly:grob-array-list (ly:grob-object grob 'normal-stems)))
 ;; not visible stems
 (stx (list-minus all-stems visible-stems)))
   (map

You probably mean for-each here?

(lambda (x y z)
  (let* ((beaming-x (ly:grob-property x 'beaming))
 (beaming-y (ly:grob-property y 'beaming))
 (all-stems-length (length all-stems)))
  (cond
;;RED
((and (member x visible-stems)
  (member y stx)
  (or (member z visible-stems) (member z stx))
  (not (equal? x (first all-stems
   ;(ly:grob-set-property! x 'thickness 10)
   ;(ly:grob-set-property! x 'color red)
   (ly:grob-set-property! x 'beaming
(cons (car beaming-x) (list 0
;;CYAN
((and (member x visible-stems)
  (member y visible-stems)
  (member z stx)
  (equal? x (first all-stems)))
   ;(ly:grob-set-property! y 'thickness 10)
   ;(ly:grob-set-property! y 'color cyan)
   (ly:grob-set-property! y 'beaming
(cons (car beaming-y) (list 0
;;BLUE
((and (member x stx)
  (member y visible-stems)
  (member z visible-stems))
   ;(ly:grob-set-property! y 'thickness 10)
   ;(ly:grob-set-property! y 'color blue)
   (ly:grob-set-property! y 'beaming
(cons (list 0) (cdr beaming-y
(else #f
 all-stems
 (cdr all-stems)
 (cddr all-stems))

This would seem to throw an error unless there are at least two stems.

But the real question is: what are you doing here, and why isn't there a
simpler way to do this?

;; print only one beam over rests
(map
for-each
  (lambda (x)
(ly:grob-set-property! x 'beaming (cons (list 0) (list 0
  stx

 modifyBeaming = \override Beam #'after-line-breaking = #modify-beaming

 #(define (position-in-list obj ls)
Search the positions of obj in ls
 (define (position-in-list-helper obj ls ls1 bypassed)
   (if (null? ls)
   (reverse ls1)
   (if (equal? obj (car ls))
   (position-in-list-helper
   obj (cdr ls) (cons bypassed ls1) (+ bypassed 1))
   (position-in-list-helper
   obj (cdr ls) ls1 (+ bypassed 1)
(position-in-list-helper obj ls '() 0))

Ok, this accumulates in ls1 the positions of obj.  What do you use this
for?  To call (position-in-list #t bool-list) when bool-list only
contains #t and #f as it is generated using integer-list.  So there is
no point whatsoever in doing comparisons here, you could just use the
boolean itself.  What do you do with `trues' afterwards?

Very little.  You use the position of the first set bit, and the
position of the last set bit, and the length.  Let's see what you do
here:

 pattern =
 #(define-music-function (parser location dur-log n)(integer? integer?)
 
   Returns one musical pattern, depending on
   @var{dur-log} for the general duration of note and rests
   @var{n} as the integer, whose bitwise representation is used
   to build the pattern.
 
(let* ((bool-list (integer-list n))
   (bool-list-length (length bool-list))
   (trues (position-in-list #t bool-list))
   (trues-length (length trues))
   (music (map
(lambda (t c)
  (if t
  (make-music
'NoteEvent
 

Re: Pattern-generating Scheme function challenge

2013-07-21 Thread David Kastrup
Thomas Morley thomasmorle...@gmail.com writes:

 2013/7/21 David Kastrup d...@gnu.org:
 Urs Liska u...@openlilylib.org writes:

 Hi Harm,

 I did a quick compilation (further investigation to follow) - and
 that's awesome! Thenk you very much.
 Of course it will be hard to 'sell' it with a 'hey, look how easy it
 is to realize that with LilyPond ;-)

 Let's see how we can improve on that.
 [...]

 Hi David,

 thanks a lot for your thoughts, proposals and the effort you've put on this.
 I was sure that there were several instances in my code which could
 have been done better.

I'm great at improving things and bad at doing them in the first place.
Because I can't bring myself to write something down that merely works
first, and then improve it afterwards.

 Though, because noone else came up with a working solution, I posted
 it in it's current state.

Sure.  Getting something done is important as a first step.

 Will have a closer look later this evening.

A programming environment/language is well designed if the first
solution that comes to mind is not far from elegant and/or optimal.

The way LilyPond's components tie together and that our learning
material helps with understanding and leads to further documentation
does not exactly make that easy.

It's one of the reasons I tailride on such threads and try promoting
simpler solutions, and when everything else fails, write helper routines
to make this possible.

-- 
David Kastrup

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


Re: Pattern-generating Scheme function challenge

2013-07-20 Thread Thomas Morley
Hi Urs,

below my approach.

Though, the function only needs one argument. :)

\version 2.17.22
%% While compiling with 2.16.2, a little modification in \layout is
%% recommended.

%% Used to get access to integer-list
%% Though, returns a warning:
%%   imported module (srfi srfi-60) overrides core binding `bit-count'
#(use-modules (srfi srfi-60))

%
%% definitions, helpers and functions
%

%% c/p from lily-library.scm
%% Why not public?
#(define (list-minus a b)
  Return list of elements in A that are not in B.
  (lset-difference eq? a b))

%% Affects beaming for mixed notes and rests.
%% For debugging, uncomment modified 'thickness and 'color
#(define modify-beaming
  (lambda (grob)
(let* ((all-stems
  (ly:grob-array-list (ly:grob-object grob 'stems)))
   (visible-stems
  (ly:grob-array-list (ly:grob-object grob 'normal-stems)))
   ;; not visible stems
   (stx (list-minus all-stems visible-stems)))
 (map
  (lambda (x y z)
(let* ((beaming-x (ly:grob-property x 'beaming))
   (beaming-y (ly:grob-property y 'beaming))
   (all-stems-length (length all-stems)))
(cond
  ;;RED
  ((and (member x visible-stems)
(member y stx)
(or (member z visible-stems) (member z stx))
(not (equal? x (first all-stems
 ;(ly:grob-set-property! x 'thickness 10)
 ;(ly:grob-set-property! x 'color red)
 (ly:grob-set-property! x 'beaming
  (cons (car beaming-x) (list 0
  ;;CYAN
  ((and (member x visible-stems)
(member y visible-stems)
(member z stx)
(equal? x (first all-stems)))
 ;(ly:grob-set-property! y 'thickness 10)
 ;(ly:grob-set-property! y 'color cyan)
 (ly:grob-set-property! y 'beaming
  (cons (car beaming-y) (list 0
  ;;BLUE
  ((and (member x stx)
(member y visible-stems)
(member z visible-stems))
 ;(ly:grob-set-property! y 'thickness 10)
 ;(ly:grob-set-property! y 'color blue)
 (ly:grob-set-property! y 'beaming
  (cons (list 0) (cdr beaming-y
  (else #f
   all-stems
   (cdr all-stems)
   (cddr all-stems))

  ;; print only one beam over rests
  (map
(lambda (x)
  (ly:grob-set-property! x 'beaming (cons (list 0) (list 0
stx

modifyBeaming = \override Beam #'after-line-breaking = #modify-beaming

#(define (position-in-list obj ls)
  Search the positions of obj in ls
   (define (position-in-list-helper obj ls ls1 bypassed)
 (if (null? ls)
 (reverse ls1)
 (if (equal? obj (car ls))
 (position-in-list-helper
 obj (cdr ls) (cons bypassed ls1) (+ bypassed 1))
 (position-in-list-helper
 obj (cdr ls) ls1 (+ bypassed 1)
  (position-in-list-helper obj ls '() 0))

pattern =
#(define-music-function (parser location dur-log n)(integer? integer?)

 Returns one musical pattern, depending on
 @var{dur-log} for the general duration of note and rests
 @var{n} as the integer, whose bitwise representation is used
 to build the pattern.

  (let* ((bool-list (integer-list n))
 (bool-list-length (length bool-list))
 (trues (position-in-list #t bool-list))
 (trues-length (length trues))
 (music (map
  (lambda (t c)
(if t
(make-music
  'NoteEvent
  'duration (ly:make-duration dur-log 0 1)
  'pitch (ly:make-pitch 1 0 0)
  'articulations
(if (and ( dur-log 2) ( trues-length 1))
(cond ((= (car trues) c)
   (list (make-music
   'BeamEvent
   'span-direction
   -1)))
  ((= (car (last-pair trues)) c)
   (list (make-music
   'BeamEvent
   'span-direction
   1)))
   (else '()))
'()))
(make-music
  'RestEvent
  'duration (ly:make-duration dur-log 0 1
  bool-list (iota bool-list-length

  (make-music 

Re: Pattern-generating Scheme function challenge

2013-07-20 Thread Urs Liska

Hi Harm,

I did a quick compilation (further investigation to follow) - and that's 
awesome! Thenk you very much.
Of course it will be hard to 'sell' it with a 'hey, look how easy it is 
to realize that with LilyPond ;-)


Best
Urs


Am 20.07.2013 23:48, schrieb Thomas Morley:

\version 2.17.22
%% While compiling with 2.16.2, a little modification in \layout is
%% recommended.

%% Used to get access to integer-list
%% Though, returns a warning:
%%   imported module (srfi srfi-60) overrides core binding `bit-count'
#(use-modules (srfi srfi-60))

%
%% definitions, helpers and functions
%

%% c/p from lily-library.scm
%% Why not public?
#(define (list-minus a b)
   Return list of elements in A that are not in B.
   (lset-difference eq? a b))

%% Affects beaming for mixed notes and rests.
%% For debugging, uncomment modified 'thickness and 'color
#(define modify-beaming
   (lambda (grob)
 (let* ((all-stems
   (ly:grob-array-list (ly:grob-object grob 'stems)))
(visible-stems
   (ly:grob-array-list (ly:grob-object grob 'normal-stems)))
;; not visible stems
(stx (list-minus all-stems visible-stems)))
  (map
   (lambda (x y z)
 (let* ((beaming-x (ly:grob-property x 'beaming))
(beaming-y (ly:grob-property y 'beaming))
(all-stems-length (length all-stems)))
 (cond
   ;;RED
   ((and (member x visible-stems)
 (member y stx)
 (or (member z visible-stems) (member z stx))
 (not (equal? x (first all-stems
  ;(ly:grob-set-property! x 'thickness 10)
  ;(ly:grob-set-property! x 'color red)
  (ly:grob-set-property! x 'beaming
   (cons (car beaming-x) (list 0
   ;;CYAN
   ((and (member x visible-stems)
 (member y visible-stems)
 (member z stx)
 (equal? x (first all-stems)))
  ;(ly:grob-set-property! y 'thickness 10)
  ;(ly:grob-set-property! y 'color cyan)
  (ly:grob-set-property! y 'beaming
   (cons (car beaming-y) (list 0
   ;;BLUE
   ((and (member x stx)
 (member y visible-stems)
 (member z visible-stems))
  ;(ly:grob-set-property! y 'thickness 10)
  ;(ly:grob-set-property! y 'color blue)
  (ly:grob-set-property! y 'beaming
   (cons (list 0) (cdr beaming-y
   (else #f
all-stems
(cdr all-stems)
(cddr all-stems))

   ;; print only one beam over rests
   (map
 (lambda (x)
   (ly:grob-set-property! x 'beaming (cons (list 0) (list 0
 stx

modifyBeaming = \override Beam #'after-line-breaking = #modify-beaming

#(define (position-in-list obj ls)
   Search the positions of obj in ls
(define (position-in-list-helper obj ls ls1 bypassed)
  (if (null? ls)
  (reverse ls1)
  (if (equal? obj (car ls))
  (position-in-list-helper
  obj (cdr ls) (cons bypassed ls1) (+ bypassed 1))
  (position-in-list-helper
  obj (cdr ls) ls1 (+ bypassed 1)
   (position-in-list-helper obj ls '() 0))

pattern =
#(define-music-function (parser location dur-log n)(integer? integer?)

  Returns one musical pattern, depending on
  @var{dur-log} for the general duration of note and rests
  @var{n} as the integer, whose bitwise representation is used
  to build the pattern.

   (let* ((bool-list (integer-list n))
  (bool-list-length (length bool-list))
  (trues (position-in-list #t bool-list))
  (trues-length (length trues))
  (music (map
   (lambda (t c)
 (if t
 (make-music
   'NoteEvent
   'duration (ly:make-duration dur-log 0 1)
   'pitch (ly:make-pitch 1 0 0)
   'articulations
 (if (and ( dur-log 2) ( trues-length 1))
 (cond ((= (car trues) c)
(list (make-music
'BeamEvent
'span-direction
-1)))
   ((= (car (last-pair trues)) c)
(list (make-music
'BeamEvent
'span-direction
1)))

Re: Pattern-generating Scheme function challenge

2013-07-20 Thread Thomas Morley
2013/7/20 Urs Liska u...@openlilylib.org:
 Hi Harm,

 I did a quick compilation (further investigation to follow) - and that's
 awesome! Thenk you very much.
 Of course it will be hard to 'sell' it with a 'hey, look how easy it is to
 realize that with LilyPond ;-)

 Best
 Urs

Well, typing
  \output #8
is _very_ easy.

homerisches Gelächter (No idea how to translate)

Cheers,
  Harm

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


Re: Pattern-generating Scheme function challenge

2013-07-20 Thread Urs Liska

Am 21.07.2013 00:07, schrieb Thomas Morley:

2013/7/20 Urs Liska u...@openlilylib.org:

Hi Harm,

I did a quick compilation (further investigation to follow) - and that's
awesome! Thenk you very much.
Of course it will be hard to 'sell' it with a 'hey, look how easy it is to
realize that with LilyPond ;-)

Best
Urs

Well, typing
   \output #8
is _very_ easy.

homerisches Gelächter (No idea how to translate)

If I'd understand what it means I could give it a try ;-)


Cheers,
   Harm



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


Re: Pattern-generating Scheme function challenge

2013-07-20 Thread Thomas Morley
2013/7/21 Urs Liska u...@openlilylib.org:
 Am 21.07.2013 00:07, schrieb Thomas Morley:

 2013/7/20 Urs Liska u...@openlilylib.org:

 Hi Harm,

 I did a quick compilation (further investigation to follow) - and that's
 awesome! Thenk you very much.
 Of course it will be hard to 'sell' it with a 'hey, look how easy it is
 to
 realize that with LilyPond ;-)

 Best
 Urs

 Well, typing
\output #8
 is _very_ easy.

 homerisches Gelächter (No idea how to translate)

 If I'd understand what it means I could give it a try ;-)


 Cheers,
Harm



https://de.wikipedia.org/wiki/Homerisches_Gel%C3%A4chter

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


Re: Pattern-generating Scheme function challenge

2013-07-20 Thread Urs Liska

Am 21.07.2013 00:17, schrieb Thomas Morley:

2013/7/21 Urs Liska u...@openlilylib.org:

Am 21.07.2013 00:07, schrieb Thomas Morley:


2013/7/20 Urs Liska u...@openlilylib.org:

Hi Harm,

I did a quick compilation (further investigation to follow) - and that's
awesome! Thenk you very much.
Of course it will be hard to 'sell' it with a 'hey, look how easy it is
to
realize that with LilyPond ;-)

Best
Urs

Well, typing
\output #8
is _very_ easy.

homerisches Gelächter (No idea how to translate)

If I'd understand what it means I could give it a try ;-)


Cheers,
Harm



https://de.wikipedia.org/wiki/Homerisches_Gel%C3%A4chter
The available articles in other languages (lacking English) seem to 
translate it quite literally, so Homeric laughter should be a good guess.



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


Re: Pattern-generating Scheme function challenge

2013-07-20 Thread Urs Liska

Am 21.07.2013 00:25, schrieb Urs Liska:

Am 21.07.2013 00:17, schrieb Thomas Morley:

2013/7/21 Urs Liska u...@openlilylib.org:

Am 21.07.2013 00:07, schrieb Thomas Morley:


2013/7/20 Urs Liska u...@openlilylib.org:

Hi Harm,

I did a quick compilation (further investigation to follow) - and 
that's

awesome! Thenk you very much.
Of course it will be hard to 'sell' it with a 'hey, look how easy 
it is

to
realize that with LilyPond ;-)

Best
Urs

Well, typing
\output #8
is _very_ easy.

homerisches Gelächter (No idea how to translate)

If I'd understand what it means I could give it a try ;-)


Cheers,
Harm



https://de.wikipedia.org/wiki/Homerisches_Gel%C3%A4chter
The available articles in other languages (lacking English) seem to 
translate it quite literally, so Homeric laughter should be a good guess.



http://www.jstor.org/discover/10.2307/3289782?uid=3737864uid=2uid=4sid=21102480961741
http://en.wiktionary.org/wiki/Homeric_laughter
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Pattern-generating Scheme function challenge

2013-07-20 Thread Thomas Morley
2013/7/21 Urs Liska u...@openlilylib.org:
 Am 21.07.2013 00:25, schrieb Urs Liska:

 Am 21.07.2013 00:17, schrieb Thomas Morley:

 2013/7/21 Urs Liska u...@openlilylib.org:

 Am 21.07.2013 00:07, schrieb Thomas Morley:

 2013/7/20 Urs Liska u...@openlilylib.org:

 Hi Harm,

 I did a quick compilation (further investigation to follow) - and that's
 awesome! Thenk you very much.
 Of course it will be hard to 'sell' it with a 'hey, look how easy it is
 to
 realize that with LilyPond ;-)

 Best
 Urs

 Well, typing
 \output #8
 is _very_ easy.

 homerisches Gelächter (No idea how to translate)

 If I'd understand what it means I could give it a try ;-)


 Cheers,
 Harm


 https://de.wikipedia.org/wiki/Homerisches_Gel%C3%A4chter

 The available articles in other languages (lacking English) seem to
 translate it quite literally, so Homeric laughter should be a good guess.

 http://www.jstor.org/discover/10.2307/3289782?uid=3737864uid=2uid=4sid=21102480961741
 http://en.wiktionary.org/wiki/Homeric_laughter

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


Thanks.

-Harm

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


Re: Pattern-generating Scheme function challenge

2013-07-20 Thread David Kastrup
Thomas Morley thomasmorle...@gmail.com writes:

 %
 %% definitions, helpers and functions
 %

 %% c/p from lily-library.scm
 %% Why not public?
 #(define (list-minus a b)
   Return list of elements in A that are not in B.
   (lset-difference eq? a b))

Not public because it is trivial and not discoverable.  People looking
through GUILE documentation will find and use lset-difference.  There is
a lot of cruft in lily-library like that which should really be thrown
out.  Making it public would be a step in the wrong direction since then
people may start depending on it.

-- 
David Kastrup


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


Re: Pattern-generating Scheme function challenge

2013-07-16 Thread Jan-Peter Voigt

Hi there,

I am not at home ... so here is not a solution, but here is a little 
snippet, that includes two functions, that may be helpful:


\version 2.16.1


musA = \relative c'' {

bes4 a c b

}

musB = #(music-map

(lambda (m)

(let* ((mus m)

(dur (ly:music-property mus 'duration)))

(if (ly:duration? dur)

(ly:music-set-property! mus 'duration

(ly:make-duration

(+ 1 (ly:duration-log dur))

(ly:duration-dot-count dur)

2 1)))

mus)) (ly:music-deep-copy musA))




\new Staff \musA

\new Staff \musB




HTH
Cheers, Jan-Peter



On 13.07.2013 16:03, Urs Liska wrote:

Hi all, the Schemers in particular,

you surely know by now that I am writing a series of posts that 
demonstrate how elegantly and efficiently we can recreate a portion of 
a book that obviously has been produced with many pains in Finale.
I'm confident that it will be an impressive display of LilyPond's 
power :-) but I would love to go even one step further.


In the post published yesterday I showed how easy it is to typeset 
that polymetric example from Aldridge's book.
In the second post (finished but scheduled for monday or tuesday) I 
show a Python function that generates the LilyPond code for a complete 
set of patterns.

The third post will set up the files to finally print the whole set.

I would be happy to include an alternative approach if I can get the 
necessary input from the list (of course I will credit it correctly): 
Instead of generating the patterns' code with Python I would like to 
see a Scheme function that achieves the same directly from within the 
LilyPond files. Probably such an approach could even simplify a few 
other things.



The Python code I used is here: 
https://github.com/openlilylib/aldridge-patterns/blob/master/pattern-generator.py
and the resulting LilyPond file here: 
https://github.com/openlilylib/aldridge-patterns/blob/master/pattern-definitions.ily

and you can of course inspect the whole repository if you want.

The task is to print these examples in five parallel metric contexts 
(see 
http://lilypondblog.org/wp-content/uploads/2013/07/aldridge-ex-19-score.pdf), 


therefore I had to do some things about those virtual time signatures.
If the patterns are generated by a Scheme function we can do better 
and handle this specification 'at source level'.


I have added a dummy file that should hold that function: 
https://github.com/openlilylib/aldridge-patterns/blob/master/pattern-definitions-scheme.ily


So:
The function should take three arguments (as already in the dummy):
- start and
- end of the range (which in my Python function is hardcoded)
- denominator of the time signatures

For each number in the range it should:
- produce a LilyPond pattern corresponding to the binary 
representation of the given number
- chose note/rest duration to be 1/denominator (which is an 
improvement over my Python approach because we can omit the \shift- 
and \scaleDurations process
- beam from the first to the last note if there is more than one note 
and if denominator  4


Additionally the function should:
- Insert a manual break after four patterns or if the length of the 
pattern increases (which happens when the number is a power of two) 
(don't forget to reset the counter in that case)
- after that break re-print the time signature (calculated from the 
length of the pattern and the given denominator) and insert a \mark 
\default


Modifications in the main file I would expect:
- The \newExercise function is obsolete (it was necessary because the 
patterns themselves weren't aware of the denominator)
- Instead of the \shiftDurations - \scaleDurations steps (which can be 
dropped) I'd move the Timing to the individual staves, that is I don't 
use the timeSignatureFractions anymore but real time signatures.
- the \noBeamForLongerNotes function would become obsolete (as we 
don't generate those beams in the first place)
  (Sorry Harm, but it's not in vain because I'd of course also present 
my first approach)

- the patterns are called with \patterns start end denominator.
- As the \shiftDurations are obsolete I don't need that I-II-III-IV-V 
stuff anymore but can place the call of \patterns directly in the \score



I'm sure this would deliver even one more deep hit in our notation 
battle, therefore I'm really looking forward to your suggestions.

They can be discussed here, or I'd happily accept them as pull requests.

Urs



___
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: Pattern-generating Scheme function challenge

2013-07-16 Thread Jan-Peter Voigt

OK, sorry ... I missed the point, you want pattern generation ;)


--snip--

#(use-modules (srfi srfi-60))

#(define-public pattern

(define-music-function (parser location n pitch dur)

(integer? ly:pitch? ly:duration?)

(let ((l (list)))

(define (pat i)

(if ( i n)

(append (pat (* 2 i))

(list

(if (= (bitwise-and i n) 0)

(make-music 'RestEvent 'duration dur)

(make-music 'NoteEvent 'duration dur 'pitch pitch

(list)))

(make-music 'SequentialMusic

'elements (pat 1))

)))


\new Staff {

\time 7/2

\pattern #73 c'' 2

}

--snip--


This will create a series of note- and restevents based on the binary 
pattern of the given integer.



I'll be back next week ;)
HTH

Best, Jan-Peter



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


Pattern-generating Scheme function challenge

2013-07-13 Thread Urs Liska

Hi all, the Schemers in particular,

you surely know by now that I am writing a series of posts that 
demonstrate how elegantly and efficiently we can recreate a portion of a 
book that obviously has been produced with many pains in Finale.
I'm confident that it will be an impressive display of LilyPond's power 
:-) but I would love to go even one step further.


In the post published yesterday I showed how easy it is to typeset that 
polymetric example from Aldridge's book.
In the second post (finished but scheduled for monday or tuesday) I show 
a Python function that generates the LilyPond code for a complete set of 
patterns.

The third post will set up the files to finally print the whole set.

I would be happy to include an alternative approach if I can get the 
necessary input from the list (of course I will credit it correctly): 
Instead of generating the patterns' code with Python I would like to see 
a Scheme function that achieves the same directly from within the 
LilyPond files. Probably such an approach could even simplify a few 
other things.



The Python code I used is here: 
https://github.com/openlilylib/aldridge-patterns/blob/master/pattern-generator.py
and the resulting LilyPond file here: 
https://github.com/openlilylib/aldridge-patterns/blob/master/pattern-definitions.ily

and you can of course inspect the whole repository if you want.

The task is to print these examples in five parallel metric contexts 
(see 
http://lilypondblog.org/wp-content/uploads/2013/07/aldridge-ex-19-score.pdf), 


therefore I had to do some things about those virtual time signatures.
If the patterns are generated by a Scheme function we can do better and 
handle this specification 'at source level'.


I have added a dummy file that should hold that function: 
https://github.com/openlilylib/aldridge-patterns/blob/master/pattern-definitions-scheme.ily


So:
The function should take three arguments (as already in the dummy):
- start and
- end of the range (which in my Python function is hardcoded)
- denominator of the time signatures

For each number in the range it should:
- produce a LilyPond pattern corresponding to the binary representation 
of the given number
- chose note/rest duration to be 1/denominator (which is an improvement 
over my Python approach because we can omit the \shift- and 
\scaleDurations process
- beam from the first to the last note if there is more than one note 
and if denominator  4


Additionally the function should:
- Insert a manual break after four patterns or if the length of the 
pattern increases (which happens when the number is a power of two) 
(don't forget to reset the counter in that case)
- after that break re-print the time signature (calculated from the 
length of the pattern and the given denominator) and insert a \mark \default


Modifications in the main file I would expect:
- The \newExercise function is obsolete (it was necessary because the 
patterns themselves weren't aware of the denominator)
- Instead of the \shiftDurations - \scaleDurations steps (which can be 
dropped) I'd move the Timing to the individual staves, that is I don't 
use the timeSignatureFractions anymore but real time signatures.
- the \noBeamForLongerNotes function would become obsolete (as we don't 
generate those beams in the first place)
  (Sorry Harm, but it's not in vain because I'd of course also present 
my first approach)

- the patterns are called with \patterns start end denominator.
- As the \shiftDurations are obsolete I don't need that I-II-III-IV-V 
stuff anymore but can place the call of \patterns directly in the \score



I'm sure this would deliver even one more deep hit in our notation 
battle, therefore I'm really looking forward to your suggestions.

They can be discussed here, or I'd happily accept them as pull requests.

Urs

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


Re: Pattern-generating Scheme function challenge

2013-07-13 Thread Urs Liska

Am 13.07.2013 16:03, schrieb Urs Liska:

Hi all, the Schemers in particular,


For each number in the range it should:
PS it would be advisable to create an 'inner function' that operates on 
a single number and an outer function that calls it repetitively. This 
is because it might someday become interesting to provide not a range of 
numbers but an arbitrary list. So this could be made useful in a general 
purpose pattern exercise generator.


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


Re: Pattern-generating Scheme function challenge

2013-07-13 Thread Janek Warchoł
Hi,

2013/7/13 Urs Liska u...@openlilylib.org:
 you surely know by now that I am writing a series of posts that demonstrate
 how elegantly and efficiently we can recreate a portion of a book that
 obviously has been produced with many pains in Finale.
 I'm confident that it will be an impressive display of LilyPond's power :-)
 but I would love to go even one step further.

[...]
 I would be happy to include an alternative approach if I can get the
 necessary input from the list (of course I will credit it correctly):

I think that it would be even more awesome to have a guest post
doing this from one of the schemers :)

Janek

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


Re: Pattern-generating Scheme function challenge

2013-07-13 Thread Urs Liska
Ok, this would be very good too.
Makes sense only after the third post is published, but doesn't mean you can't 
throw in your thoughts on the list already.

Urs



Janek Warchoł janek.lilyp...@gmail.com schrieb:

Hi,

2013/7/13 Urs Liska u...@openlilylib.org:
 you surely know by now that I am writing a series of posts that
demonstrate
 how elegantly and efficiently we can recreate a portion of a book
that
 obviously has been produced with many pains in Finale.
 I'm confident that it will be an impressive display of LilyPond's
power :-)
 but I would love to go even one step further.

[...]
 I would be happy to include an alternative approach if I can get the
 necessary input from the list (of course I will credit it correctly):

I think that it would be even more awesome to have a guest post
doing this from one of the schemers :)

Janek

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Pattern-generating Scheme function challenge

2013-07-13 Thread Jim Long
On Sat, Jul 13, 2013 at 04:03:25PM +0200, Urs Liska wrote:
 
 For each number in the range it should:
 - produce a LilyPond pattern corresponding to the binary representation 
 of the given number

It may be my misunderstanding, but is the number below the systems
meant to indicate the number whose binary representation is being used?
The PDF's musical examples show representations of 72-75, but the
numbers at the bottom are 7.73-7.76.


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


Re: Pattern-generating Scheme function challenge

2013-07-13 Thread Urs Liska
Please ask Mr. Aldridge about that ;-)

I assume it is the 'pattern number', not the binary number. So he probably 
started with 1, not 0, although I don't see much use in the two first patterns 
anyway.

Urs



Jim Long lilyp...@umpquanet.com schrieb:

On Sat, Jul 13, 2013 at 04:03:25PM +0200, Urs Liska wrote:
 
 For each number in the range it should:
 - produce a LilyPond pattern corresponding to the binary
representation 
 of the given number

It may be my misunderstanding, but is the number below the systems
meant to indicate the number whose binary representation is being used?
The PDF's musical examples show representations of 72-75, but the
numbers at the bottom are 7.73-7.76.

-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Pattern-generating Scheme function challenge

2013-07-13 Thread Thomas Morley
2013/7/13 Urs Liska u...@openlilylib.org:
 Hi all, the Schemers in particular,
[...]

Well, this schemer is tired.
Perhaps another day.

Currently i've not even tried to understand the pattern.

Cheers,
  Harm

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