I was asked about playing a .WAV file, I'm not much of a sound expert,
but ARMbasic has enough performance to do the SOUND function of PBASIC
in BASIC, so if you don't mind the square wave computerie sound using
something like this --
' freq in Hz
' duration in msec
sub sqwave (pin, freq, duration)
dim start as integer
dim period as integer
freq = 500000/freq ' freq now 1/2 period in uSec
duration = duration * 1000 ' duration in uSec
output pin
start = TIMER
while (TIMER-start) < duration
period = TIMER
high pin
while (TIMER-period) < freq
loop
low pin
period = TIMER
while (TIMER - period) < freq
loop
loop
input pin
end sub
main:
sqwave (0,220,500)
sqwave (0,233,500)
sqwave (0,247,500)
sqwave (0,262,500)
sqwave (0,277,500)
sqwave (0,294,500)
sqwave (0,311,500)
sqwave (0,330,500)
sqwave (0,349,500)
sqwave (0,370,500)
sqwave (0,392,500)
sqwave (0,415,500)
sqwave (0,440,500)
-----------------
I added -- 1K --- 1K ----- audio amp (my PC speaker)
| |
0.1uF 0.01uF
| |
V V
This could probably also be adapted to do polyphonic sounds using HIGH
LOW and INPUT to do multiple frequencies.