Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411490 Posts in 69377 Topics- by 58433 Members - Latest Member: graysonsolis

April 29, 2024, 03:15:32 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Playing sounds rapidly
Pages: [1]
Print
Author Topic: Playing sounds rapidly  (Read 2170 times)
rogerlevy
Guest
« on: April 03, 2009, 09:28:45 AM »

Let me know and feel free to lock this thread if it should be posted somewhere else on a more Flash-specific forum ...

Has anyone else wanted to play sound effects in rapid succession (e.g. machine guns, score counters ) in Flash?  I can't seem to be able to do it without it sounding like poop.  I tried stop()ing the SoundChannel that comes out, and it works, but it doesn't help the awful "latent" effect.  Anyone know what I'm talking about?  Any help is appreciated, because I really want to have an animated score counter with a rapidly-firing "ding" sound.
Logged
Ivan
Owl Country
Level 10
*


alright, let's see what we can see


View Profile
« Reply #1 on: April 03, 2009, 09:39:35 AM »

Why not have the actual sound effect be a longer continuous loop, so that you can just start it and stop it?
Logged

http://polycode.org/ - Free, cross-platform, open-source engine.
Glaiel-Gamer
Guest
« Reply #2 on: April 03, 2009, 10:09:46 AM »

for sound effects to sound good in rapid succession, you need more than just 1. Grab like 3 or 4 of the same type of effect, and randomly pick one of them.
Logged
Loren Schmidt
Level 10
*****



View Profile WWW
« Reply #3 on: April 03, 2009, 11:19:40 AM »

I've run into various issues playing rapid sounds, and sounds in general, in Flash.

Rapidly cued sounds like gunfire tend to cut each other off if I use Stop(). But if I just let the sounds overlap, there are other problems. When multiple instances of a sound are played at once it gets too loud. I'm currently just using Stop() every time an effect is played, so only one instance of it can play at a time (which is a really awful solution).

But latency is by far the biggest problem. It seems quite variable. Sometimes it will be nearly negligible, and other times it will be so latent that sounds don't seem to be related to the events that triggered them at all.
Logged
rogerlevy
Guest
« Reply #4 on: April 03, 2009, 11:47:15 AM »

But latency is by far the biggest problem. It seems quite variable. Sometimes it will be nearly negligible, and other times it will be so latent that sounds don't seem to be related to the events that triggered them at all.

I know!  It's pretty lame, right?  Hand Shake Left WTF Hand Shake Right
Logged
Glaiel-Gamer
Guest
« Reply #5 on: April 03, 2009, 12:07:46 PM »

if you're using flash 10, you could write your own sound engine, but shuffling between a few different ones is probably an easier solution and will sound better in the end
Logged
PGGB
Level 8
***



View Profile
« Reply #6 on: April 03, 2009, 02:03:01 PM »

Not a nice solution but how about simply preparing a sound file for it?
Logged
Matt Thorson
Level 7
**

c'est la vie


View Profile WWW
« Reply #7 on: April 03, 2009, 03:21:11 PM »

I found that in the preview mode (using Flash CS4), the sound latency was WAY worse than in the regular Flash Player.

The latency still exists, though, and it drives me insane.
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #8 on: April 04, 2009, 05:55:13 AM »

I've not tried it myself, but I've seen a few articles suggesting padding sounds files with a quiet period, and then seeking to the start of the actual sound in order to make latency more reliable.
Logged
takvor
Level 0
*


View Profile
« Reply #9 on: April 07, 2009, 12:53:44 PM »

Well I know that mp3 files, at least, have a small amount of silence at the beginning.  So what I did was just use mySound.play(number), where "number" is the amount of time in milliseconds into the file you want to start playing the sound.  I can't remember what value I used, maybe 20ish.
Logged
rogerlevy
Guest
« Reply #10 on: April 07, 2009, 01:35:35 PM »

Well I know that mp3 files, at least, have a small amount of silence at the beginning.  So what I did was just use mySound.play(number), where "number" is the amount of time in milliseconds into the file you want to start playing the sound.  I can't remember what value I used, maybe 20ish.
I've not tried it myself, but I've seen a few articles suggesting padding sounds files with a quiet period, and then seeking to the start of the actual sound in order to make latency more reliable.

Thanks guys I will try this.
Logged
Μarkham
Level 10
*****



View Profile WWW
« Reply #11 on: April 07, 2009, 02:30:45 PM »

You know, I just remembered what I did to combat the delay.  Flash has always had issues when playing sounds as an event, so my workaround was to make blank movie clips, put the sound in the timeline with enough frames to cover the sound and set it to Stream, with a gotoAndStop(1) command on the last frame.  Through the AS, I would add an instance of that movie clip and then tell it to play(); whenever it was necessary.

I've not tried it myself, but I've seen a few articles suggesting padding sounds files with a quiet period, and then seeking to the start of the actual sound in order to make latency more reliable.
This, as far as I know, only applies to sounds in the timeline, thoughthe problem is very related.  Sound-less frames do something weird, and play faster while what I'm going to guess are the "sound timelines" played at the normal speed, thus things getting out of sync.  The fix was similar, as you would make an empty layer that covers the whole movie, put the smallest sound file in there set to stream, set the envelope so that it is completely silent, and then tell it to loop to infinity.  You didn't add the silent space to the sound files themselves.
« Last Edit: April 07, 2009, 02:35:41 PM by Markham » Logged

rogerlevy
Guest
« Reply #12 on: April 08, 2009, 09:26:20 AM »

You know, I just remembered what I did to combat the delay.  Flash has always had issues when playing sounds as an event, so my workaround was to make blank movie clips, put the sound in the timeline with enough frames to cover the sound and set it to Stream, with a gotoAndStop(1) command on the last frame.  Through the AS, I would add an instance of that movie clip and then tell it to play(); whenever it was necessary.

I've not tried it myself, but I've seen a few articles suggesting padding sounds files with a quiet period, and then seeking to the start of the actual sound in order to make latency more reliable.
This, as far as I know, only applies to sounds in the timeline, thoughthe problem is very related.  Sound-less frames do something weird, and play faster while what I'm going to guess are the "sound timelines" played at the normal speed, thus things getting out of sync.  The fix was similar, as you would make an empty layer that covers the whole movie, put the smallest sound file in there set to stream, set the envelope so that it is completely silent, and then tell it to loop to infinity.  You didn't add the silent space to the sound files themselves.

I just tried your suggestion but when I start the game the sound starts playing repeatedly and really muffled and irregularly, even though I haven't placed the movieclip on the stage.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic