Forcing jit.matrix (or window) to black when there's no input
Hi all,
I'm sending a color, controlled by a sound, through a jit.matrix to a jit.window. The amplitude controls the saturation, which is working (more or less). I'm having trouble however: after the sound fades away, the color lessens but doesn't fade all the way out. Is there a way to force the matrix, or window, to black when the signal is under a certain threshold?
Many thanks and happy holidays!
'clear'
Hi Christopher,
Thank you for your quick reply. Could you explain a little more what you mean? Sorry, not very experienced with Max, especially jitter!
Thank you again.
Sending a 'clear' message to a jit.matrix object will set all its contents to 0.
Here's an example patch that converts audio amplitude to a level of gray, and that clears the matrix whenever the peak amplitude goes below -60 dB.
Thanks so much Christopher, works great! Thanks for taking the time to do that. One quick question, in the patch you sent the transition to black is smooth, but when I try it in my patch it is a hard cut to black once it passes the threshold. Have any idea what could be causing that?
>> "in the patch you sent the transition to black is smooth"
That's 'cause my amplitude-to-grayscale patch has already faded the color to black by the time the amplitude goes below the threshold. The 'clear' message zeros the matrix's contents instantly, so if the color was bright beforehand 'clear' will create a sudden change. If you want a fade rather than an abrupt change, you'd need to do an interpolated fade from full brightness to full darkness over some small amount of time (say, one second). You can do that with the line object or the bline object to create linearly changing values from 0 to 1 or from 1 to 0, and you can cause the fade with jit.xfade or jit.op.
Thank you again Christopher! Happy new year