Kara-Moon Forum

Developers & Technology => Musical MIDI Accompaniment (MMA) => Topic started by: sciurius on May 10, 2020, 08:38:16 PM



Title: Tweak crash
Post by: sciurius on May 10, 2020, 08:38:16 PM
The following minimal file crashes MMA:

    Tweaks DefaultDrum=0

(Similar for DefaultTone and DefaultVoice)

Code:
Traceback (most recent call last):
  File "/home/jv/bin/mma", line 84, in <module>
    import MMA.main
  File "/home/jv/src/mma/MMA/main.py", line 157, in <module>
    MMA.parse.parseFile(f)
  File "/home/jv/src/mma/MMA/parse.py", line 96, in parseFile
    parse(f)
  File "/home/jv/src/mma/MMA/parse.py", line 165, in parse
    simpleFuncs[action](l[1:])
  File "/home/jv/src/mma/MMA/tweaks.py", line 46, in setTweak
    MMA.pat.defaultDrum = MMA.midiC.decodeVoice(opt)
UnboundLocalError: local variable 'MMA' referenced before assignment


Title: Re: Tweak crash
Post by: bvdp on May 10, 2020, 09:20:39 PM
This is another stupid circular dep error. I think it's a python problem ... and python thinks it's because I'm not a good programmer :)

To fix, take the "import MMA.pat" out of the top of tweaks.py and insert it at the top of the setTweak() function. The module should end up like:

Code:
from MMA.common import *
import MMA.midiC

import copy


def setTweak(ln):
    """ Option tweaks. """

    import MMA.pat   # here to avoid a circular dep problem

    notopt, ln = opt2pair(ln)

Thanks for the report.


Title: Re: Tweak crash
Post by: sciurius on May 11, 2020, 06:15:56 AM
While at it...

Tweaks DefaultDrum (and DefaultTone) set the patch (program) for the drum channel. This is usually referred to as the drum kit.

GM defines only one drum kit (Standard Drum Kit) but all 'real life' implementations follow Roland GS and have several drum kits to use.

I'd like to propose to promote setting the drum kit from a tweak to a real command:

DrumKit Name

where Name can be one of the GS names, or a number.

See https://en.wikipedia.org/wiki/Roland_GS

Also, being able to say Tweaks DefaultDrum=Oboe doesn't really makes sense to me :) . The drum voices and the melodic voices should use separate tables.


Title: Re: Tweak crash
Post by: sciurius on May 11, 2020, 06:41:28 AM
Proof of concept:

Code:
import MMA
from MMA.common import stoi

def setdrumkit(ln):
    """ Set the default drum kit to use."""

    if not ln[0].upper() in drumkits:
        pat.defaultDrum = stoi(ln[0],
                               "DRUMKIT: Invalid argument \"{}\"".format(ln))
    else:
        pat.defaultDrum = drumkits[ln[0].upper()]

MMA.parse.simpleFuncs['DRUMKIT'] = setdrumkit

drumkits = {
    'STANDARD'   :  0,
    'ROOM'       :  8,
    'POWER'      : 16,
    'ELECTRONIC' : 24,
    'TR808'      : 25,
    'JAZZ'       : 32,
    'BRUSH'      : 40,
    'ORCHESTRA'  : 48,
    'SFX'        : 56
}


Title: Re: Tweak crash
Post by: bvdp on May 11, 2020, 04:37:31 PM
As always, good idea.

The article says there are 15 additional kits ... and then lists 10 or 11? Need to check a real manual?

I agree that drumkit=oboe makes no sense ... but, neither then does an oboe make much sense :) I'll have look at that.


Title: Re: Tweak crash
Post by: sciurius on May 11, 2020, 06:57:39 PM
Interesting catch... I didn't count them  ;D.

Several sound fonts have drum kits, but the SG seem to be more or less standard.
And we have PATCH SET to add more...