We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there!
I've searched high and low, but can't figure this out. My friend and I are trying to build a program that reads input from a microphone, and tweets at certain intervals. The problem? Most ambient noises register between a 0 and 1 volume reading--you have to be extremely loud to get it above there. The highest number we've gotten is 21, so we're thinking that the range could be 0 to 25.
This leaves us with some questions:
How does minim measure volume--what are the measuring units and range?
Further: how would I map these units from their limited 0 to 25 range to a wider range, 0 to 100, so we can capture more detail?
If we do successfully map it, how do we then plug that float into our averaging equation for volume?
Here's our code:
volume = abs(int(in.right.get(1)*mult));
float volumeConverted = map(volume,0,25,0,100); <--this isn't working, because the averaging equation that we have won't read it
// volumeConverted = volumeC <--tried this conversion as a workaround for the float issue, but it didn't seem to work at all
total = total - readings[index];
readings[index] = volumeConverted; <-- this isn't working, can't plug in float
Thank you so much!
Answers
Let me know if I should clarify anything in my question!
If you want to monitor the overall volume level of the mic you probably want to use in.mix.level() to do so. This should return a value that is between 0 and 1. in.right.get(1) will return values between -1 and 1 and I expect you are seeing values larger than that because of the *mult you've got in there. If the assignment of volumeConverted isn't working, I expect it's because readings is an array of ints you need something like
readings[index] = (int)volumeConverted;
Though I don't know why you wouldn't just store your readings in a float array to it's floats all down the line.