2024-10-31 1:30 AM - edited 2024-10-31 1:39 AM
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;
}
Solved! Go to Solution.
2024-11-08 12:06 AM
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.
2024-10-31 1:34 AM
Please see the posting tips for how to properly post source code:
2024-10-31 1:20 PM
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
Hope it helps
STOne-32.
2024-11-04 12:53 AM
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
2024-11-04 1:11 AM
@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, UM3297, Getting started with X-CUBE-AUDIO-KIT
2024-11-08 12:06 AM
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.
2024-11-08 1:20 AM
Great @KBéla.1 ! very happy to see you made it working.
2025-10-26 11:40 PM
hello Kbella ,
i am trying to use src236 library also to resample 8khz audio to 16khz in stm32h7
. i am getting this error
2025-10-27 12:43 AM
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.
2025-10-27 12:47 AM
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?