Some details about my MAX session

Because I was a bit late with submitting details about my talk at MAX in Barcelona i`ll do some advertisement here :-)
I will show some examples (RichFLV, RichMP3, WaveMixer), some theoretical background (bitwise operators…), talk about IDataInput/IDataOutput classes and walk through a full example of how to analyze an flv and extract the sound data out of it as an mp3.
The main motivation to give this presentation is that I`m still fascinated how powerfull this stuff is. I`ve always been a Flash/Flex developer and therefore have never worked with really low-level stuff.
When i realized how much power you gain if you learn a bit of this dry stuff I knew it is worth the effort. So if you`re like me – an actionscript developer that until now never really had the need to learn the basics about bits and bytes come and join my talk on monday 10am-11am. Also I`m really nervous about speaking at MAX I put a lot of effort into this talk and want to have a full house ๐Ÿ˜‰

I think MAX will really rock and i`m looking forward meeting all my heroes, especially Ty Lettau who in my opinion is the first real RIA designer out there. Be sure to catch his talks!

Richapps@MAX: What do you want to know about ByteArrays?

It`s official now! I will have a session at MAX in Barcelona. The session will be called “Bits and Bytes with AIR”.
I have a basic outline for my talk finished. It will be an introduction targeted at the intermediate Flash/Flex/AIR developer for whom the ByteArray class is still a mystery and who wants to find out more about its use. Part of the talk will be about the very basics (bits and bytes) and the other part will be a more practical one where I show how you can put this knowledge to good use ( Analyzing and manipulating Mp3, Wave, SWF and FLV files). ย I want to take one example and explain it in more detail. I thought of showing how to analyze an FLV file and extract the sound as an mp3 or how to mix two wave files.
So it would be cool if you would leave a comment what you`d like to get explained. This is your chance to make this a valuable session for everyone. Go ahead leave a comment or write me a mail to: benz (at) richapps.de

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.

Load and Play .wav files at rumtime with AS 3.0 (source included)

This is a follow up to my previous post about mixing wav files with Actionscript. I couldn`t sleep tonight so I have hacked together some classes that make it easy to load and play wave files at runtime with Actionscript 3.0.
You know that it`s not natively possible to load and play wave files at runtime. The trick is to load the wave file as a ByteArray (e.g. with Loader, FileStream, URLStream…) and than construct a swf file in memory that has the wave bytes embedded. First i created a swf file in memory that has the wave sound embeded and played it back with a StartStream-Tag. I did not liked that method because it does not give you good control over the playback of your sound. So the solution was to create a SWF file that defines a sound that is linked to a class so you can access the Sound Object directly. For those interested in details here is how the SWF file that i create in memory looks like:

structure.jpg

Here is a overview of the classes you need if you want to load a wave at runtime:

classes.jpg

What the WaveMix class is for will be revealed in the next post :-)
In order to load a wave sound these are the basic steps:
// Create a new Wave Reader
waveReader = new WaveReader();
waveReader.read(bytes);

// Create a wave SWF
var waveSwf:WaveSWF = new WaveSWF(waveReader);
waveSwf.addEventListener(Event.COMPLETE, onWaveReady);

private function onWaveReady(evt:Event):void{
sound = WaveSWF(evt.target).sound;
channel = sound.play(0,0);
}

Now you can use all methods of the Sound Object to work with your sound.

All this is still a bit buggy (all hacked together this night :-). So use it at your own risk.

I`ve prepared a little example in AIR that let`s you load a wave sound. The Wave has to be a PCM encoded (uncompressed) wave file.
Download AIR Example
Download Flex Project (Source)
Let me know what you think ๐Ÿ˜‰
This was a pretty long night :-) so in the next post i`ll add something to this (reading waveforms + mixing sounds)
Benz

Mix Wave files with Actionscript! (with source)

Today Alan Queen pointed me to his AIR application that allows to mix wave samples. It`s a really nice AIR application but what was the most remarkable thing is that it actually mixes samples and outputs a new wave file. That`s what i always (and still ;-)) dream to do with RichFLV but reencoding FLVs and Mp3 files with actionscript may not be possible because of the complex algorithms used for compression. But still i had to find out how it`s possible with Wave files. The trick is that the wave files have to be in PCM format. PCM is a periodical measure of acoustic pressure at regular intervals and thats why it`s possible to easily modify samples of PCM data with simplest math lik addition :-) In order to mix two samples you just sum up the values of the two samples. Crazy easy!
So here is a quick and really dirty test:

waveMix.gif

This AIR app mixes two wave files. The wave files should have the same sample rate and have to use PCM encoding. I did not test it really well and stopped working on it when i got some results so this might not work with all waves. Yeah it`s pretty ugly (codewise) but i think i will not put more time into this so i thought i share this information and my code. I was also able to do some other modifications like modifiying the volume and stuff like that.

Get the AIR app: WaveReader.air
Get the Flex Project (source): WaveReader.zip

Now I go back to my super cool AIR project I`m working on ( to be released in december 08 07 ;-)) . And I`ve also started to work on RichFLV Version 2! Yeah i skip version1.0 and go directly to 2.0. In this version you`ll be able to import multiple FLV and Mp3 files and merge them together with all the export and editing functionality of version 1. Ah yeah and i`ve not forgotten my article series :-) I`ll continue that soon – hopefully.

RichFLV/AIR and MP4

With the annoucement of support for h.264 and AAC in the flash player i feel a bit challenged to add support for this in RichFLV too.
I don`t know if it`s even possible to get acceptable results but that`s what i thought with flv first too. As a start i wrote a little program with
AIR that analyses MP4 files and traces out all the atoms it finds with path, position, size and container info.

You can download it here.

I`m still learning about the mp4 format. If anyone has good ressources, especially how to extract video frames…
The best ressource i found till now is the quicktime description from apple.

Man these are exiting times. H 264 support in flash player – what else could you ask for. Well i can think of a lot of things but i`m afraid the moment i write it down there is another labs release ๐Ÿ˜‰

mp4analyser.gif

Adobe AIR Camp source files

Iยดm back from the Adobe AIR Camp in Dinant (Belgium). It was a really cool event with extremely interested and motivated people.
It was nice to see how quick people were able to build applications even if they had never used AIR before.
Cudos to Serge Jespers from Adobe Beneluxe (The Mike Chambers of Europe ;-)) for putting so much effort into organizing a perfect event – and for inviting me.

If you`re interested you can get the source files of my talk here and the PDF here.
I`ve uploaded some photos to flickr. See them here.

Speaking @ AIR Summer Camp in Belgium

This week i will attend an AIR Summer Camp in belgium.
I will talk about Bits And Bytes with AIR and give some insights to RichFLV and RichMp3.
I`m a bit nervous but also flattered to see my name on an official Adobe document ๐Ÿ˜‰
I`ve prepared a lot of samples and plan to post them along with my presentation later this week.
The Adobe Beneluxe Team seems to do quite a good job in promoting AIR wonder why it`s so quite here in germany ?
adobeSummerCampInvitation.jpg