Skip to content

Posts from the ‘Processing’ Category

23
Feb

Audio Spectrum Analysis – Output to JSON File – Flash Tool

I have been unsuccessful so far in syncing animation drawn in Canvas using Processing js & audio played using the browser Audio tag with audio spectrum data I create from a ByteArray in Flash. It works in Flash due to the fact that the spectrum analysis and animation are executed together in an onEnterFrame event. The drawback to not having real time audio spectrum analysis from within the browser is the need to supply all the data to Processing js at initialization. It can be rather large and I have yet to perfect syncing the reading of the array with the current time of the audio. Some sort of progressive data stream and excellent timing system???

It may be I just have to wait until this feature is implemented into browsers. In the meantime, I thought I would post the source for the the Spectrum Analysis tool for greater minds than myself, wanting a quick way to get some data from their favorite tune and perhaps figure out a way to use it in a optimized fashion.

it’s very simple and outputs JSON with Left and Right channels to floating point numbers between 0 and 1. You can use it to make stuff move to the groove. It has a simple execution of this in the ui for you to see. Download the flash and php and throw it on your local server.

The process of accessing audio data from within the browser is quite beyond me, I really just want to see what I can create visually in Processing js and Canvas. Until it’s and easy to use API, I just have to keep looking for a way to get spectrum data quickly, hence this contraption. Have fun.
Download Source

This demo does not actually write the data for fear of abuse, but this is a sample of the output.

Get Adobe Flash player

P.S. Carving Powder mp3 is one of my own creations. :)

Related Posts:

19
Feb

Processing js, making svg fonts and your server setup.

I had some trouble getting fonts to work in Processing and then more trouble when I posted the files to my Blog. I finally got it all working so this might save you some time.

Stuff you need:

  • A True Type font, e.g Arial.ttf
  • Batik TTF to SVG Convertor
  • Possibly need access to either your servers httpd.conf or mime.types for .svg mime-type

If you have all this, you are going to get it working. :)
First off, put the ttf font you want to convert in the directory where you extracted Batik & pull up a terminal and cd to it.
Type: java -jar ttf2svg.jar myFont.ttf -o myFont.svg
Replacing the myFont with your font. The result should be myFont.svg, great!!!. Copy it to your working Processing dir.

In your Processing setup function add the lines:
font = loadFont
var myFont = loadFont("myFont.svg");
textFont(myFont, 12);

Test it and see if you like it, if not repeat the process with another font. Go ahead and upload to your server and test live.
Looks good, ? yes : no;

For a quick test to see if your server supports svg head over to http://web-sniffer.net/ and type the path to your svg font in the box and hit submit. On return, look down to the HTTP Response Header table and look @ the content-type. If it says anything other than image/svg+xml or at least something with svg in it, you need to do this next step.

This is the part that got me and where you need access to the server config files I listed above. If you do not, you need to contact your sys admin or service provider and tell them you need support for svg files. If you do, edit either the httpd.conf or mime.types file “depends on your server setup” and add the line:

AddType image/svg+xml .svg
or
Content-Type: image/svg+xml
again it depends on what flavor of Apache or whatever you have. You can Google your setup and find out.

Restart your server and you should be good to go. Happy Processing!

Related Posts:

19
Feb

Processing js Twitter search visualizer

I jumped over from Raphael back to Processing again today. I have said it before, us Flash guys might get frustrated trying to pull off some simple stuff in either Processing or Raphael. Just keep in mind that they are young languages and the future looks bright.

Anyway, another attempt to do something here with Processing. It took a me minute to find an elegant way to get Twitter json data into processing without being too sloppy. The visualizer works perfectly in Safari and Chrome but it’s completely hosed in Firefox? Demo Here

Processing JS Twitter Visualizer

Processing JS Twitter Visualizer

Related Posts:

3
Jan

HTML Canvas & Processing JS

I have been experimenting with the new HTML 5 Canvas and trying to get up to speed on the syntax. As a seasoned Actionscript 3 developer, I find JS easy to understand but difficult to write. I find myself thinking flash and trying to work a flash approach. Anyhow, I have tried canvas with js and canvas with Raphael and now canvas Processing JS.

They all have advantages and drawbacks. Processing js is giving me the most fun for now and I can’t wait till they finish implementing the entire set of methods, or at least what’s left that can be implemented into canvas.

I have read some eager articles saying that this can replace Flash and will be the end of flash. This may be so at some point in the future, but I can tell ya right now, it’s not even close. With no dedicated VM it craps out if you try anything with a couple hundred worthy sprites on screen. Also, objects are painted onto the canvas and no longer exist as objects you can have a pointer to. You basically have to paint the the canvas each time with your updates, example: Processing uses pushMatrix() and popMatrix() to store and restore stage translations. This is pissing me off and I am still trying to get my head around it. I just want to move stuff around dang it. On the other hand, when you paint, you can have an infinite amount of detail without worrying about overhead, like when you pipe MC’s into Bitmap object in Flash.

It’s all good though and a step in the right direction as far as I am concerned. No plugins, no 3rd party expensive IDE’s etc. It’s all free range and organic, yay. Can’t wait to start working in some div’s, copy etc and growing the graphics and UI for html pages.

As with all things animation and drawing, I like to start off with basic math and growing plants, trees, etc. Processing has no real shading, 3d or drop shadowing built in right now and it’s kind of refreshing going back to the old way of thinking where you have to fake it all.

Here is a screen shot of some alien plant thing I am writing. It takes about 20 mins to draw the entire 360 view. The depth and dimension is all fake like I said, drawing all the highlights, shadows etc in separate passes with slight offsets. Demo of my first processing attempt here.

Rendering Plants with Processing JS

Rendering Plants with Processing JS

Related Posts: