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

About how to add directional simulation in the pygsound #33

Open
xtgg4310 opened this issue Dec 19, 2022 · 4 comments
Open

About how to add directional simulation in the pygsound #33

xtgg4310 opened this issue Dec 19, 2022 · 4 comments

Comments

@xtgg4310
Copy link

Dear author:

I would like to know how to add directional simulation in the pygsound. I notice that parameter "Sounddirectivity" in Context.cpp can be set true. Also, in GSound/gsSoundDirectivity.cpp, it seems that several sound pattern has been defined in the program. So how can I set up the directional simulation method.

Best wishes.

@RoyJames
Copy link
Collaborator

It is possible. GSound has well-defined directivity described here

//********************************************************************************
/// A class that represents a frequency-dependent directivity pattern for a directional sound source.
/**
* The directivity determines how sound is radiated from a source in all
* directions for each frequency. The directivity is specified by providing
* frequency response measurements for various directions. Internally, a
* spherical harmonic representation is used to smoothly interpolate the
* frequency responses for all directions. The directivity is sampled for
* each sound path that is generated.
*
* The directivity is projected into the spherical harmonic basis whenever
* it has been modified and is needed for a sound source. This operation is
* slightly expensive (milliseconds), so only modify directivity when absolutely necessary.
*/

But setting that flag to True only initializes an omnidirectional pattern which doesn't do anything, a specific pattern needs to be assigned following definitions in GSound/gsSoundDirectivity.cpp as you've noticed. For people who are familiar with C++, it should be easy to leverage this API. However, I have not exposed it in current python bindings just like many other functionalities that are less often used. I may not have the bandwidth to do these additions myself. But pull requests are welcome.

@xtgg4310
Copy link
Author

xtgg4310 commented Jan 1, 2023

Thanks for your answer, I have add a specific pattern in the program and simulate a directional acoustic wave. I want to know the definition of angle and theta in GSound/gsSoundDirectivity.cpp. I find the view direction of the source is -transform.orientioan.z. Does this mean that the value of theta and phi are corresponding to the z-axis?

@xtgg4310
Copy link
Author

xtgg4310 commented Jan 2, 2023

By the way, I just found that I fail to add a sound pattern to the source. I initialise the SoundSource with the pattern defined in the SoundDirectivity in gsSoundSource.cpp but get the same RIR. Is this operation right? Or should I realise other API about SoundDirectivity.

Best wishes.

@RoyJames
Copy link
Collaborator

RoyJames commented Jan 6, 2023

By the way, I just found that I fail to add a sound pattern to the source. I initialise the SoundSource with the pattern defined in the SoundDirectivity in gsSoundSource.cpp but get the same RIR. Is this operation right? Or should I realise other API about SoundDirectivity.

Best wishes.

I cannot comment on this case without codes. My suggestion is to step into the key functions (or just print them out if you have difficulty setting up a debugger) to make sure that your new directivity is actually being called in the expected way.

Regarding coordinate convention - yes I believe the convention used throughout this project is ZYX in which -z is forward, +x is right, and +y is up.

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

2 participants