My first useful Apollo app…

This is for a project I am working on and it works pretty sweet. There were a few lessons learnt during the development of the app so I thought I would write a post on it in the spirit of the rest of the world learning from my mistakes ;). The project (that I cant tell you about yet) required a bunch of songs represented by their spectral-waveforms. I tried to find an application that would generate them for me easily but I couldnt really find a simple one. There are some applications that do it but they have so many controls that I couldnt figure out how to do it really quick. I still had source code from my FlexAmp application lying around so I figured, what the heck, I’ll just write a small application to do it. The result was the SpectrumGrapher application.

The concept is pretty simple:
1) Browse to a song on your filesystem.
2) Select it and it begins playing as well as using the computeSpectrum method to draw the graph (using a function that uses the drawing api thats called by a timer)
3) Click on the ‘Snapshot’ button to take a snapshot of the drawing (using the bitmap information of the UIComponent and the Bitmap to png class in the Adobe corelib)
4) Write the png file to the filesystem with a name like [song]_waveform.png

Screen shots (click for larger image)

Choose File
Choose File

Drawing Spectrum

Drawing the Spectrum

Final Waveform png
The output waveform (as saved to the desktop)

The problem I faced was after about 6-10 seconds of playback, my cpu would start spiking since I had too many vectors on the stage. The solution was a modified version of Grant Skinner’s ‘copy vector into bitmap and clear the vector’ approach. I put another timer that fired an event every 5 seconds to do that. The result: I tried a song that lasted almost 8 minutes and no issues (yeah Dream Theater songs are loooooong…but cool 😉 ). The other thing I just discovered was that using a filetype filter to control enabling/disabling the select button on the browse window doesnt seem to work on the mac ( I am a mac newbie and did this development on my PC). The more interesting output of this project was the file chooser dialog box which I had to write since the apollo alpha release doesnt give access to the native file chooser control (although I have seen it on the beta build demo). Maybe I’ll release that part of the code sometime soon.

Let me know what you think 🙂

Author: Arpit Mathur

Arpit Mathur is a Principal Software Engineer at Comcast Labs where he is currently working on Virtual and Augmented Reality as well as investigating Blockchains and the decentralized internet.

2 thoughts on “My first useful Apollo app…”

  1. Neato. Can’t wait to see the code. But I think you might have a misnomer here. It looks like what you have is a Waveform display rather than a spectrum display.

    Dig it:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s