ID:158852
 
Well what I'm trying to do is add in a nice mid(i) to the game I'm designing. The problem is, when the sound plays, the game's CPU raises from 0% to 80%! I use:

src<<sound('Song name.mid',1)


The song is about 3 minutes and I have it set to repeat. I don't know why the CPU raises so high. Does it download the song as it plays? If so, is there a way to fully load it then for it to begin playing without causing massive lag to the game? Same goes for any sounds(.wav files only lag the game for like a second but still need a more efficient way).

This is all tested in a single player world. Oh and also, 1 more question. Is there a way to play an MP3 upon game start up without having to open it from somewhere on your P.C.?

I really want to have a lot of nice sounds in the game to give players a greater experience but if it comes with the price of lag, what's the point?

Thanks in advance to anyone with tips or an efficient code to solve the problem :).
It really shouldn't cause a CPU spike like that. For remote clients, the sound file is downloaded, but it won't play until it has fully downloaded.

Perhaps something is wrong with your sound settings. For example, I can turn my hardware acceleration for sound down and get it to the point where all sounds played use software emulation. This would cause a CPU spike. Maybe a similar change exists on your system.

But for everybody else, it works properly. I don't get CPU spikes when playing MIDI files.

All I can say is that you could try to set the sound datum's status variable to SOUND_STREAM. This disables several features at the cost of better performance.

var/sound/S = sound('Song name.mid', repeat = 1)
S.status |= SOUND_STREAM</DM