Reading Waveform and mixing Waves with AS 3.0 (source included)

So here is part 2 (part1) of this nights sleepless hours product.
This is a little example of how to load multiple wave files and show the waveform of each wave file.

waveforms.jpg

You can also save a Mix of all files as one wav. This uses my new Wave Mix class which is super simple to use.
You have to pass it an Array of WaveReaders in the constructor like this:

var waveMix:WaveMix = new WaveMix(myWaveReaders);

Then you just call the mix() method of the WaveMix class and it return a ByteArray which is the new wave file.
You can now use this to save the bytes to the filesystem or send them to a server.
var waveBytes:ByteArray = waveMix.mix();

There are still some problems with wave files of different sample sizes. It works best if all files are 44500 Hz, 16Bit, Stereo wave files.
I`ll work on that :-)
I know it`s al a bit ugly unfinished code but it`s all from one night so bear with me.

Get The AIR file here.
and Code here.

Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on Pinterest

15 thoughts on “Reading Waveform and mixing Waves with AS 3.0 (source included)

  1. @Henry: This is currently propably not possible. The reason it`s possible with wave files is because they are uncompressed so you don`t have to do all the complex calculations to get the “real” sound bits. In theory it would be possible if you`d write a decoder/encoder for mp3 files in actionscript but it might be too much for the processor (speedwise) and definately too much for my brain 😉

  2. i am searching for days for a solution to be able to load and play wav files in air/flex. So my question is, is there a possibility to use this method to just play wav files? I checked your application but I could not make it running. Probably a version issue of my flex app.
    I would be soooo greatful to get any help !
    thanks in advance,
    uli

  3. Hi Uli,

    this is an old example that propably only works with AIR. I`ll try to make an updated example but at the moment i`ve no time for that. Are you compiling for Flash 10? Then you`ve one more option to play wav files. You can load wav and find the samples and just gived them to the sound object. This is much easier than my approach.
    Can not really help more right now but you might want to also take a look here: http://www.flexiblefactory.co.uk/flexible/ They have some pretty nice audio stuff on their site and i`m sure there is also somewhere a solution for playing waves hidden.
    Benz

  4. Pingback: Wave files in AS3 « Mix Table

  5. hey benz,
    i am working for quite sometime on flex now.Can you help me in a method to record audio locally withour using FMS.The microphone class does not allows us to do that as we do not have access to the bytes array in that..!!
    Any Help regarding this would be of great help.

    Secondly i thought of making a jar file for audio recorder but do i have any method in flex to embed that jar file in my action script project..!!

    plzz do reply.It would be of grat help!!
    thanks

  6. Hello Benjamin,

    i really want to see the sourcecode of the wavemixer.
    I need to write an application that creates 1 wav file from 1 music wav file and some other soundeffect wav files.
    Could you send me the code or give me a link?

    I would really appreciate it :-)

    greetings,

    Ramon

  7. Hi benjamin,

    Now i’m working about mixed sound on flex.
    And i want to see your sourcecode.
    Could you send me the code? plz.

    Thank you so much

  8. Hi i’m trying to download the code but it’s not working. Is it possible to download it somewhere? And the class?

    thanks in advance

  9. the link still not fix? :(

    hope you can send me the source code 😀

    I would really appreciate it :-)

  10. Is the source code permanently lost?

    or

    Is it possible to get it?

    I would be also very thankful.
    Thank you for any reply!

Leave a Reply

Your email address will not be published. Required fields are marked *