I think that track commands and names will always be different.
Good.
Currently ... you cannot strip out the leading command from a line inside the begin/end block.
That seems to be my experience as well. That's why I'm trying different approaches.
I'm assuming that your plugin returns something like "Sequence ...." and inside a begin/end loop this works since the plugin is evaluated first and its output is appended to the Begin stuff. But, in the 2nd example it'll barf ...
Let's start with the easy case:
Drum-Snare @rhythm ...This calls the trackRun() method and passes track = 'Drum-Snare' and line = ... . It pushes back the command line 'Drum-Snare Sequence {...}'.
Ok.
Now the begin/end case:
Begin Drum-Snare
@rhythm ...
EndThis is expanded to
Drum-Snare @rhythm .... Again, the trackRun() method is called, it pushes back 'Drum-Snare Sequence {...}'. Then MMA processes the pushed-back line. First it adds the begin stuff, so the actual line becomes
Drum-Snare Drum-Snare Sequence {...}And oops.
What I do now is that in the plugin I inspect parse.beginData. If it has a value and is equal to the 'track' argument the plugin returns the command line without prepending the 'track' argument and everybody is happy again.
Perhaps, a better solution would be to make the stuff in the line BEFORE the @plugin request available to the plugin? In this case, in a Begin/End there would be a null. In your 2nd call there would be "drum-snare".
Isn't this what parse.beginData is? Although I must admit that a formally defined parse method to access its content would be nice.
Might give plugins a lot more power this way!
Jay! Even more power!
Current state of the plugin (with un-modified MMA):
@rhythm Groove, Seq, Bpm=4, Level=9, RTime=0, RVolume=0, Clear=0, SeqSize=0, Debug=0This defines a groove according to the seq, with optional values for RTime etc.
For example:
@rhythm G1, Debug=1, Level=3, Clear=1, RTime=3, RVolume=2, \
Seq=SnareDrum1 |-3-2| KickDrum1 |3-3-|This is identical to:
SeqClear
Begin Drum-SnareDrum1
Tone SnareDrum1
RTime 3
RVolume 2
Sequence { 2 0 90; 4 0 60 }
End
Begin Drum-KickDrum1
Tone KickDrum1
RTime 3
RVolume 2
Sequence { 1 0 90; 3 0 90 }
End
DefGroove G1
Note about Seq : Space separated pairs of instrument and sequence data. Instrument can be one of the MMA built-in percussion tones, or a decimal number between 1 and 16. In the latter case Zoom compliant names for tracks and tones are used.
Note about Level: This indicates the maximum volume level in the sequence. Normally volumes are 0..9, corresponding to silent..90. Zoom tabs use volumes 0,1,2,3, so with level=3 these become volumes 0,30,60,90.
As a track plugin:
Track @rhythm Seq, Bpm=4, Level=9, Debug=0or
Begin Track
@rhythm Seq, Bpm=4, Level=9, Debug=0
EndFor example:
Drum-Snare @rhythm |9-9-6-9-|9-6-9--9|is identical to:
Drum-Snare Sequence { 1 0 90; 2 0 90; 3 0 60; 4 0 90 } { 1 0 90; 2 0 60; 3 0 90; 4.5 0 90 }As for the sequences: a sequence consists of one or more bars separated by vertical bars.
Each bar is divided into equal divisions, corresponding to the number of characters in the bar.
Each division has either a decimal number indicating that the instrument must sound, or a '-' to do nothing.
Special bars are:
|| repeat the previous bar. If this is the first, use a silent bar.
|-| a silent bar
|*| use the currently defined sequence
Sounds interesting?