Recording with 16kHz sampling rate

Moderator: flatmax

Post Reply
Mortis19
Posts: 4
Joined: Wed Nov 28, 2018 7:27 pm

Recording with 16kHz sampling rate

Post by Mortis19 » Wed Nov 28, 2018 7:32 pm

Hello all,

I've recently purchased the audioinjector stereo soundcard for my Raspberry Pi Model 3 B+. I set up everything and I'm trying to record with jackd and a 16kHz sampling rate but it doesn't seem to be working. Specifically I get these ALSA errors when I try to start the jackd server:
ALSA: cannot set hardware parameters for capture
ALSA: cannot configure capture channel
Cannot initialize driver
JackServer: :Open failed with -1
Failed to open server

However, the jack server starts successfully with 48kHz sampling rate for example, isn't the 16kHz sampling rate supported by the audioinjector sound card? I've also updated everything and with my previous cirrus audio card I was able to record at 16kHz sampling rate.

trekh
Posts: 2
Joined: Fri Jan 11, 2019 12:49 pm

Re: Recording with 16kHz sampling rate

Post by trekh » Fri Jan 11, 2019 1:00 pm

Hi,

I'm also having issues recording at rates of 16khz and 8khz. 32khz and above work. I'm using the ALSA arecord which produces 16khz but it's downsampled from 32khz.

Did you have any luck getting 16khz to work?

Thanks.

wh7qq
Posts: 25
Joined: Tue Jun 27, 2017 4:07 pm

Re: Recording with 16kHz sampling rate

Post by wh7qq » Mon Jan 14, 2019 7:09 am

The sampling rate is set by the "arecord" command. See https://linux.die.net/man/1/arecord. I don't use "Jack" so no comment on that interaction.

flatmax
Posts: 609
Joined: Sat Jul 23, 2016 11:39 pm

Re: Recording with 16kHz sampling rate

Post by flatmax » Mon Jan 14, 2019 1:18 pm

The simplest way to make 16kHz work is to use plughw:0 like so :
arecord -v -D plughw:0 -r 16000 -c 2 -f S32_LE test.wav

Another way to do this is to revert the firmware ....

This kernel patch to the i2s driver regressed low sample rate functionality :
https://github.com/raspberrypi/linux/co ... d4cf211cd7

That patch was from the 7th of May 2017. Which means you can get this functionality back by installing an earlier firmware such as this one :
https://github.com/Hexxeh/rpi-firmware/ ... c1b5c5532f

To do this run the following command :
sudo rpi-update e153ffdab6292509c38521896175dac1b5c5532f

You can reboot and see the version :
pi@raspberrypi:~ $ cat /proc/version
Linux version 4.9.25-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #995 SMP Thu May 4 15:52:25 BST 2017

I notice that trying to record at 16kHz reverts to 8kHz for some reason.
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

trekh
Posts: 2
Joined: Fri Jan 11, 2019 12:49 pm

Re: Recording with 16kHz sampling rate

Post by trekh » Thu Jan 17, 2019 2:35 pm

I'm just using arecord to test functionality, my actual use is with a Golang ALSA library that doesn't have re-sampling functionality. I need to record frequencies up to 4kHz and the smallest file size is preferable. I was initially hoping to record in 8kHz directly but I've read the other forum post:
viewtopic.php?f=5&t=3108

about it requiring kernel hacking which I was able to do but it still isn't optimal for my use. Reverting to a previous kernel version is also not an option in my case.

Recording in 16kHz and down-sampling 2x is the next best option, I'll just have to implement down-sampling in the Go library. It seems that the 16kHz issue isn't the same as the 8kHz one because I tried your suggestion of reverting the firmware to 4.9.25 and that fixed the 8kHz rate but not the 16kHz. The 16kHz rate didn't work after kernel hacking to modify the i2s driver either. Do you think it would be possible to find a way to get 16kHz to work with the current i2s driver?

Thanks

Mortis19
Posts: 4
Joined: Wed Nov 28, 2018 7:27 pm

Re: Recording with 16kHz sampling rate

Post by Mortis19 » Sun Jan 27, 2019 1:03 am

I still haven't achieved running the jackd server with 16kHz sampling rate using the audioinjector card. For me reverting the firmware is not an option right now but it's really annoying that the soundcard can't work with 16kHz sampling rate (while the cirrus audiocard works fine). Have you found any solutions so far?

EDIT: The plughw option works for the jackd server but the quality of the sound input is terrible...
Apart from this, I tried portaudio and it seems to be working for 16kHz.

Mortis19
Posts: 4
Joined: Wed Nov 28, 2018 7:27 pm

Re: Recording with 16kHz sampling rate

Post by Mortis19 » Tue Mar 26, 2019 6:43 pm

Hello again,

I tried changing the kernel of raspberry pi as in here, hoping to get 16kHz sampling rate to work on the audioinjector:
viewtopic.php?f=5&t=3108
After this, I managed to get jackd to start with 8kHz and 16kHz. However, when I connect the microphone input to the playback (with jack_connect) the sound output that I get is terrible and also works for only one speaker.
I am still trying to understand why the cirrus audio card works just fine with 16kHz and the audioinjector fails. I tried also changing the kernel file according to the one corresponding to the rpi cirrus but I get the same result.

If anyone has found a solution for this, please share it. The support for the audioinjector is terrible so far so in case nobody bothers to find a solution for this the sound card will still be useless.

flatmax
Posts: 609
Joined: Sat Jul 23, 2016 11:39 pm

Re: Recording with 16kHz sampling rate

Post by flatmax » Wed Mar 27, 2019 6:52 am

What happened when you use plughw ?
plughw will resample the audio from whatever sample rate it is down to 16 kHz.
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

Mortis19
Posts: 4
Joined: Wed Nov 28, 2018 7:27 pm

Re: Recording with 16kHz sampling rate

Post by Mortis19 » Wed Mar 27, 2019 5:32 pm

flatmax wrote:
Wed Mar 27, 2019 6:52 am
What happened when you use plughw ?
plughw will resample the audio from whatever sample rate it is down to 16 kHz.
As I mentioned above:
The plughw option works for the jackd server but the quality of the sound input is terrible...
Apart from this, I tried portaudio and it seems to be working for 16kHz.
So it works, but I'm trying to find a solution to get real audio out of this with 16 kHz.

UPDATE: Apparently, it works properly after tweaking the kernel and using plughw in the command of jackd. Now I can get 16 kHz audio using the audioinjector soundcard!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests