Kara-Moon Forum
October 31, 2024, 11:38:40 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: Private libraries  (Read 7427 times)
sciurius
Sr. Member
****
Posts: 443



« on: August 15, 2013, 01:00:02 PM »

The MMA documentation extensively describes how MMA finds grooves and how to create your own private libraries, however, the description is either not 100% waterproof, or I'm doing stupid things...

In my .mmarc I have
Code:
SetLibPath ~/lib/mma $_LibPath

In ~/lib/mma there's a file guitarballad.mma. There's also a standard style GuitarBallad in /usr/share/mma/lib/stdlib/guitarballad.mma.

In a music file, I start with
Code:
Use guitarballad.mma
Note that I use the file name, not the groove name. Whatever I try, MMA will always load /usr/share/mma/lib/stdlib/guitarballad.mma. I tried with/without .mma extension. With/without a local .mmaDB. I tried leaving out the USE... command.

According to my observations, MMA first processes /usr/share/mma/lib/stdlib, and then the files specified in LibPath. Not just for grooves, but also for filenames. But the docs read: “If the filename or groove names duplicate material in the stdlib you may be better off forcing the include by doing a USE”. This seems to indicate that it is possible — without resorting to unique filenames — to load the private style with a USE command.

Puzzling...


Logged
bvdp
Kara-Moon Master
****
Posts: 1449


WWW
« Reply #1 on: August 15, 2013, 04:59:39 PM »

If stdlib is in the path it is always shoved to the front of the list. So, it gets used first. Two ways around this:

Leave stdlib out of the the path:  SetLibPath  /usr/local/mma/lib/mylib

You can use a macro, which is somewhat easier:
     Set C  $_LibPath + mylib
     SetLibPath  $C

Note, you need the 2 steps since that's the only way to concatenate.

Either way, you only have "mylib" in the path. So, of course, stdlib stuff is ignored.

Now, using USE, just use a fuller path name. So,

   USE mylib/mygroove

should be fine.

Don't bother with the .mma extensions since mma will add this for you.

Clear as mud?
Logged

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



« Reply #2 on: August 15, 2013, 06:48:34 PM »

Leave stdlib out of the the path:  SetLibPath  /usr/local/mma/lib/mylib

For obvious reason's I'd rather not meddle with the site wide mma lib.

It is clear, a decent quality mud, that mma stdlib will always win, no matter what.
So the only solution is to resort to uniqe filenames, e.g., by using a path prefix:
Code:
Use mygrooves/guitarballad
or extension:
Code:
Use guitarballad.groove
Quote
Clear as mud?
Yes... Although this may be a part of MMA to rethink. IMHO it would be beneficial if user files could take precedence over stdlib files.

But it's not really important.

Thanks for your patience.
Logged
bvdp
Kara-Moon Master
****
Posts: 1449


WWW
« Reply #3 on: August 15, 2013, 08:04:16 PM »

Quote
Yes... Although this may be a part of MMA to rethink. IMHO it would be beneficial if user files could take precedence over stdlib files.

Funny thing is that I was having the same problem awhile ago Smiley I thought I was clever by forcing the stdlib to be read first. I'm wondering about that.

I have a note in my todo stuff ... my initial thought is that if the user modifies the path then we should honor his order and not move stdlib to the front of the list.
Logged

My online life: http://www.mellowood.ca
bvdp
Kara-Moon Master
****
Posts: 1449


WWW
« Reply #4 on: August 16, 2013, 08:31:13 PM »

See my announcement for a new test version which should fix the library order problem.

I'm also thinking that it might be useful to have mma look for a file "LIBORDER" in the root library directory which could be a list to use to set the search order. Let me know what you guys think about this.
Logged

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



« Reply #5 on: August 17, 2013, 08:18:21 AM »

Based on my experience with many other tools, this is what I would suggest/expect:

First, order matters. SetLibPath ~/lib/mma $_LibPath sets two search locations, in this order.

When looking for a filename (e.g., USE mygroove.mma), look it up in the search locations. Do not use the .mmaDB and do not descend to subdirectories. It's an ordinary file search. If I'd want the stdlib subdirectory to be searched I can specify SetLibPath ~/lib/mma $_LibPath $_LibPath/stdlib .

When looking for a groove (e.g., GROOVE MyGroove), first append .mma and try a filename lookup as described above, and if that fails, consult the indexes. All indexes. Again, in the order of the LibPath, but with subdirectories.

This provides ample ways to control which file is actually used.

There are some ambiguities, e.g. assume there's a MyGroove defined in $_LibPath/stdlib/foo.mma and in $_LibPath/blah/foo.mma. But this is not different from the current situation.

Also, emphasise that the user should never change or add things in mma's libpath. When you install a packaged version of mma ordinary users won't have write access to the mma library anyway.

Hope this helps.

Bonus points for an environment variable MMA_LIB that hold the initial value for $_LibPath.
Logged
bvdp
Kara-Moon Master
****
Posts: 1449


WWW
« Reply #6 on: August 17, 2013, 05:12:00 PM »

Based on my experience with many other tools, this is what I would suggest/expect:

First, order matters. SetLibPath ~/lib/mma $_LibPath sets two search locations, in this order.

Well, almost. Remember that a path in SetLibPath can contain multiple library collections (directories). The default "/usr/share/mma/lib" for example has stdlib, kara, etc.

With the new code, using your example, the search will start off in ~/lib. And if you have more that one dir in there, and you want to force one of these dirs to be first checked you can do something like:

     SetLibPath  ~/lib/testing ~/lib/new ~/lib/great  $_Libpath
 
Quote
When looking for a filename (e.g., USE mygroove.mma), look it up in the search locations. Do not use the .mmaDB and do not descend to subdirectories. It's an ordinary file search. If I'd want the stdlib subdirectory to be searched I can specify SetLibPath ~/lib/mma $_LibPath $_LibPath/stdlib .

The .mmaDB is not used for USE searches. The directories specified in LibPath are checked in their order. You can "print $_Libpath" to see the order. Also, you can add a dir to the USE: "Use mylib/funk" is fine.

Note that USE always loads in a groove file. this can be useful if you have changed things and want to start fresh in the middle of a song.

Quote
When looking for a groove (e.g., GROOVE MyGroove), first append .mma and try a filename lookup as described above, and if that fails, consult the indexes. All indexes. Again, in the order of the LibPath, but with subdirectories.

I think this is the current behavior. Mostly Smiley

Quote
This provides ample ways to control which file is actually used.

There are some ambiguities, e.g. assume there's a MyGroove defined in $_LibPath/stdlib/foo.mma and in $_LibPath/blah/foo.mma. But this is not different from the current situation.

Just a matter of using Groove stdlib:bigbandintro vrs blah:bigbandintro

Just a matter of knowing the filename, including the library, and the groovename.

Quote
Also, emphasise that the user should never change or add things in mma's libpath. When you install a packaged version of mma ordinary users won't have write access to the mma library anyway.

Good point.

Quote
Hope this helps.

Yes. I'm at a disadvantage Smiley I keep my lib in my home directory with a link from /usr/lib/mma. So I never run into access problems.

Quote
Bonus points for an environment variable MMA_LIB that hold the initial value for $_LibPath.

Isn't this simpler to do in a mmarc file?

Thanks for the input!
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.039 seconds with 19 queries.