Some advice on Audio Filter Module

This forum is about all development around libVLC.
andifuchs
New Cone
New Cone
Posts: 4
Joined: 11 Sep 2013 13:40

Some advice on Audio Filter Module

Postby andifuchs » 11 Sep 2013 16:49

Hello vlc-community,

I'm writing an Audio Filter Module similiar to the Headphone Effect, but to give a more realistic effect it is able to load SOFA (http://www.sofaconventions.org) files and read the SimpleFreeFieldHRIR data. So it is possible to load different (measured or simulated) HeadRelatedTransferFunctions. The idea is to use these transfer functions for different loudspeaker positions with the according input channel and get so a spatialized effect of the loudspeakers over headphones.

I stumbled on some problems with the VLCcore and to set the right parameters for the filter. For this Module to work I need a specific samplerate to match the samplerate in the loaded file. Additionaly my wish is to support from Mono to 8.1 of Audio for input, but the output of the module and preferably the output itself is to be always stereo. Any other output format is pointless. In the Open() Function I get the i_SamRate with the desired Samplerate in Hertz.

Code: Select all

filter_t *p_filter = (filter_t *)p_this; ... p_filter->fmt_in.audio.i_rate = i_SamRate; p_filter->fmt_out.audio.i_rate = p_filter->fmt_in.audio.i_rate; p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32 ; p_filter->fmt_out.audio = p_filter->fmt_in.audio; p_filter->fmt_out.audio.i_channels = 2; p_filter->fmt_out.audio.i_physical_channels = 0x6; p_filter->fmt_out.audio.i_original_channels = 0x6;
Is this the correct way to set the parameters?

Problem 1.) If I load a .wav file with a different samplingrate than the SOFA file vlc crashes. Mp3s and Ogg files get correct resampled.

Code: Select all

*** Error in `./vlc': free(): invalid next size (normal): 0xa47d6d18 *** ======= Backtrace: ========= /lib/i386-linux-gnu/libc.so.6(+0x767e2)[0xb75ad7e2] /lib/i386-linux-gnu/libc.so.6(+0x77530)[0xb75ae530] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(+0x8167b)[0xb74c567b] /home/andreasfuchs/vlc-2.1.0-rc1/modules/audio_filter/.libs/libsimple_channel_mixer_plugin.so(+0x1dfe)[0xa4e26dfe] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(aout_FiltersPlay+0x135)[0xb74b9525] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(+0x73444)[0xb74b7444] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(+0x39300)[0xb747d300] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(+0x3a8f9)[0xb747e8f9] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(+0x3aae2)[0xb747eae2] /lib/i386-linux-gnu/libpthread.so.0(+0x6d78)[0xb76f6d78] /lib/i386-linux-gnu/libc.so.6(clone+0x5e)[0xb76283de] ======= Memory map: ======== ... a4700000-a47f2000 rw-p 00000000 00:00 0 a47f2000-a4800000 ---p 00000000 00:00 0 ...(core dumped)
The samplingrate got set and the vlccore also loaded samplerate converter accordingly (in the debug window i get "End of audio preroll & Decoder buffering done in 256ms). Then it crashes. This happens in the 2.1.0-rc1 and the latest git sources. I'm not sure what you need for debugging, but also didn't want to overload the forum.

Problem 2.) If I have a mono file for input, the output is still mono (except i set the output module fix to stereo like the alsa driver on linux.) Is there a fix for example the pulse audio driver? It would be nice not to be dependet on the output driver or the user to manually set the stereo mode. If i have more channels than stereo the output of the filter is also mixed to more channels, which is pointless. The problem here is the policy to give the output the same number of channels as the input, but in my case this is rather unfortunate. What shall I or can I do?

I'm not sure how to contribute this plugin. Shall I just push it to the master branch? It is one Module *.c file, additionally I edited three files of the qt4 interface to control it. I added the netcdf library and at this point it need to be installed in /usr/local/ to compile and run ( or the vlc directory when cross compiled for windows). Later some help how to put external libraries inside the vlc directories to compile and run (included precompiled dlls for windows) will be appreciated.

Thanks,
Andi

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Some advice on Audio Filter Module

Postby Jean-Baptiste Kempf » 12 Sep 2013 13:20

I'm writing an Audio Filter Module similiar to the Headphone Effect, but to give a more realistic effect it is able to load SOFA (http://www.sofaconventions.org) files and read the SimpleFreeFieldHRIR data. So it is possible to load different (measured or simulated) HeadRelatedTransferFunctions. The idea is to use these transfer functions for different loudspeaker positions with the according input channel and get so a spatialized effect of the loudspeakers over headphones.
Cool. Headphone effect is very old, and has only GPL code so we will remove it at some point.
I stumbled on some problems with the VLCcore and to set the right parameters for the filter. For this Module to work I need a specific samplerate to match the samplerate in the loaded file. Additionaly my wish is to support from Mono to 8.1 of Audio for input, but the output of the module and preferably the output itself is to be always stereo. Any other output format is pointless. In the Open() Function I get the i_SamRate with the desired Samplerate in Hertz.

Code: Select all

filter_t *p_filter = (filter_t *)p_this; ... p_filter->fmt_in.audio.i_rate = i_SamRate; p_filter->fmt_out.audio.i_rate = p_filter->fmt_in.audio.i_rate; p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32 ; p_filter->fmt_out.audio = p_filter->fmt_in.audio; p_filter->fmt_out.audio.i_channels = 2; p_filter->fmt_out.audio.i_physical_channels = 0x6; p_filter->fmt_out.audio.i_original_channels = 0x6;
Is this the correct way to set the parameters?
More or less, yes. Even if I'm not sure you need to set the i_physical_channels and i_original_channels when i_channels = 2. And you should use defined constants not magic numbers.
Problem 1.) If I load a .wav file with a different samplingrate than the SOFA file vlc crashes. Mp3s and Ogg files get correct resampled.

Code: Select all

*** Error in `./vlc': free(): invalid next size (normal): 0xa47d6d18 *** ======= Backtrace: ========= /lib/i386-linux-gnu/libc.so.6(+0x767e2)[0xb75ad7e2] /lib/i386-linux-gnu/libc.so.6(+0x77530)[0xb75ae530] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(+0x8167b)[0xb74c567b] /home/andreasfuchs/vlc-2.1.0-rc1/modules/audio_filter/.libs/libsimple_channel_mixer_plugin.so(+0x1dfe)[0xa4e26dfe] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(aout_FiltersPlay+0x135)[0xb74b9525] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(+0x73444)[0xb74b7444] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(+0x39300)[0xb747d300] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(+0x3a8f9)[0xb747e8f9] /home/andreasfuchs/vlc-2.1.0-rc1/src/.libs/libvlccore.so.5(+0x3aae2)[0xb747eae2] /lib/i386-linux-gnu/libpthread.so.0(+0x6d78)[0xb76f6d78] /lib/i386-linux-gnu/libc.so.6(clone+0x5e)[0xb76283de] ======= Memory map: ======== ... a4700000-a47f2000 rw-p 00000000 00:00 0 a47f2000-a4800000 ---p 00000000 00:00 0 ...(core dumped)
The samplingrate got set and the vlccore also loaded samplerate converter accordingly (in the debug window i get "End of audio preroll & Decoder buffering done in 256ms). Then it crashes. This happens in the 2.1.0-rc1 and the latest git sources. I'm not sure what you need for debugging, but also didn't want to overload the forum.
Try to get a gdb backtrace
Problem 2.) If I have a mono file for input, the output is still mono (except i set the output module fix to stereo like the alsa driver on linux.) Is there a fix for example the pulse audio driver? It would be nice not to be dependent on the output driver or the user to manually set the stereo mode. If i have more channels than stereo the output of the filter is also mixed to more channels, which is pointless. The problem here is the policy to give the output the same number of channels as the input, but in my case this is rather unfortunate. What shall I or can I do?
We don't really do any upmixing in VLC, but we would need one. You could also do it in your filter.
I'm not sure how to contribute this plugin. Shall I just push it to the master branch? It is one Module *.c file, additionally I edited three files of the qt4 interface to control it. I added the netcdf library and at this point it need to be installed in /usr/local/ to compile and run ( or the vlc directory when cross compiled for windows). Later some help how to put external libraries inside the vlc directories to compile and run (included precompiled dlls for windows) will be appreciated.
Please read the wiki for that. All is documented.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

andifuchs
New Cone
New Cone
Posts: 4
Joined: 11 Sep 2013 13:40

Re: Some advice on Audio Filter Module

Postby andifuchs » 17 Sep 2013 10:22

Hello,

Thanks for your reply. gdb Backtracing revealed this, when the vlccore is resampling a wav file for me. Again mp3/ogg/ac3 work fine:

Code: Select all

(gdb) bt #0 0xb7fdd424 in __kernel_vsyscall () #1 0xb7dfcb1f in raise () from /lib/i386-linux-gnu/libc.so.6 #2 0xb7e000b3 in abort () from /lib/i386-linux-gnu/libc.so.6 #3 0xb7e39ab5 in ?? () from /lib/i386-linux-gnu/libc.so.6 #4 0xb7e447e2 in ?? () from /lib/i386-linux-gnu/libc.so.6 #5 0xb7e45530 in ?? () from /lib/i386-linux-gnu/libc.so.6 #6 0xb7d5c33b in block_generic_Release (block=0xad65ab88) at misc/block.c:107 #7 0xa69cb876 in block_Release (p_block=0xad65ab88) at ../../include/vlc_block.h:166 #8 Resample (filter=0xad6cc778, in=0xad65ab88) at resampler/src.c:172 #9 0xb7d5011e in aout_FiltersPipelinePlay (block=<optimized out>, count=6, filters=0xad60c7d0) at audio_output/filters.c:267 #10 aout_FiltersPlay (filters=0xad60c7c0, block=block@entry=0xacc12bc8, rate=rate@entry=1000) at audio_output/filters.c:559 #11 0xb7d4df84 in aout_DecPlay (aout=aout@entry=0x80e1bc0, block=block@entry=0xacc12bc8, input_rate=input_rate@entry=1000) at audio_output/dec.c:366 #12 0xb7d143c8 in DecoderPlayAudio (pi_lost_sum=<synthetic pointer>, pi_played_sum=<synthetic pointer>, p_audio=0xacc12bc8, p_dec=0xacc05ce8) at input/decoder.c:1242 #13 DecoderDecodeAudio (p_dec=p_dec@entry=0xacc05ce8, p_block=0x6, p_block@entry=0xacc05ce8) at input/decoder.c:1297 #14 0xb7d159a9 in DecoderProcessAudio (b_flush=false, p_block=0xacc2f048, p_dec=0xacc05ce8) at input/decoder.c:1898 #15 DecoderProcess (p_dec=p_dec@entry=0xacc05ce8, p_block=p_block@entry=0xacc2f048) at input/decoder.c:2019 #16 0xb7d15b92 in DecoderThread (p_data=0xacc05ce8) at input/decoder.c:946 #17 0xb7f8dd78 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0 #18 0xb7ebf3de in clone () from /lib/i386-linux-gnu/libc.so.6
I have the same combination of block_Alloc/block_Release of input and outbuffer in the DoWork function in my module as in the src Resampler. In one out of five cases my module crashes at block_Release() and not the src resampler.

Any suggestions anyone? i'm a little stuck. Thanks.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Some advice on Audio Filter Module

Postby Jean-Baptiste Kempf » 17 Sep 2013 14:33

Special wav file?
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

andifuchs
New Cone
New Cone
Posts: 4
Joined: 11 Sep 2013 13:40

Re: Some advice on Audio Filter Module

Postby andifuchs » 18 Sep 2013 16:03

I did some additional testing and now i can say the "special" ones work. wav files with 24 bit work fine, but wav files with 16bit crash. I have the combination of audioresampler, audio_format (which get only loaded with 16bit) and my module under suspicion.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Some advice on Audio Filter Module

Postby Jean-Baptiste Kempf » 27 Sep 2013 01:17

You should file a bug report.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 14 guests