Page 1 of 1
GetSoundVolume
Posted: Thu Aug 08, 2019 1:20 am
by ShadowStorm
Hi,
Do you know how I can recover the sound level of the PC speakers?
There is a subject on French PB here:
https://www.purebasic.fr/french/viewtop ... =1&t=15283
I would like to recover 3 values, 1 minimum:
The general noise level
The Relative sound level
Current noise level
http://www.aht.li/2692085/Son_pc.png
I would like at least to recover the current sound level of the speakers.
I would like to make a program.
Sometimes in some movies or videos, the dialogues are low and the music very loud, the software would then adjust the sound volume in real time!
And it would avoid doing it yourself!
I hope you can help me!
Re: GetSoundVolume
Posted: Thu Aug 08, 2019 2:58 pm
by CELTIC88
goood luck
Code: Select all
Interface IMMDeviceEnumerator Extends IUnknown
EnumAudioEndpoints()
GetDefaultAudioEndpoint(Flow.l, role.l, IMMDevice.i)
GetDevice()
RegisterEndpointNotificationCallback()
UnregisterEndpointNotificationCallback()
EndInterface
Interface IAudioEndpointVolume Extends IUnknown
RegisterControlChangeNotify()
UnregisterControlChangeNotify()
GetChannelCount()
SetMasterVolumeLevel()
SetMasterVolumeLevelScalar()
GetMasterVolumeLevel()
GetMasterVolumeLevelScalar()
SetChannelVolumeLevel()
SetChannelVolumeLevelScalar()
GetChannelVolumeLevel()
GetChannelVolumeLevelScalar()
SetMute()
GetMute()
GetVolumeStepInfo()
VolumeStepUp(*context)
VolumeStepDown(*context)
QueryHardwareSupport()
GetVolumeRange()
EndInterface
Interface IMMDevice Extends IUnknown
Activate(iid, dwClsCtx.l, *pActivationParams, *ppInterface)
OpenPropertyStore()
GetId()
GetState()
EndInterface
Interface IAudioMeterInformation Extends IUnknown
GetPeakValue(*pfPeak)
GetMeteringChannelCount()
GetChannelsPeakValues()
QueryHardwareSupport()
EndInterface
DataSection
IAudioMeterInformation:
Data.l $C02216F6
Data.w $8C67,$4B5B
Data.b $9D,$00,$D0,$08,$E7,$3E,$00,$64
IAudioEndpointVolume:
Data.l $5CDF2C82
Data.w $841E,$4546
Data.b $97,$22,$0C,$F7,$40,$78,$22,$9A
MMDeviceEnumerator:
Data.l $BCDE0395
Data.w $E52F,$467C
Data.b $8E,$3D,$C4,$57,$92,$91,$69,$2E
IMMDeviceEnumerator:
Data.l $A95664D2
Data.w $9614
Data.w $4F35
Data.b $A7,$46,$DE,$8D,$B6,$36,$17,$E6
EndDataSection
CoInitialize_(0);
deviceEnumerator.IMMDeviceEnumerator
defaultDevice.IMMDevice
audiomaterinformation.IAudioMeterInformation
endpointVolume.IAudioEndpointVolume
CoCreateInstance_(?MMDeviceEnumerator, 0, 1, ?IMMDeviceEnumerator, @deviceEnumerator);
deviceEnumerator\GetDefaultAudioEndpoint(0, 0, @defaultDevice) ;
deviceEnumerator\Release()
defaultDevice\Activate(?IAudioEndpointVolume, 1, 0, @endpointVolume);
defaultDevice\Activate(?IAudioMeterInformation, 1, 0, @audiomaterinformation);
defaultDevice\Release() ;
Peak.f
;Pointer To a float variable into which the method writes the peak sample value For the audio stream. The peak value is a number in the normalized range from 0.0 To 1.0.
While 1
audiomaterinformation\GetPeakValue(@Peak)
If Peak <= 0.5
endpointVolume\VolumeStepUp(0)
Else
endpointVolume\VolumeStepDown(0)
EndIf
Delay(10)
Wend
audiomaterinformation\Release()
endpointVolume\Release();
CoUninitialize_();
Re: GetSoundVolume
Posted: Thu Aug 08, 2019 3:21 pm
by RASHAD
Removed
Re: GetSoundVolume
Posted: Thu Aug 08, 2019 4:48 pm
by ShadowStorm
Thanks for your help

, yes, I don't know where and what to look for, and I can't do it, it's too hard for me.
I don't understand why it takes so much code to do something like that.
I can't understand the codes you gave.
Re: GetSoundVolume
Posted: Thu Aug 08, 2019 7:20 pm
by RASHAD
Removed
Re: GetSoundVolume
Posted: Thu Aug 08, 2019 7:27 pm
by ShadowStorm
Good evening,
I need to know the current sound level of the sound that comes out of the PC speaker.
Re: GetSoundVolume
Posted: Thu Aug 08, 2019 7:49 pm
by RASHAD
Removed
Re: GetSoundVolume
Posted: Thu Aug 08, 2019 9:18 pm
by ShadowStorm
No !!!
You don't understand anything!
Read the French forum you will understand!
I'm on Windows 7!
Re: GetSoundVolume
Posted: Fri Aug 09, 2019 3:44 am
by oreopa
I know this is a coding forum, and therefore you may simply be interested in making your own solution...
But VLC video player has a compressor in the audio effects section of "effects and filters" and would surely be a quicker solution to your problem.
Google Translate wrote:Je sais que ceci est un forum de codage, et donc vous pouvez simplement être intéressé par la création de votre propre solution ...
Mais le lecteur vidéo VLC a un compresseur dans la section effets audio de "effets et filtres" et serait sûrement une solution plus rapide à votre problème.
Re: GetSoundVolume
Posted: Sat Aug 10, 2019 2:35 pm
by ShadowStorm
Can we please help me?