bytearray

Just for a short overview,

I sometimes play drum and bass on parties. To improve the audience experience, I use flash to visualize the digital culture I’m living. For this, I wrote some applications in flash and air. These apps are more experiments to find out how my sound can influence visual media to generate a special atmosphere.

Sometimes some people notice what I am doing or know what is happening. Therefore, questions came up and it is difficult to have a productive conversation at a party….

So why flash?

I think the main reason was that I wanted to experiment with Flash and later on with the new features of the player 10.

So let us get started.

The first step to reach the stuff I had in mind was to grab the audio signal. I have a line-in, so let us take a look what possibilities I have in flash to use this. I found the flash.media package providing some classes to access the microphone and the sound spectrum. I found out that it was not really easy to get apply the computeSpectrum method on the microphone. So I thought. O.K. I’ll code a Java app that catches the audio signal, computes spectrum and send this data as bytearray to flash. However, this was not very cool, even having some java code, I could re use and I wanted to stay with flash.

I explored the possibilities and none of them were easy and latency efficient for my purposes. I really needed some time to find the solution and it was sooo simple !

Setup a streaming Server on your computer. My choice after some tests was Icecast2 here is a sample of my config:

 xml |  copy |? 
01
02

03
	
04
        	2
05
 0
06
 1
07
 0 
08
    
09
    
10
        hackme
11
        hackme
12
        admin
13
        hackme
14
    
15
16
    localhost
17
	
18
6666
19
    
20
    1
21

22
        ./logs
23
        ./web
24
        ./admin
25
        
26
    
27
    
28
        access.log
29
        error.log
30
      	3 
31

Setup a streaming client on your computer like Edcast and choose the right audio in.

When you get this programs running you will have a streaming server running under the following URL:

http://localhost:6666/stream

or if you are using shoutcast :

….. /;stream.nsv

So now, you can catch this audio stream from your flash app like this:

 actionscript |  copy |? 
1
2
this._sfx = new Sound();
3
var req:URLRequest = new URLRequest("http://localhost:6666/stream");// /;stream.nsv
4
var context:SoundLoaderContext = new SoundLoaderContext(0, false);
5
this._sfx.load(req, context);
6
this._channel = this._sfx.play();
7
SoundMixer.bufferTime=0;  // works for me locally
8

Now you can get the spectrum over an onEnterFrame Event with SoundMixer.computeSpectrum. I am going to explain this in part II

http://privatefunction.net/wp-content/plugins/sociofluid/images/digg_32.png http://privatefunction.net/wp-content/plugins/sociofluid/images/delicious_32.png http://privatefunction.net/wp-content/plugins/sociofluid/images/technorati_32.png http://privatefunction.net/wp-content/plugins/sociofluid/images/google_32.png http://privatefunction.net/wp-content/plugins/sociofluid/images/facebook_32.png http://privatefunction.net/wp-content/plugins/sociofluid/images/mixx_32.png http://privatefunction.net/wp-content/plugins/sociofluid/images/twitter_32.png