[Csnd] Csound and SOFA (HRTF) files

Hey hey,
I've been scouring the net to see if there are applications to convert .sofa files to Csound HRTF data format. Well, I don't know which format Csound exactly uses.

Does anyone know of applications to do that? Preferably on the commandline and Unix compatible or does Csound itself already support the SOFA format?

Best wishes,

Jeanette

Maybe the “sofar” Python package can do that?

See https://www.sofaconventions.org/mediawiki/index.php/Software_and_APIs#sofar:Maybe_the_most_complete_Python_package_for_the_SOFA_file_format(read/write_support).

I believe sofa are just more or less hdf5-files - at least I have managed to read them into GNU Octave using the ordinary “load” command with the -hd5 flag.
So the hdf5read plugin for csound might perhaps work?

[

hdf5read
csound.com

](hdf5read)

What format csound uses for the hrtf opcodes I’m not entirely sure though.

Regards,
Anders

Brian tells me you can find the info here

best

Hi everyone,
thanks, Andy, Anders and Victor. there was valuable info here.

Victor, could you ask Brian, if he has some contact info for Thomas McDonnell? The paper is ace and the code looks clean and concise enough. Though it would be helpful to obtain a raw copy. I couldn't find it online, only in the context of the paper. Extracting it by hand, having to reformat it, is tedious work. Not impossible, but I wold like to avoid it. :slight_smile:

Best wishes and thanks again to all of you,

Jeanette

Brian said he'll ask him on Monday.
Prof. Victor Lazzarini
Maynooth University
Ireland

Apr 20 2024, Victor Lazzarini has written:

Brian said he'll ask him on Monday.

Many thanks to both of you!

Best wishes,

Jeanette

...

Hello all,
This sound spatialisation is quite a new item for me. I found this page related to basics of HRTF:

https://www.katarinahoeger.com/2018/06/20/moving-sound-with-csound-hrtfmove2

The 1’st example there, yes, did show the movement of the sound source between left and right channels (x-axis).

Anyway this kind of example can’t propably present much movement in y-direction (or i didn’t hear it well).

The second example was supposed to show movement in z-direction. No way. Am I totally 3d-deaf or
is that example also too simple ?

Here’s an example of “naturally” created movement by instrument locations. Requires quite accurate playing from
the players. I haven’t heard any other case like this, but maybe some similar c-sound compositions exist ?

https://www.youtube.com/watch?v=sufmXGDd224

The c-sound manual https://flossmanual.csound.com/sound-modification/panning-and-spatialization gives quite a lot of background about spatialisation,
especially about ambisonics. However, the 3d binaural principle remains a bit of mystery to me.
I suppose there are some practical restrictions in order to achieve real 3d-like experience ?

–Risto

la 20. huhtik. 2024 klo 11.38 Jeanette C. (julien@mail.upb.de) kirjoitti:

Apr 20 2024, Victor Lazzarini has written:

Brian said he’ll ask him on Monday.
Many thanks to both of you!

Best wishes,

Jeanette

For whatever reason,
I feel like I’ve been wanting you all my life <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Hi Risto,
HRTF-based binaural 3d relies on a "generic" head model. This is supplied with Csound or can be downloaded, the hrtf-44100-left.dat and hrtf-44100-right.dat and similar.

The heads used to create these files were generic. The idea is to suite many people quite well. Though there are always some people for whom they don't work well.

To get the best experience, you should sit or stand quite still with your head erect. I.e. normal head position for looking straight ahead.

It help to have more audio cues. There are the hrtfearly and hrtfreverb opcodes. They also simulate a virtual room. This can help. I have used that in Csound compositions. For example:

or

The first and second one offer a bit of movement, the second one perhaps the most, also along the z-axis.

the basic idea of HRTF-based binaural spatialisation is: you can hear that something is in front of you or behind you, because your own head and the shape of your ears, filter audio and cause phase shift. In the real world you can hear 3d with two ears, so you should be able to hear 3d with a pair of headphones, because the headphone speakers are directly above your ears, i.e. playing straight into your ears. If you then mimic these filters and phase shift and everything, you should get a 3d-impression.

If you don't simulate that, you could use in-ear microphones, also sometimes called ambisonic microphones. "Ambisonic" can be a bit misleading here. You can find demos of those on youtube as well. Roland has one or two products in that line, the Beyerdynamic Ambeo mics made a splash, a few years ago. Or there is the OKM II by Soundman. they had a few nice musical demos on their website, with a string quartet in fixed places though.

You could also find open source, free and commercial plugins in the usual formats, compatible with many DAWs.

If you want a small demonstration of the effects involved, there was a Youtube video with someone making their own "HRTF-like" Ableton device. He didn't use a true recorded HRTF, but he observed all the things that change when a signal is in front, behind, below or above a head and emulated them. But I can't find that video. It was posted as news on SonicState just a few weeks ago though.

I hope some of that helps.

Best wishes,

Jeanette

For some reason, I might not be getting some mails from the list. The email you replied to here did not come to me.
You had also mentioned Anders and Andy and I did not see their replies either.

I wonder what is going on. Nothing in my junk folder either.

Prof. Victor Lazzarini
Maynooth University
Ireland

Hi Victor,
this is strange. It is most likely a really stupid idea, but might it be related to your interaction with the list. I mean that all your replies come with subject lines:
Re: [Csnd] [EXTERNAL] [Csnd] ...
instead of just:
Re: [Csnd] ...

I'm very glad my first mail reached you and you were so kind as to forward my question to Brian.

Best wishes,

Jeanette

That [EXTERNAL] is added by my mail server and when I reply it is there.
I don’t really know what is going on, maybe Andy, Anders and Risto are blacklisted here somehow. I can see their replies in the list server, but these did not seem to have been delivered to me. Strange. I’ll ask IT here.

Thanx Jeanette!

The examples were quite interesting and the space impression was good in all of those.
The last example had also those nice question-answer type structures with corresponding location changes.

I suppose the natural sounding echoes are quite important.

I did use open headphones (KOSS Portapro), but i suppose that was OK, because there was no background noise at the time of listening.
Somehow many of the voices seemed to come from behind my head. I switched the phones from left to right but strangely that didn’t change
the behind - in front of -situation. Of course sounds coming from left turned to right and vice versa.

The 3’rd dimension was not very clear, at least for me. Maybe my ears’ transfer functions are not standard enough?

–Risto

–Risto

la 20. huhtik. 2024 klo 20.21 Jeanette C. (julien@mail.upb.de) kirjoitti:

Hi Risto,
HRTF-based binaural 3d relies on a “generic” head model. This is supplied with
Csound or can be downloaded, the hrtf-44100-left.dat and hrtf-44100-right.dat
and similar.

The heads used to create these files were generic. The idea is to suite many
people quite well. Though there are always some people for whom they don’t
work well.

To get the best experience, you should sit or stand quite still with your head
erect. I.e. normal head position for looking straight ahead.

It help to have more audio cues. There are the hrtfearly and hrtfreverb
opcodes. They also simulate a virtual room. This can help. I have used that in
Csound compositions. For example:
http://juliencoder.de/nama/in_a_room.mp3
https://youtu.be/bah-8V_s47U
or
https://youtu.be/_Qsr5tS86QA

The first and second one offer a bit of movement, the second one perhaps the
most, also along the z-axis.

the basic idea of HRTF-based binaural spatialisation is: you can hear that
something is in front of you or behind you, because your own head and the
shape of your ears, filter audio and cause phase shift. In the real world you
can hear 3d with two ears, so you should be able to hear 3d with a pair of
headphones, because the headphone speakers are directly above your ears, i.e.
playing straight into your ears. If you then mimic these filters and phase
shift and everything, you should get a 3d-impression.

If you don’t simulate that, you could use in-ear microphones, also sometimes
called ambisonic microphones. “Ambisonic” can be a bit misleading here. You
can find demos of those on youtube as well. Roland has one or two products in
that line, the Beyerdynamic Ambeo mics made a splash, a few years ago. Or
there is the OKM II by Soundman. they had a few nice musical demos on their
website, with a string quartet in fixed places though.

You could also find open source, free and commercial plugins in the usual
formats, compatible with many DAWs.

If you want a small demonstration of the effects involved, there was a Youtube
video with someone making their own “HRTF-like” Ableton device. He didn’t use
a true recorded HRTF, but he observed all the things that change when a signal
is in front, behind, below or above a head and emulated them. But I can’t find
that video. It was posted as news on SonicState just a few weeks ago though.

I hope some of that helps.

Best wishes,

Jeanette

Top down, on the strip
Lookin’ in the mirror
I’m checkin’ out my lipstick <3
(Britney Spears)

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Hi Risto,
well, front and back wouldn't change, they are not bound to left and right, but to certain filters, phases and volume, which remains the same, no matter which way you wear your headphones.

There wasn't much in the way of height in two of them. Hatched from an empty shell had stronger elements of height. The echoes help in emphasizing the effect.

Btw. I heard that the example link you have posted worked a lot with sine waves. Sine waves, especially steady tones, are not good to demonstrate that. Parts of the impression come from filtering. I think a usual change happens within the 8-10kHz bands. Good ways to show these effects work with wider band tones (voice, saw waves, noisy elements, pluck strings) and clear envelopes, especially with simulated rooms so you can clearly perceive the reflections on the walls. So spoken word, drum loops, clearly pucked strings, sharp modulations. Good transients in short.

Naturally, you can introduce more cues, like doppler effects for quickly moving objects. But that's just icing on the top. :slight_smile:

Best wishes,

Jeanette