Kara-Moon Forum
March 28, 2024, 04:33:33 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: You can go back to the main site here: Kara-Moon site
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Variable substitution  (Read 1745 times)
sciurius
Sr. Member
****
Posts: 443



« 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

* macro-enhance.patch.txt (29.96 KB - downloaded 186 times.)
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #1 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 Smiley
Logged

My online life: http://www.mellowood.ca
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.044 seconds with 19 queries.