Skip to main content

songbird-record

Audio and MIDI recording — capture input from hardware devices into clips.

Module Map

songbird-record/src/
├── lib.rs                — Public API, recording state machine
├── audio_recorder.rs     — Audio recording (cpal input → ring buffer → WAV file)
├── midi_recorder.rs      — MIDI recording (midir input → timestamped events → clip)
└── loopback_recorder.rs  — Loopback recording (capture engine output)

Recording Modes

Audio Recording

Captures audio from a cpal input device into a WAV file:
let mut recorder = AudioRecorder::new(sample_rate, channels);
recorder.start("/path/to/recording.wav");
// ... audio callback feeds samples via push_samples() ...
recorder.stop(); // Finalizes WAV file

MIDI Recording

Captures MIDI events with beat-accurate timestamps:
let mut recorder = MidiRecorder::new();
recorder.start(bpm, time_sig);
recorder.record_event(MidiEventKind::NoteOn { note: 60, velocity: 100, channel: 0 }, beat_position);
let clip = recorder.stop(); // Returns a Clip with MidiNote data

Loopback Recording

Captures the engine’s master output (for bounce-to-disk or “what you hear” recording):
let mut recorder = LoopbackRecorder::new(sample_rate, channels);
recorder.start("/path/to/loopback.wav");
// ... engine feeds output samples ...
recorder.stop();

Testing

cargo test -p songbird-record