Page 1 of 1
[SOLVED] No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Wed Mar 12, 2025 8:17 am
by Randy Walker
InitSound failed me so I tried the code below and still nothing. What's going on?
Other apps play sound. Checked dxdiag and it shows directx 12:
Code: Select all
Debug "start"
Beep_(800,100)
Beep_(900,100)
Beep_(1070,100)
Delay(2000)
Beep_(800,100)
Beep_(900,100)
Beep_(1070,100)
Delay(2000)
Beep_(800,100)
Beep_(900,100)
Beep_(1070,100)
Debug "end"
Re: No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Wed Mar 12, 2025 8:23 am
by Randy Walker
Sorry. Just tested beep code in PB v6.20 and worked fine.
Re: No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Thu Mar 13, 2025 4:05 am
by Randy Walker
Somebody marked my OP [Solved] when it was not??? Hmmmm.
Anyway, Here is a snippet from my PB v5.62 and it shows "InitSound OK" so why no sound and no errors?
Code: Select all
If FileSize("C:\Windows\Media\Alarm01.wav") > 0
Debug "see the file"
If InitSound() <> 0
Debug "initSound OK"
If LoadSound(0,"C:\Windows\Media\Alarm01.wav")
EndIf
Else
Debug "Don't get the InitSound"
EndIf
Debug "Play Sound"
PlaySound(0)
EndIf
As mentioned earlier I have Directx 12
Also same code on my PB v6.20 does not play.
Re: No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Thu Mar 13, 2025 5:28 am
by RASHAD
Hi Randy
Which one you suspect Fred,freak,kiffi or idle
You need a proper delay time
Try the next
Code: Select all
If FileSize("C:\Windows\Media\Alarm01.wav") > 0
Debug "see the file"
If InitSound() <> 0
Debug "initSound OK"
If LoadSound(0,"C:\Windows\Media\Alarm01.wav")
EndIf
Else
Debug "Don't get the InitSound"
EndIf
Debug "Play Sound"
PlaySound(0, #PB_Sound_Loop)
MessageRequester("Sound", "Playing the sound (loop)..."+#LF$+"Click to quit..", 0)
EndIf
Re: No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Thu Mar 13, 2025 6:10 am
by Randy Walker
RASHAD wrote: Thu Mar 13, 2025 5:28 am
Hi Randy
Which one you suspect Fred,freak,kiffi or idle
You need a proper delay time
Try the next
Code: Select all
If FileSize("C:\Windows\Media\Alarm01.wav") > 0
Debug "see the file"
If InitSound() <> 0
Debug "initSound OK"
If LoadSound(0,"C:\Windows\Media\Alarm01.wav")
EndIf
Else
Debug "Don't get the InitSound"
EndIf
Debug "Play Sound"
PlaySound(0, #PB_Sound_Loop)
MessageRequester("Sound", "Playing the sound (loop)..."+#LF$+"Click to quit..", 0)
EndIf
Hi RASHAD. As always, you did it again. THANKS!!!!
Could have been any one of them. They've probaby all learned to hate the site of me by now

Re: No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Thu Mar 13, 2025 10:09 am
by Randy Walker
RASHAD wrote: Thu Mar 13, 2025 5:28 am
Hi Randy
Which one you suspect Fred,freak,kiffi or idle
I'm going to go with Idle on that one. He's been Posting comments to my uptime code over there in the Windows forum Like I've never seen so I think he might be feeling a little guilty.
Whoever... I take no offense.

Re: [SOLVED] No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Thu Mar 13, 2025 10:26 am
by AZJIO
Code: Select all
ini_Signal$ = "C:\Windows\Media\Alarm01.wav"
;- InitSound
Global IsSound = 0
#RingTone = 0
If Asc(ini_Signal$) And FileSize(ini_Signal$) > 0 And InitSound()
If LoadSound(#RingTone, ini_Signal$)
IsSound = SoundLength(#RingTone, #PB_Sound_Millisecond)
If IsSound > 3000
IsSound = 3000
EndIf
EndIf
EndIf
success = 1
If success And IsSound
PlaySound(#RingTone)
Delay(IsSound)
EndIf
The sound in the thread does not block the window.
Code: Select all
EnableExplicit
Define x, success
Define ini_Signal$ = "C:\Windows\Media\Alarm01.wav"
Global IsSound = 0
#RingTone = 0
If Asc(ini_Signal$) And FileSize(ini_Signal$) > 0 And InitSound()
If LoadSound(#RingTone, ini_Signal$)
IsSound = SoundLength(#RingTone, #PB_Sound_Millisecond)
EndIf
EndIf
Procedure Sound(*Value)
If PeekI(*Value) = 1 And IsSound
PlaySound(#RingTone)
Delay(IsSound)
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 420, 100, "The sound in the thread does not block the window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(1, 10, 10, 99, 30, "Sound")
ButtonGadget(2, 10, 50, 242, 30, "click when a melody is playing")
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case 2
x + 1
SetGadgetText(2, Str(x))
Case 1
success = 1 ; some operation was successful, signaling with a sound
CreateThread(@Sound(), @success)
EndSelect
Case #PB_Event_CloseWindow
CloseWindow(0)
End
EndSelect
ForEver
EndIf
Re: [SOLVED] No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Thu Mar 13, 2025 7:24 pm
by Randy Walker
AZJIO wrote: Thu Mar 13, 2025 10:26 am
The sound in the thread does not block the window.
Hmmm. THANKS AZJIO -- I never messed with threads before. Maybe I should tick the thread safe option?
I can't pretend to know what Asc in this If line is doing:
If Asc(ini_Signal$) And FileSize(ini_Signal$) > 0 And InitSound()
Re: [SOLVED] No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Thu Mar 13, 2025 7:55 pm
by AZJIO
Randy Walker wrote: Thu Mar 13, 2025 7:24 pm
I can't pretend to know what Asc in this If line is doing:
This checks that the row is not empty. If there is any character in it, it returns a number greater than zero. If Null, it returns 0. This is the fastest way to check that the row is not empty. This function takes the first character and returns the code of the number. More precisely, the string is binary data, the first binary code is taken, for example, for "A" it is 65. It is not necessary to read the entire string, just take the first character and check that it is not 00. An empty string ends with a null-terminated 00 character, so if we take an empty string, we get 0.
Randy Walker wrote: Thu Mar 13, 2025 7:24 pm
Maybe I should tick the thread safe option?
yes
Re: [SOLVED] No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Thu Mar 13, 2025 8:03 pm
by Randy Walker
AZJIO wrote: Thu Mar 13, 2025 7:55 pm
Randy Walker wrote: Thu Mar 13, 2025 7:24 pm
I can't pretend to know what Asc in this If line is doing:
This checks that the row is not empty. If there is any character in it...
Maybe I should tick the thread safe option?
yes
Got it. THANKS AZJIO !!!!
Re: [SOLVED] No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Thu Mar 13, 2025 8:07 pm
by AZJIO
Modern operating systems do not provide access to the system speaker, the squeaker. Sometimes this sound is emulated on an audio card. I used to play with this by creating
melodies, now I realize that you can't hear it on many computers.
Re: [SOLVED] No Sound at All (Windows 11 Pro / PB v5.62)
Posted: Fri Mar 14, 2025 1:59 am
by Randy Walker
AZJIO wrote: Thu Mar 13, 2025 8:07 pm
Modern operating systems do not provide access to the system speaker, the squeaker. Sometimes this sound is emulated on an audio card.
Yeah, works here ok but comes out sound card, yep.