jarikomppa / soloud

Free, easy, portable audio engine for games
http://soloud-audio.com
Other
1.76k stars 275 forks source link

Support midi without external dependencies (portmidi / timidity) #195

Open fungos opened 5 years ago

fungos commented 5 years ago

Expected behavior:

Be able to play a midi files as music stream in a simple API without requiring 3rd party dlls/libraries. A music.play("file.mid") API using a default (but with option to use a different) soundfont2 (sf2) file would be great to have.

https://github.com/schellingb/TinySoundFont is a very good candidate for this.

Actual behavior:

SoLoud is able to use portmidi to generate midi audio, but it does not seems to have support to playing .mid files via a WaveStream or a similar API.

jarikomppa commented 5 years ago

TinySoundFont has a too restrictive license for SoLoud; it requires attribution.

At the moment you can use libmodplug to play .mid files through SoLoud.

fungos commented 5 years ago

Hi again! :)

I did implement MIDI support for my own use, but I'm having trouble with a noise that happens due to SAMPLE_GRANULARITY being 512. I'm not sure to understand what is happening, but if I set this to 8 the sound is perfect, any other value has different kinds of noise.

I tried to a lot of different things, but I fear not grasp enough about sound stuff to fix this.

If you want to take a look, my implementation is here: https://github.com/fungos/ass/commit/458f0f9231f8791fb0fe8466ed61bd7e6435111b

Thanks

jarikomppa commented 5 years ago

Granularity shouldn't matter, as then everything else would also break.