matlab-play-record-audio

Play and record audio in MATLAB using the audiostreamer device I/O API.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-play-record-audio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-play-record-audio
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/signal-processing/matlab-play-record-audio
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-play-record-audio

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Agents default to legacy audio APIs like audioDeviceWriter, audioDeviceReader, or sound(), producing less capable MATLAB code for audio hardware I/O. This Skill provides the correct patterns for the unified audiostreamer object introduced in Audio Toolbox R2025a.

Core Features & Use Cases

  • Unified Device I/O: Configure player, recorder, or full-duplex modes with driver selection (ASIO, WASAPI, CoreAudio, ALSA), channel mapping, and sample rate control.
  • Callbacks and Transport Control: Use PlayerFcn/RecorderFcn callbacks, blocking and non-blocking play/record, start/stop/pause/resume, and loopback latency measurement.
  • Migration Guidance: Replace audioDeviceReader/audioDeviceWriter loops, audioplayer/audiorecorder, and sound() with correct audiostreamer equivalents, avoiding pitfalls like single-channel default recording.
  • Use Case: Run an acoustic measurement by playing a sweep tone and recording the response simultaneously with playrec, then compute the impulse response with impzest.

Quick Start

Ask your agent to write MATLAB code that plays an audio signal through the sound card and records the microphone input simultaneously using audiostreamer.

Frequently Asked Questions about matlab-play-record-audio

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I play and record audio simultaneously in MATLAB?

Create an audiostreamer with Mode="full-duplex" and call playrec(as, x) to play a signal while recording. Use the blocking form playrec(as, x, numSamples) to get the recorded data directly, or read(as) after a non-blocking call.

What replaces audioDeviceReader and audioDeviceWriter in MATLAB?

The audiostreamer object in Audio Toolbox R2025a replaces both with a single unified object supporting player, recorder, and full-duplex modes. It adds callbacks, pre-buffering, transport control, and latency measurement that the legacy objects lack.

Does audiostreamer support ASIO audio devices?

Yes, audiostreamer supports ASIO on Windows, plus DirectSound and WASAPI. On macOS it uses CoreAudio and on Linux ALSA. Set the Driver property at construction and select devices with the Player and Recorder properties.

Why does my MATLAB recording only capture one channel?

audiostreamer records one channel by default because RecorderChannels defaults to 1. Set RecorderChannels=1:2 for stereo or provide a channel mapping vector matching your device's available inputs.

When should I use sound() instead of audiostreamer?

Use sound or soundsc only for a single isolated playback of a short clip with no sequencing. For sequential playback, recording, full-duplex work, or callbacks, use audiostreamer since overlapping sound calls play simultaneously rather than queueing.