2020-01-22 12:59:41

Hi,

   I keep trying to implement an advanced audio library with HRTF and 3D reverb effects in c#. I experimented with FMOD and some plugins but nothing worked for me. Then I tried to write a simple c++/cli wrapper of OpenAL-soft but I was able just to open and close device and when I wanted to play a sound I was constantly getting an System.BadImageException. Then I realized that I should rather learn ALure. I guess the best way should be writing a simple c++/CLI wrapper and using it in c#.

So as the first step I wanted to compile an example program from ALure source distribution. I created an empty c++ Windows console application in Visual studio community 2019 and simple added the *.c file with the example. As they write in ALure read me file I copied the appropriate static library in to lib directory, I set path to the directory in project properties -> Linker -> General -> Additional library directories, then I named the library in project properties -> Linker -> Input and I did the same with libOpenAL32.a. And I am still getting linker errors lnk2019 and lnk2120 and it says that 26 symbols are unresolved. There are two static libraries and one dynamic library within the distribution and I tested all variations. Could you tell me what I'm doing wrong?
You can take a look at the project here.


I'm really getting upset because I claimed that I'll use HRTF in my final bachelory project but I didn't know how hard it will be to implement it in c# and how much time it will take.

Best regards
Luky

Thumbs up

2020-01-22 13:33:20

Why you won't write the wrapper directly in C#? It is possible and good.

Raduvay se, raduvay
Raduvay se domaki ne
Kolko liste po gorach
Tolko zdrave na taz kyshcha

2020-01-22 17:29:19

Am, which problems do you have with fmod?

If I'm not wrong, I remember that you achieve implement in a small c# example fmod with resonance audio.

And, I created too a small example loading a sound, and positioning it in the space, exactly with that; using fmod and resonance audio, in c#.

Which problems do you have with that? Why you giveup to try with it?

Thumbs up

2020-01-22 18:08:41

@2: That's also an acceptable method. I was just affraid it could be hard to cope with data type conversion or it could then run slowly. However, I'll probably try it this way too.
But if you import functions from ALure's DLL do you also have to import something from OpenAL32.dll or soft_OAL.dll? Do you know some good tutorial or example?

Thumbs up

2020-01-22 18:25:40

@4, marshaling is not hard. Types are coresponding almost fully.
See this table for the details:
https://docs.microsoft.com/en-us/dotnet … orm-invoke

Raduvay se, raduvay
Raduvay se domaki ne
Kolko liste po gorach
Tolko zdrave na taz kyshcha

2020-01-22 18:25:58

Hi lightsome.
In C# I use OpenTK to wrap OpenALSoft for HRTF and playback, and NLibsndfile to wrap libsndfile for reding audio formats like ogg, flac, and wav.
I use NAudio to read mp3 files, and OpusFileSharp to wrap libOpusFile for reading opus files.

If you would like some help getting HRTF playback working with OpenALSoft, email me at [email protected] and I'll put together some example code that we can discuss on a skype call.
It takes me much longer to type up an explanation than it does to explain over the phone, and I would need to take a lot more time to review my example code if I were sharing it publicly.

~ Ian Reed
Visit BlindGamers.com to rate blind accessible games and see how others have rated them.
Try my free JGT addon, the easy way to play Japanese games in English.
Or try the free games I've created.

2020-01-22 18:37:10

@3: you're right but it worked just partially. I was able to set that room properties and it was really making much interesting reverb effects, it even reacted on listener's position so if you set position near a wall of the virtual room the reverberation sound changed. But I didn't find any way how to control behavior of the source plugin so that most desired functionality (HRTF) didn't work at all. Changing parameters of source plugin had no effect.

I tried your example but unfortunately it also didn't seem to be working. When I compiled it I could hear a sound coming from behind but I wasn't able to change it's position. If I remember it well you were trying to use FMOD function for setting 3d parameters but I read somewhere that it should be controled via DSPDescription.SetParameterData.

Thumbs up

2020-01-22 19:41:31

@lightsome

Exactly, to control the properties of a source, you have to set them using the functions setDspFloatProperti, setDspParameterData, and other stuf.

So, in the last time that I've tested the example, it works fine.

The only thing that I don't test, was change dinamically the properties of the source, but at the time it works nise. So, other step that i want to do, is convine my example with yours to have a source, with a room reverb effect.

So, In your tests... which things aren't working?
You can't compile the example? or didn't work modifying the parameters dinamically.

and @Ian Reed

Your sound engine sounds very interesting; can you updload some WIP to check it?

I know, you said that isn't polished now, as to be published, but upload a first example...

I really preffer have some information in text that speak it through skype, because im not a native english speacker.

smile

¡so thanks!

Thumbs up

2020-01-22 20:11:51

@6: Ian, I've just sent you a mail. Please make sure it didn't fall into spam.
@8: I'll test your example again and then write some details to you and I'll upload my test program.

Thumbs up

2020-01-22 21:20:13

Hi sanslash332.

I'd rather not share a public link until it is more polished.
That said, if you email me I will share the same version I shared with lightsome with you.
I can imagine the difficulty of not being a native English speaker.
That is why my future projects will all have built in Google translation to any language, just like AHC did.
I have some OCD that makes writing emails or posts take a very long time, so I prefer voice chat, but I will email with you a bit due to the language barrier.

~ Ian Reed
Visit BlindGamers.com to rate blind accessible games and see how others have rated them.
Try my free JGT addon, the easy way to play Japanese games in English.
Or try the free games I've created.

2020-01-22 21:34:16

[email protected] Reed. I send a email to you too, Im very interested in the example. But same as sanslash 332, im not a native english speaker

Sorry for my english

Thumbs up

2020-01-22 21:49:35

@Ian Reed perfect!

let me send you an email to have more information! smile

And for english, na, isn't really a big problem; I can speak English with other person, obviously with some... difficulties, but when I have the option to choose a communication channel, I prefer the text instead the voice. Specially for a technical topic.

For example, to play AHC, I didn't use the translator; I love play games in English; or for this conversation; I'm not translating anything now.

@lightsome

Perfect! I'm waiting for your observations!

For now, I'm trying to migrate the fmod example from resonanse to oculus spatialicer.
For simply check how works Oculus in a small test. smile

Thumbs up

2020-01-22 22:40:44

@ian, would it be a problem if I were to send you an email? I'm pretty interested as well.

if you wish,  you could give a look at my github profile.
If you want to get in touch with me you can follow me on Twitter
have a nice day.
Paul

2020-01-23 01:01:12

@pauliyobo, that is no problem. Send me an email.

To be clear, this is just an example I quickly threw together for Lightsome.
It is mostly so he could examine my sound API and how I call into OpenTK and the decoders to get everything working together.
It is not an interesting example of HRTF. It just plays a sound in front and to the left of the listener.
I expect Lightsome to make it more interesting by moving the sound around on its own or in response to keyboard input.
I just want that to be clear so you are not disappointed.

~ Ian Reed
Visit BlindGamers.com to rate blind accessible games and see how others have rated them.
Try my free JGT addon, the easy way to play Japanese games in English.
Or try the free games I've created.

2020-01-23 08:27:31

A bit of caution on FMOD's various DSP functions: only set parameters relevant to the DSP in question. SetParameterData isn't used on that may DSPs, and usually requires a pointer or something else like that.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.

Thumbs up +1

2020-01-23 22:10:06

@12: Sanslash, I downloaded and compiled your example again and played a bit with Game1.listenerPos and parameters in Game1.setSourceParameters. Unfortunately, it seems to me that the sounds moves just on Z axis. But you said that it worked to you, can you then tell me how you tested it?

I just added a bit of code into Game1.Update:


                    case Keys.J:                         listenerPos.x += .1f; break;
                    case Keys.L:                        listenerPos.x -= .1f; break;
                    case Keys.U:                         listenerPos.y += .1f; break;
                    case Keys.O: listenerPos.y-= .1f; break;
Resonance Audio Reverb Test

Here is my test program.
It makes really nice reverb and you can play with it's parameters by changing them manually. The program also activates Source plugin and tries to set it's parameters but it doesn't affect it at all.

Thumbs up

2020-01-26 05:21:57

Hello lightsome;

After update the values in the update method, do you push again the new values using the setDSPParameterData?

Currently, for simply fun, I changed resonance audio for oculus spatialicer, and for now I get only move on the z axis, but im working now on try new update methods to get more moves.

smile

Something interesting about oculus, is that aparently it takes listener properties directly from the fmod set3dListenerPosition function of fmod, instead of pass listener properties through each source smile

And, which forward, and up vectors are you using?

smile

Thumbs up

2020-01-31 06:53:28

@lightsome

If you want, pull again my repository.

Now it works with oculus spatialicer, and currently we implemented correct 3d source positioning, and listener rotation smile

The next step is configure correctly the rooms settings.

https://github.com/sanslash332/fmod-test-in-monogame


a @Ethin I found in the fmod forum, a old post of yours, about rotation.
Thanks for all the information on that post; witht that, we with @Alisson got implement correctly the rotation in this example   

smile

Thumbs up

2020-02-09 12:47:49

@18: heeeey now it finally works for me! Good job, Sanslash! Please keep experimenting and implement all other effects as 3d reverberation, distance attenuation and so on. In my bachelory final project game I had to implement OpenAL due to lack of time but I definitely return back to Oculus spatializer and Resonance Audio experimenting in future.

Thumbs up +1

2020-02-10 04:17:27

O awesome!

So, currently the small project, evolved on this:

https://github.com/sanslash332/exploudEngine

A small classical sound engine, but implementing our (you and me) discovers on how to use fmod with oculus, turned in a classical and easy to use sound engine.

For now, can instantiate and put different sound sources with their basic properties, play sounds without spatialicer without affect the other sources, and stream audio data, like music. All of these three different kind of audio, played in different channels.

The next steps, is start to play with room properties, to set things like width, height length, reflection levels for each wall, methods for change the room fast, and other stuf that oculus offers. And well, any thing that fmod can do, obviously using oculus features, or mixing them if is possible.

For now is very ugly, and it lacks of good documentation, but... using the example, and reading the signature of the methods and classes, I suppose that you can got a basic idea of how this little monster works.

I hope that can be good for you in the future! The plans is continuing working on it!

¡thanks!

Thumbs up