Archive: Wondering if this exists:


3rd May 2007 01:24 UTC

Wondering if this exists:
Hey everyone...lurker here. :-D

I've been programming software that generates ambient music for a couple years, and I was thinking about making an installation with it.

Basically, I'm looking for an AVS preset (or even tips) that would simply fade the screen to a color from a black screen when it hears a certain peak level of sound.

I've been searching for something that could do this easily for a long time, and AVS seems like my best option. Funny how something so basic can be so hard to find!

Any help would be greatly appreciated!

-b


3rd May 2007 02:06 UTC

Re: Wondering if this exists:

Originally posted by benn

Basically, I'm looking for an AVS preset (or even tips) that would simply fade the screen to a color from a black screen when it hears a certain peak level of sound.


it sounds easy enough, but you'll need to be more specific. what does it do after the colour fades in? what colour do you want and at what volume will trigger it?

3rd May 2007 02:25 UTC

thanks for the reply!
white would be fine...this should be easily changable i'm sure. i have a bit of noob avs knowledge to sort that out.

the volume of the audio would trigger the brightness, however, i can't seem to work one out that "fades in and out". i could get it to fade out...but it just flashes in. no "fade in" effect. :)


4th May 2007 02:03 UTC

i get what you want i get it now. i'll have a shot when i get home.


4th May 2007 14:11 UTC

okay the preset's too small for me to bother zipping and posting so here's the code.

superscope with the code


init//

n=1

frame//

col1=getspec(0.16,0.27,0);
col1=col1*0.9;
col=col*0.9+sin(col1)*0.25

point//

x=0;
y=0;
red=col;
blue=red;
green=red;


followed by a movement trans with the code
x=0;
y=0;
(rect-coords on)

hope thats what you're after

4th May 2007 14:37 UTC

protips(tm):

There are three tasks in your question:

- Detect if the music is above a certain volume (which is what you mean by 'peak level of sound')
- Interpolate from one colour to another
- Fill the screen with that colour

To detect the volume of the music at any particular time it is easiest to take the DC component of the frequency

spectrum, you can do this using getspec(0,0,0) which will take the zero'th bin of the FFT with a width of zero on

the centre (average of left and right) channel. To test it is above a value you can use above(getspec(0,0,0),<value>), so for example to set the value of register 0 to 1 when the music goes above a normalised 'volume' of 0.9 you can use reg00=if(above(getspec(0,0,0),<value>),1,reg00); note that this will set it to 1 and leave it at 1. You can be more clever when detecting volume by taking a rolling average or using a more sophisticated algorithm but this way is simple and effective. Rather than just switching from 0 to 1 you would probably want a register to smoothly transition from 0 to 1, to do this you can have a second variable which tends towards the value of the other variable over time.

Interpolating from one colour to another is a simple case of linear interpolation:
pal1r=128/255; //define your pallete
pal1g=255/255;
pal1b=0/255;
pal2r=0/255;
pal2g=128/255;
pal2b=255/255;

red=pal1r+(pal2r-pal1r)*lvl; //interpolate (lvl is a value from 0-1)
green=pal1g+(pal2g-pal1g)*lvl;
blue=pal1b+(pal2b-pal1b)*lvl;

Filling the screen with this colour is easiest achieved with a superscope and movement. You render a dot of the desired colour in the centre of the screen and use a movement to set ever other pixel equal to that colour. So create a superscope with n=0, x=0, y=0 and red/green/blue equal to your desired colour. Place a movement after it with the user code 'd=0', this means for every pixel, make the pixel colour equal to the pixel at d=0 in radial coordinates (i.e. the very centre of the screen)

Put that all together and you're done


4th May 2007 19:56 UTC

@pak-9, just a little correction:
Quote:


5th May 2007 02:07 UTC

works lovely! thanks so much for your help. now if only there was a stable way to render it to AVI....but that'll be another battle. :-D


5th May 2007 02:22 UTC

Why not just use fraps? :up:



So create a superscope with n=0, x=0, y=0 and red/green/blue equal to your desired colour. I think n has to be at least 1 (well exactly 1 in this case :) ) or nothing will be rendered.

greets, zha