Skip to content

Conversation

@SaintEverett
Copy link

Added a single function to Math that allows for the generation of SN3D normalized spherical harmonics via the function call Math.sh(int order, float azimuth, float zenith) // doc_func included. Also added an example that creates basic ambisonic encoding via Math.sh() // included in add_ex, located in examples/spatial.

@gewang
Copy link
Member

gewang commented Nov 14, 2025

Hi @SaintEverett! Thank you for this. We are looking into merging this, but running into a few issues:

  1. we are extremely careful about adding new files to chuck core, and have tried to move SHCT.h and chuckSH.h into util_math.h and util_math.cpp (crediting you in the comments of course for the contribution)
  2. to maximize compatibility for chuck core, we are supporting c++11, which does not support things like constexpr

If you'd like, could you update this PR to address the above?

  1. no new files (please put SHCT.h and chuckSH.h in util_math.cpp if possible, and into util_math.h only if necessary as the header is included by many other files)
  2. everything should be c++11 compatible (even at the cost of performance)
    (ulib_math.h and ulib_math.cpp looks good as is!)

Thank you again and please let me know if you have any questions!

cc @nshaheed

@SaintEverett
Copy link
Author

Hi @SaintEverett! Thank you for this. We are looking into merging this, but running into a few issues:

  1. we are extremely careful about adding new files to chuck core, and have tried to move SHCT.h and chuckSH.h into util_math.h and util_math.cpp (crediting you in the comments of course for the contribution)
  2. to maximize compatibility for chuck core, we are supporting c++11, which does not support things like constexpr

If you'd like, could you update this PR to address the above?

  1. no new files (please put SHCT.h and chuckSH.h in util_math.cpp if possible, and into util_math.h only if necessary as the header is included by many other files)
  2. everything should be c++11 compatible (even at the cost of performance)
    (ulib_math.h and ulib_math.cpp looks good as is!)

Thank you again and please let me know if you have any questions!

cc @nshaheed

Hi Ge, good to hear from you! It's no problem; I'm incredibly excited to be able to work on ChucK.

In regards to the merging of files and removal of SHCT.h and chuckSH.h, this all makes sense and can be done.

One issue is that the c++ std::assoc_legendre() used in the spherical harmonic algorithm was introduced in c++17. I initially opted for this since associated Legendre Polynomials have large recurrence relations and c++17 took advantage of that. It has been in the back of my mind to take some time and write my own associated Legendre Polynomial algorithm, as reliance on c++17 is not ideal (and such a project would be valuable to my research). I will look into developing an optimized replacement for std::assoc_legendre(), IEM in Graz has written their own along with many others.

Hope to talk to you soon! Should be able to get a lot of this done rather soon.

cc @nshaheed

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

Successfully merging this pull request may close these issues.

2 participants