/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Suppressing Audio clicks

Username:     
Password:     
             

Forum

# 1   2009-11-30 11:54:21 Suppressing Audio clicks

slimjim
New member
Registered: 2009-11-26
Posts: 9

Suppressing Audio clicks

Hi,

I got my Primer 2 a couple of days ago and am new to the forum, so hello...

I have been trying to develop a kind of drum sampler, based on the wav player demo.
As this application requires instant playback of samples I have stored all my samples in 16 Bit, little endian 44.1khz mono raw format and removed all the wav parsing and endian functions.

It works well, the sounds are triggered immediately but:

Now what I notice is that at the start and end of playback there is an very noticeable click or transient spike. It is probably only noticeable to me as I am triggering many short samples, and wouldn't be so much of an issue if one was to play a song or longer piece of audio...

I am wondering if there is some low level function which could suppress these transients, I have tried writing to the registers directly to effect an audio ramp up/down, but still the transients appear at AUDIO_Play and AUDIO_Playback stop.

Any help would be appreciated, I will post my code if it helps but it is really something I think anyone using the above 2 functions would notice if they listen.

-James


Ride 7                   : 7.24.09.0251
RKit-ARM for Ride7 : 1.22.09.0254
Primer2
CircleOS                : 3.8

Offline

 

# 2   2009-11-30 23:16:56 Suppressing Audio clicks

slimjim
New member
Registered: 2009-11-26
Posts: 9

Re: Suppressing Audio clicks

Problem solved,

The solution was to only call the AUDIO_Play function in init and the AUDIO_Playback_stop at exit, merely emptying the buffer between files.

Still I think it would be something to think about for future versions of circle os, some way to make the functions suppress the clicks they generate.


Ride 7                   : 7.24.09.0251
RKit-ARM for Ride7 : 1.22.09.0254
Primer2
CircleOS                : 3.8

Offline

 

# 3   2009-12-01 06:42:26 Suppressing Audio clicks

repzak
Member
Registered: 2008-03-05
Posts: 170

Re: Suppressing Audio clicks

Hello,

Why don't you just use the playback in AUDIO_CIRCULAR_MODE, and then fill up the buffer before play?

Kasper

Offline

 

# 4   2009-12-01 07:13:58 Suppressing Audio clicks

slimjim
New member
Registered: 2009-11-26
Posts: 9

Re: Suppressing Audio clicks

Thanks for the reply, the problem is sorted.

repzak :

Hello,

Why don't you just use the playback in AUDIO_CIRCULAR_MODE, and then fill up the buffer before play?

Kasper

This is what I tried first, as in your wav/mp3 demos, it works, but the transient spikes are too noticeable for a musical instrument application that way.

My audio samples sound immediately I touch the screen, there is no wav parseing to slow the process down, and so the spikes are obvious. As a side note I have to say I am really impressed with the low latency time the system has compared to trying the same thing on a very high spec pc...

As far as I can tell the problem lay in the low level functioning of Audio_Play() and Audio_Playback_stop(). I believe these functions (especially stop) power down the codec and this generates an audio spike. I was filling the buffer before playing but due to my short samples (1 sec at most) I would notice the transients and it was unuseable.

Since the application is audio specific, I don't need the codec to shut down until I exit the program, and so by only calling AUDIO_Play() in the Application_init function, and Audio_Playback_Stop() at the end of the program, I can purely manipulate the buffers, opening and closing files and emptying/filling the buffer as nesessary without incurring shutdown or restart of the codec. The sound is vastly improved, and in my application this was of paramount importance.

Thanks for the suggestion and your work on the wav and mp3 demos, they helped enormously

James


Ride 7                   : 7.24.09.0251
RKit-ARM for Ride7 : 1.22.09.0254
Primer2
CircleOS                : 3.8

Offline

 

# 5   2009-12-01 07:57:55 Suppressing Audio clicks

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: Suppressing Audio clicks

Hi,

The switch to standby mode during Audio_Playback_Stop was added in order to avoid non expected noises, generated sometimes by the codec, when no sound is playing.
Effectively, for an pure audio application, it  may be annoying if  transient spikes appear. We will think about it for further version of CircleOS.

Yves

Offline

 

# 6   2009-12-02 00:16:57 Suppressing Audio clicks

slimjim
New member
Registered: 2009-11-26
Posts: 9

Re: Suppressing Audio clicks

Yes, there is a systemic high pitched clock noise present constantly when leaving the codec active, but it is preferable to the transient spikes. By using the AUDIO_WriteRegister() function it is possible to manually suppress this noise by decreasing the treble value during silence.

The datasheet for the codec mentions that during startup and standby there is transient suppression applied, so perhaps the spikes are rather caused by the DMA_Cmd() or   SPI_I2S_DMACmd() functions within the AUDIO_Playback stop() and AUDIO_Play() functions


Ride 7                   : 7.24.09.0251
RKit-ARM for Ride7 : 1.22.09.0254
Primer2
CircleOS                : 3.8

Offline

 

Board footer