Page 1 of 1

Beeping (when I am tired I do things like this

Posted: Tue Dec 26, 2017 9:44 pm
by Psychophanta
Soundcard not needed:

Code: Select all

Global.l dur=80,para1=900,sum=800
Procedure beeper(*tim.unicode)
  Protected t.u
  For t=1 To *tim\u
    Beep_(Random(para1)+sum,dur)
  Next
EndProcedure

OpenWindow(0,0,0,240,180,"Soundcard not needed",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
ButtonGadget(0,10,10,70,30,"START",#PB_Button_Toggle)
TrackBarGadget(1,10,50,200,40,1,300):SetGadgetState(1,dur)
TrackBarGadget(2,10,90,200,40,10,1E4):SetGadgetState(2,para1)
TrackBarGadget(3,10,130,200,40,0,1E4):SetGadgetState(3,sum)
TextGadget(4,210,60,50,25,Str(dur))
TextGadget(5,210,100,50,25,Str(para1))
TextGadget(6,210,140,50,25,Str(sum))
u.u=40000
thr.i=CreateThread(@beeper(),@u):PauseThread(thr)
Repeat
  Event.i=WaitWindowEvent()
  Select Event
  Case #PB_Event_Gadget
    eventgadget.i=EventGadget()
    Select eventgadget
    Case 0:If GetGadgetState(0):SetGadgetText(0,"STOP"):ResumeThread(thr):Else:SetGadgetText(0,"START"):PauseThread(thr):EndIf
    Case 1
      dur=GetGadgetState(1)
      SetGadgetText(4,Str(dur))
    Case 2
      para1=GetGadgetState(2)
      SetGadgetText(5,Str(para1))
    Case 3
      sum=GetGadgetState(3)
      SetGadgetText(6,Str(sum))
    EndSelect
  EndSelect
Until Event=#PB_Event_CloseWindow

Re: Beeping (when I am tired I do things like this

Posted: Tue Dec 26, 2017 9:59 pm
by nco2k
as a side note, Beep_() is not supported in vista and xp 64. since win7, Beep_() sends the signal to the sound device. in xp 32 and earlier, it used to send the signal to the internal system speaker.

c ya,
nco2k

Re: Beeping (when I am tired I do things like this

Posted: Wed Dec 27, 2017 12:28 am
by Dude
Sound cards are obsolete, as motherboards have sound chips built-in. Been that way for many years. Can't remember the last time I saw a sound card for sale, or even inside a PC tower.