Beeping (when I am tired I do things like this

Share your advanced PureBasic knowledge/code with the community.
User avatar
Psychophanta
Addict
Addict
Posts: 4997
Joined: Wed Jun 11, 2003 9:33 pm
Location: Lípetsk, Russian Federation
Contact:

Beeping (when I am tired I do things like this

Post 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
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB :mrgreen:
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

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

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

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

Post 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.
Post Reply