Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Sound.ahk - Sound functions for use with AutoHotkey


  • This topic is locked This topic is locked
36 replies to this topic
Drugwash
  • Members
  • 1078 posts
  • Last active: May 24 2016 04:20 PM
  • Joined: 07 Sep 2008
It's always good to leave a sign of your passage through. ;)

BTW, have you tried the modded player I posted? I'm now using Trout (when I happen to listen to music) but before that, I really enjoyed this MusicPlayerMod. 8)

(AHK 1.0.48.05 and Win98SE) forever | My scripts are here


Stefan V
  • Members
  • 78 posts
  • Last active: Oct 11 2010 03:51 AM
  • Joined: 16 Jun 2009
[email protected]@@
This is so awesome! Thank you Fincs.
I used these functions combined with Rajats song launcher... Look what I made
#Include Sound.ahk
Path = c:\music\*.*
OnExit, ExitSub
Pause = false
SetBatchLines, 10ms

~F10::
	if hSound {
Sound_close(hSound)
}
        Input, UserInput, T5,{enter}{ins}
        ifequal,userinput,, return
        endkey=%errorlevel%
        Loop, %Path%, 1, 1
        {
                mp3 = %A_LoopFileFullPath%
                Found = Yes
                Loop, Parse, UserInput, %a_space%
                        IfNotInString, mp3, %A_LoopField%, SetEnv, Found, No

                IfEqual, Found, Yes
                {
                        Ifnotinstring, mp3,.mp3, Ifinstring, mp3,., break
			hSound := Sound_Open(mp3, "myfile")
                        ifequal, endkey, Endkey:Insert, Play()
                        ifnotequal, endkey, Endkey:Insert, Play()
                        Found = No
                        break
                }
        }
Return
 
~Pause::
status := Sound_Status(hSound)
If(status = "stopped" OR status = "paused")
{
   If status = stopped
      Sound_Play(hSound)
   Else
      Sound_Resume(hSound)
   playing = 1
}Else{
   Sound_Pause(hSound)
   playing = 0
}
Return


Play() {
hSound := Sound_Open(mp3, Alisa = "")
Sound_Play(hSound)
}
Return


~F12::
Sound_Stop(hSound)
playing = 0
Return

~F11::
Sound_Close(hSound)
Return

ExitSub:
Sound_Stop(hSound)
ExitApp
Return

Instructions :
Set Path to your music directory
Press F10 and type a word of your song < Press enter or insert or it while time out in 5 seconds.
Press Pause to start/stop

F11 to close the song (will automatically close if you press f10)
F12 to stop the song (Restart)

fincs
  • Moderators
  • 1662 posts
  • Last active:
  • Joined: 05 May 2007
Please read:
<!-- m -->http://www.autohotke... ... 462#256462<!-- m -->

webster14
  • Members
  • 17 posts
  • Last active: May 30 2011 09:38 PM
  • Joined: 02 Jul 2010
1) are there any functions to modify the volume for the sound being played?
sound set sets the sistem volume

2) is there something for an equalizer?

3) Sound_Length gives me a longer value. I have a mp3 file with a lenght of 4:29 but the function returns 9:37. For some files it returns the corect value for some it doesn't. I'm using only mp3 files

tmplinshi
  • Members
  • 245 posts
  • Last active: Mar 12 2015 02:29 PM
  • Joined: 06 Apr 2012

How to play sound resource in the compiled exe (RCData)? Thanks.
 
I have tried this one http://www.autohotke...lread-possible/, but it will paused when sound is playing. (Works now)


Edited by tmplinshi, 29 August 2013 - 07:56 AM.


chaidy
  • Members
  • 57 posts
  • Last active: Oct 21 2015 05:53 PM
  • Joined: 20 Apr 2010
nice

Multigamer
  • Members
  • 9 posts
  • Last active:
  • Joined: 26 Feb 2014

Thx Alot.could be usefull.