Acoustic recording and playing back in Flash

date: 10 Jan, 2011, actionscript: 3.0, complexity: complexity level 4.5 of 5complexity level 4.5 of 5complexity level 4.5 of 5complexity level 4.5 of 5complexity level 4.5 of 5, feedback (votes): users score 5 of 5 (284 votes)users score 5 of 5 (284 votes)users score 5 of 5 (284 votes)users score 5 of 5 (284 votes)users score 5 of 5 (284 votes)

Here we are once again speaking about midi files and how to use them in flash through actionscript. In my previous article "from fruityloops to actionscript" where I am explaining deeply my approach of loading midi files and play them with a certain predefined samples set, I did mention that dealing with acoustics instruments could be a waste of time due to the complexity of waveforms and how we link them making transitions smoothly. What I meant is that all samples of an acoustic instrument recording rely each other and they have to be played in the same sequence order otherwise it sounds just broken. Well, that's true but it is not too bad at all and there are some things we can do with it.

Recording elements

One of the tricky parts of this was cutting the recordings in tiny small samples, so I can have control on them and manipulate important things like time (tempo) and audio pitch completely separated, and even more interesting, doing it per channel.

All it comes during the new years eve, I actually got an idea (among some whiskeys) of making a very simple equation that could give me a hand for positioning the tiny samples in the fruity loops time line (or any audio software time line) and then I allocate a midi channel for each instrument... It took me a while, it was completely a manual procedure (monkey job) but at the end it wasn't that bad, I didn't spend more than 2 hours on that. I actually made an excel file using the equation per every single sample (per instrument) and then I went through the whole fruity loops time line placing all the samples that excel told me, in the right position and assigning channels. Does it sounds complicated? nah! guys, it is actually very simple.

Here is the equation I used for generating the samples positioning once I cut the recordings:
SQR = 96 //sequencer resolution, ticks per square note
BT = ?? //how many beats (square notes) the whole recoding uses
TT = BT x SQR //total amount of ticks used in the sequencer for the whole recording
TS = ?? //total samples used in the whole recording based on 44100 per second
SPW = ?? //amount of samples per unique waveform
waveform_position = round(((SPW / TS) x TT ) mod SQR)

You can find out more on this excel file as an example, that was the one I used for generating the cavaquinho recording. Don't forget, each sequencer uses different kind of resolutions, in fruity loops you can adjust it by clicking in options > project general settings > Timebase (PPQ). I use it in 96, it is good enough for doing whatever you want.

FruityLoops Time Settings

http://www.youtube.com/watch?v=J4u2MmBsr5A

The Brazilian "Pagodinho" test 300KB

Guys, I love everything about music, plus I'm a very curious person, so every time I hear something that takes my attention I won't rest till learn and discover it all. I have been involved with music since I am 7 or 8 years old, unfortunately I never took the music to a professional level and make a living of it, I don't consider myself a musician but I am always looking forward and learning new things about it, music is the biggest hobby I have. I would like to say that one of the best challenges I got so far while playing around with music was... learning Brazilian Samba (Pagode), it is very interesting, it is complex, at the same time simple, it is elegant, it has a very unique character. I got the chance of living in Brazil for about 3 years, part of it was in Rio de Janeiro, where I met a crazy 3D designer who taught me how to play some Brazilian percussion instruments and together we used to play within a band in a crazy city towards Rio called "São Gonçalo", holly moments, amazing memories.

I have chosen record a Brazilian tune for this article for 2 main reasons, the first one is because of it is bloody tricky to handle all the percussion and acoustic recordings (probably the hardest rhythm ever, Samba) which it was a very good challenge, and the second reason is because of I am so happy that I am going to be soon on very long holidays in Brazil (I will stay longer than 2 months) and also I am going to be in Flash Camp Brasil 2011 which made it feel inspirited, Huuuuhuuuu galera, já to com a passagem comprada e com as malas prontas... to com muita vontade de conhecer o pessoal que mexe na plataforma flash aí no brasil, acho que vai ser bastante interesante, quem sabe agente poderia trabalhar junto no futuro, valeu! até...

Dude! put your headphones on a have a go with it, let me know what you think!

yeap, as usual, here is the source code (including all waveforms files separated)

Who's coming to Flash Camp Brazil 2011?

Flash Camp Brazil 2011

During the last year I've been so busy and I didn't have the chance of participating much on adobe events/conferences, I just been in some of them at the ending of the year, the ones I liked the most was Flash Camp London, also Flash on the beach (Brighton), and ahhhh! I almost forgot, I was constantly one of the chip leaders on the Adobe Poker Coder tables in London, I almost won the tournament, I still won a Flash Professional CS5, take a look on the top ten winners, my name is that list poker coder winners list, lol!

guys, that's all! any question just let me know, cheers!

date: 01 Mar 2011 - 17:36:09, published by ap
Which books would you recommend someone read before getting into making their own synthesizers in as3?
date: 03 Feb 2011 - 16:33:11, published by kratz
i think its crazy and i want know more about it i want to create a flash exe or swf that have one pitch sliver and bottons for loops can you help me
date: 27 Jan 2011 - 10:19:59, published by Lipão