Looping sound on export has silent gaps

I'm trying to loop sound with Hype's build in loop function.

If I preview the scene, sound loops seamlessly.
If I export the same scene and view it through a browser the loop has very clear silent gaps in it.

Take for example @jonathan 's file here:

If previewed the scream in the file goes like WhaWhaWhaWhaWhaWhaWha etc. (no pauses)
If exported and browser viewed it goes like Wha.... Wha..... Wha.... Wha..... etc. (with pauses)

I'm trying to find out if it's just me having this behavior or do others hear this as well?
I reinstalled Hype 3, thinking it might be a Hype4 thing but this had the same result.
Or have these gaps when looping always been the case? :no_mouth:

engine_sound.zip (269.9 KB)

if you run the export from a server and webaudio can be used it’ll work without gap. it’s related to standard audio-tag. webaudio can’t be used locally because its basic approach is to use an XMLHttpRequest for fetching sound files …

3 Likes

Oh, here I go again. (kickselfsmiley) Not running it through a server. Argh!
Thank you Hans! :star_struck:

To test local export ( saves you from keep having to upload to server) you can use this method

It did work ok when I did this.

2 Likes

Wow! That’s handy! :smile:
Thank you too!

Did I mention that I love this place?
:heart_eyes:

2 Likes

may come in handy too

2 Likes

That’s a great tip too!
Thank you Hans. :grinning:

I'm close to suicide.

I found that there is a problem with the loops whether I listen to them locally or upload them to a FTP server. After reading this topic, I decided to make the following very detailed infographic that shows my research. I haven't tried it on PC yet.

Here are my conclusions:

  1. The best result is when I load a file with pauses to Safari. For some reason, Safari prefers not to read the pauses and the loop plays perfectly seamless. The problem is that most people use Chrome and that's not a solution for me. I want the loops runs smoothly on Chrome.

  2. When I remove file pauses, Chrome improves but Safari gets worse. Both browsers sounds the same wrong way.

  3. It would be ideal if Chrome preferred the ogg file, because that way I would submit an mp3 with pauses for Safari and an ogg file without pauses for Chrome! Maybe @jonathan nows better why the ogg file doesn't open in any of the four browsers?

This is the file: ChromeLoopProblem.zip (517.8 КБ)

Are the images you included in your test file from your audio editing app?

If I get a segment of pink noise and loop it, I'm only seeing issues in Opera when using Hype's built in audio player. It's kind of hard to see what should be happening in your file because some files have blank spaces.

audiotest.hype 2.zip (31.2 KB)

Regarding whether browsers play mp3 vs ogg -- In the list of sources, the browser will play the first compatible audio file (more info) and I think we put MP3 sources first.

You could create your own custom audio element and place the source in a higher order:

<audio id="thefoo" controls loop>
 <source src="${resourcesFolderName}/foo.ogg" type="audio/ogg; codecs=vorbis"/>
 <source src="${resourcesFolderName}/foo.mp3" type="audio/mpeg"/>
</audio>

I did make a test with Howler.js' loop, and it requires a small JS function that looks like this, which can be triggered by a button:

var sound = new Howl({
  src: ['${resourcesFolderName}/pink-shorter.mp3', '${resourcesFolderName}/pink-shorter.ogg'],
  loop: true,
  volume: 1
});

sound.play(); 

It also requires a snippet in the 'head' to load the library:

<script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.2.1/howler.min.js" integrity="sha512-L6Z/YtIPQ7eU3BProP34WGU5yIRk7tNHk7vaC2dB1Vy1atz6wl9mCkTPPZ2Rn1qPr+vY2mZ9odZLdGYuaBk7dQ==" crossorigin="anonymous"></script>

This seems to resolve the issue in Opera -- here's a demo:

audiotest.hype 3.zip (32.5 KB)

Note that a looping audio issue was recently fixed in Firefox, but I don't know much about Opera's development:

1 Like

Hi, @Daniel!

Yes, the images are screenshots from audio editing app.

The guitar riff for example must floating seamless but it happens only when I'm using the mp3 file with blank spaces at the both ends and play it via Safari. On Chrome the loop didn't plays seamless even I have cleared the blank spaces. See the difference between Safari and Chrome: Safari works perfect with this file, but in Chrome there is a pause between the loops.

audiotest-guitar.zip (120.7 КБ)

Maybe the problem is in the files, I don't know... I'll check.

I prefer using only mp3 files, but I'm wondering why it's recommended to have both, mp3 and ogg when all browsers works fine with mp3s.

Yeah, I'm already using Howler but the problem is the same. Maybe the trick is really in the files. Also it's easier to use Hype's built in audio player and if there is an fade in/out option like the "loop" check box it would be perfect!

Opera is not important after all. The goal is Chrome.

Thank you for your quick response!

@dsedlarski

I checked the file You provided ("ep1_49_mansion_moon_loop_48_192.mp3") in Adobe's "Audition" sound editor at high magnification and found this small gap at the end (please see Fig.1). Removing this gap resulted in a seamless loop - at least to my ear.

Fig.1
Gap

Hype sorts audio by type alphabetically and plays the first one that is allowed by the browser. Therefore if it has an mp3 and ogg, the mp3 will play since m comes before o. A hack workaround would be to have separate names for the files, do your own browser detection, and then play the audio via triggering a custom behavior with the audio action.

It seems others on this thread are looking into this and helping out, so I'll just chime that you are hitting something we've seen and it is woefully sad how inconsistent browser audio is. Sometimes you'll get different results by unchecking the "Use low latency Web Audio API" box to force the <audio> tag, but I think in most situations this is worse.

We found it!!!
The problem was totally in the mp3 files! Do you know that when exporting your audio project, every software in the world puts this silent gaps in your mp3 file? We work with Logic and when we put the exported mp3 from Logic to another software there is a silent gaps! We realized that this is typical of the mp3 format.

Here is some topics:

https://gearspace.com/board/music-computers/1183037-rendering-mp3-creates-silence-begining.html?fbclid=IwAR1G814DA8JO_tWg62zicNJ1deHDYd2Zia52GLKHhH2igcUJAb5UHsKV-kI

That is just how MP3 works. The only way around it is to use the LAME MP3 encoder (which you should be using anyway, not the crap MP3 encoder apple uses), because it encodes a playback offset in the metadata (id3) tags that good players should see and thus allowing gapless playback.

Well, MP3 works by breaking the audio up into frames of a fixed length which then get put in blocks of a fixed length and so in the likely chance that the audio does not start or stop bang on a block you will end up with some silence added.

What LAME (which lots of programs use for MP3 encoding) does is write the amount of silence that has been added to the id3 tag (same thing as artist, song, album etc tag).
What that means is that programs that support it can play the files back without gaps.

Now we export the sounds from Logic to wav format and then convert them to mp3 using LAME MP3 encoder with Reaper.

Now the loops sounds great!
ChromeLoopProblem_test2.zip (352.7 КБ)

1 Like

Hey that's great! So weird that different encoders add gaps. I was exporting with Audacity which I think uses LAME.

1 Like

I just tried this program and it gave the best result! With its version LAME3.1, mp3s have no gaps.
Thank you all!

2 Likes