# Phase Perception [Open the live app](https://vault1.magland.org/proof-of-concept/phase-perception/site/) A small web app for testing whether a listener can hear the difference between two periodic tones that have the same harmonic amplitudes but different harmonic phases. Both tones are built by additive synthesis from a fundamental frequency f0 and N harmonics: x(t) = sum_k a_k sin(2 pi k f0 t + phi_k). The amplitudes a_k are shared between tone A and tone B; each tone has its own phases phi_k. The app plots one period of each waveform together with the amplitude and phase spectra, so you can see that the waveforms differ while the amplitude spectra do not. The hypothesis under test is that the phases are perceptually irrelevant: the two tones should sound identical. The blind test checks this. Each trial plays two tones in a row, either the same tone twice or A and B in random order, and you answer "same" or "different". The app tallies accuracy and reports the one-sided binomial probability of doing at least that well by guessing. There is also a continuous mode: a steady tone whose harmonic phases glide from A's values to B's and back, following a raised cosine at an adjustable rate. Amplitudes stay fixed, so any audible change is due to phase alone. This mode runs in an AudioWorklet, and edits to the phases, amplitudes, fundamental, or rate take effect while it plays. ## Running npm install npm run dev Then open the printed URL. `npm run build` produces a static site in `dist/` with a relative base path, so it can be served from any subdirectory. ## Notes Both tones are scaled by the same output gain, computed from the amplitudes alone, so they have identical RMS level regardless of phase and cannot clip. Tones are monaural with 10 ms raised-cosine fades. Phase is not always inaudible. Phase differences between harmonics become audible when several harmonics fall within one auditory filter, which happens at low fundamental frequencies (roughly below 100 Hz) or with many high harmonics, and are more easily heard over headphones than loudspeakers. The controls for f0 and the number of harmonics are there to explore these conditions. A planned next step is to extend the test from steady tones to more complex, time-varying sounds.