| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version |
Arguments: device &key from to notify-p wait-p insert-p overwrite-p
Records audio that may be saved as a .wav file by
calling mci-save.
device is an mci-wave-audio
instance. from may be nil
to default to recording at the end of the
already-recorded audio on this device (if any), or else an integer
indicating the starting position within the already-recorded audio
(see mci-device-set-time-format and
tmsf-to-integer)
from which to begin overwritting. to may be
either nil
to default to recording
indefinitely until mci-stop is called, or else a
position indicating the position at which to stop recording
automatically.
If the wait-p argument is specified true, this
function will not return until the action is completed. If nil
, this function is run asynchronously. If
notify-p is true, mci-notify will be called when this
function completes.
See cg-mci.htm for information about MCI support in Common Graphics.
Here is a sample recording session as a series of top-level forms that may be evaluated sequentially in the IDE editor, for example. Note that mci-record returns immediately though recording continues until the mci-stop call is made. A real application would typically have widgets that make these calls.
When recording audio, a microphone or other audio input must be connected to a sound card, with a driver for that sound card selected as the default audio device in Control Panel. The sound card may have a mixer applet in which you must select the current recording input jack(s) and level.
(use-package :cg) ;; Create and open a wave audio device for recording. (setq wav (make-instance 'mci-wave-audio)) (mci-open wav) ;; Check the default audio quality (low). (mci-device-bits-per-sample wav) ;; ==> 8 (mci-device-samples-per-second wav) ;; ==> 11025 (mci-device-channels wav) ;; ==> 1 (monophonic) ;; Set higher quality audio before recording. (mci-set-wave-options wav :bits-per-sample 16 :samples-per-second 48000 :channels 1) ;; still monophonic for now ;; Try a recording. (mci-record wav) ;; recording starts now (start talking ...) (mci-stop wav) ;; recording stops now (mci-record wav) ;; append more recording to the end (mci-stop wav) ;; stop again ;; Save the recording so far to a .wav file. (mci-save wav :file "c:\\temp1.wav") ;; Play back what we've recorded. (mci-seek wav :seek-to-start-p t) ;; rewind to beginning (mci-play wav) ;; play from current position (mci-stop wav) ;; interrupt a long playback ;; Start over, re-using the same device. (mci-delete wav) ;; delete everything recorded so far (mci-set-wave-options wav ;; try a stereo recording this time :bits-per-sample 16 :samples-per-second 48000 :channels 2) ;; stereo (mci-record wav) ;; record from scratch (mci-stop wav) ;; stop recording ;; Try "editing out" a middle section of the recording. (mci-seek wav :seek-to-start-p t) ;; rewind to beginning (mci-play wav) ;; play the recording for a little while (mci-stop wav) ;; stop in the middle of playback (setq from (mci-device-position wav)) ;; remember where we stopped (mci-play wav) ;; play back a bit further (mci-stop wav) ;; stop playback again (setq to (mci-device-position wav)) ;; remember where we stopped again (mci-delete wav :from from :to to) ;; delete the middle section (mci-seek wav :seek-to-start-p t) ;; rewind to beginning (mci-play wav) ;; play the edited recording ;; Save the edited recording over the file that was saved earlier. (mci-save wav :file "c:\\temp1.wav") (mci-close wav) ;; close the device when we're done with it
Copyright (c) 1998-2022, Franz Inc. Lafayette, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2019.8.20.
| Allegro CL version 10.1 Unrevised from 10.0 to 10.1. 10.0 version |