Love2d and .mid files

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Valentio
Prole
Posts: 6
Joined: Mon Sep 05, 2016 10:29 am

Love2d and .mid files

Post by Valentio »

Hi everybody!

I would want to know how i can play .mid file sounds in a love game with several soundfonts (.sf2, are instruments) without sounding very horrible. I've seen a lot of libreries that supports midi, but i don't know how i can use them.

I want to use .mid because the other audio formats are very heavy. Could someone explain me how i can do this?
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Love2d and .mid files

Post by zorg »

At least two MIDI related projects exist, but as far as i can tell, one used a dll to hook into the MIDI device set to default on windows, which isn't cross-platform (and probably isn't developed further currently), while the other, which does use a soundfont player as dependency, might be what you want, but i don't know the current state of that project, sadly.

That said, if we'd knew the correct path that libmodplug (in löve) expects for timidity patches, then MIDI files would probably sound at least marginally better, with distinguishable instruments.

Edit: Should be one of the following: "C:\\TIMIDITY\\INSTRUMENTS" "/usr/local/share/timidity/instruments" "/usr/share/timidity/patch"
"/usr/local/share/timidity/timidity.cfg" "/etc/timidity.cfg"
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Love2d and .mid files

Post by raidho36 »

Well yeah sounds are data-heavy, you'll just have to deal with it. Choosing midi over waveform formats just for file size is a poor decision, especially now that soundcard manufacturers don't bother anymore with proper midi support, oftentimes you can't get midi to play at all, not without resorting to software rendering. If you want small music files that badly, consider using module tracker formats, most common being those of impulse tracker, modplug tracker and fast tracker 2. Otherwise, choose what sounds best.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Love2d and .mid files

Post by pgimeno »

I looked into playing MIDI files with LÖVE for Thrust II Reloaded. Timidity patches turned out to be pretty broken. https://sourceforge.net/p/modplug-xmms/bugs/19/

My advice: don't, because it won't be cross-platform. I ended up converting the MIDI file to ogg (and later a musician made a better song anyway).
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Love2d and .mid files

Post by zorg »

raidho36 wrote:Well yeah sounds are data-heavy, you'll just have to deal with it. Choosing midi over waveform formats just for file size is a poor decision, especially now that soundcard manufacturers don't bother anymore with proper midi support, oftentimes you can't get midi to play at all, not without resorting to software rendering. If you want small music files that badly, consider using module tracker formats, most common being those of impulse tracker, modplug tracker and fast tracker 2. Otherwise, choose what sounds best.
Proper MIDI support is iffy, not only because the actual soundbanks have exactly zero to do with MIDI itself, but also because some companies had proprietary extension messages (Yamaha XG, Roland GS, also incompatible) that aren't emulated by nigh anything (not that that many files even use those, mind you).
Also, even GM (General MIDI, or at least MPU-401 compatible) doesn't define what note "velocity" is... so you can't rely on a mid file having the same mixing level across soundfonts or patches.

Also, older soundcards used FM synthesis for sounds. Whether one prefers PC Speaker, Tandy, AdLib, GUS or SB patches, or a Hardware soundbank like Roland SC-88 had it, is really subjective.

I agree that with most soundcards, one needs to resort to software rendering, but depending on the renderer, the sound will vary. (Yes, the default windows one is bad.)

I'd also agree with using a tracker module format, even if you don't want to hand-convert notes, for example, OpenMPT can import midi, and save it (with instruments) as a module. It'll be a bit bigger than a mid file, but still less than an ogg or mp3. You can even use different samples for the various instruments, if you're not satisfied by what MPT uses by default (again, you shouldn't be).

So yeah, either have it fully rendered as an ogg, or make it/them into tracker modules.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest