Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vid 5: sum(hms) incorrect? #1

Open
AidanGG opened this issue Apr 6, 2021 · 0 comments
Open

Vid 5: sum(hms) incorrect? #1

AidanGG opened this issue Apr 6, 2021 · 0 comments

Comments

@AidanGG
Copy link

AidanGG commented Apr 6, 2021

In the cell labelled In [126], you have

all_harmonics=True
if all_harmonics:
    tot = sol.sum(axis=1)[::10] # all harmonics
else:
    tot = sum(hms)[::10] # only first 10 harmonics
tot = 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.

Edit: Actually I'm not sure if taking the average y value at each time t is correct, since even harmonic contributions to the average y 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-simulation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant