Playback 24bit audio not possible
Asked Answered
A

1

10

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

  1. Download Legacy HD Audio Filter
  2. regsvr32.exe AudioTypeConvert.ax
  3. Play 24bit file in windows media player (works) and AHK (no sound).
  4. 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
}
Arbitress answered 17/5, 2011 at 14:59 Comment(2)
Ideas to improve the question itself are happily accepted in comments.Arbitress
How to improve something that is so perfect. +1 for the details provided in question.Airlike
C
1

I would convert the 24-bit file to a 16-bit file, if that's at all feasible.

Coextensive answered 31/5, 2011 at 22:8 Comment(2)
In this case I don't have any control over the files. I guess the only solution is to call a thirdparty DLL like Bass to do the playback.Arbitress
If it were me, I'd check the file header for 24-bitness and make a temporary 16-bit copy and play that before I'd pull in another DLL, but I'm old school.Coextensive

© 2022 - 2024 — McMap. All rights reserved.