Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 02-03-2008, 10:13 PM   #1
cybereality
Registered User
 
Join Date: Jul 2005
Posts: 40
Default Seamless looping MP3 sound (or silent gap glitch)?

I am trying to have an mp3 sound play in the background as a seamless loop. I am using the Sound and SoundChannel class and I can play the sound fine. The problem I have is that when the sound loops there is a small gap between the end of the loop and the start at the beginning. I did a search I didn't find any obvious solution. Is there something I'm missing here, this seems like a very basic feature.

From what I understand this issue has to do with the encoding of the mp3 file. So what do I need to do in order to export an mp3 file without the silent gap? Is there any workaround in flash to get around with without editing the audio files? What about support for other audio formats aside from mp3? Any help will be greatly appreciated.
cybereality is offline   Reply With Quote
Old 02-03-2008, 10:29 PM   #2
atomic
Banned by AS.org Staff
 
Join Date: Jan 2007
Location: Montréal, Québec
Posts: 14,075
Default

The problem was the same with AS2.0... Don't see why it'd be different for AS3.0...
Looping soundObjects have never looped as seamlessly as simple timeline looping sounds. On some of them (again on AS2.0), playing with the second offset parameter would help to shorthen the gap, but it wasn't very steady...
atomic is offline   Reply With Quote
Old 02-03-2008, 11:05 PM   #3
cybereality
Registered User
 
Join Date: Jul 2005
Posts: 40
Default

What has changed is that you were able to use wav sounds for music previously, and it appears AS3.0 only supports mp3 audio. I was hoping there was something new to AS3.0 that would help with looping sounds, but I guess not. So is the only way to use the timeline for placing sounds? There must be some workaround with code.

Last edited by cybereality; 02-03-2008 at 11:10 PM..
cybereality is offline   Reply With Quote
Old 02-03-2008, 11:49 PM   #4
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 2,060
Send a message via AIM to Mazoonist
Default

MP3 files are the only kind that can be loaded from an external file. You can still import WAV files to the library, give them a class name, and play them with Actionscript (without placing them on the timeline).
__________________
My new website: theflashconnection.com
Mazoonist is offline   Reply With Quote
Old 02-04-2008, 12:08 AM   #5
cybereality
Registered User
 
Join Date: Jul 2005
Posts: 40
Default

Quote:
Originally Posted by Mazoonist View Post
MP3 files are the only kind that can be loaded from an external file. You can still import WAV files to the library, give them a class name, and play them with Actionscript (without placing them on the timeline).
Thanks so much, that is what I was looking for. Its kinda funny actually because I just figured it out (doing a google search) like 5 minutes before you posted. I'm very surprised that this solution wasn't widely posted before on this forum, I noticed a lot of other people had struggled with the same problem.

Heres the code if anyone is interested:

Code:
var soundLoop:Sound = new LoopingSound();
soundLoop.play(0, 99);
Just import your audio file (wav/aif) into the library and give it a linkage class of "LoopingSound" (for the above example, it could be anything you like) by default it should extend the "Sound" class which is what you want. Then you can call it from script as above and it loops correctly.
cybereality is offline   Reply With Quote
Old 02-04-2008, 01:43 AM   #6
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 2,060
Send a message via AIM to Mazoonist
Default

Exactly!

By the way....

If your sound file does have a gap of silence (one that isn't flash's fault), you can edit it out with Audacity. This free program came on a disk with a USB turntable I got, but you can also get it as a free download from: http://audacity.sourceforge.net/. Consult the help files to learn how to export MP3, as it involves downloading a dll file, which isn't a big deal either. After playing with the program and the turntable for awhile, and recording a few vinyl albums, I realized that you can also use the program to easily load and edit any MP3 files, and other sound file types, too, including WAV.

Find and highlight the gap of silence, and press the delete key. Easy! Then, save (export as MP3) the file under a different name to preserve the original.
__________________
My new website: theflashconnection.com
Mazoonist is offline   Reply With Quote
Old 02-04-2008, 03:42 AM   #7
cybereality
Registered User
 
Join Date: Jul 2005
Posts: 40
Default

Quote:
Originally Posted by Mazoonist View Post
By the way....

If your sound file does have a gap of silence (one that isn't flash's fault), you can edit it out with Audacity.
Oh yes, me and Audacity are old friends . Thanks for the tip though.
cybereality is offline   Reply With Quote
Old 02-25-2008, 07:32 AM   #8
cybereality
Registered User
 
Join Date: Jul 2005
Posts: 40
Default

It turns out that the audio file did need editing with audacity, although the mp3 streaming was making the problem worse.

Last edited by cybereality; 02-25-2008 at 07:45 AM..
cybereality is offline   Reply With Quote
Old 10-08-2008, 09:15 PM   #9
rajpar3
Registered User
 
Join Date: Sep 2008
Posts: 4
Default

u can use the below for endless looping-

soundLoop.play(0, int.MAX_VALUE);
rajpar3 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kenny Bellew Sound Object Tutorial Updated Kennyb ActionScript 2.0 23 05-09-2007 09:38 PM
Sound Looping Malfunction smalls312 ActionScript 2.0 2 03-01-2006 12:02 AM
looping sound and silent space question? ladyofbenjamin ActionScript 2.0 3 04-24-2005 08:26 PM
Sound looping and soundoncomplete time lag jingomelingo ActionScript 2.0 0 04-01-2005 09:33 AM
Stopping movie but keeping sound looping phil_roy ActionScript 1.0 (and below) 2 02-02-2002 10:57 PM


All times are GMT. The time now is 08:57 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.