no audio/sound from mushclient (sound or Playsound)

Posted by Arana on Mon 11 Oct 2010 04:48 PM — 4 posts, 18,675 views.

#0
i get no audio from sound function, i am trying to find the reason. PC Volume is ok (tested with 3 players)

File exists and is the exact name and the root path of drive c:

i get no error but no sound either.
if i play the sound using any sound player it works fine.

wav specs are as following:


Size 90 KB (0% Compressed)
Original Size 90 KB
Length 2.1 seconds
Channels 1 (mono)
Sample Rate 22 KHz;
Sample Size 16 bit
Bit Rate 352 kbps
Encoder
Encoder Settings PCM
Audio Quality Perfect (Lossless)
Contains
Channel Mapping Center
File bombalarm
Type BSplayer file [.wav]


<aliases>
  <alias
   match="test"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>PlaySound (1, "c:\bombalarm.wav", false, 0, 0)
Sound("c:\bombalarm.wav")</send>
  </alias>
</aliases>
Amended on Mon 11 Oct 2010 09:47 PM by Arana
Australia Forum Administrator #1
When something like that happens it helps to put "check" around the function to see what the error message is, eg.


check (PlaySound (1, "c:\bombalarm.wav", false, 0, 0))
check (Sound("c:\bombalarm.wav"))


In your case I'm guessing you would see:


Run-time error
World: xxxxxx
Immediate execution
[string "Command line"]:1: Cannot open the specified file


The reason is the lack of backslashes. First, inside a Lua string you need to change \ to \\. Second, inside "send to script" you have to double them again because MUSHclient also converts backslashes. So assuming the file is there and is the right format, you at least need:


PlaySound (1, "c:\\\\bombalarm.wav", false, 0, 0)


Or save yourself some effort and use forward slashes:



PlaySound (1, "c:/bombalarm.wav", false, 0, 0)

#2
thanks Nick, that did it this is not for me but for a hard headed pal lol, so forward slashes it is, trying to explain him about escaping backslashes and parsing would be very very hard :P
Australia Forum Administrator #3
What might be simpler for your friend is, put the sounds in the MUSHclient "sounds" folder. See here:

http://www.gammon.com.au/scripts/doc.php?function=PlaySound

To quote from that page:


If the file name is a fully-qualified path name (ie. it starts with a slash, or a drive letter, colon, slash like "C:/") then it is used "as is".

Otherwise, MUSHclient prepends the MUSHclient execution directory + "sounds" subdirectory to the name

For example, the file name "swordhit.wav" would be looked for at: C:/Program Files/MUSHclient/sounds/swordhit.wav

You can use forward slashes in the file name (for convenience in typing strings in scripts), they are converted to backslashes.



So if you use the sounds folder then you don't need slashes of any kind. That is:


PlaySound (0, "bombalarm.wav")