Kara-Moon Forum
March 28, 2024, 12:20:11 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: Tweak crash  (Read 2848 times)
sciurius
Sr. Member
****
Posts: 443



« 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
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


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

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.
Logged

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



« Reply #2 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 Smiley . The drum voices and the melodic voices should use separate tables.
« Last Edit: May 11, 2020, 06:24:34 AM by sciurius » Logged
sciurius
Sr. Member
****
Posts: 443



« Reply #3 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
}
Logged
bvdp
Kara-Moon Master
****
Posts: 1436


WWW
« Reply #4 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 Smiley I'll have look at that.
Logged

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



« Reply #5 on: May 11, 2020, 06:57:39 PM »

Interesting catch... I didn't count them  Grin.

Several sound fonts have drum kits, but the SG seem to be more or less standard.
And we have PATCH SET to add more...
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.039 seconds with 19 queries.