Archive for Flash 10
Gesture Source
So, here is the source for the Gesture Test I posted before.
http://labs.hellokeita.com/files/gesture/gesture.zip
As I said, it’s really simple, it’s not the best code but it gives you some ideas of how it’s made.
Inside the “tags” folder, I have three pngs for each shape (triangle, square and circle).
You draw the shape you want, I trim it, and compare to each png.
The comparisson is, get the drawn image, stretch it to the size of each png, and apply threshold. The BitmapData.threshold returns you an uint, the number of pixels that has been changed. With this number, divide it to the area of the png, and than, you choose the one that returns you tha smallest number.
and… that’s it. simple simple…
actually, it’s a technique used for some facial/object recognition softwares, but in a simplified way.
Gesture Test
Well, I went to the Flash On The Beach for the first time this year. Was really cool and inspiring.
The first night, I had some inspiration, nothing to deal to any of the presentations I saw, but just something that I wanted to test. I couldn’t upload it because I didn’t have internet at the hotel, and at the venue the firewall was blocking me to connect to my FTP.
So, what was my experiment this time?
Gesture!
I think it’s working quite nice for a code I took less than an hour to write. It was much easier than I thought.
Just click and try to draw a Triangle, Circle or Square.
[kml_flashembed fversion="10.0.0" movie="/files/gesture/gesture1.swf" targetclass="flashmovie" publishmethod="static" width="401" height="431"]
Enjoy!
I’ll post the source code later… let me take a nap now.
LFPUG Presentation and Sources
As promissed, here is the presentation I made at LFPUG in PDF format.
http://www.hellokeita.in/presentations/LFPUG/20090827/MakingMusicFP10.pdf
And the source files zipped with the demos I showed.
http://www.hellokeita.in/presentations/LFPUG/20090827/examples.zip
The contents are:
Example01-SineWaveExample: Simple example generating a sine wave
Example02-KeyboardExample: Example of a piano keyboard
Example03-WaveformExample: Changing the waveform of a sound
Example04-TimePitchExample: Changing pitch and tempo of a mp3
Example05-HeliumBalloon: Real time pitch shifting using Java
Enjoy!
UPDATE
LFPUG website uploaded the video of my presentation
http://www.lfpug.com/flash-10-making-music/
LFPUG Presentation Summary
Yesterday was my very first time presenting in English at LFPUG.
I was quite nervous but everything went really well.
Thanks Tink to letting me speak there.
Thank you for everyone that went there. The applause in the middle of the presentation cheered me up.
I really enjoyed speaking, and I hope there’s a next time.
I’ll prepare a PDF of the presentation I did together with the source code of the demos I showed and post it here.
Also, Tink should upload the recorded video of the presentation in few days on LFPUG website http://www.lfpug.com
LFPUG Presentation
Tomorrow Aug 27th, I’ll be presenting at LFPUG (London Flash Platform User Group) about dynamic sound in Flash 10.
Feel free to pop-up there, it’s for free.
Here is the link:
http://www.lfpug.com/27th-august-2009-27082009/
Signing up, you’ll have a chance to get a Flash On The Beach ticket!
Time: 19:00 – 23:00 (doors open at 18:30)
Venue: CosmoBar, 50-54 Clerkenwell Road, EC1M 5PS (click for map)
Tube: Barbican/Farringdon
Fake Pitch Shifting
Pitch shifting is the method to change the frequency or the height of a sound.
And why it’s fake? Because, I’m really not using the correct algorithm, actually I just made one for demo purpose. If you listen carefully, you can hear some clippings when you change the slider position.
There is a difference between my previous post about pitch Controlling Pitch and Tempo.
The previous one I was using a dynamically generated sine wave and changing the pitch. It’s much easier because I already have the samples for each sound.
On this example I’m using an MP3 file (Daft Punk, please don’t sue me…If you want, I can change it) and changing the pitch on runtime.
Well it’s working, and as you can see no FPS loss.
[kml_flashembed fversion="10.0.0" movie="/files/pitchShifting/PitchShifting.swf" targetclass="flashmovie" publishmethod="static" width="400" height="300"]
The source… well, I’m preparing for my LFPUG presentation so, I’ll try to explain about it there, and than release some kind of source.
There is a post from my friend Li http://www.lidev.com.ar/?p=237 where he is using more accurate algorithm to change the pitch. There’s not much loss on quality and no clips.
Komposer alpha test release
I’m releasing this little interface for music composing.
http://www.hellokeita.in/komposer/
I tried to make as similar to a MIDI editing software.
Ok…, it’s really far to be similar… but I’m trying…
There’s somethings that I didn’t like in Flex so maybe I’ll start recreate all just with AS3.
Well, about the functionalities…
Click ‘Add track’ to add a new Track.
You can change the Edit, Remove or change the Volume.
The Mute and Solo functions are not working yet.
Clicking on Edit, will take you to a sequencer interface.
Double clicking on the Sequencer, you can add a new Note.
You can playback it, change the positions and durations.
Clicking on Close from the Sequencer, you get back to the main screen.
Here you can playback all the tracks together.
After all, you can save/load the composition to/from you local hard drive.
Enjoy, and give me some feedback please.
Controlling Pitch and Tempo
UPDATE: fixed the clicking noise correcting the zero-crossing, thanks to Caco Teixeira
Just another test now controlling the pitch and the tempo of the playback.
Source… soon, I’m re-writing the classes trying new approaches.
Creating music in AS3 Flash 10
Has been a while Flash 10 has been released and I never got really into the new sound capabilities.
So, here is a demo I made with the best game sound track ever.
Dragging the points in the graph will change the tone of the sound.
And of course, here is the source.
And a quick explanation about the code.
Komposer is the main class, who will playback the music.
Timbre is the class that defines the tone of the sound.
Track is a groups of notes that will play with the defined timbre. Currently it will only play one track.
Note is the class that defines the pitch(frequency) and the in/out of the sound.
var komposer:Komposer = new Komposer();
var timbre:Timbre = new Timbre();
timbre.addValue(0);
timbre.addValue(1);
timbre.addValue(-1);
timbre.addValue(0);
var track:Track = new Track(timbre);
track.addNote(new Note(Notes.toFrequency(Notes.C, Notes.OCTAVE_4), 0, 500));
track.addNote(new Note(Notes.toFrequency(Notes.D, Notes.OCTAVE_4), 500, 1000));
track.addNote(new Note(Notes.toFrequency(Notes.E, Notes.OCTAVE_4), 1000, 1500));
track.addNote(new Note(Notes.toFrequency(Notes.F, Notes.OCTAVE_4), 1500, 2000));
track.addNote(new Note(Notes.toFrequency(Notes.G, Notes.OCTAVE_4), 2000, 2500));
track.addNote(new Note(Notes.toFrequency(Notes.A, Notes.OCTAVE_5), 2500, 3000));
track.addNote(new Note(Notes.toFrequency(Notes.B, Notes.OCTAVE_5), 3000, 3500));
track.addNote(new Note(Notes.toFrequency(Notes.C, Notes.OCTAVE_5), 3500, 4000));
komposer.addTrack(track);
komposer.volume = 0.1;
komposer.play();
