Kara-Moon Forum
March 29, 2024, 02:08:32 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: Using Grooves Aliases  (Read 2866 times)
sciurius
Sr. Member
****
Posts: 443



« on: September 11, 2019, 12:38:49 PM »

Me again with my stupid and unexpected problems  Evil.

    Groove MellowJazz
      1 C

This works.

    DefAlias MellowJazz Foo
    Groove Foo
     1 C


This complains that MellowJazz is not a defined groove:
DefAlias: Groove MellowJazz has not been defined.

    Groove MellowJazz
    DefAlias MellowJazz Foo
    Groove Foo
     1 C


Still not defined?

    Groove MellowJazz
    print $_GrooveList
    DefAlias MellowJazz Foo


This prints:

MELLOWJAZZ MELLOWJAZZEND MELLOWJAZZFILL MELLOWJAZZINTRO MELLOWJAZZPLUS MELLOWJAZZSUS MELLOWJAZZSUSPLUS
Error: <Line 3> <File:groove2.mma> DefAlias: Groove MellowJazz has not been defined.

Well it turns out that the grooveAlias method in grooves.py has its arguments swapped... So either the documentation should be changed to "DefAlias AliasName ExistingGrooveName", or the roles of variables g and a in lines 156/157 of grooves.py must be swapped. Both solutions have pros and cons.

Final question: Shouldn't DefAlias auto-load grooves?
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #1 on: September 11, 2019, 04:10:26 PM »

Got me Smiley

I just spent a bunch of time with the load groove code and have added the option to load from a specific directory. So, you can now do "groove casio:80sPopIntro" instead of the more verbose "groove casio/80spop:80sPopIntro". But, I didn't look a the alias code.

If memory serves, the idea behind the alias stuff is really just to create an alternate name for an existing groove. The advantage being that it's also a copy. That is because you now have 2 references to the groove info. Well, that's the way it's supposed to work. I will check that again!!

Certainly the docs here need work! I'd rather fix the docs than the code ... less chance of breaking things.

I'd not thought about autoloading grooves at this point. It would be easy enough to fork off, search and load, and then define. Guess I have to ask why and what are the downfalls? One "problem" I see is that if loading the groove involves reading a file (esp. from another directory) you could inadvertently clobber existing groove info which may not be desired.

To be honest, it's a feature I've never used. Could be that it's not that useful and should be dumped???
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #2 on: September 11, 2019, 04:29:33 PM »

I turned some custom plucking grooves in song files into general usable library grooves and ran cross the uglyness of having to say

    Groove MyCustomPluckingPattern4E
    ...
    Groove MyCustomPluckingPattern4A
    ...


and so on. So I wanted to use aliases:

    DefAlias MyCustomPluckingPattern4E  GE
    DefAlias MyCustomPluckingPattern4A  GA
    ....


to obtain neater code, and the ability to change to a different plucking pattern by just changing the aliases instead of all the groove settings in the music.

So I find the aliases feature very useful.

And there's nothing wrong with the current code... You just need to swap the two arguments. Everything else seems to work fine.
Autoloading would be fine, but I have no problems to insert an explicit 'use' before defining the aliases.
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #3 on: September 11, 2019, 05:05:19 PM »

So, just a doc fix. Easy! Consider it done.
Logged

My online life: http://www.mellowood.ca
sciurius
Sr. Member
****
Posts: 443



« Reply #4 on: September 11, 2019, 05:15:57 PM »

Eh, I'd rather prefer the code fix... I find 'DefAlias groove alias' more intuitive than the other way around. And the code also mentions this in the error message.

*** grooves.py~   2019-08-04 20:28:14.000000000 +0200
--- grooves.py   2019-09-11 14:36:26.555921789 +0200
***************
*** 153,160 ****
      if len(ln) != 2:
          error("DefAlias needs exactly 2 args: GrooveName AliasName.")
 
!     a = ln[0].upper()
!     g = ln[1].upper()
 
      if not g in glist:
          error("DefAlias: Groove %s has not been defined." % ln[0])
--- 153,160 ----
      if len(ln) != 2:
          error("DefAlias needs exactly 2 args: GrooveName AliasName.")
 
!     g = ln[0].upper()
!     a = ln[1].upper()
 
      if not g in glist:
          error("DefAlias: Groove %s has not been defined." % ln[0])
Logged
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.047 seconds with 19 queries.