Project 1: The WAV Player

A command-line program that reads an uncompressed 16-bit PCM WAV file and plays it through your speakers using the native OS audio API.

Quick Reference

Attribute Value
Primary Language C
Alternative Languages N/A
Difficulty Level 3: Advanced
Time Estimate 1-2 weeks
Knowledge Area Low-Level System APIs / Audio Programming
Tooling ALSA (Linux), Core Audio (macOS), or WASAPI (Windows)
Prerequisites Strong C programming skills, including pointers and structs.

What You Will Build

A command-line program that reads an uncompressed 16-bit PCM WAV file and plays it through your speakers using the native OS audio API.

Why It Matters

This project builds core skills that appear repeatedly in real-world systems and tooling.

Core Challenges

  • Parsing the WAV header → maps to reading the first 44 bytes of the file to get format, sample rate, channels, etc.
  • Interfacing with the native audio API → maps to the multi-step process of opening a PCM device, allocating hardware parameters, and setting them
  • Writing audio data in a loop → maps to reading chunks of the WAV file’s data section and writing them to the audio device’s buffer
  • Handling different OS APIs → maps to understanding that this code is inherently non-portable

Key Concepts

  • PCM Audio: The digital representation of a waveform.
  • ALSA Programming Tutorial (Linux): A good starting point for Linux users.
  • Core Audio Overview (macOS): Apple’s documentation on the concepts.
  • WASAPI Documentation (Windows): Microsoft’s official documentation.

Real-World Outcome

Deliver a working demo with observable output that proves the feature is correct.


Implementation Guide

  1. Reproduce the simplest happy-path scenario.
  2. Build the smallest working version of the core feature.
  3. Add input validation and error handling.
  4. Add instrumentation/logging to confirm behavior.
  5. Refactor into clean modules with tests.

Milestones

  • Milestone 1: Minimal working program that runs end-to-end.
  • Milestone 2: Correct outputs for typical inputs.
  • Milestone 3: Robust handling of edge cases.
  • Milestone 4: Clean structure and documented usage.

Validation Checklist

  • Output matches the real-world outcome example
  • Handles invalid inputs safely
  • Provides clear errors and exit codes
  • Repeatable results across runs

References

  • Main guide: LEARN_C_MP3_PLAYER_FROM_SCRATCH.md
  • The official documentation for your OS’s audio API.