Music related command?
Music related command?
Is it possible to set a command (or a set of commands) to activate once a certain song has started? (by once, I mean that if it got to that command and the song didn't start yet, the script pauses until the song starts)
Re: Music related command?
I have seen a voice recognition script around here somewhere. You might be able to use part of that to detect sound and trigger events based on that.
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: Music related command?
Needs more info. What are you using to listen to music? Browser, media player, game, etc., and if it's on a browser, what website? Does it put the name in the title of the browser tab? In the future, please be more descriptive with your questions.
Re: Music related command?
it's a media player... it's a song downloaded on my PC, an MP3 file. The song is being played by a different application, and I want a command that can recognize when it's being played thereMasonjar13 wrote:Needs more info. What are you using to listen to music? Browser, media player, game, etc., and if it's on a browser, what website? Does it put the name in the title of the browser tab? In the future, please be more descriptive with your questions.
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: Music related command?
If it's title, window text, or control text shows the information, that can be done without any extra, and very easily. You'll have to figure that out yourself though; use AU3_Spy, included in the AHK installation, and see what you can find.
- JoeWinograd
- Posts: 2213
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Music related command?
It's not clear if you're trying to recognize that a song is being played by analyzing the audio stream, such as what SoundHound and Shazam do, or if you're fine with simply looking at what's in the Title bar of the media player. If the former, that's tough stuff, and I don't have a clue; if the latter, it should be relatively easy, but it will depend a bit on your media player. I use VLC, and when it's playing a song, it puts the Performer tag and the Track Name tag (with a space-hyphen-space separator) in the Title bar. In other words, when a song starts playing, the Title bar looks like this:
Bob Dylan - Forever Young - VLC media player
When the song stops playing, the Title bar becomes this:
VLC media player
So your script could have something like this:
Of course, the code above may need modification depending on the media player.
Regards, Joe
Bob Dylan - Forever Young - VLC media player
When the song stops playing, the Title bar becomes this:
VLC media player
So your script could have something like this:
Code: Select all
SetTitleMatchMode:=3
PerformerName:="set this variable"
TrackName:="set this variable"
SongInTitleBar:=PerformerName . " - " . TrackName . " - VLC media player"
Loop
{
IfWinExist,%SongInTitleBar%
{
; code goes here for specified song started playing
; for test purposes, a msgbox and break the loop
msgbox,4160,song playing,%SongInTitleBar%
break
}
Else
{
; code goes here for the specified song not playing
; for test purposes, a msgbox with a 3-second timeout and continue the loop
msgbox,4144,song not playing,%SongInTitleBar%,3
}
}
Regards, Joe
Re: Music related command?
Thanks for taking time to answer me, but unfortunately, it was the former one...JoeWinograd wrote:It's not clear if you're trying to recognize that a song is being played by analyzing the audio stream, such as what SoundHound and Shazam do, or if you're fine with simply looking at what's in the Title bar of the media player. If the former, that's tough stuff, and I don't have a clue; if the latter, it should be relatively easy, but it will depend a bit on your media player. I use VLC, and when it's playing a song, it puts the Performer tag and the Track Name tag (with a space-hyphen-space separator) in the Title bar. In other words, when a song starts playing, the Title bar looks like this:
Bob Dylan - Forever Young - VLC media player
When the song stops playing, the Title bar becomes this:
VLC media player
So your script could have something like this:Of course, the code above may need modification depending on the media player.Code: Select all
SetTitleMatchMode:=3 PerformerName:="set this variable" TrackName:="set this variable" SongInTitleBar:=PerformerName . " - " . TrackName . " - VLC media player" Loop { IfWinExist,%SongInTitleBar% { ; code goes here for specified song started playing ; for test purposes, a msgbox and break the loop msgbox,4160,song playing,%SongInTitleBar% break } Else { ; code goes here for the specified song not playing ; for test purposes, a msgbox with a 3-second timeout and continue the loop msgbox,4144,song not playing,%SongInTitleBar%,3 } }
Regards, Joe
Does it help if I know exactly which MP3 file is being played, but played through a different application?
- JoeWinograd
- Posts: 2213
- Joined: 10 Feb 2014, 20:00
- Location: U.S. Central Time Zone
Re: Music related command?
I don't know. My gut tells me that you're talking about a huge effort. I'm pretty sure Shazam and SoundHound don't have APIs, but there may be an API out there that would work for you. I would research the web for a music recognition API. Here's an interesting article that discusses how Shazam works:Does it help if I know exactly which MP3 file is being played, but played through a different application?
https://www.toptal.com/algorithms/shaza ... ecognition
Good luck on the project. Regards, Joe
Re: Music related command?
Doing some kind of sound recognition was a feature I had mentioned in some unofficial survey about how you use AHK, answering the question of what you'd like to see in it.
To my knowledge, there's no native way to identify most anything audio. You can produce audio, but that's about it. With things like ImageSearch, it would be neat to have an AudioSearch that looks through the played audio to try to identify a matching clip. Much of AHK's automation is either "senseless" or visual, though you can consider temporal a factor too (assessing how long it has been between certain checkpoints).
To my knowledge, there's no native way to identify most anything audio. You can produce audio, but that's about it. With things like ImageSearch, it would be neat to have an AudioSearch that looks through the played audio to try to identify a matching clip. Much of AHK's automation is either "senseless" or visual, though you can consider temporal a factor too (assessing how long it has been between certain checkpoints).
Re: Music related command?
You can do it with BASS Audio Recognition Library:
https://www.3delite.hu/Object%20Pascal%20Developer%20Resources/bassaudiorecognitionlibrary.html
https://www.3delite.hu/Object%20Pascal%20Developer%20Resources/bassaudiorecognitionlibrary.html
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], peter_ahk and 141 guests