GetSoundVolume

Just starting out? Need help? Post your questions and find answers here.
ShadowStorm
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Feb 14, 2017 12:07 pm

GetSoundVolume

Post 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!
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
User avatar
CELTIC88
Enthusiast
Enthusiast
Posts: 154
Joined: Thu Sep 17, 2015 3:39 pm

Re: GetSoundVolume

Post 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_();



interested in Cybersecurity..
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: GetSoundVolume

Post by RASHAD »

Removed
Last edited by RASHAD on Thu Aug 08, 2019 9:28 pm, edited 1 time in total.
Egypt my love
ShadowStorm
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Feb 14, 2017 12:07 pm

Re: GetSoundVolume

Post by ShadowStorm »

Thanks for your help :D , 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.
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: GetSoundVolume

Post by RASHAD »

Removed
Last edited by RASHAD on Thu Aug 08, 2019 9:29 pm, edited 2 times in total.
Egypt my love
ShadowStorm
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Feb 14, 2017 12:07 pm

Re: GetSoundVolume

Post by ShadowStorm »

Good evening,

I need to know the current sound level of the sound that comes out of the PC speaker.
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: GetSoundVolume

Post by RASHAD »

Removed
Last edited by RASHAD on Thu Aug 08, 2019 9:30 pm, edited 1 time in total.
Egypt my love
ShadowStorm
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Feb 14, 2017 12:07 pm

Re: GetSoundVolume

Post by ShadowStorm »

No !!!
You don't understand anything!

Read the French forum you will understand!
I'm on Windows 7!
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: GetSoundVolume

Post 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.
Proud supporter of PB! * Musician * C64/6502 Freak
ShadowStorm
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Feb 14, 2017 12:07 pm

Re: GetSoundVolume

Post by ShadowStorm »

Can we please help me?
I am French, I do not speak English.
My apologies for the mistakes.

I have sometimes problems of expression
I am sometimes quite clumsy, please excuse me and let me know.
Post Reply