stop
Syntax
Description
stop( stops both playing and recording for
the as)audiostreamer.
Examples
Create an audiostreamer object with the "recorder" mode.
as = audiostreamer("recorder");Call record to start recording with the audiostreamer. The audiostreamer will record continuously until you pause or stop the recording. Use the MATLAB pause function to wait for three seconds, then call stop on the audiostreamer object to stop recording.
record(as) pause(3) stop(as)
Call read to get all of the available recorded audio from the audiostreamer.
x = read(as);
Alternatively, you can call record with a specified number of samples after which the recording will automatically stop. Calling read with the specified number of samples will block MATLAB execution until that number of samples has been recorded.
N = 3*as.SampleRate; % 3 seconds of samples
record(as,N)
y = read(as,N);You can use a callback function to asynchronously provide audio to the audiostreamer to play. Define your callback as a function that generates pink noise and plays it on the audiostreamer. The callback function takes in the audiostreamer object and a struct containing information about the event that triggered the callback. Create an audiostreamer object and set the PlayerFcn callback to the myPlayerFcn function handle.
function myPlayerFcn(obj,ev) y = randn(1024,1); play(obj,y) end as = audiostreamer; as.PlayerFcn = @myPlayerFcn;
Now calling play on the audiostreamer will call the PlayerFcn callback whenever the number of samples in the output queue drops below PlayerMinSamples.
play(as) pause(3) stop(as)
Input Arguments
The audiostreamer
object that is playing and/or recording the audio.
The audiostreamer mode to stop, specified as
"player", "recorder", or
"both".
Data Types: char | string
Version History
Introduced in R2025a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)