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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- 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)