A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How to play multiple sounds from the custom positions (delays)?

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    3

    How to play multiple sounds from the custom positions (delays)?

    I need to realize something like a multiple track player. The users can upload multiple tracks and start to play them together. My problem is to allow the user to define a start position of each track to allow a synchronization between them, something like this:
    Track 1: start at [x] sec.
    Track 2: start at [y] sec.
    play/stop

    where the user can input the x and y. I've tried with AS2 (using netstream and SetIntervall) and AS3 (using netstream or sound and timer). If I set the same x and y both tracks are playing simultaneously. But not if the x and y are different.

    Can you tell me how to solve the problem. Any help would be appreciated!

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    To be clear - are you trying to start two sounds at a different times, or start two sounds at the same time at different offsets in the sound files?
    Please use [php] or [code] tags, and mark your threads resolved 8)

  3. #3
    Junior Member
    Join Date
    Dec 2009
    Posts
    3
    Quote Originally Posted by neznein9 View Post
    To be clear - are you trying to start two sounds at a different times, or start two sounds at the same time at different offsets in the sound files?
    I want to start two sounds at a different (or custom) times.

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Well - timers or intervals will get you roughly what you want...the problem is that Sounds take a little while to buffer up in flash and using timers adds at lease a 1-frame delay into the code execution.

    For a little more precision, I'd load both sounds without playing them (eg. cache) then start one sound and record the time. From there turn on an enterFrame and compare the current time every frame to the delayed time you're looking for - if you've overshot it, you can play the second clip with a startTime of the offset to try and synch back up - or if the next frame will overshoot, you can call play a little bit ahead of time.

    If you want to get into the extreme end of sequencing and sound generation, head over to http://www.make-some-noise.info/ and look through the advanced stuff that's being developed there.
    Please use [php] or [code] tags, and mark your threads resolved 8)

  5. #5
    Junior Member
    Join Date
    Dec 2009
    Posts
    3
    Quote Originally Posted by neznein9 View Post
    For a little more precision, I'd load both sounds without playing them (eg. cache) then start one sound and record the time. From there turn on an enterFrame and compare the current time every frame to the delayed time you're looking for - if you've overshot it, you can play the second clip with a startTime of the offset to try and synch back up - or if the next frame will overshoot, you can call play a little bit ahead of time.
    Can you please show me your working code, because I can't implement it correctly.
    Thank you in advance!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center