Page 1 of 1

Continuous sound in a loop?

Posted: 12 Sep 2017, 12:48
by mast4rwang
How to make the sound run continuously in a loop?

Let's say this is the code, when you press w it starts music, releasing the key silences it

Code: Select all

loop,
{
if GetKeyState("w","P")
soundplay,looooooongsound.wav
else
soundplay,empty.wav ;its purpose is to break the looooooongsound.wav

sleep,25
}
return
The result when you hold W is continuous first 25 milliseconds of the looooooongsound.wav.

How to make it so it doesn't replay the looooooongsound.wav?? :shifty:

maybe with A_index in a loop? :wtf: :wtf: :wtf:

Re: Continuous sound in a loop?

Posted: 12 Sep 2017, 13:18
by mast4rwang
Nvm, I already thought this out:

Code: Select all

A:=1
loop,
{
	if GetKeyState("w","P")
	{
	if (A=1)
	{
	soundplay,looooongsound.wav
	A:=A+1
	}
	if (A>360)
	A:=1
	}
	else
	{
	soundplay,none.wav
	A:=1
	}
sleep,25
}
return

Re: Continuous sound in a loop?  Topic is solved

Posted: 12 Sep 2017, 13:42
by mast4rwang
I wish there was less CPU taxing method though, it eats up lots of CPU while sending empty wav file :/

edit: found out that pointing to non existent wav file reduces CPU usage exponentially :)