We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello all,
I am currently having some major trouble attempting to turn input sound into color (using minim fft).
I am hoping to use bandpass filters to set three frequency ranges and then use the numbers that come out of the analysis of the audio input waves to determine the r,g,b fill values of a square.
(Also I am open to any other suggestions for ways to turn input audio into colors.)
Any help is MUCH appreciated! Thank you so much in advance! Cheers!
Katherine
Answers
Please tell us some details about the problem. What specifically is the trouble? Do you have any code yet? Remember to format your code.
This is a sample code demonstrating the effect. To run it, you need to install the minin library using Processing's library manager. You also need to have your image in your data folder of your sketch. I hope this helps,
Kf
Working code from @kfrajer, hope you understood it.
Thank you for your reply! I am quite new to Processing, so here is my very basic code. I am trying to change the color of the rectangle according to three different frequencies of the input sound but I'm not sure how to set up three separate bandpass filters. I want the first filter to detect the low range Hz of the input, the second filter to detect the mid range Hz of the input, and the third filter to detect the high range Hz of the input. Then, I want to fill the rect by feeding the low range number into red, the mid range number into green, and the high range number into blue.
Thank you for any help!
OK, I'll mention again, please format your code.
Click on the gear icon to edit your post. Select your code and press ctrl + o to indent. Leave a line above and below (the code). Markdown will do the rest for you.
Thank you, kfrajer! That is helpful. I will try to apply it to my code now!
So this is what I have now, but I'm hoping to make the color change effect happen only to a rectangle. Also, I'm not sure if there is a way to make the color change happen more fluidly or more frequently? Any suggestions are much appreciated!
@kmooney
You are doing a good approach. Testing your code generating the color change separate from your filter calculations. Your life will be easier if you figure the projects in steps.
Your line 34 above needs some consideration:
pixels[i] = color(r*p, g/p, b+p);
You need to check the reference and become familiar with colorMode. In a nutshell, the default color mode is RGB and each color is a number from 0 to 255, a total of 256 values. Now when you multiply, let's say red by your value stored in p, r [times]p can be bigger than the color limit of 255. For example if red is 250 and p is 200, r[times]p will give you 500000. But reds are defined from 0 to 255, inclusive! :-?? There are different ways to solve this problem.
One way:
Then the value of p needs to be constrained from 0 to 2. How to do this? Use the map function: https://processing.org/reference/map_.html
p=map(p,min,max,0,2);
where min and max are the minimum and max values p can be. To calculate p, you will need to understand where you are getting this value from. In your code, from line 24. In this case you will need to understand what values p can take in order to define min and max. A good guess for min is 0 (aka zero). Max depends on the summation of values of buffer size.
On a side note, for the green color, g/p needs two considerations. First, you need to watch for zero divisions. Second, you have to consider the previous definition of p for red doesn't work for green because for green (and blue) you are using another operation (division instead of multiplication). Values for green and blue needs to also be constrained to 255.
There are other options, but it really depends to what effect you want to obtained at the end. For example, https://processing.org/reference/constrain_.html
There are other questions to resolve:
First, get the color concept down.
Kf
Here is a sample code for you to consider based on your previous post.
Kf
Thank you so much, kfrajer! That code is very helpful! I'll update you when I figure out how to use it correctly. You're so great for helping!
Sorry for necrobumping this old thread, but I'm trying to make my app work with a mic, but there is the following problem... I have a dummy microphone input on my Linux, but I have no idea how I can switch between 2 or more devices with minim.
it's also a different question completely - start a new one
that said, i think the answer is - choose microphone using system settings.