> ## Documentation Index
> Fetch the complete documentation index at: https://songbird.studiocollective.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# songbird-record

# 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:

```rust theme={null}
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:

```rust theme={null}
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):

```rust theme={null}
let mut recorder = LoopbackRecorder::new(sample_rate, channels);
recorder.start("/path/to/loopback.wav");
// ... engine feeds output samples ...
recorder.stop();
```

## Testing

```bash theme={null}
cargo test -p songbird-record
```
