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 live.flashbrighton.org (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”
Original 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 live.flashbrighton.org. 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.
(previously titled : Flash Player bug? for each..in loops)
[UPDATE] Kudos and much thanks to Tim Knip who pointed out that it was in fact my mistake – there’s a stray semi-colon at the end of the line :
for each(byteArray in soundSources);
Which is of course ending the loop there and just running the code in braces after that once. I seem to keep accidentally typing semi-colons lately. Perhaps it’s the frustration of having to work with the sound API. 🙂
And of course the good news is that we can safely continue to use for each…in. Yay! Thank you everyone for helping me find this.
I’ve been pulling my hair out over the last few days trying to get a sound toy working, don’t you hate it when you feel like you’re fighting against Flash? Anyway, I think I’ve found a bug, I’m iterating through an array of ByteArrays using for each, but for some reason it will only give me the last ByteArray.
I’m sure this has been the source of several unexpected behaviours in my current project. Can you let me know if it happens in your FlashPlayer? I’m currently running the debug player version 10.1.51.82.
Here’s the swf :
[sorry, content no longer available]
And here’s what I see :
And here’s what I would expect to see :
You can see I’m iterating through the array twice, firstly with the iterator i and secondly with the for each directive.
And here’s the code :
Continue reading “Mind your semi-colons!”
… 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 🙂
… 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?
UPDATE – HTML 5 Canvas version now online
During my session at the Flash Gaming Summit, I showed a very simple 3D particle renderer to attempt to demystify the process of converting 3D into 2D.
Click and drag.
The actual code that converts from 3D to 2D is easy! First you have to figure out how much you have to resize things depending on how far away they are. (ie what their z position is).
Where f is a notional field of view. Changing this will change how wide the (virtual) camera is. A good starting point would be 250. Then you multiply the 3D x and y positions by the newscale to get their 2D x and y positions.
x2d = x3d * newscale;
y2d = y3d * newscale;
So that’s where we put our particle, in this case represented by a MovieClip that we also need to resize by our new scale :
clip.scaleX = clip.scaleY = newscale;
And then the final thing we need to do is sort by the z position so that particles in front appear above particles in the background.
particles.sortOn("z", Array.DESCENDING | Array.NUMERIC);
for(var i:int = 0; i< particles.length;i++)
particle = particles[i];
There’s some other stuff in there too, to create the depth of field blur and also the bitmap trails, but have a look and see what you can do with it.
Download the source code for simple 3D engine.
* I haven’t actually counted the number of lines. I’m guessing it’s about 10. 🙂
It was great to catch up with Pablo and the ActionScriptHero crew in Amsterdam, and we had a good chat about the future of Flash, the exciting changes in digital and what inspires me.
I’ve just finished my Brighton training courses which were seriously good fun, and everyone seemed to enjoy themselves, I’ve certainly got excellent feedback so far!
My next training course is short notice; it’ll be a Papervision course in San Francisco on the 9th March particularly aimed at 3D games. It’ll coincide with the Flash games summit so if you’re interested, let me know and I’ll make sure to get in touch with more information as I have it.
Then it’s on to Cologne for FFK in April, where I’m running both a Papervision3D course and a Flash games training course! More info on the FFK website.
And back to NYC for Flash and the City in May, and I’ll be running courses around the conference. Again, mail me if you’re interested and I’ll send you the details as they are announced.
And finally in FlashBelt in June, I’ll be teaching a one day Flash games workshop. Teaching you maths by stealth – who knew that you could learn trigonometry from Asteroids and vector maths from platform games? 🙂 It’s a fantastic conference and I’m really looking forward to coming back for my fourth year in a row!
Can’t make any of these events? Then help me organise one near you! Mail me.