|
From: | Rob Canning |
Subject: | Re: scheme - notes as variables |
Date: | Sat, 31 Jan 2009 10:44:44 +0000 |
User-agent: | Mozilla-Thunderbird 2.0.0.17 (X11/20081018) |
#!/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.
this is very usefull and does pretty much what i need - unfortunatly i dont really have the skill to extend and modify script as i dont know perl - i am going to learn perl as it looks very useful but this might take a while. i have two questions about how to extend this script which maybe trivial to add and just a couple of lines, but i understand that it might be much more involved and not something i can expect help with here.
but here it goes anyway ;)what i would like would be numbered variables (%s[1-n]) so i can repeat/recall certain elements within the script like this:
like this (quasi-code): my $format = "%s1''8 r16 %s1'4 %s2''1 %s3'''4 r8 %s3''4 %s4''8";also would it be possible to incorperate a second variable reading from a second list? %B
my $format = "%sA1''%sB1 r16 %sA1'%sB2 %sA2''%sB1 %sA3'''%sB3 r8 %sA3'' %sB2 %sA4''"%sB4;
also to read from a list my @list = qw"a b c d a" is something like this possible? my @list = qw"mynotelist.txt"if anyone has any ideas how to do the above in perl / scheme or anything else i would be most interested
many thanks rob
[Prev in Thread] | Current Thread | [Next in Thread] |