lilypond-user
[Top][All Lists]
Advanced

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

Re: scheme - notes as variables


From: Andrew Wilson
Subject: Re: scheme - notes as variables
Date: Wed, 28 Jan 2009 19:27:45 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

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




reply via email to

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