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.

Comments

15 responses to “Reading Waveform and mixing Waves with AS 3.0 (source included)”

  1. Henry Schmieder Avatar
    Henry Schmieder

    That definitely kicks ass. Would it be possible to do a runtime mix of mp3 files ?

  2. mike Avatar

    will try it out have the same problem.

  3. Benjamin (Admin) Avatar
    Benjamin (Admin)

    @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 😉

  4. bwise Avatar
    bwise

    Do you know if just reading the waveform like this would be possible on an mp3?

  5. uli Avatar

    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

  6. Benjamin (Admin) Avatar
    Benjamin (Admin)

    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

  7. […] files in AS3 By svbhikha Reading Waveform and mixing Waves with AS 3.0 (source included) – Unfortunately, the site has been hacked, and all attachments are unavailable for the […]

  8. ankur Avatar
    ankur

    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

  9. Ramon Avatar
    Ramon

    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

  10. serene Avatar
    serene

    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

  11. IdeasMX Avatar

    Hi, 😛 Can you publish the link of the code and the air file please?

  12. indream Avatar

    can not open the link of source file and air file.
    thank you

  13. Davide Avatar
    Davide

    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

  14. learning Avatar
    learning

    the link still not fix? 🙁

    hope you can send me the source code 😀

    I would really appreciate it 🙂

  15. johnnyblaze Avatar
    johnnyblaze

    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 *