/flash/soundtouch-as3/src/com/ryanberdeen/soundtouch/StretchSS.as

http://echo-nest-remix.googlecode.com/ · ActionScript · 30 lines · 25 code · 4 blank · 1 comment · 0 complexity · 17f7546b9e24e8a02b52299215af3287 MD5 · raw file

  1. package com.ryanberdeen.soundtouch {
  2. import com.ryanberdeen.audio.ISampleSource;
  3. import flash.media.Sound;
  4. import flash.utils.ByteArray;
  5. public class StretchSS implements ISampleSource {
  6. private var stretch:Stretch;
  7. public function StretchSS(sound:Sound, tempo:Number):void {
  8. stretch = new Stretch();
  9. //stretch.setParameters(44100, 30, 75, Stretch.DEFAULT_OVERLAP_MS);
  10. stretch.sound = sound;
  11. stretch.tempo = tempo;
  12. }
  13. public function set tempo(tempo:int):void {
  14. stretch.tempo = tempo;
  15. }
  16. public function extract(target:ByteArray, length:Number, startPosition:Number = -1):Number {
  17. return stretch.process(target);
  18. }
  19. public function toSourcePosition(position:Number):Number {
  20. return -1;
  21. }
  22. public function get length():Number {
  23. return -1;
  24. }
  25. }
  26. }