Barelyfocusedhttp://barelyfocused.net/blog
360 degree peripheral vision.Sun, 20 Dec 2009 10:11:40 +0000http://wordpress.org/?v=2.0.7enFlash Vorbis playerhttp://barelyfocused.net/blog/2008/10/03/flash-vorbis-player/
http://barelyfocused.net/blog/2008/10/03/flash-vorbis-player/#commentsFri, 03 Oct 2008 03:23:31 +0000ArekDevelopmentXiphhttp://barelyfocused.net/blog/2008/10/03/flash-vorbis-player/Yes, it’s been quite some time since I last posted. And yes, it’s been even longer since I promised something here, and still haven’t delivered. And no, there will be no excuses.

Instead, how about I share one thing with you…

The name is: FVorbis. Which stands for more or less “Ogg and Vorbis in Flash”. That’s right, pure ActionScript 3 implementation of the Ogg and Vorbis libraries that require no kind of native support from the Flash Player. A simple Vorbis player implemented using the new FVorbis lib compiles to about 46KB SWF file. And that’s it.

The source is actually written in haXe, not ActionScript, but the haXe compiler is able to produce proper AVM2 bytecode and put it into an SWF file that can be used with Flash Player all the same. Plus, using haXe has its numerous advantages.

The implementation relies on some new features that appeared in Flash Player version 10 (of which beta/RCs are available already for the most common platforms). That includes the new flash.Vector type and ability to generate sound programmatically.

For a very rough performance estimation: a ~50 seconds Vorbis file decodes completely in about 3-4 seconds at full speed of a single CPU core on my machine. In a player designed to decode at minimum speed allowing it to keep audio device playing continuous stream the CPU usage is at 5-15% of a single core. The machine is Core 2 Duo 2.6 GHz.

The haXe/Flash implementation of the Ogg and Vorbis libraries has been initially auto-translated from the Cortado’s JOrbis code, followed by several-thousand-lines patch transformation and manual type and system library call changes and adjustments. Followed by further fixing of imperfections of the automated translation and tedious hunting of a bug in haXe compiler. The patches for haXe compiler - adding support of the flash.Vector, SampleDataEvent, and forced tagging of generated swf files with version 10 - are included in the fogg.dev branch. In case you would like to play with the libraries yourself…

At this point great many thanks need to go to the whole Xiph.Org team for Vorbis and more, to the Fluendo group for Cortado and a hacking environment, to the author of the JOrbis for java implementation and to Tor-Einar Jarnbjo for inspiration.