I'm trying to play a 24bit audio file with my AutoHotkey app. It just uses SoundPlay. Windows 7 has no problem, however Windows XP users cannot play the 24bit files.
The documentation says:
All Windows OSes should be able to play .wav files. However, other files (.mp3, .avi, etc.) might not be playable if the right codecs or features aren't installed on the OS.
Possible fixes mentioned in the article How to play 24bit WAV files in Windows Media Player are fixing the problem for Windows Media Player, however but not for autohotkey:
Step-by-step guide
- Download Legacy HD Audio Filter
- regsvr32.exe AudioTypeConvert.ax
- Play 24bit file in windows media player (works) and AHK (no sound).
- regsvr32.exe /u AudioTypeConvert.ax to uninstall
Expected behaviour: audio file playsback without errors in both Windows Media Player and AutoHotkey Apps. Actual behavious: audio file playsback without errors only in Windows Media Player and does not playback in AutoHotkey Apps under Windows XP.
Further Investigation
As mentioned in the AutoHotKey forums SoundPlay is using mciSendString under the hood and more information on the nature of the error can be gained by calling it directly.
Using the mciSendString alternative DLL call I get error message 320 which corresponds to MCIERR_WAVE_OUTPUTSINUSE
All waveform devices that can play files in the current format are in use. Wait until one of these devices is free; then, try again.
How do I play 24bit audio files in Windows XP in my AutoHotkey app?
SoundPlay based Test app (download)
#NoEnv
SetWorkingDir %A_ScriptDir%
FileSelectFile, f
SoundPlay, %f%
Msgbox, You should hear audio - except for 24bit wave files under Windows XP.
MCI based test app (download)
#NoEnv
SetWorkingDir %A_ScriptDir%
FileSelectFile, f
TryPlaySound(f)
Msgbox, You should hear audio - except for 24bit wave files under Windows XP.
; If SoundPlay does not work TryPlaySound
TryPlaySound( mFile )
{
; SKAN www.autohotkey.com/forum/viewtopic.php?p=361791#361791
VarSetCapacity( DN,16 ), DLLFunc := "winmm.dll\mciSendString" ( A_IsUnicode ? "W" : "A" )
DN := DllCall(DLLFunc, Str, "play " """" mFile """" "", Uint, 0, Uint, 0, Uint, 0)
Return DN
}