start
Description
start( starts playing and/or recording for
the as)audiostreamer
object, as. The behavior of start depends on
the operating mode of as and whether audio is already streaming. For
more information, see Algorithms.
start(
specifies options using one or more name-value arguments.as,Name=Value)
Examples
Input Arguments
Name-Value Arguments
Tips
These pseudocode examples illustrate best practice when using the
audiostreamer object functions start and
write in different workflows.
Read and write in full-duplex mode.
as = audiostreamer("full-duplex"); start(as) % start rec., enable play for ii = 1:100 x = read(as,1024); % blocks y = process(x); write(as,y); end stop(as)
Pre-buffer for measurement sequences.
as = audiostreamer("full-duplex"); swLatency = sweeptone(0.5,2); swMeasure = sweeptone(5,2); N1 = length(swLatency); N2 = length(swMeasure); % avoid creating temporary vector write(as,swLatency) write(as,swMeasure) write(as,swMeasure) start(as) recLatency = read(as,N1); recMeasure = read(as,N2*2); plot(impzest(x,recMeasure))
Play audio from file stream without blocking.
as = audiostreamer; afr = dsp.AudioFileReader; while ~afr.isDone write(as,afr()); % pre-buffer end start(as)
Play audio without blocking (one shot).
as = audiostreamer; % Pre-fill to avoid blocking write(as,x) % fills the output queue start(as) % or play
Record a predetermined length of audio.
as = audiostreamer("recorder",… RecorderChannels=1); % Start the recording (in samples) start(as,RecordingLength=5*44100) % Get the recording (N samples) x = read(as);
Algorithms
The behavior of start depends on the mode and whether audio is
already streaming (because of calls to play, record, or a prior
call to start).
Mode | Behavior |
|---|---|
"player" | The stream is enabled and playback is un-paused/resumed.
|
"recorder" |
|
"both" |
|
Version History
Introduced in R2026a