🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

MIDI in games

Started by
9 comments, last by LorenzoGatti 9 years ago

Is MIDI used much in games anymore? I have a game concept I intend to create that will involve using realtime processing of MIDI to create the music in game. I'm just not sure what I'm going to do when it comes to the sound synthesis, because most default MIDI playback sounds awful. I recall learning that older consoles used hardware chips for sound synthesis, but I don't know if consoles still use hardware that can play back MIDI. I fear this means coding a whole sound engine...

Just looking to start a general discussion with this one :)

Advertisement

Modern Consoles don't have dedicated synth chips, they use audio middle-ware like Wwise. I would need to know more specifically what you're trying to accomplish but you can create procedural music and the like with automated pre-rendered splits/stems

I wouldn't be using any audio whatsoever. On an abstract level, I'm trying to have an invisible MIDI sequencer in my game, where the gameplay manipulates the MIDI data before music is played back. A basic gameplay example would be that the player sprite can pick up different musical instruments, which would change the instrument that plays back a specific MIDI file. Recordings won't work, because the MIDI fiile has to be manipulated musically by the game in ever-varying ways.

You would have to go with some basic MIDI processor then. If it's electronic music that uses a synth manipulating square waves and so on that's not a big deal. But if you're using instruments like you said, and you want them to sound good that would be just about impossible. First you would need a MIDI sample library that you would license into a game which would be expensive if you can get a license like that at all. Second the space required would make it impractical. For example my EastWest library, which is just maybe 30 classical instruments, is about 60GB and Vienna is like 150GB, Even something really cheap, that doesn't sound very good, like Miroslav is like 20GB. You're going to have to compromise a lot of quality to make this practical.


On an abstract level, I'm trying to have an invisible MIDI sequencer in my game, where the gameplay manipulates the MIDI data before music is played back. A basic gameplay example would be that the player sprite can pick up different musical instruments, which would change the instrument that plays back a specific MIDI file. Recordings won't work, because the MIDI fiile has to be manipulated musically by the game in ever-varying ways.

To do this, MIDI is obsolete technology. There's no value in basing your custom sound synthesis engine and your models of dynamically altered music layers and parts on a slow, overly abstract wire protocol designed for physical instruments.

In music authoring MIDI has still a place as a reliable interoperability standard for disparate hardware and software from different ages and vendors, but in the closed world of your game you only need to import samples, music segments and sequences of notes, with no use for MIDI data.

Omae Wa Mou Shindeiru

Well, /someone/ doesn't share my vision. tongue.png The reason I want to use MIDI is for its ability to store musically meaningful data. There is surely no better protocol that exists. Every aspect of music composition is important to me here - the bar, the time sig, the key sig etc; MIDI can handle all of that for me. My game has to be able to say "change the 2nd chord in bar 2 to the next inversion of its self", or "replace this bar of music with a music bar created from data based entirely on user input" for e.g. This is the level of musical control I'm exploring. I suppose it's hard for me to explain the idea, but I've thought about it a lot and I'm definitely using MIDI for this. If anything, I'd have to write my on sequencing protocol if I weren't using MIDI.


If anything, I'd have to write my on sequencing protocol if I weren't using MIDI.

Of course, and it would probably be easier. You want to edit a score programmatically, and there are many examples of comprehensive representations of music with good, hierarchical data structures which would be much better for your purposes than the flat MIDI structure of events on a track.

For example, the Euterpea.library for Haskell has a generic "music" type containing notes and rests as primitive values, sequential and parallel playing operators, and a wealth of modification operators (e.g. repetition, change pitches, change tempo, etc.); you could freely build any hierarchy of superstructures like parts, chords and bars and operators like chord inversions very easily on top of that.

Omae Wa Mou Shindeiru

I see your point and will check this out once Im at a computer (mobile currently). The problem I imagine with this approach is that Id have to compose music in this format. Pretty much everything lets you export to MIDI, but im not sure about this? The other thing is that im writing algorithms in C++ for a MIDI utility plugin, and planning on reusing some of that code in the game music engine. Although I have options on how to handle musical data in a game, I dont have a choice when it comes to the plugin. It makes sense for me to make these two projects somewhat cross-compatible

In the Euterpea for Haskell documentation it mentions that you're still using virtual instrument suites to sample the music, which brings you right back to size vs. quality. Also you would be working in Haskell which isn't exactly the most popular language, that will limit the number of resources available to you.

Composing your music is going to be only a small and easy task compared to manipulating it, linking the manipulations to the game itself in meaningful ways, and actually synthesizing the notes.

I'm sure you'll be able to convert MIDI sketches made in a traditional sequencer to music fragments in any practical system, possibly through an intermediate conversion to easily edited text formats like abc or MusicXML or using a library to parse MIDI files.

If you have a MIDI-based synthesizer, it's far more complex than you need. Rip out the actual synthesis and its control data (pitches, volumes, durations, etc.) and adapt the synthesizer to a good music representation rather than the difficult music manipulation part of your project to the unnecessary constraints of MIDI.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement