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 »

That snippet (with "SetAudio" changed to "Set Audio") has the volume the same for both plays - too low. It doesn't go up to normal for the second play like the PB code does.
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 »

I just added another snippet :P
Egypt my love
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 »

Same. Equal but volume too low.
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 »

Just encase there's some doubt regarding it not being PB fault.

If you played that file with your associated media player, and the playback begins with the low volume and increases. We know PureBasic isn't responsible then. :wink:
ʽʽ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 »

Yup that's what happened. Definitely nothing to do with PB.
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 »

I wish I was with Windows 8.1. I would see if this issue is shared.
ʽʽ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 »

I'm grasping at straws... Have you tried with another set of speakers or even with an headset?
ʽʽ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 »

Nah I don't really care. As long as my code doesn't have a bug and PB doesn't have a bug I'm fine.
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 »

It might be a problem with one of the sound affects faulting.
  • 1) Right-click on Volume systray Icon
    2) Select "Playback devices"
    3) Double click on "Speakers"
    4) Click the 'Enhancements' tab
    5) Check "Disable all sound effects"
    6) Click OK.
Wait couple of seconds and test.
ʽʽ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
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: Sound volume wrong on first PlaySound()

Post by SeregaZ »

i have some file mono, 8 bit wav. how i can make some change volume of it? i try to make some like this:

Code: Select all

Number.a = ReadAsciiCharacter(0)
limit = 5
if Number > $80+limit
  Number - limit
elseif Number < $80-limit
  Number + limit
endif
WriteAsciiCharacter(1, Number)
when limit is 5 - it give just little sound down, but when i set to more value 30 for more silence - it play more silence, but add some hiss effect. how to correct make this lower or louder sound?
User avatar
kenmo
Addict
Addict
Posts: 2056
Joined: Tue Dec 23, 2003 3:54 am

Re: Sound volume wrong on first PlaySound()

Post by kenmo »

Code: Select all

Number.a = ReadAsciiCharacter(0)
Number = (Number - 127.5) * 0.25 + 127.5  ; scaling = 0.25
WriteAsciiCharacter(1, Number)
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: Sound volume wrong on first PlaySound()

Post by SeregaZ »

thanks. no any hiss :)
User avatar
kenmo
Addict
Addict
Posts: 2056
Joined: Tue Dec 23, 2003 3:54 am

Re: Sound volume wrong on first PlaySound()

Post by kenmo »

Visualized, for fun:

Code: Select all

Procedure Update()
  Value1 = GetGadgetState(1)
  Value2 = GetGadgetState(2)
  ShowSine = GetGadgetState(3)
  If StartDrawing(CanvasOutput(0))
    Box(0, 0, OutputWidth(), OutputHeight(), $FFFFFF)
    Box(256, 0, 1, OutputHeight(), $e0e0e0)
    For i = 0 To 255
      If (ShowSine)
        x = 255.0 * (0.5 + 0.5 * Sin(2 * #PI * i / 256))
      Else
        x = i
      EndIf
      
      If (x > $80 + Value1) ; Method 1
        y = x - Value1
      ElseIf (x < $80 - Value1)
        y = x + Value1
      Else
        y = x
      EndIf
      Box(i, 255-y, 1, 512, $f0f0FF)
      Box(i, 255-y, 1, 1, $0000FF)
      
      scale.f = 1.0 - Value2 / 255.0
      y = (x - 127.5) * scale + 127.5 ; Method 2
      Box(i + 256, 255-y, 1, 512, $f0FFf0)
      Box(i + 256, 255-y, 1, 1, $00c000)
    Next i
    StopDrawing()
  EndIf
  GadgetToolTip(1, "Limit = " + Str(Value1))
  GadgetToolTip(2, "Reduce = " + Str(Value2) + "/255")
EndProcedure

OpenWindow(0, 0, 0, 256*2, 256 + 30 + 25, "Test", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CanvasGadget(0, 0, 0, 256*2, 256)
TrackBarGadget(1, 0, 256, 256, 30, 0, 255)
  SetGadgetState(1, Value1)
TrackBarGadget(2, 256, 256, 256, 30, 0, 255)
  SetGadgetState(2, Value2)
CheckBoxGadget(3, 256, 256 + 30, 256, 20, "Show as Sine waves")
  SetGadgetState(3, ShowSine)

BindEvent(#PB_Event_Gadget, @Update())
Update()
Repeat : Until (WaitWindowEvent() = #PB_Event_CloseWindow)
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: Sound volume wrong on first PlaySound()

Post by SeregaZ »

i have old PB... not see how it work :) but my looks like this:
Image
green borders it is sample cut borders. soon i will plug your volume control. it will be converter for midi music to sega mega drive games with sample recording tab.
Post Reply