Lab 6 Tasks
Requested Functions
int audio_map_buffer(void)int audio_fill_square_wave(uint32_t hz, uint32_t ms)int audio_play(size_t byte_count)int audio_stop(void)
Guided Gaps
- Reject zero frequency or duration.
- Compute samples per half-period.
- Pick amplitude without clipping.
- Keep byte count and sample count separate.
- Make
audio_stopsafe when nothing is playing.
IMPORTANT
Do not write past the mapped audio buffer. Duration, sample rate, channels, and bytes per sample must agree before writing.
Common Mistakes
- Using frequency where period is required.
- Treating milliseconds as samples.
- Writing one channel when stereo is expected.
- Starting playback before filling the buffer.
Next: checks and references.