Data AcQuisition And Real-Time Analysis
Scope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
The following is from the Daqarta Help system:



Spectrum Analyzer

Signal Generator

(Absolutely FREE!)


Pitch Tracker


DaqMusiq Generator
(Free Music... Forever!)

Engine Simulator

LCR Meter

Remote Operation

DC Measurements

True RMS Voltmeter

Sound Level Meter

Frequency Counter
    Spectral Event

    MHz Frequencies

Data Logger

Waveform Averager


Post-Stimulus Time
Histogram (PSTH)

THD Meter

IMD Meter

Precision Phase Meter

Pulse Meter

Macro System

Multi-Trace Arrays

Trigger Controls


Spectral Peak Track

Spectrum Limit Testing

Direct-to-Disk Recording



Frequency response

Distortion measurement

Speech and music

Microphone calibration

Loudspeaker test

Auditory phenomena

Musical instrument tuning

Animal sound

Evoked potentials

Rotating machinery


Product test

Contact us about
your application!

Sound Card Audible Phase Demonstration


The Audible_Phase macro mini-app is a demonstration of the audibility of relative phase among harmonic tones, using a simple 3-tone scheme.

To run Audible_Phase, hit the F8 key followed by the 'a' key, or hit CTRL+F8 to open the Macro Dialog and double-click on Audible_Phase in the Macro List.

Audible_Phase uses a Custom Controls dialog that allows adjustment of various parameters. You can open this Help topic by right-clicking anywhere in the dialog.

Upon starting Audible_Phase you'll hear 3 simultaneous tones, at 360, 400, and 440 Hz. A Base Frequency control adjusts the lowest tone, while Spacing Frequency changes the separation between tones.

Play WAV sample: Audible Phase Demo (3 sec, headphones recommended)

By default, the phase of the Base tone changes smoothly between 0 and 180 degrees (polarity inversion) once each second. A Base Phase control changes the starting phase, and a Cycle control changes the timing. (The default Cycle is 2 seconds, or one second per phase.)

A Decimate button defaults to Decimate ON, which effectively compresses the time axis by a factor of 5, showing over 100 msec instead of the default 21 msec. This allows you to see multiple cycles of the default tone complex at 25 msec each. You can toggle this button to Decimate OFF to see finer detail.

When the Smooth Changes button state is present (default), the Base phase changes smoothly over a 250 msec interval while maintaining full amplitude of each component. Toggling this button to Tone Bursts results in the 3-tone complex being presented as a discrete burst with 50 msec rise and fall times. Then the Base phase is changed while the burst is off, so the phase alternates between bursts.


Thanks to Robert Adams of the Comp.DSP newsgroup for the original inspiration for this demonstration.


In general, the human ear is not very sensitive to the relative phases of the harmonic components of a sound. (Note that a sound with inharmonic components has relative phases that are continually changing, and won't be considered here.) Changes in phase affect the shape of the waveform, but don't change the fundamental pitch. Even fairly major shape changes may have rather modest effects on the tonal quality or "timbre", typically making the tone slightly "brighter" or "darker".

The most dramatic audible differences arise when going between a case where all harmonics start at zero phase, which produces the waveform with the most prominent peaks, and another alignment which produces minimal peaks.

The Audible_Phase macro provides a continuous alternation between two such cases, each lasting one second (default), with smooth transitions between them. The default tone consists of 3 components: Sine waves of 360, 400, and 440 Hz, with the 400 Hz component having twice the amplitude of the other two.

Play WAV sample: Audible Phase Demo (3 sec, headphones recommended)

Notice that 360, 400, and 440 are all multiples of 40 Hz, and can be regarded as the 9th, 10th, and 11th harmonics of a missing 40 Hz fundamental. (See the Missing Fundamental mini-app to explore that aspect, including the Phase Experiments subtopic.)

The resulting zero-phase alignment looks exactly like a 400 Hz sine with amplitude modulation by a 40 Hz sine modulator at 100% depth. The envelope has peaks every 25 msec, the reciprocal of 40 Hz. Troughs detween the envelope peaks go completely to zero. The crest factor (ratio of absolute peak to RMS) is about 2.6, or 8.3 dB.

However, when the phase of the 360 Hz component is flipped to 180 degrees, the envelope has peaks every 12.5 msec (80 Hz). Peak amplitude is reduced to about 70% and the troughs now go down only to 50% instead of zero. The crest factor drops to about 1.6, or 4.1 dB.

Audibly, the zero-phase condition has a noticeable roughness or trill compared to the the 180-flipped condition, which is about what you might expect just from the waveforms. Another way to think about the pseudo-AM of the zero-phase waveform is as a stream of tone bursts with a 40 Hz repetition rate, so a buzz at that rate should be expected.

The Base Phase control adjusts the initial phase (default 0 degrees) of the base component, to which 180 degrees is added or removed on alternate phase changes. For example, if you set this to 90 the phase of the 360 Hz component will alternate between 90 and 270 degrees relative to the other two components. In this case you will get a waveform that is midway between the above shapes, similar to 40 Hz AM at 60% Depth on a 400 Hz wave with an amplitude of only 90%. It has less audible roughness than the zero-phase case, and it changes only subtly on the 180 degree phase changes.

Play WAV sample: 90 Deg Base Phase (3 sec, headphones recommended)

The above shows the 90 degree condition; the 270 degree condition looks the same, but inverted. (Notice the two nearly-equal positive peaks of the 400 Hz "carrier", compared to the larger single negative peak flanked by two smaller peaks.) This polarity inversion is barely audible, sounding (to the author's ears anyway) as if the overall pitch is just slightly lower in the 270 state than the 90 state.

It's important to note that this sort of subtle detection test can be easily confused by transient effects during the phase change. Since this experiment is intended to compare two different conditions, they must be presented close together in time. But changing things rapidly can cause "spectral splatter" or outright clicks. The default Smooth Changes button state attempts to minimize this problem by making very smooth transitions lasting 250 msec... much longer than needed simply to avoid a click.

Since the polarity effect is subtle at best, you may want to eliminate any possibility of transition effects by toggling Smooth Changes to Tone Bursts. Bursts are 1 second each (default), with phase transitions taking place while all tones are off between bursts.

Another approach to comparing subtle effects is to add a burst of white noise to mask each transition. This option is not included in Audible_Phase but you may want to incorporate it into your own experiments.

How Audible_Phase Works:

The Audible_Phase macro loads the AudPhase.GEN generator setup that does most of the work. It sets up the needed Custom Controls, then activates the _Aud_Phase_Ctrls subroutine that handles control changes. Its main function is to modify settings in the AudPhase.GEN setup according to the control settings.

The setup consists of 3 sine waves, on Left Streams 1, 2, and 3. The tone frequencies default to 360, 400, and 440 Hz, all with phase set to 0. The levels are set to 25, 50, and 25% respectively. This gives the rough-sounding zero-phase "pseudo-AM" waveform shown in the first image above.

To produce the 180-degree phase changes, Stream 1 uses Phase Modulation (PM) with the modulation depth set to 50%. (100% gives +/-360 degrees.) Stream 0 is used as the modulation source for Stream 1 (Stream Modulation), producing a base level of 0 (no modulation) that smoothly rises to 100% for 180 degrees (since modulation depth is 50%).

Stream 0 uses the Burst generator to produce the modulator signal. Here we want only the overall shape of the burst, essentially the envelope that would normally be applied to a tone, but without the tone. To do this we use a trick: Since a sine wave is at its positive peak (100% level) when its phase is at 90 degrees, we set that phase but set the tone frequency to zero. That provides a constant 100% DC signal for Burst shaping, with the result that the generated burst is the envelope itself.

One more trick is used with Stream 0 to generate the trigger sync to get a stable display. Normal trigger mode, which looks for threshold crossings like a conventional oscilloscope, won't work very well on these waveforms. (Look at the images above, and try to pick a level that only happens once per 40 Hz cycle; you have to pick the highest peak, or else the trigger can happen at multiple points in the cycle. But if you pick the highest peak in the zero-phase condition, the 180-degree condition will never hit it!)

Instead, we can use Gen Sync mode to sync directly to a Generator component. But here we want to sync to the 40 Hz separation frequency between the tone components; there is no actual 40 Hz output component to sync to. Luckily, Gen Sync doesn't need an actual output component. Since any modulator can be a sync source, Stream 0 uses its otherwise-unused Phase Modulation (PM) for this, with the modulator frequency set to 40 Hz and the depth depth set to 0 so there is no actual modulation, even though PM is toggled on. Setting PM Sync tells Gen Sync to use the 40 Hz "modulation" frequency, which it cheerfully does without caring that it's only a dummy stand-in.

Audible_Phase Macro Listing:

Close=                             ;Close any open data file
Sgram=0                            ;Spectrogram off
Spect=0                            ;Spectrum off
SpectWindOn=1                      ;Spectrum window on
E.IF.Input=                        ;If Input is enabled,
    Input=0                            ;Force Input off
UX=DecX                            ;Save initial Decimate Factor
DecX=5                             ;New factor to 5x
UD=Decimate                        ;Save initial Decimate state
Decimate=1                         ;Set Decimate on
UT=TrigMode                        ;Save initial Trigger mode
TrigMode=GenSync                   ;Set to Generator sync
Trig=1                             ;Trigger on
SmplSec=Smpl                       ;Set Burst Units to samples
A.LoadGEN="AudPhase"               ;Load Generator setup, no prompt
Ctrls="<<Phase Audibility"         ;Set Custom Controls title
Ctrl0="<<Base Frequency, Hz"       ;Set Ctrl0 label
Ctrl0="<S(20,16000)"               ;Set slider edit type, 20-16000
Ctrl0=360                          ;Default to 360
Ctrl1="<<Spacing Frequency, Hz"
Ctrl2="<<Base Phase, Deg"
Ctrl3="<<Cycle, sec"
Btn0="Decimate ON"                 ;Set Btn0 title
Btn0="<T"                          ;Toggle-type button
Btn0=1                             ;Default to on
Btn1="Smooth Changes"
Btn2="<X"                          ;Btn2-Btn3 hidden

@_Aud_Phase_Ctrls=Ctrls            ;Custom controls run until close
Gen=0                              ;Generator off
TrigMode=UT                        ;Restore initial Trigger mode
Decimate=UD                        ;Restore Decimate state
DecX=UX                            ;Restore Decimate Factor

_Aud_Phase_Ctrls Macro Listing:

IF.Ctrls=<2                        ;Ctrl0 Base Freq or Ctrl1 Spacing
    L.1.ToneFreq=Ctrl0                 ;Update Base freq
    L.2.ToneFreq=Ctrl0 + Ctrl1         ;Update center freq
    L.3.ToneFreq=Ctrl0 + 2 * Ctrl1     ;Update upper freq
    L.0.PMmodFreq=Ctrl1                ;Sync to Spacing freq

IF.Ctrls=2                         ;Ctrl2 Base Phase
    L.1.TonePhase=Ctrl2                ;Set new phase for Base Freq

IF.Ctrls=3                         ;Ctrl3 Cycle
    IF.Btn1=0                          ;Smooth Changes?
        L.0.BurstHigh=(Ctrl3 / 2) -0.25    ;High for 1/2 Cycle, less rise
        L.0.BurstCycle=Ctrl3               ;Full cycle with fall + low
    ELSE.                              ;Tone Bursts
        L.0.BurstHigh=(Ctrl3 / 2) - 0.05   ;Longer High for phase mod
        L.1.BurstHigh=(Ctrl3 / 2) - 0.15   ;Base tone High
        L.1.BurstCycle=Ctrl3 / 2           ;Base tone Cycle
        L.2.BurstHigh=(Ctrl3 / 2) - 0.15   ;Mid tone High
        L.2.BurstCycle=Ctrl3 / 2           ;Mid tone Cycle
        L.3.BurstHigh=(Ctrl3 / 2) - 0.15   ;Upper tone High
        L.3.BurstCycle=Ctrl3 / 2           ;Upper tone Cycle

IF.Ctrls=4                         ;Decimate On/Off
        Btn0="Decimate OFF"
        Btn0="Decimate ON"

IF.Ctrls=5                         ;Smooth Changes / Tone Bursts
    IF.Btn1=0                          ;Smooth Changes?
        Btn1="Smooth Changes"
        L.0.BurstRise=0.25                 ;Longer Rise
        L.0.BurstHigh=(Ctrl3 / 2) - 0.25   ;Shorter High
        L.0.BurstFall=0.25                 ;Longer Fall
        L.1.Burst=0                        ;Tone Bursts off
    ELSE.                              ;Else Tone Bursts
        Btn1="Tone Bursts"
        L.0.BurstRise=0.05                 ;Shorter Rise
        L.0.BurstHigh=(Ctrl3 / 2) - 0.05   ;Longer High
        L.0.BurstFall=0.05                 ;Shorter Fall
        L.1.Burst=1                        ;Tone Bursts on

See also Auditory Phenomena and Experiments, Macro Examples and Mini-Apps


Questions? Comments? Contact us!

We respond to ALL inquiries, typically within 24 hrs.
Over 30 Years of Innovative Instrumentation
© Copyright 2007 - 2017 by Interstellar Research
All rights reserved