; Sound: a scale and a siren

BYTE clock=20                ; this byte grows by 1 fifty times a second

PROC Wait(BYTE ticks)
  clock=0
  WHILE clock<ticks
  DO
  OD
RETURN

PROC Main()
  BYTE ARRAY notes=[121 108 96 91 81 72 64 60]   ; C D E F G A B C
  BYTE i, pitch

  PrintE("A scale...")
  FOR i=0 TO 7
  DO
    Sound(0, notes(i), 10, 8)        ; voice, pitch, pure tone, volume
    Wait(15)
  OD
  SndRst()                           ; silence
  Wait(25)

  PrintE("A siren...")
  FOR i=1 TO 3
  DO
    FOR pitch=40 TO 100 STEP 4
    DO
      Sound(0, pitch, 10, 10)
      Wait(1)
    OD
  OD
  SndRst()

  PrintE("Two voices together...")
  Sound(0, 121, 10, 8)
  Sound(1, 81, 10, 8)
  Wait(50)
  SndRst()

  PutE()
  Print("Press any key")
  GetD(7)
RETURN
