An iOS app that plays a 440 Hz pulse wave sound and draws a scrolling waveform in sync with the audio.
Screen.Recording.2026-02-13.at.8.11.08.PM.mov
- Plays a 440 Hz pulse wave through the device speaker.
- Displays a scrolling waveform animation that stays in sync with the audio.
- Tap Play to start both the audio and the animation; tap Stop to silence both.
A Remote I/O Audio Unit generates the tone. iOS invokes a render callback each time it needs samples; the callback reads the current phase and duty cycle (0.5 = square wave), writes +0.25 or −0.25 per sample, and advances the phase for the next call.
AVAudioSession is configured for playback so the output routes to the speaker.
PulseWaveView draws the pulse waveform. While playing, a CADisplayLink fires every frame, redrawing the view and advancing its phase at the same frequency and rate as the audio engine to keep the animation in sync with what you hear.
ViewController owns the audio unit, registers itself as the render-callback context (refCon), and manages the Play / Stop toggle and display-link lifecycle.
| Library | Role |
|---|---|
| AudioToolbox | Remote I/O Audio Unit and render callback |
| AVFAudio | AVAudioSession playback configuration and audio session activation |