mungewell / zoom-zt2

Python script to install/remove effects from the Zoom G1Four pedal
MIT License
50 stars 10 forks source link

"BDL" output Eq #61

Open mungewell opened 1 year ago

mungewell commented 1 year ago

There are different "BDL" files on the Guitar vs Bass pedals, digging into what make these different.

The appears to be tables of frequencies in each, and these are encoded float values.

$ python3 ../extract_device_icon.py -r -t "LoFreqTBL" G_OUT_EQ.BDL
Target matched: LoFreqTBL
Symbol located: 0x800002d8
$ hexdump -C raw.bin 
00000000  00 00 48 42 00 00 96 42  00 00 c8 42 00 00 fa 42  |..HB...B...B...B|
00000010  00 00 16 43 00 00 c8 42  00 00 c8 42 00 00 c8 42  |...C...B...B...B|
00000020  00 00 c8 42 00 00 c8 42  00 00 c8 42              |...B...B...B|
0000002c
$ python3 ../extract_device_icon.py -r -t "MidFreqTBL" G_OUT_EQ.BDL
Target matched: MidFreqTBL
Symbol located: 0x80000368
$ hexdump -C raw.bin 
00000000  00 00 c8 43 00 00 c8 43  00 00 c8 43 00 00 c8 43  |...C...C...C...C|
00000010  00 00 c8 43 00 00 48 44  00 00 48 44 00 00 48 44  |...C..HD..HD..HD|
00000020  00 00 48 44 00 00 48 44  00 00 48 44              |..HD..HD..HD|
0000002c
$ python3 ../extract_device_icon.py -r -t "HiFreqTBL" G_OUT_EQ.BDL
Target matched: HiFreqTBL
Symbol located: 0x80000248
$ hexdump -C raw.bin 
00000000  00 00 48 45 00 00 48 45  00 00 48 45 00 00 48 45  |..HE..HE..HE..HE|
00000010  00 00 48 45 00 00 fa 44  00 00 fa 44 00 00 fa 44  |..HE...D...D...D|
00000020  00 00 fa 44 00 00 fa 44  00 00 fa 44              |...D...D...D|
0000002c

and for Bass


$ python3 ../extract_device_icon.py -r -t "LoFreqTBL" B_OUT_EQ.BDL
Target matched: LoFreqTBL
Symbol located: 0x800002d8
$ hexdump -C raw.bin 
00000000  00 00 a0 41 00 00 a0 41  00 00 a0 41 00 00 a0 41  |...A...A...A...A|
00000010  00 00 a0 41 00 00 c8 42  00 00 c8 42 00 00 c8 42  |...A...B...B...B|
00000020  00 00 c8 42 00 00 c8 42  00 00 c8 42              |...B...B...B|
0000002c
$ python3 ../extract_device_icon.py -r -t "MidFreqTBL" B_OUT_EQ.BDL
Target matched: MidFreqTBL
Symbol located: 0x80000368
$ hexdump -C raw.bin 
00000000  00 00 7a 44 00 00 7a 44  00 00 7a 44 00 00 7a 44  |..zD..zD..zD..zD|
00000010  00 00 7a 44 00 00 96 43  00 00 96 43 00 00 96 43  |..zD...C...C...C|
00000020  00 00 96 43 00 00 96 43  00 00 96 43              |...C...C...C|
0000002c
$ python3 ../extract_device_icon.py -r -t "HiFreqTBL" B_OUT_EQ.BDL
Target matched: HiFreqTBL
Symbol located: 0x80000248
$ hexdump -C raw.bin 
00000000  00 00 7a 45 00 00 7a 45  00 00 7a 45 00 00 7a 45  |..zE..zE..zE..zE|
00000010  00 00 7a 45 00 80 3b 45  00 80 3b 45 00 80 3b 45  |..zE..;E..;E..;E|
00000020  00 80 3b 45 00 80 3b 45  00 80 3b 45              |..;E..;E..;E|
0000002c
mungewell commented 1 year ago
$ python3 guitar.py
Container: 
    Values = ListContainer: 
        50.0
        75.0
        100.0
        125.0
        150.0
        100.0
        100.0
        100.0
        100.0
        100.0
        100.0
Container: 
    Values = ListContainer: 
        400.0
        400.0
        400.0
        400.0
        400.0
        800.0
        800.0
        800.0
        800.0
        800.0
        800.0
Container: 
    Values = ListContainer: 
        3200.0
        3200.0
        3200.0
        3200.0
        3200.0
        2000.0
        2000.0
        2000.0
        2000.0
        2000.0
        2000.0
$ python3 bass.py 
Container: 
    Values = ListContainer: 
        20.0
        20.0
        20.0
        20.0
        20.0
        100.0
        100.0
        100.0
        100.0
        100.0
        100.0
Container: 
    Values = ListContainer: 
        1000.0
        1000.0
        1000.0
        1000.0
        1000.0
        300.0
        300.0
        300.0
        300.0
        300.0
        300.0
Container: 
    Values = ListContainer: 
        4000.0
        4000.0
        4000.0
        4000.0
        4000.0
        3000.0
        3000.0
        3000.0
        3000.0
        3000.0
        3000.0
mungewell commented 1 year ago
$ arm-linux-gnueabi-objdump -t B_OUT_EQ.BDL.code | grep TBL
80000308 l     O .const 0000002c .hidden LoGainTBL
800002d8 l     O .const 0000002c .hidden LoFreqTBL
80000338 l     O .const 0000002c .hidden LoQTBL
80000398 l     O .const 0000002c .hidden MidGainTBL
80000368 l     O .const 0000002c .hidden MidFreqTBL
800003c8 l     O .const 0000002c .hidden MidQTBL
80000278 l     O .const 0000002c .hidden HiGainTBL
80000248 l     O .const 0000002c .hidden HiFreqTBL
800002a8 l     O .const 0000002c .hidden HiQTBL
nomadbyte commented 1 year ago

These are likely the settings for the on-device 3-par EQ, those 4 knobs: Lo/Mid/Hi/Vol. While different freq selection for the Lo/Mid/Hi between G and B models, these could be compensated with a separate EQ effect module or in-effect EQ controls.

There may be some more differences between G and B OUT_EQ modules, based on the differing sizes.

mungewell commented 1 year ago

I'm not really sure what they are doing with these tables (clear on GE7 effect), but it's simple to parse with:

from construct import *

EQ = Struct(
        "Values" / GreedyRange(Float32l),
)

table = open("raw.bin", "rb")
if table:
    data = table.read(10000)
    print(EQ.parse(data))

For example

$ python3 ../extract_device_icon.py -r -t "HiFreqTBL" B_OUT_EQ.BDL
Target matched: HiFreqTBL
Symbol located: 0x80000248
$ python3 dump_tbl.py
Container: 
    Values = ListContainer: 
        4000.0
        4000.0
        4000.0
        4000.0
        4000.0
        3000.0
        3000.0
        3000.0
        3000.0
        3000.0
        3000.0

We suspected that BDLs were similar to PARAEQ, but that does not seem to be the case. The tables in PARAEQ are different structure.

shooking commented 1 year ago

is this same as what Viktor found here? https://zoomeffectmanager.com/dist/files/Instructions_for_editing_effect_files_Zoom_MS_B_G_1on_Xon_En.pdf

Roseweave commented 1 year ago

Is it possible to swap on the EQ profile from the B1xFour? I'm making a hybrid guitar/FX unit out of it thanks to the compressed ZD2s. Even better would be one that works decently for both, i.e. a more generic EQ.

mungewell commented 6 months ago

It is possible to take the Code section of a ZD2, and inject it into another ZD2 file. And then this modified ZD2 can be uploaded to the pedal (in place of PARAEQ) and placed into a patch.

$ python3 decode_effect.py PARAEQ.ZD2 -D G_OUT_EQ.BDL -C -o PARAEQ_G.ZD2

For a normal PARAEQ the screen shows

Effect: ParaEQ (On)
FREQ :  125 
Q :  0.6 
Gain : 0.0
VOL : 80

However for a modified BDL effect, the display is different, matching what is normally seen under the 'Output' section

Effect: ParaEQ (On)
Lo : 0
Mid : 0
Hi : 0

Note: 'VOL' is not listed as a parameter.

@Roseweave I see no reason as to why the code section of B_OUT_EQ.BDL couldn't be loaded into a G_OUT_EQ.BDL file and then that uploaded to a pedal.

[EDIT] The BDL files do NOT use generic entry symbols, so this likely means that a G1Four needs the G_OUT_EQ.BDL file. See below, as we now have a way to adjust the settings/tables in the file(s).

If we worked out what the TBL sections actually meant, then perhaps they could modified in an ad-hock fashion.

mungewell commented 6 months ago

As the Lo/Mid/Hi dial in the output section go between -50 to +50, and the tables have 11 items I presume that it interpolates between the values in the table - changing Freq/Gain/Q in lock-step.

Here's the contents of all the tables: tables tbl_dump.ods

I don't know why they use these particular values, let's just say that Zoom are the experts.. ;-)

mungewell commented 6 months ago

If someone has the A1Four/A1FourX can they decode the (presumably) A_OUT_EQ.BDL file?

nomadbyte commented 6 months ago

It'd be interesting to translate the {F,G,Q} values into the frequency bands to visualize the filter profile. It appears that tweaking any EQ knob may actually change either/all {F,G,Q} values.

Just judging by ear tweaking the EQ knobs on the pedal seems to yield smooth/continuous changes to the tone. So maybe these values are meant to keep the filter profile linear?

Q:0.666667 ==> Bandwidth:2 Octaves

Q Factor vs Bandwidth Calc

mungewell commented 6 months ago

I added a script to decode/adjust/re-encode these BDL files.

$ python3 decode_bdl.py --help
usage: decode_bdl [-h] [-o OUTPUT] [-l] FILE

positional arguments:
  FILE                  File to process

options:
  -h, --help            show this help message and exit
  -o OUTPUT, --output OUTPUT
                        output adjusted BDL to FILE
  -l, --list            list available symbols

The is a section in the file with the values from the B1Four, un-comment the table(s) you want to adjust (and maybe change values to your own settings). https://github.com/mungewell/zoom-zt2/blob/master/decode_bdl.py#L28

Changes are written to specified file... I believe that when uploaded to the pedal the original file name is required. Note: I have NOT tested the result on real hardware as of yet.

$ python3 decode_bdl.py G_OUT_EQ.BDL -o G_OUT_EQ_2.BDL
...
Table located: HiQTBL 0x800002a8
ListContainer: 
    1.0
    1.0
    1.0
    1.0
    1.0
    1.0
    1.0
    1.5
    2.0
    2.5
    3.0
Updating: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Checksum Recalculated: 0xb7dc33e4
mungewell commented 6 months ago

If you run linux, there are some tools which might help figure out what it happening on the pedal.

For example; http://kokkinizita.linuxaudio.org/linuxaudio/jaaa-pict.html

This outputs white/pink(?) noise and analyses what comes back, with the pedal in the loop 'we' should be able to tell what the filters are actually doing.

mungewell commented 6 months ago

Confirmed this actually works on hardware!

As stock the G1Four 'Hi' control will boost 2KHz. Screenshot_2023-12-17_11-36-20

Using the decode_bdl.py script I can change the 'Hi' control to boost 8KHz instead....

HiFreqTBL =  [8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000, 8000]

Screenshot_2023-12-17_11-44-51

Edit the script to make EQ changes, and then

$ mkdir modified_eq
$ python3 decode_bdl.py G_OUT_EQ.BDL -o modified_eq/G_OUT_EQ.BDL
Table located: LoFreqTBL 0x800002d8
...
Checksum Recalculated: 0x22c5aef5
$ python3 zoomzt2.py --uninstall-only G_OUT_EQ.BDL 
Uninstalling effect: G_OUT_EQ.BDL
$ python3 zoomzt2.py --install-only modified_eq/G_OUT_EQ.BDL 
Installing effect: modified_eq/G_OUT_EQ.BDL
uploading...

The reboot pedal to use modified EQ file.

mungewell commented 6 months ago

Due to copyright I can't upload the full (adjusted) BDL file, but I can give you a patch file. This can be used as an alternate to running the script yourselves (ie. if you can't install Python + required modules).

$ bsdiff G_OUT_EQ.BDL modified_eq/G_OUT_EQ.BDL G1Four_to_B1Four.patch
$ gzip G1Four_to_B1Four.patch

G1Four_to_B1Four.patch.gz