I'm trying to see if I can write a macro that will make a sound meter accessible. In other words when an on screen LED column lights up, the macro see's which pixel that is bright is the highest up on the y axis. Depending on how high up on the y axis it is will then determine what level the sound is/how loud it is.
So the meter I'm currently looking at using is one called a PPM meter that has values from 1 - 7 and there are roughly 40 pixels between each division.
I don't need to check every single pixel, my thinking is just to check 1 every 20 as that would tell me whether the audio was at PPM 0.5, 1, 1.5,2, 2.5 etc.
So I'm thinking of just using GetPixelColor to capture the colour at each of these pixels.
I then need to work out if the colour it captures is essentially on or off which is just comparing the captured colour to the LED Off colour.
That bit is simple enough.
I think I can then get it to tell me which is the highest illuminated LED by using nest if's. In other words if pixel a is on look to pixel b. If b is also on look to c if c is off then return b.
The bit I can't get my head around though is this. A meter moves up and down quickly depending on the type of sound being measured. Therefore I want to the macro to find the highest LED that is on over a period of time, say 3 seconds.
So if we were to look at three pixels A, B & C when I run the macro it looks at these pixels at the same time for 3 seconds and lets say at 1 second A is on but the rest are off, at 2 seconds A, B & C are on and at 3 seconds only A&B are on. I would want it to then tell me that pixel c had been on even though at 3 seconds it was now off.
For the life of me I can't work out how to do that as that would mean having an unknown number of variables as I couldn't overwrite the same one for each pixel.
I haven't even begun writing this yet as I don't know if it's even possible. Anyone know how or has anyone done something similar in the past?
Find Brightest Pixel Within A Range?
Moderators: JRL, Dorian (MJT support)
Re: Find Brightest Pixel Within A Range?
Rather than using GetPixelColor> I would create a one pixel sized BMP and use FindImagePos> using the "EXACT" matching algorithm. Loop through the resulting x and y variable pairs and find the smallest y. Comparing the y position with your known LED scale position will tell you the meter reading.
Re: Find Brightest Pixel Within A Range?
Ahh, yes good thinking!
Some meters change colour the louder the sound is which may complicate matters a bit but I think I may be able to switch that off in this particular program.
Some meters change colour the louder the sound is which may complicate matters a bit but I think I may be able to switch that off in this particular program.
Re: Find Brightest Pixel Within A Range?
Assuming you know the meter column location and size on the screen and assuming the background color is a uniform color, ScreenCapture> a potentially lighted vertical slice of the entire column then use FindImagePos> with a one pixel needle file to search the captured image for the background color rather than the "illuminated " color. Loop through the x,y coordinate results looking for the biggest y value. Compare that to the meter y location to determine the meter reading.Some meters change colour the louder the sound is