Recording Callbacks
The current record implementation supports both direct recording and callback-driven asynchronous recording.
Direct Recording
Direct recording returns an audio value immediately.
x = record
y = record(0, 1000, 1)
Current argument meaning:
device_idduration_mschannelsblock_ms
For ordinary record(), the engine currently accepts up to three explicit arguments:
record()record(device_id)record(device_id, duration_ms)record(device_id, duration_ms, channels)
Callback Form
The async form uses a callback name:
h = record(0, -1, 1, 100).cb1
In the current engine:
- the callback form can take up to four arguments:
device_id,duration_ms,channels,block_ms duration_msmay be-1for indefinite recordingchannelsmust currently be1or2block_msmust be positive
The callback name after the dot is required in callback mode.
Callback Payload
The current callback payload contains:
sample_ratenum_channelscallback_indexinterleaved
In AUX callback code, this payload is exposed through the input argument. The checked-in example cb1.aux uses:
in.?indexto detect the open callin.?datafor later audio blocks
That means the callback is invoked in phases:
- callback index
0: open/setup phase - callback index
1and later: recorded block delivery
Example
This example is already present in the repo and shows a plotting callback:
function [out,h,ax]=cb1(in)
if in.?index==0
out = []
h=figure
ax = axes(h)
ax.xlim=[0 10]
else
out ++= in.?data
plot(ax, out)
ax.xlim=[0 10]
repaint(h)
end
This pattern is useful because the callback can both:
- accumulate captured audio into
out - create and update graphics handles across callback invocations
Handle State During Recording
The runtime recording handle currently carries members such as:
typeiddevIDfschannelsdurblockdurRecdurLeftprogactivepaused
These fields are updated while recording progresses, and auxlab2 also attaches callback outputs back onto the handle state when possible.
Notes
- Callback output and preview text may appear in the
auxlab2console. - In
auxlab2, callback failures stop the recording session. - Recording support depends on an installed playback/recording backend in the active frontend.
Current source basis:
aux_engine/src/func/record_builtin.cppaux_engine/include/auxe/auxe.hauxlab2/src/AuxEngineFacade.cppauxlab2/src/MainWindow.cppauxlab2/cb1.aux