Phase Shifting
Two audio waveforms, rendered as black lines on an SVG, visualize the phase-shifting technique from Steve Reich’s *Come Out* and *It’s Gonna Rain*. The top waveform shows the original track, while the bottom one offsets the second channel by a user-selected millisecond delay, creating repeating phase patterns. Controls let the viewer load either piece, step the offset manually, reset it, or play the sound while a red rectangle tracks playback position. The code uses D3 v4’s `d3.line` and `d3.scaleLinear` to draw the waveforms, and the Web Audio API’s `AudioContext` and `BufferSource` to manipulate and play the audio data.
AI-generated descriptionThis is an experiment in manipulating audio at the bit level, using the Web Audio API. It's also a kind of homage to a couple Steve Reich pieces: <a href="https://en.wikipedia.org/wiki/Come_Out_(Reich)">Come Out</a> and <a href="https://en.wikipedia.org/wiki/It%27s_Gonna_Rain">It's Gonna Rain</a>. Where Reich spliced audio tape, this offsets the second track on each repetition, thus creating the phase.
- The select menu at the top left selects between the two pieces.
- Another select menu adjusts the phase offset/rate of change.
- The 'One Step' button lets you skip forward if you get impatient.
- And the 'Reset' button brings the two tracks back into phase.
Also see: <a href="http://bl.ocks.org/alexmacy/f25c39867546f8c72af13cb7e5bc654a">I Am Sitting in a Room - Alvin Lucier</a>