[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Obtain actual volume of sample being played



Hello,

Does anyone know if it is possible to obtain the actual volume of the sample being played at a given moment? This is not the same as getting the volume level which was set earlier, on either the sample or the channel.

For instance, assume that I am playing a sample which starts at low volume (-70dB), increases to 0dB after 5 seconds, then fades out to -70dB again. If I play that sample at volume = 1.0, I would want to be able to return an approximation of the actual dB value at the given time. For instance, if I were to query it at 0 seconds, I would get 0.000001; querying at 5 seconds would return 1.0; querying at 7.5 seconds would give 0.5 or something. Make sense? I would want to have this controllable at the channel and / or sample level, not the mixer - I need to show each channel separately. I don't care about linear / logarithmic conversions or anything... I essentially just need a number from 0 to 9 indicating very approximately how loud the sound is.

I want this information to display semi-accurate VU / peak meter information, based on actual samples. This is for my slave software for an electronic drum set. Currently I show VU information based on the velocity of a drum pad hit, which is decent, but it would be nice to use the actual sample information as well.

I have looked through the documentation, and I don't think it can be done, but I figured I may as well submit this question to the gurus on teh interwebs. 8-)

Cheers