Skip to content

Commit 230aa9d

Browse files
committed
add getter, setter for source position
1 parent 70987fd commit 230aa9d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/com/ryanberdeen/soundtouch/SimpleFilter.as

+13-4
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ package com.ryanberdeen.soundtouch {
2525
public class SimpleFilter extends FilterSupport {
2626
private var sourceSound:Sound;
2727
private var historyBufferSize:int;
28-
private var sourcePosition:int;
28+
private var _sourcePosition:int;
2929
private var outputBufferPosition:int;
3030
private var _position:int;
3131

3232
public function SimpleFilter(sourceSound:Sound, pipe:IFifoSamplePipe) {
3333
super(pipe);
3434
this.sourceSound = sourceSound;
3535
this.historyBufferSize = 22050;
36-
sourcePosition = 0;
36+
_sourcePosition = 0;
3737
outputBufferPosition = 0;
3838
}
3939

@@ -53,10 +53,19 @@ package com.ryanberdeen.soundtouch {
5353
_position = position;
5454
}
5555

56+
public function get sourcePosition():int {
57+
return _sourcePosition;
58+
}
59+
60+
public function set sourcePosition(sourcePosition:int):void {
61+
clear();
62+
_sourcePosition = sourcePosition;
63+
}
64+
5665
override protected function fillInputBuffer(numFrames:int):void {
5766
var bytes:ByteArray = new ByteArray();
58-
var numFramesExtracted:uint = sourceSound.extract(bytes, numFrames, sourcePosition);
59-
sourcePosition += numFramesExtracted;
67+
var numFramesExtracted:uint = sourceSound.extract(bytes, numFrames, _sourcePosition);
68+
_sourcePosition += numFramesExtracted;
6069
inputBuffer.putBytes(bytes);
6170
}
6271

0 commit comments

Comments
 (0)