lee321987 Posted March 1, 2020 Share Posted March 1, 2020 Hello. I'm trying to write a program that adjusts it's own volume level (SoundSetWaveVolume()) depending on the current system volume level (so the program doesn't blast my ears if the system volume is up high). Both numbers (the script's volume, and the system volume) can be from 0-100. My problem is i have no idea how to create a single formula that will work like this: If system volume = 22 Then script volume = 50 If system volume = 100 Then script volume = 3 So if the formula is fed "22" it outputs "50". If it's fed "100" it outputs "3". I want the formula to work for all system volume levels (0-100), but the only numbers I know are: system=22, script=50 system=100, script=3 Can anyone help? Link to comment Share on other sites More sharing options...
Nine Posted March 1, 2020 Share Posted March 1, 2020 #include <Constants.au3> ; m = (Yb - Ya) / (Xb - Xa) $m = (3-50) / (100-22) $b = 50 - $m*22 ; y = mx + b $y = $m * 100 + $b MsgBox ($MB_SYSTEMMODAL,"",$y) Linear geometry... lee321987 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
lee321987 Posted March 3, 2020 Author Share Posted March 3, 2020 (edited) @Nine Thanks a lot. Unfortunately it doesn't work like I expected -- I think it's because the Windows master volume and the script volume (SoundSetWaveVolume) use different scale types (one linear and the other logarithmic?). Apparently changing SoundSetWaveVolume() has no effect on the levels picked up by recording software, so I did some tests with my audio Line-out connected to Line-in. For each system volume level, I found the value for SoundSetWaveVolume that resulted in getting closest to outputting -42.3db (the level I'm trying to make output always be). If anyone want's to try and build a formula, I'd really appreciate it. Exactness isn't crucial, I just need a formula that outputs somewhere around 59 when fed the number 20, and somewhere around 5 when fed 80, that increases something like the center column of this chart (chart is also attached as a .CSV file): System Volume SoundSetWaveVolume Line-out output 14 100 -43.0db 15 99 -42.3db 20 59 -42.3db 30 30 -42.1db 30 29 -42.4db 40 18 -42.2db 50 12 -42.3db 60 9 -42.1db 70 7 -41.9db 70 6 -43.2db 80 5 -42.8db 90 4 -43.0db 96 4 -42.0db 100 4 -41.4db Is there a website or program that you can feed four numbers, and it will build a logarithmic function what will work for both sets of numbers? Meaning you specify 4 numbers (A1, A2, B1, B2) and it builds one formula that will turn number "A1" into number "A2" AND also turn "B1" into "B2". volume - system vs script.csv Edited March 3, 2020 by lee321987 Link to comment Share on other sites More sharing options...
ripdad Posted March 3, 2020 Share Posted March 3, 2020 (edited) What are you using to detect current volume level? -edit- Here is something that might help... https://www.autoitscript.com/forum/topic/121624-sound-level-sampling/?do=findComment&comment=1399692 Edited March 3, 2020 by ripdad "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
lee321987 Posted March 3, 2020 Author Share Posted March 3, 2020 @ripdad Never mind about sound levels not changing in recording software when I changed SoundSetWaveVolume() -- it's working now. I don't know what happened that made me think it wasn't. As far as what I'm using to measure sound levels, I've been using Audacity (record audio, then do Plot Spectrum), and this: And thanks for the link to your BASS.dll peak meter. I saved it to my examples dir! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now