Sound volume wrong on first PlaySound()

Windows specific forum
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Sound volume wrong on first PlaySound()

Post by netmaestro »

@RASHAD:

Here's a snippet to try, you should hear two soft clicks and then two loud clicks:

Code: Select all

InitNetwork()
file$ = GetTemporaryDirectory()+"click.wav"
If FileSize(file$) = -1
  Debug "downloading test file"
  If Not ReceiveHTTPFile("http://lloydsplace.com/click.wav", file$)
    Debug "could not download sound"
    End
  EndIf
Else
  Debug "test file found"
EndIf

InitSound()
LoadSound(0,file$)

SoundVolume(0, 10) 
Delay(1000)

PlaySound(0) 
Delay(1000) 

PlaySound(0) 
Delay(1000)

SoundVolume(0, 100) 

PlaySound(0) 
Delay(1000) 

PlaySound(0) 
Delay(1000)
BERESHEIT
Thade
Enthusiast
Enthusiast
Posts: 266
Joined: Sun Aug 03, 2003 12:06 am
Location: Austria

Re: Sound volume wrong on first PlaySound()

Post by Thade »

@thunder
That saves the problem for the ones who are able to do it. But the majority of Win 8 users will not be able to use your program because they will not go through that hassle ... that's why I decided not to use wavs anymore ...
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Re: Sound volume wrong on first PlaySound()

Post by RASHAD »

Yes it is OK
So maybe a small delay time after SoundVolume() will solve the conflict
It looks like a puzzle
I am out of here :mrgreen:
Egypt my love
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Sound volume wrong on first PlaySound()

Post by Thunder93 »

It is called troubleshooting. If a person is willing to install / update codec packages, especially K-Lite.. be prepared to encounter problems at some point ... and be prepared to troubleshoot. Unless you willing to workaround like you have with your issue by now always converting all wav files which does seem like more of a hassle to me... than to take a few minutes to address the problem.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Sound volume wrong on first PlaySound()

Post by netmaestro »

@Thunder93:

Ok, I followed the steps you outlined:

Before taking steps: Short sound plays softly the first time, full volume thereafter.

-uninstall k-lite package and MPClassic
-restart computer
-check for updates
-windows update says there's a broken codec, this is an important update
-windows update downloads/installs all available updates
-restart computer, it is perfectly up to date

After taking steps: Short sound plays softly the first time, full volume thereafter.

-shit. Thade has it right...

Thanks for the assistance though, it's been quite helpful and instructive.
BERESHEIT
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Sound volume wrong on first PlaySound()

Post by Thunder93 »

Then it might be a bad driver install. Upgrading to the latest sound driver package, or re-installing the latest package (first uninstalling and rebooting). ... this would be different than to simply run a broken codec repair utility.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Sound volume wrong on first PlaySound()

Post by netmaestro »

I went into Device Manager and found the following devices under 'Sound, video and game controllers':

AMD High Definition Audio Device
Bluetooth Hands-free Audio
IDT High Definition Audio CODEC

For all three items, I clicked on 'Update Driver Software' and chose the 'Check internet and computer for updated drivers'. In all three cases I was told 'Windows has determined that the driver software for your device is up to date.' So I'm out of ideas...
BERESHEIT
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Sound volume wrong on first PlaySound()

Post by Thunder93 »

There was a small handful of cases that those with the latest Microsoft offered NIC drivers was causing crashes with use of a firewall. When they updated to the latest NIC drivers offered by the manufacture, the problem was addressed. This is just one of a very large list of examples I can give.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Sound volume wrong on first PlaySound()

Post by Thunder93 »

Often enough newer drivers can be found from the computer manufacturer site. If you give me the manufacturer name and model number for that computer, I can point you easily enough directly to the official site and to the official page for your product.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Sound volume wrong on first PlaySound()

Post by netmaestro »

HP Envy 700-059c
BERESHEIT
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Sound volume wrong on first PlaySound()

Post by Thunder93 »

If your package happens to be the latest, then completely uninstalling the existing sound driver package via 'Programs and Features' and rebooting. Then installing the same package may also address the anomaly you experiencing.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Sound volume wrong on first PlaySound()

Post by Thunder93 »

HP Envy 700-059c http://h10025.www1.hp.com/ewfrf/wc/soft ... g=en&cc=ca
netmaestro wrote:HP Envy 700-059c
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Sound volume wrong on first PlaySound()

Post by Thunder93 »

The latest Audio package for Windows 8.1 x64


Released: 2013-10-16

File name: sp63932.exe [1/1, 20.69M]

Version: 6.10.6486.0 Rev. A

Compatibility: Microsoft Windows 8.1 (64-bit)
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Sound volume wrong on first PlaySound()

Post by netmaestro »

I downloaded and ran that file, it said it installed successfully and asked for a restart. After restarting, behavior is unchanged. I'm convinced it's a setting somewhere in Windows 8.1 or possibly a bug in the OS. A longer .wav file plays at full volume and after several careful tests I'm sure it isn't starting out low, it seems to be at full volume for the whole duration. Which suggests it's a bug in Windows as something deliberate would probably start a longer .wav out low for the first part of a second and then go to full volume. I guess, anyway. Just casting around for things that seem to make sense.
BERESHEIT
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Re: Sound volume wrong on first PlaySound()

Post by RASHAD »

@NM
Try the next snippet and tell the difference if any
It is exact as your first post but using MCI

Code: Select all

InitNetwork()
file$ = GetTemporaryDirectory()+"click.wav"
If FileSize(file$) = -1
  Debug "downloading test file"
  If Not ReceiveHTTPFile("http://lloydsplace.com/click.wav", file$)
    Debug "could not download sound"
    End
  EndIf
Else
  Debug "test file found"
EndIf

mciSendString_("OPEN "+Chr(34)+file$ +Chr(34)+" Type MPEGVIDEO ALIAS "+Str(1),0,0,0) 
mciSendString_("SetAudio "+Str(1)+" volume to "+Str(100),0,0,0) 
mciSendString_("Play "+Str(1),0,0,0)
Delay(1000)

mciSendString_("Play "+Str(1)+" from "+Str(0),0,0,0) 
Delay(1000)
Edit :
There was as I remember another discussion about WAV files and PlaySound()
Will you try the next snippet as well

Code: Select all

InitNetwork()
file$ = GetTemporaryDirectory()+"click.wav"
If FileSize(file$) = -1
  Debug "downloading test file"
  If Not ReceiveHTTPFile("http://lloydsplace.com/click.wav", file$)
    Debug "could not download sound"
    End
  EndIf
Else
  Debug "test file found"
EndIf

InitMovie()
LoadMovie(0,file$)
MovieAudio(0, 100, 0)
PlayMovie(0,0)
Delay(1000)

PlayMovie(0,0)
Delay(1000)
Last edited by RASHAD on Sat Oct 25, 2014 11:17 pm, edited 2 times in total.
Egypt my love
Post Reply