maxl0rd / standingwave3

Flash ActionScript3 dynamic audio library
http://www.noteflight.com
162 stars 28 forks source link

Replaying sounds #26

Open garakatsamol opened 12 years ago

garakatsamol commented 12 years ago

HI, thanx for your work. I am trying to record something with a backgrounf music. So i have succesfully implemented a player where i have two sources. The one is loading from an mp3 and the other is the recorder data.

I make a sequence and an audio performerfor each of my sources and then i use both audio performers as sources and i add them to a new sequence. (that is because i want to control in realtime the gain of each performer.). The outcome is assign to an audioplayer

This works fine until i replay the sound. At this case the recorded sound seems to play in fast forward and at the end of the recording sound throws an error

Error: Sample pointer out of range. at com.noteflight.standingwave3.elements::Sample/getSamplePointer()

Before i replay the sound i try to ensure that audioplayer is stopped

player.stop()

reset the audio performer

_aPerformer.resetPosition()

I get the microphone data with

WaveFile.createSample(recorder.output)

And before i replay it (not really sure if this has a point) i set the position of the recorded data byteArray to 0

recorder.output.position=0

I would appreciate any help. Thanx in advance!

garakatsamol commented 12 years ago

well, the problem was that i was constructing again each time the sequences because i wanted to add a different starting point and i was actually adding the same source each time, which resulted in playback issues.

Since i found a way to remove the sources from the sequences and manage the proccess, i finally got it working. i did that with the help of jordan's implementation http://www.jordansthings.com/blog/?p=5

He added in the ListPerformance class the following function

 /* added by jordan */
public function removeSource(elementnum:int):void
        {
            _elements.splice(elementnum, 1)
    }
}

so when i want to remove all the sources from a sequence i do it by

while(_sequence.elements.length>0)
{               
    _sequence.removeSource(0)
}

It seems a little rough but it worked for me