Record sound: Difference between revisions
Content deleted Content added
Capra Hircus (talk | contribs) mNo edit summary |
Added BBC BASIC |
||
Line 4:
(This task neglects to specify the sample rate, and whether to use signed samples. The programs in this page might use signed 16-bit or unsigned 16-bit samples, at 8000 Hz, 44100 Hz, or any other sample rate. Therefore, these programs might not record sound in the same format.)
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<lang bbcbasic> wavfile$ = @dir$ + "capture.wav"
bitspersample% = 16
channels% = 2
samplespersec% = 44100
alignment% = bitspersample% * channels% / 8
bytespersec% = alignment% * samplespersec%
params$ = " bitspersample " + STR$(bitspersample%) + \
\ " channels " + STR$(channels%) + \
\ " alignment " + STR$(alignment%) + \
\ " samplespersec " + STR$(samplespersec%) + \
\ " bytespersec " + STR$(bytespersec%)
SYS "mciSendString", "close all", 0, 0, 0
SYS "mciSendString", "open new type waveaudio alias capture", 0, 0, 0
SYS "mciSendString", "set capture" + params$, 0, 0, 0 TO res%
IF res% ERROR 100, "Couldn't set capture parameters: " + STR$(res% AND &FFFF)
PRINT "Press SPACE to start recording..."
REPEAT UNTIL INKEY(1) = 32
SYS "mciSendString", "record capture", 0, 0, 0 TO res%
IF res% ERROR 100, "Couldn't start audio capture: " + STR$(res% AND &FFFF)
PRINT "Recording, press SPACE to stop..."
REPEAT UNTIL INKEY(1) = 32
SYS "mciSendString", "stop capture", 0, 0, 0
SYS "mciSendString", "save capture " + wavfile$, 0, 0, 0 TO res%
IF res% ERROR 100, "Couldn't save to WAV file: " + STR$(res% AND &FFFF)
SYS "mciSendString", "delete capture", 0, 0, 0
SYS "mciSendString", "close capture", 0, 0, 0
PRINT "Captured audio is stored in " wavfile$</lang>
=={{header|C}}==
|