Kara-Moon Forum

Developers & Technology => Musical MIDI Accompaniment (MMA) => Topic started by: sciurius on May 11, 2020, 12:51:43 PM



Title: Variable substitution
Post by: sciurius on May 11, 2020, 12:51:43 PM
The problem with substituting macro values is that the macro names must be surrounded by spaces.

Function opt2pair provides a workaround for some commands, where options can be specified as NAME= VALUE (note the space), thus allowing for variable substitutions like Trigger Beats = $Macro1 , $Macro2 ...

What would break if we add the following functionality to macro.expand: Process the line once and replace all occurrences of $NAME, where NAME is a simple identifier and exists as a defined macro and evaluates to a simple string, by the corresponding value without requiring $[i]NAME[/i] to be surrounded by spaces.

My regtests over all examples and library files did not reveal a single change.

With the enhanced functionality it will be (finally!) possible to write

Code:
Set Strong 90
Set Normal 70
...
Begin Plectrum Define
      G4E       1.0   0   6:$Strong 5-4:0;   \
              1.5   0   3-1:$Normal;       \
        2.0   0   4:$Normal;         \
        2.5   0   3-1:$Normal;
End

and (in .mmarc)

Code:
// Sound font.
Set SoundFont AirFont340
// MIDI player.
If EQ $SoundFont Default
  SetMidiPlayer timidity -a -U
Else
  SetMidiPlayer timidity -c ~/.timidity-$SoundFont.cfg -a -EFchorus=n -EFreverb=n
Endif


Title: Re: Variable substitution
Post by: bvdp on May 11, 2020, 04:11:41 PM
Not looking at any code just now, but I think the problem is with needing a trailing space at the end of the macro. I think this whole issue is in the TODO (if not, it should be!). Let me look in the next day ... right after I look at auto midi track allocation :)