Skip to main content
aymanw46296751
Participant
November 30, 2018
Question

Speed ​​up the audio on this code

  • November 30, 2018
  • 2 replies
  • 170 views

!

Speed ​​up the audio on this code

var musicChannel:SoundChannel;

var currentSongIndex:int;

function  onPlayBtnPressed() {

  currentSongIndex = 0;

  playSongFromIndex(currentSongIndex);

}

function playSongFromIndex(songIndex:int) {

  musicChannel = ars[songIndex].play();

  musicChannel.addEventListener(Event.SOUND_COMPLETE, songFinished);

  currentSongIndex++;

}

function songFinished(e:Event) {

  if (currentSongIndex < ars.length) {

       playSongFromIndex(currentSongIndex);

  } else  {

       currentSongIndex=0;

  }

}

You can apply this code to the top code

var sourceSnd:Sound = new sou1();

var outputSnd:Sound = new Sound();

outputSnd.addEventListener(SampleDataEvent.SAMPLE_DATA, processSound);

outputSnd.play();

function processSound(event:SampleDataEvent):void {

    var bytes:ByteArray = new ByteArray();

    sourceSnd.extract(bytes, 4096);

    event.data.writeBytes(upOctave(bytes)); }

function upOctave(bytes:ByteArray):ByteArray {

    var returnBytes:ByteArray = new ByteArray();

    bytes.position = 0;

    while(bytes.bytesAvailable > 0)

    {

        returnBytes.writeFloat(bytes.readFloat());

        returnBytes.writeFloat(bytes.readFloat());

        if (bytes.bytesAvailable > 0)

        {

            bytes.position +=8;

        }

    }

    return returnBytes;

}

////////////

///////////

//////////

////////

////////// ! !

This topic has been closed for replies.

2 replies

aymanw46296751
Participant
November 30, 2018

The program uses the Adobe Animate CC

[Moved from the non-technical Lounge to the specific Program forum... Mod]

[Here is the list of all Adobe forums... https://forums.adobe.com/welcome]

John T Smith
Community Expert
Community Expert
November 30, 2018

Please post the name of the program you use so a Moderator may move this message to that forum

-A program would be Audition or Premiere Pro or ???