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

Json to midi #31

Closed
bbonczek opened this issue May 3, 2017 · 6 comments
Closed

Json to midi #31

bbonczek opened this issue May 3, 2017 · 6 comments

Comments

@bbonczek
Copy link
Contributor

bbonczek commented May 3, 2017

Hi, I was searching in your documentation and tests, however I could not find feature I am interested in.

Is it currently possible to generate midi file from json, that was created via MidiConvert?

My use-case is :

  1. translating regualar midi file into JSON via MidiConvert,
  2. tweaking json in some text editor,
  3. translating it back to midi
@appsforartists
Copy link
Collaborator

Did you look at .encode()? Based on both the README and the unit tests, it looks like that does what you want it to do.

@bbonczek
Copy link
Contributor Author

bbonczek commented May 3, 2017

It is almost, what I am looking for, but not exactly. encode() method allows me to transform MidiConvert object (that is created for example by using MidiConvert.create()) into midi file that can be started in media player.

What I am missing, is feature, that would allow me to transform json into MidiConvert object (deserialize it in other words).

json_midiobject_midifile_schema

@appsforartists
Copy link
Collaborator

Ahhh. I don't see a fromJSON(), but I bet you could open a PR for one.

Or, if something quick and dirty is more your style, maybe something like this?

const midi = new Midi()
const encoded = midi.encode.apply(myJSON);
midi.decode(encoded)

It would roundtrip through the encoder, which is a bit wasteful, but it would get you the object you wanted. Alternatively, I'd copy decode, name it static fromJSON, and modify it to parse a JSON object rather than a string.

@bbonczek
Copy link
Contributor Author

bbonczek commented May 4, 2017

I'll try with pull request :)

@appsforartists
Copy link
Collaborator

This can close now.

@tambien tambien closed this as completed Jul 7, 2017
@ghost
Copy link

ghost commented Aug 29, 2018

How do i use fromJSON() fx to get the midi file i mean how to get the midi file.
Say for example i put the json as input and call fromjson(myjson) then where is the midi file actually?

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

No branches or pull requests

3 participants