-
Notifications
You must be signed in to change notification settings - Fork 8
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
parsing abc into an object and converting back to a string #32
Comments
Hello @moinejf just following up on this. Is there any way to access the objects generated from the parser or just the parser itself? |
After searching through the code more I found the get_abcmodel but its not working when I call tosvg.
|
I am adding a 'to ABC' script for you, but it is not ready yet. I hope it will be out before the end of this week. |
Thanks for getting back to me. Will toABC create an object from an ABC string? |
I uploaded the new script toabc.js.
You may add your own scripts after this one, but using %%abc-include. Example:
Here is an example of what can be done:
|
Awesome! I just tried it but it didnt work. Also there was an error on line 875:
which I commented out. Here's my code
|
Sorry I think my question should be how can I use this in the browser as opposed to the console. |
Then, I don't see the problem. |
I double checked it. Yes the abc2svg-1.js is included before toabc.js and after I include my script. However I'm still getting that error. |
And what do you mean by convert ABC to ABC? Convert a string to an obj? Or vice versa? or both? |
I thought abc2svg was simple enough.
The user 'get_abcmodel' may be replaced by an other function which may 'manipulate' the model before sending it back to the original get_abcmodel function. That's what the 'test.js' script does in my previous message. So, in brief, you must:
|
Hello, yes I understand how it works but as I mentioned it's not working with the code I shared. Could you create a code example? Also, one of my questions were can to ABC convert both ways: ABC str to obj and obj to str? |
OK, let's restart from the beginning: which driver are you using? Otherwise, I don't understand your 'obj'. ABC is music, and music is composed of a lot of objects: notes, rests, staves, clef, key and time signatures, various decorations... In get_abcmodel, I propose two main entry points:
You may know what are the properties of each music object (called 'symbol' in the source) by looking at the script toabc.js. |
What do you mean by 'driver'? By 'obj' I mean converting ABC notation into a Javascript object/JSON. It's good to know what tsfirst and voice_tb mean. How difficult would it be to recreate the ABC notation as a string using them. |
The driver is the entity which is responsible to inject the source into the translator.
About your 'obj', there is no such entity in abc2svg. The music representation cannot be done by a linear structure as JSON. The recreation of ABC from the ABC model is done by the new script toabc.js. |
I was away from keyboard for a while and saw this ticket. I think what @jisike asks for is provided by AbcJSON.gen_json Of course it should be possible to implement a processor which renders the result of gen_json to an ABC-String, even if I think this is not a simple task. |
JSON is not the right way to serialize data as the music representation: it lacks references. |
Well JSON vs. YAML is just another serialization format. So if YAML works fine, then JSON also will do. I agree, that serialization is bascically useful to to transfer data. I case of Zupfnoter AbcJSON provided a safe way to get the model, dump it to a log file, and and transfer it to Opalrb (Ruby) land. ABCJSON.gen_json solved two issues:
Therefore I anticipated that it can be helpful for @jisike as well. Of course it is not possible to create exactly the same ABC as in the input file. But I am convinced that it would be possible to create a valid ABC representation. I sometimes feel tempted to do this in order to achieve a kind of beautifier / normalizer for ABC. |
You wrote:
That's not true: YAML has references, so that you can rebuild the exact data, including the pointers, in any language. It solves your two issues and serializes the circular references . About a 'beautifier / normalizer for ABC', did you try toabc.js? |
i've been using musicxml and xml2abc (https://wim.vree.org/js/xml2abc-js.html) to manipulate it like a DOM using d3.js and translate it into abc. i just needed the music to be in a format that was easier to manipulate so it had to be either xml or json. itd be great if the libraries that rendered abc also parsed them into standard formats like musicxml or musicjson. |
oh, I was not aware of this. Thanks for the hint.
not yet, but I surely will. Thanks. |
@jisike, now I see what you want. |
Hello, I'm trying to computationally manipulate an abc tune and wanted to ask how I can use your library to parse an abc string into an object, manipulate the object (ie remove notes, change pitch) then convert it into an abc string. Thanks!
The text was updated successfully, but these errors were encountered: