Tape API
Access to tape state and transport controls
Get the global tape instance
Returns — Pointer to tape (never NULL after system init)
Get current tape state
| const tape_t* | tape | Tape instance from tape_get() |
Returns — Current state (TAPE_STATE_UNMOUNTED, TAPE_STATE_IDLE, etc.)
Check if tape is idle (not playing or recording)
| const tape_t* | tape | Tape instance from tape_get() |
Returns — true if tape is idle
Get tape length in tape positions (SD sectors)
| const tape_t* | tape | Tape instance from tape_get() |
Returns — Tape length in positions. 1 position = 1 sector = 64 stereo frames, so multiply by 64 to compare against tape_read()/tape_write() frames.
Begin recording session
| tape_t* | tape | Tape instance from tape_get() |
| uint32_t | pos | Starting position in tape POSITIONS (SD sectors), NOT frames. tape_get_position() returns frames — divide by 64. |
| bool | reverse | True for reverse direction |
Returns — Recording handle, or NULL if already recording
Note — This only brackets the take (undo, timeline, mark). It writes NO audio — your engine callback has replaced the one that normally does. Stream your output to the tape with tape_write() between begin and commit.
Commit recording session
| tape_rec_t* | rec | Recording handle from tape_rec_begin() |
| uint32_t | end_pos | End position of recorded region |
Returns — Final end position
Abort recording (discard without creating marks)
| tape_rec_t* | rec | Recording handle |
Check if undo is available for last recording
| const tape_t* | tape | Tape instance from tape_get() |
Returns — true if undo data is valid
Execute undo - restore original audio from last recording
| tape_t* | tape | Tape instance from tape_get() |
Returns — true on success
Number of recording marks on the tape
| const tape_t* | tape | Tape instance from tape_get() |
Returns — Mark count (0 if none / no tape)
Get the start/end of mark `idx`
| const tape_t* | tape | Tape instance from tape_get() |
| uint32_t | idx | Mark index (0 .. tape_marks_count()-1) |
| uint32_t* | start_frame | Output: region start, in stereo frames |
| uint32_t* | end_frame | Output: region end, in stereo frames |
Returns — true if idx is valid and outputs were written
Read recorded audio into a RAM buffer (stereo-interleaved L,R,...)
| const tape_t* | tape | Tape instance from tape_get() |
| uint32_t | pos_frame | Start position in stereo frames |
| float* | dst | Destination buffer (must hold 2*n_frames floats) |
| uint32_t | n_frames | Number of stereo frames to read |
Returns — Number of stereo frames actually read
Warning — Blocks on SD DMA. Call from tick()/init() (main thread), NEVER from the audio process() callback. Sequence the slices yourself in process().
Write audio to the tape (stereo-interleaved L,R,...)
| tape_t* | tape | Tape instance from tape_get() |
| uint32_t | pos_frame | Start position in stereo frames |
| const float* | src | Source buffer (2*n_frames floats) |
| uint32_t | n_frames | Number of stereo frames to write |
Returns — Number of stereo frames actually written
Warning — Blocks on SD DMA. Call from tick()/init() (main thread), NEVER from the audio process() callback.
Current tape playhead position, in stereo frames
| const tape_t* | tape | Tape instance from tape_get() |
Returns — Playhead position (frames)