Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import from text #28

Open
johnuopini opened this issue Mar 26, 2024 · 3 comments
Open

Import from text #28

johnuopini opened this issue Mar 26, 2024 · 3 comments
Labels
feature request New feature or request

Comments

@johnuopini
Copy link

johnuopini commented Mar 26, 2024

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 kulek1 added the feature request New feature or request label Mar 26, 2024
@kulek1
Copy link
Owner

kulek1 commented Mar 26, 2024

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
Copy link
Author

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
Copy link

mpparodi commented Jun 8, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants