kulek1 / guitar-tab-maker-issues

Public repository for issue tracking https://tab-maker.com
49 stars 9 forks source link

Import from text #28

Open johnuopini opened 6 months ago

johnuopini commented 6 months ago

Is your feature request related to a problem? Please describe. I would like to be able to import from something like this:

G|--------------------------|
D|--------------------------|
A|----5---8--5----5---8--5--|
E|-0-------0---0-------0----|

Describe the solution you'd like I guess it should be easy to do

Describe alternatives you've considered I tried pasting but app says "clipboard is empty" I have tried manually creating a JSON like this:

{"state":{"tabs":{"0":{"notes":[(lull,null,5,null),(null,null,0,null),(null,null,8,null),(ull,null,5,null),(ull,null,8,null),(ull,null,5,null))}},"tuning":[["G",2],["D",2],["A",1],["E",1]],"instrument":"bass","audio":"B1"},"myTabs":null}

Then using base64 encode and then import but import shows an error

kulek1 commented 6 months ago

Thanks for the feature request! I'll add it to my todo list although I wouldn't fully agree on "I guess it should be easy to do" thing 😄 Parsing tabs requires handling a lot of custom cases, even if something looks simple at first glance.

I'll let you know once it's released 👍

johnuopini commented 6 months ago

Yeah sorry, i know it might not be super easy as there could be a lot of corner cases, still i think it could be really useful as there are a lot of examples in that syntax and a lot of other tools exporting in that syntax so having an import for it would be cool

mpparodi commented 3 months ago

De esta forma solucionas el problema de la codificación y funciona!


import json
import base64

tablatura = {
    "state": {
        "tabs": {
            "0": {
                "notes": [
                    [0, 0, None, None, None, None],
                    [None, None, None, None, None, None],
                    [0, None, None, None, None, None],
                    [None, None, 2, None, None, None],
                    [None, None, 0, None, None, None],
                    [None, None, None, 2, None, None],
                    [None, None, None, None, None, None],
                    [None, None, None, None, None, None]
                ],
                "txtTop": ""
            }
        },
        "tuning": [
            ["E", 4],
            ["B", 3],
            ["G", 3],
            ["D", 3],
            ["A", 2],
            ["E", 2]
        ],
        "instrument": "guitar"
    },
    "myTabs": None
}

json_str = json.dumps(tablatura)
encoded_str = base64.b64encode(json_str.encode('utf-8')).decode('utf-8')

with open('nueva_tablatura.back', 'w') as file:
    file.write(encoded_str)