Skip to main content
KBéla.1
Associate III
October 31, 2024
Solved

SRC236 Sample rate converter, noisy

  • October 31, 2024
  • 7 replies
  • 1652 views

Hy,

I have tried to resample a 16bit/8kHz audio signal to 16kHz and 48kHz.

Conversion works, but the audio is noisy. I am tested it on development board STM32H747 CM7 core.

I have tried libraries: SRC236_CM7_GCC.a and SRC236HQ_CM7_GCC.a without quality improvement.

I am working with 10ms blocks.

Initialization parameters are:

 

 

// conversion from 8kHz to 16kHz
src236_static_param_t src236_static_param.src_mode = SRC236_RATIO_2;
// library initialization
src_error = src236_reset(PSrc236PersistentMem_ToCodecOut, PSrcScratchMem_ToCodecOut);
if (src_error != SRC236_ERROR_NONE)
{
 return (-1); //error AUDIO_ERROR_SRC
}
/* SRC236 effect static parameters setting */
src_error = src236_setParam(&src236_static_param, PSrc236PersistentMem_ToCodecOut);
if (src_error != SRC236_ERROR_NONE)
{
 return (-1); //error AUDIO_ERROR_SRC
}

// 8kHz, 16 bit audio input // 10ms block
LowRateConversionBuff_ToCodecOut.nb_channels = 1;
LowRateConversionBuff_ToCodecOut.nb_bytes_per_Sample = 2;
LowRateConversionBuff_ToCodecOut.mode = NOT_INTERLEAVED;
// LowRateConversionBuff_ToCodecOut.data_ptr = //set data pointer before usage
LowRateConversionBuff_ToCodecOut.buffer_size = 80;

// 16kHz, 16bit audio output
HighRateConversionBuff_ToCodecOut.nb_channels = 1;
HighRateConversionBuff_ToCodecOut.nb_bytes_per_Sample = 2;
HighRateConversionBuff_ToCodecOut.mode = NOT_INTERLEAVED;
// HighRateConversionBuff_ToCodecOut.data_ptr = //set data pointer before usage
HighRateConversionBuff_ToCodecOut.buffer_size = 160;

 

 

Processing part:

 

 

LowRateConversionBuff_ToCodecOut.data_ptr = pInData;
HighRateConversionBuff_ToCodecOut.data_ptr = pOutData;

src_error = src236_process(&LowRateConversionBuff_ToCodecOut, &HighRateConversionBuff_ToCodecOut, PSrc236PersistentMem_ToCodecOut);
if (src_error == SRC236_ERROR_NONE)
{
 return 0;
}

 

 

 

Best answer by KBéla.1

Thank you for your helps, it was my fault.

I sometimes processed the same packet of data more times. It generated a noise when a new packet started.

After a repair, audio quality is good, both in normal, and in HQ modes, too. 

Anyway I am extracted the resample functionality from X-CUBE-AUDIO-KIT, for IIR mode, 16 bit data, without any malloc, OS functionality, and it works too. 

 

7 replies

Andrew Neil
Super User
October 31, 2024
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
STOne-32
Technical Moderator
October 31, 2024

Dear @KBéla.1 ,

 

It may happen you are using a Library not compatible yet with STM32H7 series .  let us know which version are you using .

You can check this link  : X-CUBE-AUDIO-KIT - Audio processing software expansion for STM32Cube - STMicroelectronics

 

If you are using this Library : X-CUBE-AUDIO - Audio effects software expansion for STM32Cube - STMicroelectronics  you can see 

  • STM32Cube audio effect modules and libraries for the STM32F4 and STM32F7 Series of microcontrollers

Hope it helps

STOne-32.

KBéla.1
KBéla.1Author
Associate III
November 4, 2024

I tried SRC236 lib version: V1.0.3 , from 

X-CUBE-AUDIO v1.1.1, and it is noisy. The only parameter which I can change is the audio block size, which can be a mono or stereo signal. Now I am using 10ms Mono audio blocks, which not works.

 

Now I am going to try resample functionality from X-CUBE-AUDIO-KIT. I can`t find documentation for it, but the sources are available, so I hope, I can do it.

Thanks for the info

 

 

Andrew Neil
Super User
November 4, 2024

@KBéla.1 wrote:

X-CUBE-AUDIO-KIT. I can`t find documentation for it


Did you see:

https://www.st.com/en/embedded-software/x-cube-audio-kit.html#documentation

In particular, UM3297Getting started with X-CUBE-AUDIO-KIT

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
KBéla.1
KBéla.1AuthorBest answer
Associate III
November 8, 2024

Thank you for your helps, it was my fault.

I sometimes processed the same packet of data more times. It generated a noise when a new packet started.

After a repair, audio quality is good, both in normal, and in HQ modes, too. 

Anyway I am extracted the resample functionality from X-CUBE-AUDIO-KIT, for IIR mode, 16 bit data, without any malloc, OS functionality, and it works too. 

 

STOne-32
Technical Moderator
November 8, 2024

Great @KBéla.1  ! very happy to see you made it working.

Associate
October 27, 2025

hello Kbella ,
i am trying to use src236 library also to resample 8khz audio to 16khz in stm32h7
. i am getting this error 

SRC236_BAD_HW
could you please share your working code snippet or guide me how i can use this to correctly resample the audio frames
thank you
KBéla.1
KBéla.1Author
Associate III
October 27, 2025

Hello Sajidehsan,

BAD_HW means, that you are triing to use a library, which is not compatible with your hardware.

Possible solutions:

- Find right library for your or HW,

or

- If I correctly remember, also can be a problem, if you do not have a correct setup for your floating point unit. Now I have a setupfor Floating-point ABI: Hardware implementation (-mfloat-abi=hard), but actually I am not using SRC library, and I am not able to test it actually. I am using other DSP libs from STM, and they are OK with that setup.

Associate
October 27, 2025

hello kbela,
thank you for the reply.
i am using stm32h723, yes you are right i guess this library is not compatible, because my board doesnot have Hardware SRC. 
could you please share other libs which you used for resample?
and if you have configured codec2 on stm32? if yes could you please share your code snippet?

KBéla.1
KBéla.1Author
Associate III
October 27, 2025

Sorry but, now I am not using any resampling. Everything works on 16kHz. :), and I do not know what is codec2.

I worked with resampling on cpu STM32F769, I do not have experience with H723.