MIDI support

Open-source port of PoP that runs natively on Windows, Linux, etc.
Falcury
Calif
Calif
Posts: 568
Joined: June 25th, 2009, 10:01 pm

Re: MIDI support

Post by Falcury »

Norbert wrote: February 27th, 2018, 8:26 pm So, does this mean SDLPoP will soon support both .ogg and .mid in data/music?
Or maybe you're planning to keep just the .mid files and allow replacing them with .ogg files... or?
I am working on a new SDLPoP branch with MIDI support. Will upload it to GitHub soon (need to clean up the history a bit...).

EDIT:
Here is the GitHub branch:
https://github.com/Falcury/SDLPoP/tree/midi

On that branch, the MIDI files are loaded directly from MIDISND1.DAT and MIDISND2.DAT, similar to how other resources are loaded.
(Or equivalently, folders MINISND1 and MIDISND2 with res*.mid files in them.)
The music/ folder could be deleted.

It doesn't look like the MIDI support would work well in combination with SDL_Mixer, because SDL_Mixer abstracts away the audio callback (I think). And manually programming an audio callback is needed for MIDI playback to work.
So, for now I undefined USE_MIXER to allow for adding MIDI support.

If we do want to keep supporting OGG files, how could MIDI playback be combined with SDL_Mixer, if at all? Converting whole MIDI songs to Mix_Chunks, only because SDL_Mixer doesn't allow direct access to the audio callback feels a bit like overkill. (Is there an alternative?)
(I suspect the cleanest way to have both OGG and MIDI support at the same time is to remove SDL_Mixer and use stb_vorbis.c instead for OGG support.)

The question is, would there still be any reason to have support for .ogg files?
Edit: maybe so that people can continue to make mods like this?
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5786
Joined: April 9th, 2009, 10:58 pm

Re: MIDI support

Post by Norbert »

Falcury wrote: February 27th, 2018, 11:52 pmHere is the GitHub branch:
https://github.com/Falcury/SDLPoP/tree/midi
I think maybe it's missing PRINCE.DAT in data/?
I get a "Missing MIDI instruments data (resource 1)" error.
Falcury wrote: February 27th, 2018, 11:52 pmEdit: maybe so that people can continue to make mods like this?
Yessir.
Falcury
Calif
Calif
Posts: 568
Joined: June 25th, 2009, 10:01 pm

Re: MIDI support

Post by Falcury »

Norbert wrote: February 28th, 2018, 3:21 pm I think maybe it's missing PRINCE.DAT in data/?
I get a "Missing MIDI instruments data (resource 1)" error.
It looks like I forgot to add res1.bin to git. Fixed it.
Falcury
Calif
Calif
Posts: 568
Joined: June 25th, 2009, 10:01 pm

Re: MIDI support

Post by Falcury »

This branch has support for both MIDI and OGG (using stb_vorbis.c):
https://github.com/Falcury/SDLPoP/tree/midi_stbv

To use the OGG files instead of the MIDI files, put them back in the data/music folder. If you delete them again, the MIDI files will be used instead.
Post Reply