blog.omine.net

Posts tagged with “actionscript”


Pixel Bender audio visualization

October 25th, 2009

This simple audio visualization is based on a combination of pixel shader effects (2D lookup table deformation with sine and cosine functions) and BitmapData effects (accumulation effect, additive blending, blur filter).

Instead of running a “real” audio analysis with SoundMixer.computeSpectrum, I just measured the sound’s intensity level with SoundChannel.leftPeak and SoundChannel.rightPeak.

The SWF file was compiled with Flex SDK 3.3 and weighs 3.985 bytes (PBJ data included).

Music: “A” by Turzi.

Flash Player 10 Cover Flow

May 17th, 2008

A beta version of Flash Player 10 (codename Astro) was released this week, along with a new build of the free Flex SDK 3 that allows developers to test the new Flash Player capabilities.

The following demo is a simple implementation of Cover Flow that takes advantage of the 2.5D API — all DisplayObjects now have x, y, and z properties (position, rotation, scale).

Use the arrow keys to navigate:


I developed a Cover Flow clone with Papervision3D 1.5 for the Quatro Arquitetura website a few months ago, and adapting it to the new FP10 API was really easy. Download the source code. You’ll also need Tweener.

PV3D sound visualization

April 21st, 2008

Playing with computeSpectrum() and PV3D 2.0 alpha (Great White). The mesh reacts to sound by having its vertices moved along the Z axis (X and Y coordinates are fixed). Had a problem with FlatShadeMaterial failing to render on regions of coplanar faces; small creases were made in the mesh to fix it.

Sound analysis was made with SoundMixer.computeSpectrum(), FFTMode set to true (a frequency spectrum results in a more interesting visualization) and stretchFactor set to 4. Increasing the stretchFactor value means analyzing a smaller frequency range of the sound —thus ignoring non-audible high frequencies. The 16×16 vertex grid represents the average values of left and right channels.

Music Is Music As Devices Are Kisses Is Everything (5:20) by 65daysofstatic (from the 2007 album The Destruction Of Small Ideas) is the song; a nice fit for this visualization because of the contrasting quiet and loud parts —the visualization of the piano notes in the quiet sections is very clear.

View SWF (5MB, move mouse on X direction to change rotation, music plays 10 times)

Update: comments closed because of spam.

Update #2: this experiment was featured on PV3D blog — 9 Cool Experiments in 3D.

PV3D ribbons

April 13th, 2008

This week I worked on converting last week’s Particles and trails code to 3 dimensions, using the Effects branch of Papervision3D.

The final SWF runs smoothly at 30fps on my computer, and initially uses about 5MB of memory as measured by System.totalMemory. The biggest challenge in this project was fixing a memory leak that occurred whenever a ribbon was removed from the scene. If you run into this problem when removing a DisplayObject3D, remember to:

public function destroy():void
{
    geometry.faces = [];
    geometry.vertices = [];
    material.unregisterObject(this);
}

Each ribbon has 3 life phases:

  1. Growth: the ribbon grows until it reaches 120 vertices;
  2. Stability: the ribbon keeps moving but older faces and vertices are removed, keeping vertex count equal to 120;
  3. Removal: the ribbon stops moving and 2 vertices and 2 faces are removed frame by frame until it reaches zero vertices and zero faces.

The applied material is a simple FlatShadeMaterial with a moving light source. Finally, a BitmapLayerEffect with BlurFilter was applied and the viewport.blendMode was set to BlendMode.ADD.

View animation (move mouse to change camera rotation)

Particles and trails

April 6th, 2008

This is a remake of one of the first programmatic animations I did with Flash (AS2 at that time). I decided to translate it to AS3, looking for a better performance.

The pseudo swarm behaviour of the particles is obtained by combining the movement of the visible particles with the movement of a non-visible, reference particle.

Interestingly, the animation performed much better when I unified all Event.ENTER_FRAME handlers in one single place. Originally I made each particle and each trail listen to Event.ENTER_FRAME, removing the event listeners when destroying the particle. Now I only listen to Event.ENTER_FRAME in the Main class, and then loop through all instances to call each instance’s update() method.

The background color changes with time; one cycle should take 1 minute to complete. You can also click the background to toggle full screen mode.

View SWF