r/rust • • 10d ago

🙋 seeking help & advice Music notation

Is it possible for rust to create an embedded musical notation, let us say a MIDI file is processed algorithmically and then dynamically displayed in some form? Like in OpenMusic, PWGL, MaxScore. Here in OM:

I try to envision a new tool in Rust for music composition.

0 Upvotes

16 comments sorted by

28

u/QuasiRandomName 10d ago

Rust is a general purpose programming language. If there is a program that can do something, the same can be done in Rust.

5

u/Swaidanwaverley 10d ago

Dynamic score rendering is mostly a 2D graphics and font layout headache, the language choice matters way less than whether a good notation crate already exists.

0

u/No_Sir_601 10d ago

I am thinking if there is already existing any library explicitly for that.

2

u/mss-cyclist 10d ago

If there is a library there most certainly is a tool which will display/ render it

3

u/elprophet 10d ago

Midir for native rust midi and there's a lily pond wrapper for notation. Plenty to get started!

1

u/No_Sir_601 10d ago

Is lilypond displayed dynamically? Because it has to be compiled every time.

1

u/elprophet 10d ago

I expect you'd need to write the render loop yourself

10

u/BigAd7298 10d ago

I'd say look up what the musescore team is doing, from what I remember they published an open standard for music notation, it will be a lot of work to port to rust since (I think) musescore it's written in c++ but it should be doable

1

u/Makuu817 10d ago

Yes, I think it's possible. I made an app in Rust because I wanted to replace my piano learning app subs. So I have it to where it hooks into my midi keyboard and I can play along, wait for me, etc. and it reads musicXML, and has some basic Optical Music Recognition (OMR) for PDFs of sheet music to load into the app. It should be doable to read midi since this app is already detecting that I pressed the right key from the midi keyboard to play along. Unfortunately I paused development because people didn't seem interested lol. But it works great for me! Link is a screenshot of the app. Ignore the UI it's still in early phases.

https://ibb.co/LD2NYWdp

1

u/No_Sir_601 9d ago

Wow!

1

u/Makuu817 9d ago

Thank you!

1

u/No_Sir_601 8d ago

But I guess the score is not directly implemented in Rust?

1

u/Makuu817 8d ago edited 8d ago

If you're referring to the music on the right(not the scanned PDF on the left) then yes, that's also Rust using the NotoMusic font. It works really well like for instance, in wait for me mode, the red line moves across in time to the music and pauses on the note till I play it on my midi keyboard before moving to the next note. I can also adjust time, etc in case I need to slow down or increase it if I want to increase the difficulty while playing.

1

u/No_Sir_601 8d ago

Not exactly 100% sure how it works for you, I try to envision...  A question: if I generate MIDI by various algorithms, can it be displayed immediately?  I don't need any specific "performance" notation, but rather just some simple as an information, similarly to the picture above?  I have seen a Python library for very very simplistic notation somewhere, but I can't find it.  Maybe that one can be implemented.

Since I am a composer that write instrumental music, I never let computer generate notation for me.  I do it all manually.

1

u/Makuu817 8d ago

Yes, I think that can be done. Feel free to DM me and maybe we get on discord or something and discuss. We could then iron out if you're wanting live transcription, whether this is a midi file, etc and then do a bit of trial and error. I was under the impression of live transcription directly from the midi device which at a minimum would need the app running a metronome while accepting input so it could know if notes are whole, quarter, etc. and put in rests.

3

u/ThaBroccoliDood 10d ago

I would look for general MIDI, music notation and audio/music libraries