Pages: [1]   Go Down
Author Topic: Light organ with software filter for different spectrums.  (Read 806 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone!

I'm pretty new with the whole arduino with some knowledge in C etc. I have a project that im working on with some friends. The basic thing is that we are bulding a microphone with some OP amps and getting the signal into the Arduino's Analogread and then make three different LEDs blink according to the base, the high notes and the middle register.

 Now i would like to run a main loop with an array of digital filtered spectrums, one for high tones, one for middle tones and one for base tones. In that main loop i would like to get an interupt lets say 10000 times a second to sample the music/sound that the microphone picks up. Then lets say every 0.1 seconds you take the new numbers of the array and send it to the LEDs to blink accordingly.

I mostly just need some help to get the starting structure of the program. I can do some mathlab tricks to get the digital filters right i think. And the thought behind the interupt was so that the sampling would be smooth and consistent.

Any input or thought would be greatly appriciated.
« Last Edit: April 10, 2013, 02:07:05 pm by Coding Badly » Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2573
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do not cross post same question.
You may find some projects educative, check on a link below.
Logged

Offline Offline
Edison Member
*
Karma: 33
Posts: 1290
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You might want to look at the MSGEQ7 chip.  It takes your audio signal, splits it into 7 bands, and gives you 7 (time mulitplexed) DC signals.   You don't have to use all 7 bands, or you could combine some of the bands in software.

Once you get it working...

One "trick" I use with lighting effects is to make them auto-calibrate to the signal level (over period of 1/2 minute or so).  That way, the effect responds well to quiet or loud songs, or when the volume is adjusted, and you never have to manually adjust the sensitivity of the lighting effect.   For example, you can make a simple effect where a light/LED comes on when the signal is louder than average, and off when it's less than average.   You get a lot of blinking/flashing action with the sound/music, no matter what.

With a color organ I'd auto-calibrate the frequency bands separately, so that a song that's light on the bass generates almost as much "action" in the bass channel as a bass-heavy song, etc.

I built a light organ (AKA color organ) in the 1970s (from a kit that didn't use a microcontroller).  IMO, the effect can get boring.  A couple of suggestions to make the effect more interesting...   Switch the channels around randomly so that different lights/colors respond to the different bands at different times.   Or if you are using LEDs, consider using RGB LEDs to change the colors around.
If you make a spectrum analyzer, you can randomly reverse it to put the bass on the right, or make it randomly run upside-down.

Since I got bored with the color-organ effect, I ended-up redesigning mine into a 4-channel random color/pattern effect that just pops-up a different pattern with the volume-beat.   I still have that  effect, and with colored floodlights it makes a good "main" or "background" lighting effect that runs full-time at my occasional DJ gigs.  (It's designed so that it's never "dark".... There's always at least one light on. )

----------------------------------------------------------------
Or, if you want some other lighing effect ideas...
The last lighting effect that I built (with the Arduino) has two channels (left & right) with 24 LEDs each and 7 different fucnctions/modes, such as a (giant 8-foot tall) VU meter effect that works as a normal bar-graph meter or as a moving-dot meter, and it can be reversed so that it works upside down, and/or inverted (so that the LEDs go off when they would normally go on).    There are other random chasing/sequencing/flickering/blinking modes with random patterns variations for each mode.  For example, there is a chase mode where it "moves" a number of steps in one direction and a different number of steps in the other direction with the speed controlled by volume.   And an option where the chase-direction changes with the beat, etc.   With all of the variations, it can run a long time before you see a function/option/pattern repeated. 

I don't have any effects that respond to frequency.... I've thought about a giant spectrum analyzer, but it woud require LOTS of wiring/soldering and it would be bulky.  And... I want to build stuff you don't see everyday.  Or, I've thought about making a matrix that could work as a spectrum analyzer or all kinds of other effects/patterns... But I think a 10x10 matrix wouldn't be enough, so again....  Too much wiring/soldering in a large matrix.

Now, I'm working on a super-simple effect that will basically toggle between two floodlights with the volume/beat.    Of course, I won't keep the software quite that simple, but it will remain a two-channel effect.   I consider this a "special effect" that could get boring quickly and the idea is that it will NOT run "all night".

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, Can you use that chip with an analog input? since i've built an audio detector with a microphone and some OP amps. And i would like to build it as i described with an AnalogInput with a timerinterupt to sample the frequencys. Or use that chip to sample Frequency
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Once you get it working...

One "trick" I use with lighting effects is to make them auto-calibrate to the signal level (over period of 1/2 minute or so).  That way, the effect responds well to quiet or loud songs, or when the volume is adjusted, and you never have to manually adjust the sensitivity of the lighting effect.   For example, you can make a simple effect where a light/LED comes on when the signal is louder than average, and off when it's less than average.   You get a lot of blinking/flashing action with the sound/music, no matter what.

With a color organ I'd auto-calibrate the frequency bands separately, so that a song that's light on the bass generates almost as much "action" in the bass channel as a bass-heavy song, etc.


Hi,
that sounds pretty much exactly like what I'm trying to accomplish. I have got my msgeq7 up and running and was trying to find a way to get the most dynamic range out of my LED flickering for whatever volume and music there is.  Searching for moving averages, maxima and minima i stumbled across your post.

As I want to drive up to 60 RGB-LEDs and also a second msgeq7 for stereo I dont't want to calculate the average, min, max as seen in the smoothing example, as it would require quite some memory and time for all the arrays.

I am currently using a running moving average (average=((x-1)*average+value)/x) for some effects and am calculating a moving maximum by comparing it to the sensor value and letting it fall off slowly, something similar to:

if (vektor > vector_max)
  {
    vector_max = vektor;
  }

if (i % n == 0)
{
vector_max--; //or something like vector_max -= (vector_max - average) * 0.1 to keep the decay linked to the amplitude
}
i++


It's not really a moving maximum, but it let's me control the time constant quite easily and feels at least a bit more efficient to me than to search through arrays all the time.
Could you share your thoughts/strategies for auto calibration? As I'm still at the beginning of programming I guess there are some obvious solutions for the problem at hand and/or ways to make my code more efficient.

Greetings
 
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 604
Posts: 33448
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
i would like to build it as i described with an AnalogInput with a timerinterupt to sample the frequencys
You can't build it like you said because the arduino can not sample the A/D fast enough. About 10K is all you can get.
Logged

Manchester, NH
Offline Offline
Full Member
***
Karma: 0
Posts: 116
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm interested in how you "make them auto-calibrate to the signal level". DO you just read the average signal level and change a brightness ot threshold variable accordingly?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As I killed my MSGEQ7, I'm sending values from processing to the Arduino now. Using something like the following gives me a good auto calibration in Processing.


Code:
ledvalue[3];
float array[3]; //output of the FFT bins I'm interested in
float peak[3];  //peak values of the FFT bins

for (i=0;i<3;i++){
  if (array[i]>peak[i]){
    peak[i]=array[i];
  }else{
    peak[i]*=0.999;
  }

  ledvalue[i]=map(array[i], 0,255,0,peak[i]);
}
I would change it to integer operations on the Arduino though, peak=(peak*999)/1000;


Logged

Pages: [1]   Go Up
Jump to: