[pulseaudio-discuss] Sample format spec with Linear 16bit 16kHz

Shinnosuke Suzuki suzukisn at gmail.com
Sat Feb 10 01:11:10 UTC 2018


Hi

> PA 11.1 should work fine with your kernel and bluez version.

Thank you, I’ll try that.

>>> When you record from the BT headset, the BT headset is set to HSP/HFP.
>>> This means that recording and playback stream are at 8kHz, not 16kHz.


I want to handle voice packet as Linear 16bit little endian 16000Hz,
I configure stream as follows.
 static pa_sample_spec samplespec = {
     .format = PA_SAMPLE_S16LE, /* Linear 16bit */
     .rate = 16000, /* 16000Hz */
     .channels = 1 /* mono */
 }
Does it means .rate should be 8000?

> You should not expect to get a fixed number of bytes in a fixed time
> interval. This is only true on average but not for a single callback. Are
> the 96 bytes an average value?
> If your application needs constant size data packets, you may have to
> buffer some data.
> Did you take a look at the pacat code to see how reading data from
> a stream is done correctly?

I don’t expect fixed number of bytes. So, I implemented to  buffer voice packets in read callback.
However I got voice packet on my callback at 96 bytes per 10ms constantly.
It means I couldn’t get sufficient voice packet because voice packet needs 
at least 320bytes per 10ms in case of Linear 16bit little endian 16000Hz.

I read pacat how to handle voice packet in read callback.
I implemented like pacat except silence hole using pa_silence_memory().

> Did you test other resample methods? There are quite a few available
> and "trivial" is definitely the worst of them.

No I didn’t. I’ll change the coniguration.

Best Regards,
Shinnosuke Suzuki.
> Date: Fri, 9 Feb 2018 08:42:39 +0100
> From: Georg Chini <georg at chini.tk>
> To: General PulseAudio Discussion
> 	<pulseaudio-discuss at lists.freedesktop.org>,  Shinnosuke Suzuki
> 	<suzukisn at gmail.com>
> Subject: Re: [pulseaudio-discuss] Sample format spec with Linear 16bit
> 	16kHz
> Message-ID: <c16ab184-45a0-9401-523d-009d1e9dd33f at chini.tk>
> Content-Type: text/plain; charset=utf-8; format=flowed
> 
> On 09.02.2018 07:17, Shinnosuke Suzuki wrote:
>> Sorry, I didn't change the Subject.
>> 
>> Hi, Thank you for prompt reply.
>> 
>>> Can't you use a newer version? We are at 11.1 already and the
>>> bluetooth code has changed significantly.
>> 
>> I hope to do so, but I am developing on a embedded system (linux 
>> kernel 3.10.49 Openwrt).
>> And I use BlueZ 5.30.
>> If pulseaudio 11.1 doesn't depend on kernel version, I would like to 
>> install pulseaudio 11.1.
>> Does it any dependency on this?
> 
> PA 11.1 should work fine with your kernel and bluez version.
> 
>> 
>>> When you record from the BT headset, the BT headset is set to HSP/HFP.
>>> This means that recording and playback stream are at 8kHz, not 16kHz.
>>> Pulseaudio only supports CVSD codec, not mSBC.
>> 
>> Thank you, I understand what codec pulseaudio uses.
>> So pulseaudio convert codec like this?
>>  My app <- Linear 16bit 16kHz <- Pulseaudio  <-  CVSD codec ( 8kHz?) 
>> <- Bluetooth Headset
>> My application want to use a Linear 16bit 16kHz because of a DSP spec.
>> From your point out, Do I have to set a sample format to PA_SAMPLE_U8?
>> If so, Do I have to convert voice packet which I get from callback 
>> from 8kHz to 16kHz?
>> I thought pulseaudio do this.
> 
> yes, PA will do the re-sampling.
> 
>> And I could get a voice data by 96byte per 10ms.
>> If stream is 8kHz, What codec could get in My app? PCM 8bit?
>> I couldn't understand why My app get 96byte per 10ms.
> 
> You should not expect to get a fixed number of bytes in a fixed time
> interval. This is only true on average but not for a single callback. Are
> the 96 bytes an average value?
> If your application needs constant size data packets, you may have to
> buffer some data.
> Did you take a look at the pacat code to see how reading data from
> a stream is done correctly?
> 
>> 
>>> resample-method=trivial might result in bad audio quality.
>> I did set because CPU load is extremely high. I don't know why CPU 
>> load is high.
>> So CPU load becomes low, I'll change configuration file.
> 
> Did you test other resample methods? There are quite a few available
> and "trivial" is definitely the worst of them.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20180210/03bdf44a/attachment.html>


More information about the pulseaudio-discuss mailing list