1
Ask a Question / Re: Converting .wav to .mp3 without a delay
« on: February 22, 2018, 08:27:54 am »
There are two delays - both unavoidable, but can be minimized to be imperceptible. One is in the waveform itself. Does your waveform show an empty gap at the beginning (usually between .05 and .1 secs)? In addition to this delay, there is also a second delay that is in the file, but not the waveform -- this is the codec information and is also unavoidable, but can be minimized by using the LAME mp3 encoder to convert (this encoder is included in the most recent builds of Audicity, I believe). The good news is that both of these can be minimized to the point where they are not important.
I just did a test -- I converted a WAV file (16-bit signed PCM) with no gap at all to an MP3 (128 kbps, constant bitrate, joint stereo, no metadata) in Audacity 2.1.1 (using the LAME mp3 encoder included with recent Audacity downloads). The result was a delay of .04 secs in the waveform itself. This is small enough to be completely trivial. I then made a flash game in Stencyl and had the sound play on a keystroke (up arrow). The result was close enough to be perceived as "immediate". I've included the game as an attachment.
Note: the very first time the sound is played, there is still a small delay - maybe about .15 or so. I think this is unavoidable, but it's only the first time. After this, the playback of the sound effect is "immediate".
Up arrow plays the sound in the sample game.
Also: if you ever need to seamlessly loop an mp3 (music, for example), the key is to use two separate channels that alternate playing the track at time intervals that create the illusion of one seamless loop.
Also also: fortunately, Flash is on its way out of relevance (and with it the need for MP3 sound resources in games) and is being replaced by html5, which uses OGG format for sound, superior in both quality and without the delays.
I just did a test -- I converted a WAV file (16-bit signed PCM) with no gap at all to an MP3 (128 kbps, constant bitrate, joint stereo, no metadata) in Audacity 2.1.1 (using the LAME mp3 encoder included with recent Audacity downloads). The result was a delay of .04 secs in the waveform itself. This is small enough to be completely trivial. I then made a flash game in Stencyl and had the sound play on a keystroke (up arrow). The result was close enough to be perceived as "immediate". I've included the game as an attachment.
Note: the very first time the sound is played, there is still a small delay - maybe about .15 or so. I think this is unavoidable, but it's only the first time. After this, the playback of the sound effect is "immediate".
Up arrow plays the sound in the sample game.
Also: if you ever need to seamlessly loop an mp3 (music, for example), the key is to use two separate channels that alternate playing the track at time intervals that create the illusion of one seamless loop.
Also also: fortunately, Flash is on its way out of relevance (and with it the need for MP3 sound resources in games) and is being replaced by html5, which uses OGG format for sound, superior in both quality and without the delays.