Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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 MIDI files #326

Closed
daveyarwood opened this issue Nov 24, 2016 · 9 comments
Closed

Import MIDI files #326

daveyarwood opened this issue Nov 24, 2016 · 9 comments
Labels
Projects

Comments

@daveyarwood
Copy link
Member

Moved from #85.

Quoth @crisptrutski:

We need some help from the machines in the effect to build the Library of Aldaxandria

Shout-out to @alandipert for also having the same intriguing idea. 💡

It would be cool to be able to read a MIDI file and spit an Alda score to STDOUT. You could then redirect that to a file...

$ alda import -f carry_on_my_wayward_son.mid > carry_on_my_wayward_son.alda

...or even pipe it back to alda to play it, effectively making alda a sort of command-line MIDI player!

$ alda import -f gangnam_style.mid | alda play
@daveyarwood
Copy link
Member Author

It took me a while to figure out which Alda subproject repo this issue should belong to.

What I'm describing could be implemented as a standalone CLI tool, kept in its own repo and installed separately to Alda.

But it would be great if we included such a thing as a built-in alda command. So that made me think this should be filed under alda-client-java.

...Then I thought about implementing it in Java and puked in my mouth a little bit. If it were up to me, I'd do it in Clojure.

So I finally landed on alda-core being the right place to add this feature. We could make it a part of the Alda "standard library," and implement the alda import command as just another request to the server to do something, get the response, and print it to STDOUT. (This is akin to the alda parse task.)

@gdpelican
Copy link

I'd like to take a crack at this. No guarantees (it's a clojure learning project for me, and MIDI parsing seems a bit hairy, even using the java libraries), but I'll give it a go. 😺

@daveyarwood
Copy link
Member Author

daveyarwood commented Jan 1, 2017 via email

@Dongsh
Copy link

Dongsh commented May 7, 2017

So, It is still not a exact way to import the midi file?😅

@truj
Copy link

truj commented Dec 2, 2019

I found this issue by accident after googling for "MIDI-decompiler".
I don't know much about ALDA but I'm working on a MIDI-decompiler for another project: truj/midica
Since yesterday I have a first working prototype and tested with some random files. For most of them it works pretty well, for some I still need to optimize a lot.

I guess the base problems in both languages (ALDA and MidicaPL) are the same. So maybe you can re-use a part of the strategies that I'm using. Or even parts of my code, if you prefer to do it in Java.

In Midica the decompilation is mainly distributed over the following classes:

  1. MidiParser reads the sequence from the MIDI file.
  2. SequenceCreator creates a different instance of the sequence. This instance is actually used by the Midica Player and the decompiler. It contains mostly the same events than the original sequence. But this instance guarantees that each channel corresponds to one single track.
  3. SequenceAnalyzer reads and stores a lot of information from the sequence, not only for the decompiler but also for other purposes.
  4. MidicaPLExporter is the heart of the decompiler. It reads the data structures produced by the SequenceAnalyzer and translates them to MidicaPL source code.
  5. Slice is just a helper class that helps splitting the sequence into slices that can be processed after each other.

My decompiler works only for MIDI files with division type PPQ (pulse per quarter note). This makes it easier to guess the note length of a Note-ON/Note-OFF combination from the MIDI file.
Fortunately this works for most files available on the internet as most of them use PPQ.

I hope this can help you for building a decompiler for ALDA as well.
If you have questions, let me know.

@daveyarwood
Copy link
Member Author

@truj Midica looks awesome! It's very much in the same spirit as Alda, but with its own flavor and a different niche. It makes me happy that there are other people out there doing similar things.

Your MIDI decompiler will be super helpful as a reference. Thanks for sharing!

@truj
Copy link

truj commented Mar 3, 2020

Meanwhile I tried out ALDA and had a bit of time to learn more about it.
So I decided to support it as a decompilation format from Midica.
Maybe I'll have some ALDA related questions later.
Is it OK to post them here?
Or maybe better there, than I don't need to misuse this issue any more.

@daveyarwood
Copy link
Member Author

Interesting! I'd be happy to help, feel free to ping me with any questions in truj/midica#53.

@daveyarwood daveyarwood transferred this issue from alda-lang/alda-core Jan 1, 2021
@daveyarwood
Copy link
Member Author

@gdpelican started implementing MIDI import for Alda v1 (in Clojure) here: alda-lang/alda-core#30

At this point, Alda v2 (Go / Kotlin) is almost ready for release, so we'll have to close the aforementioned PR, but it's still valuable to use as reference when we implement this feature (in Go) for Alda v2.

@alda-lang alda-lang locked and limited conversation to collaborators Oct 7, 2022
@daveyarwood daveyarwood converted this issue into discussion #438 Oct 7, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
Alda
  
Up for Grabs
Development

No branches or pull requests

4 participants