Sound Effect Delay

Hello Sirs,
We’re developing an application using C++ for backend and QML for frontend.
In this application we’ll play some audios which format is WAV and length from
1 to 5 secs.

The problem is that when an audio will be played after no audio was played
before under ~6 seconds, it is delayed about ~2 seconds before starting
playing. So If the audio is played constantly, it has no delay.

Follows below two C++ functions, the first one (loadSystemSounds) is executed
in constructor’s class, the second function is a SLOT that’s called from QML
when a button is clicked.

As you can see, I’m debbuging the sound status before calling the play
function, and it’s always loaded and ready to play (status = 2 =
QSoundEffect::Ready).

private:
void TerminalManager::loadSystemSounds()
{
clickSoundUrl.setUrl("qrc:/sounds/SOUND_CLICK_2.wav");
clickSound.setSource(clickSoundUrl);
}

public slots:
void TerminalManager::playClickSound()
{
if(clickSound.isPlaying()){
clickSound.stop();
clickSound.play();
}else {
clickSound.play();
}
}

private:
void TerminalManager::loadSystemSounds()
{
qDebug() << clickSound.status();
clickSoundUrl.setUrl("qrc:/sounds/SOUND_CLICK_2.wav");
clickSound.setSource(clickSoundUrl);
}

void TerminalManager::loadSystemSounds()
{
clickSoundUrl.setUrl("qrc:/sounds/SOUND_CLICK_2.wav");
clickSound.setSource(clickSoundUrl);
}

void TerminalManager::playClickSound()
{
qDebug() << clickSound.status();

if(clickSound.isPlaying()){
clickSound.stop();
clickSound.play();
}else {
clickSound.play();
}
}

We’re using pulseaudio, there’s any configuration to be set on
pulseaudio to work properly with Qt?

One important detail that we’ve tested.
We put the oscilloscope on the pin module - pin15 - output for headphone left.
This pin Toradex recommend to use for audio system.
At stand-by mode, this pin have the level 0 (0V). When I play one sound, this
pin goes to level 1 (3.3V). After 5 seconds, this pin return to 0V.
If you play a sound before this 5 seconds, the module maintain this pin in
3.3V - and the delay doesn’t occur.
But, the delay every occurs when this pin is 0V.
So, I think maybe have one configuration about this (delay time to pin go to
0)

Are there any important configuration for this … or for SGTL500??

In terms of audio, we enabled alsa and pulseaudio using:

IMAGE_INSTALL_append = "
pulseaudio pulseaudio-server pulseaudio-misc pulseaudio-module-dbus-protocol
alsa-tools alsa-utils \ "

Regards,

Hi dlmmartins

Could you provide the version of software and hardware of your module? Which carrier Board are you using?

Can you provide a small application, so we could reproduce the issue on our side?

Thanks and best regards
Jaski

Sirs,

Like below: is there any delay configuration like in this topic for a Colibri iMX6 to decrease the delay?

https://www.toradex.com/community/questions/22423/sound-effect-playback-is-delayed-when-playing-movi.html

Hello Jaski,
Thanks to reply. We’re using a Colibri iMX6DL, version V1.1A.
About the board, we develop our own board.
I’m using the sound output at pin 15 (Headphone L) of SODDIM.
Attached a little application to test. Change the line 59 (delayTimer), if over 5 seconds I’ll reproduce our delay problem.link text

Jaski,
I forgot - we using a Qt version 5.9.4 - Yocto Rocko …

Hi @dlmmartins

I think the problem is the dynamic audio power management (DAPM), can you try to disable this and check if the problem still remains?

echo 0 > /sys/devices/soc0/sound/HiFi/pmdown_time

Regards,
Stefan

Hello

Could you try setting a big value to pmdown_time (1e6 or -1)?

Hello Stefan,
Sorry for the delay for the test.
Well, we tested to put your configuration:

echo 0 > /sys/devices/soc0/sound/HiFi/pmdown_time

But, the the delay stay equal.

However, I think we found the problem. Can you see the attach, with our screen.
This is the log of our test.
When we play any sound, and we cat dapm_widget value, we can see the paremeter ‘PM State:’
When we play any sound, this parameter goes to On - and any sound play with NO delay.
After 5 seconds, this parameter goes to ‘Standby’, like in the picture.
So, the next sound will be with the delay.
We need to fid one way to configure this parameter to stay forever in ON.
Kindly,

Sorry,
Attached picture,

Hello Jaski,
Sorry, nothing work, neither with -1, neither with a long value … 1e8 or 1e6.
The delay is still occurs.

Is the PM_State always ON or does it switch to “Standby”?

Hi @dlmmartins

Maybe it’s the pulseaudio configuration on my image pulsaudio forces the audio driver to stay awake. Can you once try to remove “load-module module-suspend-on-idle” from /etc/pulse/default.pa and /etc/pulse/system.pa?

Regards,
Stefan

Hi

You can set a parameter in uboot. Boot the module to uboot and type the following:

  • setenv defargs vmalloc=400M user_debug=30 enable_wait_mode=off
  • savenv

Dear Stefan,
Sorry for the daly for the reply.
Well, we removed “load-module module-suspend-on-idle” from /etc/pulse/default.pa and /etc/pulse/system.pa - but this remove cause other problem: no sound was played - no one.
If I put again the line, the sounds come back, with delay.
If help, here my little file with test.
One thing: I made a same question at NXP Community - and I received the follow reply:
“As for Linux one can try not use lower power modes (with “enable_wait_mode=off” kernel boot paramter)”
But I don’t know how to make this.
Kindly,link text

Dears,

https://community.nxp.com/thread/476707

Link da NXP, if help, OK

Dear Sirs,
We still have the same problem.
Anyone have one new solution for this case.
The las thing that we try, was put the parameter “enable_wiat_mode=off” on the kernel.
But this didn’t solve the problem.
Kindly,

Hi @dlmmartins

Could you provide your kernel .config and qt version?

Thanks and best regards,
Jaski

Hello jaski.tx, how are you?
I used the command: uname -a
Is this?
The answer is:

Linux inel 4.1.44-2.8.1+g18717e2b1ca9 #57 SMP Fri Mar 1 21:16:11 EST 2019 armv7l armv7l armv7l GNU/Linux
And the Qt version is: 5.9.4

Hi @dlmmartins!

The .config mentioned is the kernel configurations file. This should be inside your kernel repository you use to build. Alternatively, you can get these configs by running the following on your board:

# zcat /proc/config.gz > config.txt

Then paste the contents of config.txt here.

Best regards,
Gustavo.

Dear Sirs,
Attached the files.link text