Sub Process_Globals
Dim streamer As AudioStreamer
Dim timer1 As Timer
Dim freq As Int = 500
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
streamer.Initialize("streamer", 11025, True, 16, streamer.VOLUME_MUSIC)
streamer.StartPlaying
timer1.Initialize("timer1", 1000)
End If
timer1.Enabled = True
End Sub
Sub Timer1_Tick
Log(freq)
Beep(1000, freq)
freq = freq + 500
End Sub
Sub Beep(Duration As Int, Frequency As Int)
Dim dur As Double = Duration / 10000
Dim sampleRate As Int = 11025
Dim numSamples As Int = sampleRate * dur
Dim snd(2 * numSamples) As Byte
For i = 0 To numSamples - 1
Dim d As Double = Sin(2 * cPI * i / (sampleRate / Frequency))
Dim val As Short = d * 32767
snd(i * 2) = Bit.AND(0xff, val)
snd(i * 2 + 1) = Bit.ShiftRight(Bit.AND(0xff00, val), 8)
Next
streamer.Write(snd)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
timer1.Enabled = False
End Sub