Sound detection Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
HIAC
Posts: 109
Joined: 11 Oct 2017, 17:59
Location: Republic of Serbia

Sound detection

17 Nov 2017, 19:09

Can AHK detect while sound is playing? Music from game
User avatar
Capn Odin
Posts: 1273
Joined: 23 Feb 2016, 19:45
Location: Denmark

Re: Sound detection

17 Nov 2017, 19:31

It is possible but I only know how to get the volume.

Code: [Select all] [Expand] [Download] (Get Sound Volumen.ahk)GeSHi © Codebox Plus

Small Gradient.png
Small Gradient.png (2.48 KiB) Viewed 208 times
VA.ahk
(34.56 KiB) Downloaded 5 times
Please excuse my spelling I am dyslexic.
User avatar
KuroiLight
Posts: 258
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: Sound detection

17 Nov 2017, 22:46

This is a cut down version of VA, strictly for detecting master audio level.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



use example:

Code: [Select all] [Download] GeSHi © Codebox Plus

IsAudioPlaying() {
AudioLevel := 0.0
VA_IAudioMeterInformation_GetPeakValue(VA_GetAudioMeter(), AudioLevel)
return (Round(AudioLevel, 4) > 0)
}
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]
HIAC
Posts: 109
Joined: 11 Oct 2017, 17:59
Location: Republic of Serbia

Re: Sound detection

18 Nov 2017, 22:15

Thank you both.. So how can I have message pop up when sound is detected? :)
User avatar
KuroiLight
Posts: 258
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: Sound detection

18 Nov 2017, 22:22

If your on Windows 10 use this for tray popups.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


otherwise: TrayTip

as for your question, just check periodically for sound using the code I post previously.
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]



HIAC
Posts: 109
Joined: 11 Oct 2017, 17:59
Location: Republic of Serbia

Re: Sound detection

18 Nov 2017, 22:31

Sorry but I don't really know how exactly to do it.. I'm on windows 7,so what would be the code to get msgbox when sound is detected? :D
User avatar
KuroiLight
Posts: 258
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: Sound detection  Topic is solved

19 Nov 2017, 11:33

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]



Georgie Munteer

Re: Sound detection

19 Nov 2017, 11:57

on windows 10 if you comment out the msgbox and just leave the traytip it crashes

KuroiLight wrote:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
KuroiLight
Posts: 258
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: Sound detection

19 Nov 2017, 14:23

does not for me.
might be for you because it gets spammed, thats why I use an alternative [code from my 2nd post] on windows 10, so I have more control over display time.

Code: [Select all] [Download] GeSHi © Codebox Plus

Loop {
While(!IsAudioPlaying())
Sleep, 2000
TrayTip,, % "Sound Detected", 1
While(IsAudioPlaying())
Sleep, 2000
}
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]



Georgie Munteer

Re: Sound detection

19 Nov 2017, 14:38

KuroiLight wrote:does not for me.
might be for you because it gets spammed, thats why I use an alternative [code from my 2nd post] on windows 10, so I have more control over display time.

Code: [Select all] [Download] GeSHi © Codebox Plus

Loop {
While(!IsAudioPlaying())
Sleep, 2000
TrayTip,, % "Sound Detected", 1
While(IsAudioPlaying())
Sleep, 2000
}

regardless thanks for the code, works the best of all methods i tried, incredible how many things have to be done to figure out sound
User avatar
KuroiLight
Posts: 258
Joined: 12 Apr 2015, 20:24
GitHub: KuroiLight

Re: Sound detection

19 Nov 2017, 16:30

Yeah, Microsoft made a lot of things a pain in the *** after windows xp.
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]



HIAC
Posts: 109
Joined: 11 Oct 2017, 17:59
Location: Republic of Serbia

Re: Sound detection

20 Nov 2017, 02:00

KuroiLight wrote:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Woah it works :superhappy: Thank you very much!

Return to “Ask For Help”

Who is online

Users browsing this forum: devnullsp, elModo7, Rohwedder and 43 guests