lilypond-user
[Top][All Lists]
Advanced

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

Re: scheme - notes as variables


From: Rob Canning
Subject: Re: scheme - notes as variables
Date: Thu, 29 Jan 2009 14:19:01 +0000
User-agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018)

Andrew Wilson wrote:
On Wed, Jan 28, 2009 at 12:35:16PM +0000, Rob Canning wrote:
i have been doing this kind of thing before using a combination of puredata and sed but that was really ugly and the regular expressions were getting out of control! i would really appreciate any help learning how to do this using scheme

It seems to me that what you want can be achieved with a very small
amount of perl:

=======================================================
#!/usr/bin/perl

sub InsertNotes {
   my ($num, $form, @notes) = @_;

   my ($output, @temp);
   while (@notes) {
     (@temp[0..$num-1], @notes) = @notes;
     $output .= sprintf $form, (@temp);
   }
   return $output;
}
my @list = qw"a b c d a b c d a f cis d aes b c d g b c d a bes c dis c c c d a e c d a b c d";

my $format = "%s''4\\pp r16 %s'4\\accent %s''1 %s'''4 r8 %s''4\\mf \\accent %s8 
\\staccato\n";

print InsertNotes(6, $format, @list);
=============================================================

You can probably do it with scheme, but why would you want to.

Both @list and $form (and the number of %s to replace) can all
be read from files insterad of hard coded.  This is also
trivial.

andrew


thanks andrew!
yes indeed this does what i want - i in the middle of trying to figure out how it works so i can modify it -

adding a second variable fed by a second list etc.

i was trying to do it using scheme just because i thought learning to do this kind of thing in scheme would help me with other aspects of lilypond in general - perl looks neat though "the swiss army chainsaw of languages" i heard it refered to as :)-

maybe scheme is the wrong tool for the job?
anyone?

many thanks for your help

rob






reply via email to

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