Making a multi-track recorder in Flash part 2

Get Adobe Flash player

On Tuesday night I did a last minute ad hoc presentation to FlashBrighton to share the experiments I’ve done with the microphone capabilities of FlashPlayer 10.1. You should be able to see the recording at (if it’s not there, bear with us while we try to get it working). Click “media” to see the available videos.

I had a lot of fun and there were actually 85 people watching the live stream and heckling me (including Lee Brimelow and John “Flash on the Beach” Davey), which I really enjoyed, despite my feigned irritation. 🙂

I explained exactly how audio works, what it means when we see a wave form, and how that gets turned into audio that we can hear. And then I showed that a waveform gets all jumbled up when you mix sounds, but our brain can still separate it all.

Then I showed how simple it was to make a sine wave tuned to concert A, 440 Hz. And then we mixed in the C above it to make a two note chord. Here’s the code for that :
Continue reading “Making a multi-track recorder in Flash part 2”

Making a multi-track recorder in Flash

Toy recorder

Toy recorderOriginal Photo : PhotoCapy

I’ve been playing with the Flash microphone input to record and playback multiple tracks. I thought it’d be really easy, but sadly it’s been really really tricky. The main problem is to do with knowing exactly when data from the microphone was recorded, particularly relative to when some audio was played!

I could write a lengthy blog post about it, but instead, I’ll just be presenting my findings, along with source code, at FlashBrighton tonight. If you’re not in Brighton you can watch at Sorry for the short notice, I’m covering for someone who had to pull out at the last minute.

It should be recorded but I’m not sure how quickly we’ll be able to post it so I’d recommend you watch it live if you can. It starts at 7.15pm GMT.

ActionScript SoundDataEvent.position

… is measured in samples. Not bytes or mils.

So if you want to know how it relates to the ByteArray you’re working with, you need to multiply it by 4 (as each floating point sample requires 4 bytes). And if you want to convert it to mils, you need to divide by 44.1, the number of samples per millisecond.

I just thought I’d point it out because it doesn’t seem to be mentioned in the AS3 docs. Or the Flex docs. I checked this time 🙂

I expect you’re wondering why I’m discovering all this stuff. Watch this space 🙂

ActionScript SoundChannel.position

… is measured in milliseconds.

Why do I mention this? Because it seems to have been entirely omitted from the ActionScript live docs and it took me a while to figure it out. Maybe this post will save someone some time in the future. 🙂

[UPDATE] I just noticed that this is actually specified in the latest Flex 3.5 language reference, but not in the ActionScript reference. I guess it would be boring if it were too easy, huh?