AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to detect if a sound was played

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Guest2
Guest





PostPosted: Sun Aug 31, 2008 10:25 am    Post subject: How to detect if a sound was played Reply with quote

I want to activate AHK-functions, triggered when my soundcard plays any sound.

There is no other way to detect if a special event takes place. The one and only indicator is a "build in" sound from another program.

PLEASE can anybody help me to solve this problem?

Tank you!
(regards from Germany)
Back to top
heresy



Joined: 11 Mar 2008
Posts: 291

PostPosted: Sun Aug 31, 2008 3:45 pm    Post subject: Reply with quote

as far as i know, there's no neat way to do this unless dealing in the driver level.
here's the trick.

1) capture sound by using MixMP3
2) record with silence filter (read help of mixmp3)
3) check output file size consistently.
4) if it's over 16.1kb (16.0kb is minimal) sound is playing.

Example (Mixmp3.exe need to be in same directory)
Code:
#Persistent
Run, Mixmp3.exe -s -50 -ql -mm,,,PID
SetTimer, SizeCheck, 100
Return

SizeCheck:
FileGetSize, Size, out.mp3, K
if (Size > 16) ;larger than 16KB
{
    ControlSend,, {ESC}, ahk_pid %PID%
    SetTimer, SizeCheck, Off
    GoTo, DoSomething
}
Return

DoSomething:
MsgBox, Sound is Playing
Exitapp

_________________
Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com
Back to top
View user's profile Send private message
BoBo˛
Guest





PostPosted: Sun Aug 31, 2008 5:43 pm    Post subject: Reply with quote

Someone might extract something usefull from this: [audio-input-output-level], hopefully.
Back to top
garry



Joined: 19 Apr 2005
Posts: 2214
Location: switzerland

PostPosted: Sun Aug 31, 2008 6:44 pm    Post subject: Reply with quote

thank you heresy the script about mixmp3
a freeware tonedet
http://www.nch.com.au/action/misc.html#TONEDET
but you need a soundcard Smile

Quote:
ToneDet is used to monitor an audio signal a for specific frequency tone or multiple tones and run other software when it detects the tones. Althrough it can detect any audio frequency, ToneDet is usually used to detect very low frequency tones that cannot be heard by humans.

Typical Applications
~ Radio Network Broadcasts (to automatically trigger commercial breaks).
~ Control Systems. To control remove systems over an audio system.
~ Remote Audio Switches. To switch signals on and off using tones.

~ Sub-band information transmission. To transmit information over an audio transmission.
~ Many more related applications.

Back to top
View user's profile Send private message
Guest2
Guest





PostPosted: Mon Sep 01, 2008 11:49 am    Post subject: Thank you Reply with quote

Thank you very much indeed!
@garry - ToneDet is exactly what I need.
@heresy - MixMP3 solves another problem for me. Thank´s a lot for link and code.
@BoBo˛ - could be really helpfull for someone, who is able to understand the code. Thank you!

This community is not less awesome than AHK...
Back to top
bvladimirpl



Joined: 12 Apr 2011
Posts: 1

PostPosted: Tue Apr 12, 2011 1:07 pm    Post subject: Reply with quote

I have a question... how to do the inverse with the "mixmp3.exe"? when there is no audio and the pc do something...?

Thank's!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group