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.
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);
March 21, 2009 at 3:46 am
· Filed under AIR, AS3, source
I just found out something cool using URLRequestHeaders in AIR.
Using the “Range” header, you can download specific part of a file.
var urlLoader:URLLoader = new URLLoader();
var urlRequest:URLRequest = new URLRequest("http://upload.wikimedia.org/wikipedia/commons/f/f2/Fanciful_Landscape-1834-Thomas_Doughty.jpg");
urlRequest.method = "GET";
urlRequest.requestHeaders = [new URLRequestHeader("Range", "bytes=0-99")];
urlLoader.addEventListener(Event.COMPLETE, loaded);
urlLoader.load(urlRequest);
function loaded(e:Event):void{
trace(e.currentTarget.data);
}
In this example above, it will load just the first 100 bytes of the file.
I don’t know if there is other ways to do it, but, at least it worked fine for me.
With this, you can manage downloads for huge files pausing and resuming not loosing datas.
Like, if the internet connection breaks while you are downloading something, you can simply resume after the internet connection comes back.
It’s a small class br.hellokeita.utils.MathUtils.
Inside, there are few methods: combination, factorial, solveCramer and squareMatrixDeterminant.
I think method name tells what it does, so please check it out and comment about it.
Basically, the curveTo method uses a quadratic bézier, so you need a control point and a anchor point.
But it’s difficult to find the precise control point for a curve you want, because the control point is not inside the curve.
Also, you just can create a curve with just one control point, or if you want to use many curveTo methods in sequence, sometimes the curve doesn’t became as straight as you want.
So, I created a class that calculates the control points with multiple values bézier.
You can also get the position in this curve.
Here goes the examples. (you can click and drag the points)
This is an example using 7 positions, the start and the end anchors and 5 control points.
In the class, there’s a method that returns me an array with the approximated quadratic bézier values, so I’m using this values to draw the green line.
You see that it still hard to draw a path that you want.
This is the same example, but now the positions are inset in the curve.
Now, it became easier to create a curve line.
And here, a animation over the curve.
Sorry for lack of explanation, actually I’m in vacation now, but I wanted to post this class.
Later I’ll try to post more examples and uses.
I will try to update my svn with these classes, commented, after I came back from vacation.
So, for now, here is the source code.
December 17, 2008 at 3:44 am
· Filed under AS3, BitmapData
Hi, long time that I don’t post here…
I’ve been helping Romu here at work where he was trying to use a JPG instead of a PNG with alpha channel.
Why he was trying to do that?
Firstly he was using PNGs but each image was around 600 kb. So he was trying somehow remove the white background from those images because saving as JPG it’s less than 60kb.
It’s not a perfect background remover, but it works with the website he’s developing.
I don’t know if there are easier or more accurate chroma-key like background removing techniques, but… here is my workaround.
The images is not from the website… it’s a Brazilian cartoon called ‘A Turma da Mônica’
Sources?
Not yet… I’m busy right now but I’ll try to explain how I did it.
1. Using ColorMatrixFilter, I converted each RGB channel to the alpha channel.
2. Using BitmapData.threshold, converted every pixel with alpha bigger than 0 to black.
3. Applyed a Blur.
4. Mask the original Bitmap using cacheAsBitmap = true;