You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
all_harmonics=Trueifall_harmonics:
tot=sol.sum(axis=1)[::10] # all harmonicselse:
tot=sum(hms)[::10] # only first 10 harmonicstot=tot.astype(np.float32)
When calculating with all_harmonics, you take the average y value across the string at each time t to generate your PCM sound stream (this makes sense). The average value of a periodic function is just the amplitude of its zeroth harmonic; summing all harmonic amplitudes at a timeslice t is a different calculation. You can check this by listening to WAVs with all_harmonics=True vs all_harmonics=False with a high number of harmonics and finding that they don't sound similar.
In the cell labelled
In [126]
, you haveWhen calculating with
all_harmonics
, you take the averagey
value across the string at each timet
to generate your PCM sound stream (this makes sense). The average value of a periodic function is just the amplitude of its zeroth harmonic; summing all harmonic amplitudes at a timeslicet
is a different calculation. You can check this by listening to WAVs withall_harmonics=True
vsall_harmonics=False
with a high number of harmonics and finding that they don't sound similar.Edit: Actually I'm not sure if taking the average
y
value at each timet
is correct, since even harmonic contributions to the averagey
would be zero. Here's an open SE question on the topic: https://physics.stackexchange.com/questions/574906/derive-shape-of-sound-wave-from-vibrating-string-simulationThe text was updated successfully, but these errors were encountered: