MATH528 Lab09: Sturm-Liouville guitar string example

Input sound

This is the recorded sound from vibration of the (Subscript[E, 2]) guitar string

m=

These are the properties of the sound sample

props={AudioLength,Duration,AudioChannels,AudioSampleRate,AudioType};

Dataset@AssociationThread[props,Through[props[m]]]

Find the sampling frquency

fs=AudioSampleRate[m]

Transform the sound into data

d=AudioData[m];

Dimensions[d]

ListPlot[{d[[1,1;;4096]],d[[2,1;;4096]]},PlotStyle->{Red,Blue} ]

Frequency representation of sound (Fourier transform)

Conformant window

Choose one channel and a window that corresponds to a repeating signal

data=d[[1,5000+270;;5000+2559]];
ListPlot[data]

nd=Length[data]

Compute the Fourier coefficients

nMax=100; dj=2. π/nd;
a=Table[  1/2./nd Sum[data[[j]] Cos[j n dj],{j,1,nd}],{n,1,nMax}];
b=Table[  1/2./nd Sum[data[[j]] Sin[j n dj],{j,1,nd}],{n,1,nMax}];
c2c=Log10[(a^2)+(b^2)];

Find index of largest coefficient

kmx=Position[c2c,Max[c2c]][[1,1]]

Compute the signal period

T=nd/fs

The dominant frequency is

fmx = N[(((T/kmx))^(-1))]

The (Subscript[E, 2]) note should have a frequency of 82.41 Hz, hence the recorded sound is mistuned by

fE2=82.41; fE2G=83.8428;
err = N[(fE2G-fE2)/fE2]

ConformantWindowSpectrum=ListPlot[c2c,PlotStyle->Blue]

Non-conformant window

If the sound sampling window is chosen correctly, for example induces a discontinuity in the derivative as below, the resulting spectrum is affected by aliasing errors

data=d[[1,5000+270;;5000+2870]];
ListPlot[data]

nd=Length[data]

nMax=100; dj=2. π/nd;
a=Table[  1/2./nd Sum[data[[j]] Cos[j n dj],{j,1,nd}],{n,1,nMax}];
b=Table[  1/2./nd Sum[data[[j]] Sin[j n dj],{j,1,nd}],{n,1,nMax}];
c2c=Log10[(a^2)+(b^2)];

NonConformantWindowSpectrum=ListPlot[c2c,PlotStyle->Red]

Show[ConformantWindowSpectrum,NonConformantWindowSpectrum]

Notice that the dominant frequency is still at mode k=4, but the low-frequency amplitudes are higher than in the case of the conformant sample window. This is due to the discontinuity in the boundary condition inducing high frequency components that are not resolved by the sampling rate, but are captured as false low-frequency modes. We say that the unresolved high-frequency modes are “aliased” onto low-frequency modes, similar to the apparent slow motion of a helicopter rotor filmed at some fixed frame rate lower than the rotor angular velocity.