home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / sound / sound.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-21  |  2.2 KB  |  83 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2550
  5.    ClientLeft      =   3690
  6.    ClientTop       =   2370
  7.    ClientWidth     =   2370
  8.    Height          =   2955
  9.    Left            =   3630
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2550
  12.    ScaleWidth      =   2370
  13.    Top             =   2025
  14.    Width           =   2490
  15.    Begin CommandButton Command3 
  16.       Caption         =   "Stop Sound/Siren"
  17.       Height          =   615
  18.       Left            =   240
  19.       TabIndex        =   2
  20.       Top             =   1680
  21.       Width           =   1815
  22.    End
  23.    Begin CommandButton Command2 
  24.       Caption         =   "Play Siren"
  25.       Height          =   615
  26.       Left            =   240
  27.       TabIndex        =   1
  28.       Top             =   840
  29.       Width           =   1815
  30.    End
  31.    Begin CommandButton Command1 
  32.       Caption         =   "Play Sound"
  33.       Height          =   615
  34.       Left            =   240
  35.       TabIndex        =   0
  36.       Top             =   120
  37.       Width           =   1815
  38.    End
  39. Option Explicit
  40. DefInt A-Z
  41. Dim SoundStat%
  42. Sub Command1_Click ()
  43. PlaySounds
  44. End Sub
  45. Sub Command2_Click ()
  46. PlaySiren
  47. End Sub
  48. Sub Command3_Click ()
  49. Dim x%
  50. If SoundStat% <> 0 Then
  51.     x% = StopSound()
  52.     CloseSound
  53.     SoundStat% = 0
  54. End If
  55. End Sub
  56. Sub PlaySiren ()
  57. Dim SoundVal&, Freq%, Duration%, OffSet%, x%
  58. If SoundStat% = 0 Then SoundStat% = OpenSound%()
  59. x% = SetVoiceQueueSize(1, 1000)
  60. x% = SetVoiceAccent(1, 120, 255, 1, 0)
  61. Freq% = 800
  62. Duration% = 10
  63. OffSet% = 5
  64.     SoundVal& = CLng(Freq%) * &H1000
  65.     x% = SetVoiceSound%(1, SoundVal&, Duration%)
  66.     Freq% = Freq% + OffSet%
  67.     If Freq% >= 1000 Then OffSet% = -5
  68.     If Freq% <= 800 Then OffSet% = 5
  69. Loop While x% = 0
  70. x% = StartSound%()
  71. End Sub
  72. Sub PlaySounds ()
  73.     Dim Note%, Duration%, x%
  74.     If SoundStat% = 0 Then SoundStat% = OpenSound%()
  75.     x% = SetVoiceQueueSize(1, 1024)
  76.     Do
  77.         Note% = Int(Rnd * 84 + 1)
  78.         Duration% = 2 ^ Int(Rnd * 4)
  79.         x% = SetVoiceNote%(1, Note%, Duration%, 1)
  80.     Loop While x% = 0
  81.     x% = StartSound%()
  82. End Sub
  83.