ztzhang / SoundSynth

Code for sound synthesis
http://sound.csail.mit.edu/
50 stars 9 forks source link

Eigenvalue ordering #2

Open RoyJames opened 4 years ago

RoyJames commented 4 years ago

Thank you for integrating the modal sound code and posting this repo! I have one question regarding this file https://github.com/ztzhang/SoundSynth/blob/master/file_generator/ev_generator60.m

According to matlab's documentation, [V, D] = eigs(K,M,num+shift,'sm') should give you the eigen pairs in ascending order. However, you used D=flip(diag(D)) to reverse it before writing to file. The consequence is that when they are read by ModalModel::load_eigenmodes, 0 audible modes can be loaded because the first mode frequency (which is the biggest) is beyond your threshold and will terminate the loading process. So I removed the flip operation in your code and can verify that the problem is gone and the sound is correct. Was this unintentional in your code?

ztzhang commented 4 years ago

This is actually intentional. The order of the returns in MATLAB is version dependent. Newer versions switched to the behavior you just described. I'll keep this issue open since this is quite tricky...