Having problems with playing wav music file. I purchase some wav music file to play in a game. Started to code the music function. During testing the functions the music playing wound start to distort, then repeat a small part of the music, and finally exit with error code 135 error message Bus error. This would happen around the fourth music file. Change the order of music file and still the same error. I'm unable to upload the music files because of the license. So download some music file that allow me to share. But unable to reproduce the same error code, but during testing these music file will continue play without stopping. It repeats a small part of the song, but the positioning show it starting over from the beginning of the music.
Would like to find out if it's my system or Hollywood. Can someone please test to verify? I'm using Debian Linux System Version 10 4.19.0-26-amd64 #1 SMP Debian 4.19.304-1 (2024-01-09) x86_64 GNU/Linux
music.hws file:
Code: Select all
/*****************************************************************************
*
* Music
*
*****************************************************************************/
Const #MSC_CHANNEL = 1
Const #MSC_VOLUME = 32
Const #MSC_IRRAT = 0
Const #MSC_FELEX = 1
Const #MSC_MAX = 1
Global gSongList = { "Irrational Machines.wav",
"Felix de Natris.wav" } ; This songs repeats a small part of song forever. Pos starts over?
Global gSongIndex
Global gSongID
Global gPlayMusic
Global gSongRandom
Global gSongCount
Global gMusicPos
Global gMusicFor
Global gMusicDur
Function p_InitMusic()
;OpenAudio()
gSongID = Nil
gSongIndex = -1
gPlayMusic = False
gSongRandom = False
gSongCount = 0
gMusicPos = 0
gMusicDur = 0
gMusicFor = Nil
DebugPrint("p_InitMusic: Initialized.")
EndFunction
Function p_SongRandomOn()
gSongRandom = True
EndFunction
Function p_SongRandomOff()
gSongRandom = False
EndFunction
Function p_PlaySong(Idx)
If Idx < 0 or Idx > #MSC_MAX
DebugPrint("p_PlaySong: Song index out of range. Idx:", Idx)
Return
EndIf
If gSongID <> Nil
StopMusic(gSongID)
;CloseMusic(gSongID)
DebugPrint("p_PlaySong: Close-->", gSongList[Idx])
EndIf
gSongID = Nil
DebugPrint("p_PlaySong: Open--->", gSongList[Idx])
gSongID = OpenMusic(Nil, GetDirectoryEntry(3, gSongList[Idx]))
gMusicDur = GetAttribute(#MUSIC, gSongID, #ATTRDURATION)
gMusicFor = GetAttribute(#MUSIC, gSongID, #ATTRFORMAT)
gMusicPos = GetAttribute(#MUSIC, gSongID, #ATTRPOSITION)
gSongIndex = Idx
If gPlayMusic = True
DebugPrint("p_PlaySong: Play--->", gSongList[Idx])
PlayMusic(gSongID, {Channel = #MSC_CHANNEL})
gSongCount = gSongCount + 1
DebugPrint("p_PlaySong: gSongCount -->", gSongCount)
EndIf
EndFunction
Function p_MusicOff()
gPlayMusic = False
If gSongID <> Nil
StopMusic(gSongID)
EndIf
DebugPrint("p_MusicOff: gPlayMusic =", gPlayMusic)
EndFunction
Function p_MusicOn()
gPlayMusic = True
If gSongID <> Nil
PLayMusic(gSongID)
EndIf
DebugPrint("p_MusicOn: gPlayMusic =", gPlayMusic)
EndFunction
; 0 = mute, 1 to 64
Function p_SetMusicVolume( volume)
If volume > 64 Then volume = 64
If volume < 0 Then volume = 0
DebugPrint("p_SetMusicVolume:", volume)
SetChannelVolume(#MSC_CHANNEL, volume)
EndFunction
Function p_PlayNextSong()
If gPlayMusic = False Then Return
If gSongID <> Nil
If IsMusicPlaying(gSongID) = True
gMusicPos = GetAttribute(#MUSIC, gSongID, #ATTRPOSITION)
Return
EndIf
DebugPrint("p_PlayNextSong: IsMusicPlaying = False")
;StopMusic(gSongID)
;CloseMusic(gSongID)
gSongID = Nil
EndIf
DebugPrint("p_PlayNextSong: Old gSongnIndex:", gSongIndex)
If gSongRandom = False
gSongIndex = gSongIndex + 1
DebugPrint("p_PlayNextSong: New gSongnIndex:", gSongIndex)
Else
gSongIndex = Rnd(#MSC_MAX)
DebugPrint("p_PlayNextSong: Random Song:", gSongIndex)
Endif
If gSongIndex > #MSC_MAX Or gSongIndex < 0 Then gSongIndex = 0
If IsMusic(GetDirectoryEntry(3, gSongList[gSongIndex])) = True
DebugPrint("p_PlayNextSong: Open--->", gSongList[gSongIndex])
gSongID = OpenMusic(Nil, GetDirectoryEntry(3, gSongList[gSongIndex]))
DebugPrint("p_PlayNextSong: Play--->", gSongList[gSongIndex])
PlayMusic(gSongID, {Channel = #MSC_CHANNEL})
gMusicDur = GetAttribute(#MUSIC, gSongID, #ATTRDURATION)
gMusicFor = GetAttribute(#MUSIC, gSongID, #ATTRFORMAT)
gMusicPos = GetAttribute(#MUSIC, gSongID, #ATTRPOSITION)
Else
DebugPrint("p_PlayNextSong: Unsupported Music Format -->", gSongList[gSongIndex])
gMusicDur = 0
gMusicFor = Nil
gMusicPos = 0
Return
EndIf
gSongCount = gSongCount + 1
DebugPrint("p_PlayNextSong: gSongCount -->", gSongCount)
EndFunction
main.hws file:
Code: Select all
/****************************************************************
** **
** playmusic bug
** Interpreter: Hollywood 10.0 **
** **
** **
****************************************************************/
/*
** For Hollywood 10.0
*/
@VERSION 10,0
@OPTIONS {EnableDebug = True}
@OPTIONS {ConsoleMode = True}
/*
** Information about this app
*/
@APPTITLE "PlayMusic Bug"
@APPVERSION "$VER: Bug .1 (1/20/24)"
@APPCOPYRIGHT "(C) 2024 Randy Butler"
@APPAUTHOR "Randy Butler"
@APPDESCRIPTION "PlayMusic Bug"
Const #MUSIC_DIR_LOC = "music"
@DIRECTORY 3, #MUSIC_DIR_LOC
@INCLUDE "music.hws"
@DISPLAY {Title = "Playmusic", Width = 800, Height = 600} ;Borderless = True
Function p_MainMenu()
p_PlayNextSong()
Cls
SetFontColor(#YELLOW)
/* Music Information */
TextOut(20, 100, "FILENAME:")
TextOut(20, 110, "FORMAT:")
TextOut(20, 120, "DURATION:")
TextOut(20, 130, "POSITION:")
TextOut(20, 150, "COUNT:")
TextOut(100, 100, gSongList[gSongIndex])
TextOut(100, 110, gMusicFor)
TextOut(100, 120, gMusicDur)
TextOut(100, 130, gMusicPos)
TextOut(100, 150, gSongCount)
Flip
;Wait(10)
EndFunction
;LegacyControl("SingleMusic", False)
;Initialize
p_InitMusic()
p_MusicOn()
;p_SongRandomOn()
;LeftMouseQuit(TRUE)
EscapeQuit(TRUE)
BeginDoubleBuffer(True)
SetInterval(1, p_MainMenu, 1000/30) ; 30fps
Repeat
info = WaitEvent()
;DebugPrint("WaitEvent", info.Action, info.ID, info.Triggered)
Forever
Music files
https://familybusinesssoftware.com/imag ... sic.tar.gz