RosettaCodeData/Task/Record-sound/Liberty-BASIC/record-sound-2.basic
2023-07-01 13:44:08 -04:00

34 lines
1.2 KiB
Text

print "Starting 5 sec. recording..."
r$ =mciSendString$( "open new type waveaudio alias capture")
r$ =mciSendString$( "set capture time format ms bitspersample 16")
r$ =mciSendString$( "set capture channels 1 samplespersec 8000")
r$ =mciSendString$( "set capture alignment 1 bytespersec 8000")
r$ =mciSendString$( "record capture")
timer 5000, [on]
wait
[on]
timer 0
print " .... now stopping the recording."
r$ =mciSendString$( "stop capture")
r$ =mciSendString$( "save capture " +chr$( 34) +"sample.wav" +chr$( 34))
r$ =mciSendString$( "close capture")
print "Done recording."
r$=mciSendString$( "open " +q$ +"sample.wav" +q$ +" type waveaudio alias sfx")
r$=mciSendString$( "play sfx wait")
r$=mciSendString$( "close sfx")
print "Done playing back."
end
function mciSendString$( s$)
print s$
buffer$ =space$( 1024) +chr$( 0)
calldll #winmm, "mciSendStringA", s$ as ptr, buffer$ as ptr, 1028 as long, 0 as long, r as long
buffer$ =left$( buffer$, instr( buffer$, chr$( 0)) -1)
if r >0 then
mciSendString$ ="error"
print "returned "; mciSendString$
else
mciSendString$ =""'buffer$
print "OK"
end if
end function