Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8775057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:42:54+00:00 2026-06-13T18:42:54+00:00

So I’m making a simple flash game. Basically I have a turntable that goes

  • 0

So I’m making a simple flash game. Basically I have a turntable that goes on for 30 seconds with a couple of sample music that adds up together in multiple layers of sound to form a final song.

Now I would like to be able to record and play the sounds at the end of the game.

I’ve created a SoundFx class that takes mp3 audio and turns it into byteArrays with the hope to mix the audios in to the same Sound channel.

Now I’ve reached a certain impass since I cannot properly mix the bytearrays. I’m starting to think it’s not possible to encode the byte Arrays as you add the channels to the mix.

I’d love to be guided in the right direction. I’m not sure if the best way to proceed from here, even just the playback would be nice. Creating a button log would probably fix the playback and mixing the audio in a second run to go straight to the file. but it sure seems like a long path to achieve this.

Many thanks and apologies for my crappy english in advance

David R.

some code on the matter:

    private var srcSound:Sound; 
    private var sound1:Sound;
    private var sound2:Sound;
    private var soundChannel:SoundChannel;  
    private var bytes:ByteArray;
    private var incbytes:ByteArray;
    private var mixedBytes:ByteArray;

    public var pitchShiftFactor:Number;     
    public var position:Number;
    public var AddSound:Boolean = false;
    public var incremental:Number;
    public var left1:Number;
    public var left2:Number;
    public var right1:Number;
    public var right2:Number;
    public var mixedBytes1:Number;
    public var mixedBytes2:Number;


    public function SoundFx() {         

    }

    public function playFx(srcSound:Sound):void{

    this.srcSound = srcSound;
        position = 0;

    var morphedSound:Sound = new Sound();
        morphedSound.addEventListener(SampleDataEvent.SAMPLE_DATA, sampleDataHandler);

        soundChannel = morphedSound.play();

    }

    public function addSound(sound1:Sound , sound2:Sound):void{

    this.sound1 = sound1;
    this.sound2 = sound2;


        sound1.addEventListener(SampleDataEvent.SAMPLE_DATA, addSampleData);
        position = 0;

        soundChannel = sound1.play();
        soundChannel = sound2.play();

        AddSound = true;

        }

    private function addSampleData(event:SampleDataEvent):void{

        position = 0;

    var incbytes:ByteArray = new ByteArray();
        position += sound1.extract(incbytes, 4096, position);

    var bytes:ByteArray = new ByteArray();
        position += sound2.extract(bytes, 4096, position);

        event.data.writeBytes(mixBytes(bytes, incbytes));


    }

    private function sampleDataHandler(event:SampleDataEvent):void
    {           

    var bytes:ByteArray = new ByteArray();
        position += srcSound.extract(bytes, 4096, position);

        event.data.writeBytes(editBytes(bytes));

    }

    private function mixBytes(bytes1:ByteArray , bytes2:ByteArray ):ByteArray{

        bytes.position = 0;
        incbytes.position = 0;

        var returnBytes:ByteArray = new ByteArray();


        while(bytes1.bytesAvailable > 0)
        {

        left1 = bytes1.readFloat();
        left2 = bytes2.readFloat();

        right1 =  bytes1.readFloat(); 
        right2 =  bytes2.readFloat(); 

        mixedBytes1 = left1 + left2;
        mixedBytes2 = right1 + right1;

        mixedBytes.writeFloat(mixedBytes1);
        mixedBytes.writeFloat(mixedBytes2);

        }

        return mixedBytes;

        }

    private function editBytes(bytes:ByteArray):ByteArray{

        //var skipCount:Number = 0;
        var returnBytes:ByteArray = new ByteArray();
        bytes.position = 0;


        while(bytes.bytesAvailable > 0)
        {
            //skipCount++;


                returnBytes.writeFloat(bytes.readFloat());
                returnBytes.writeFloat(bytes.readFloat());

            }

        return returnBytes;
    }



}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:42:55+00:00Added an answer on June 13, 2026 at 6:42 pm

    i think i get your idea,hope i did.

    You should try to pass all of your SoundChannel classes (sound layers being added) to a SoundMixer class (there is plenty of info on this in adobe site),like a funnel,and then add a SAMPLEDATA event listener to that soundmixer, and capture the byte array of that sound mixer,it is like getting the byte array of the final mixdown…then encode those bytes to wav or mp3 .
    Sorry i can not write that code down for you,i am not very good with the code yet, but im good at mixing sounds.

    Here is an example form adobe site itself:

        function loaded(event:Event):void
    {
        outputSnd.addEventListener(SampleDataEvent.SAMPLE_DATA, processSound);
        outputSnd.play();
    }
    

    Useful link:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html

    soundmixer class link:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/SoundMixer.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.