christofmuc / KnobKraft-orm

The KnobKraft Orm - The free modern cross-platform MIDI Sysex Librarian
GNU Affero General Public License v3.0
207 stars 27 forks source link

Patches showing wrong bank #343

Open milnak opened 1 month ago

milnak commented 1 month ago

This is my new adaptation, so maybe I'm doing something wrong?

I have 20 banks * 8 patches:

def bankDescriptors() -> list[Dict]:
    return [
        {
            "bank": x,
            "name": f"Bank {x + 1}",
            "size": 8,
            "type": "Patch",
            "isROM": False,
        }
        for x in range(20)
    ]

when I click on one of the "in synth" banks, e.g. "bank 20", I see friendlyProgramName called for program 152->159. "Synth Bank" window shows "20-1", "20-2" (good), but center window shows "1-1", "1-2" ...

Is that expected? I also notice that if I do: MIDI > Import Patches > Import All, the center window has "1-1", "1-2", ... "1-8", "1-1", "1-2", ...

I see def friendlyProgramName(program): only getting program numbers from 0-7. Shouldn't the program number be set up to 159 (in my case) here?

christofmuc commented 1 month ago

Out of the top of my head, I think this is expected. The Python code assums all patches are enumerated sequentially across all banks, and the bank number and patch number are extracted from the combined total.

So patches 0-7 are Bank 1, patches 8-16 are Bank 2, etc.

If you see the center window not showing the bank, it got dropped somewhere. Checkout the properties of a patch, it additionally shows the location at import time. What does it say?

Did you implement numberFromDump()? That should also return the full bank * 8 + program. Sometimes, the bank can no longer be extracted from the patch because only the program number is stored, then the displayed value falls bank to bank 0.

milnak commented 1 month ago

Yes, I implemented numberFromDump.

I imported bank 10. Center window shows:

[1-1 Classic Gt] [1-2 Steel Gt] .... [1-8 Slap Bass]

Properties shows:

Type: Patch
Import: Imported from synth Bank 10 on ...
Program: 1-1
In synth at: no place known

does that help?

milnak commented 1 month ago

I changed

def bankDescriptors() -> list[Dict]:
    return [
        {
            "bank": x,
            "name": f"Bank {x + 1}",
            "size": 8,
            "type": "Patch",
            "isROM": False,
        }
        for x in range(20)
    ]

to

def bankDescriptors() -> list[Dict]:
    return [
        {
            "bank": 0,
            "name": f"Patches",
            "size": 20 * 8,
            "type": "Patch",
            "isROM": False,
        }
    ]

and the bank numbers all show properly, so I'm guessing you might have a bug somewhere. Have you tested a case where bankDescriptor returns 20 banks?

christofmuc commented 3 weeks ago

I think I might have at least one fix for this, there were several problems with bank numbers when not being known defaulting to 0 and not NULL in the database, causing numbers to jump back to 0. I have some code in PR #361 , but this really needs a bit more testing before release. Thanks again for reporting!