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
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user