The AUDIO SetMode function is used only to configure the audio codec. You have to declare your own buffer and pass it as parameter to the AUDIO_Play function. The transfer from the buffer to the codec is made with DMA, and the variable "AUDIO_PlaybackBuffer_Status" (acceded by the AUDIO_PlaybackBuffer_GetStatus function) is used to indicate the status of the buffer (half and full tranfered). The AUDIO mode is used for playing from buffers, and VOICE mode for recording to buffers. The MONO mode is special because the samples are copied to a local intermediate buffer in order to copy the sample to left and right chanels before to be sent to the codec. The Circular modes do the DMA transfer from or to the buffer indefinitely in loop, instead to transfer the buffer contents once. This allows to manage a buffer as a double buffer, and filling the first part during transfer the second part of the buffer.
But the better for you is to take a look at the "PlayWav" and "Dictaphone" projects on the web site that use double buffer for playing and recording.
Circular mode will play the buffer until you stop it, and normal mode will play the buffer once.
In mono mode you will have only 16bit for 1 sample, but in stereo you will have 2*16bit for one sample, because both Left & Right data is present.
When the LOW_EMPTY is present the low half of the buffer has just been played, and you can fill data in to that area. When HIGH_EMPTY is present it just finished playing the upper half of the buffer and if circular mode is chosen it will start from the beginning of the buffer.
So that means you ½ buffer length to fill up the buffer.
Yes, you will only use 1 buffer in total... (split in 2 halfs)
So when it's LOW_EMPTY i want to fill the lower part. But what part is the lower part in C?
When I have programed other ARM platforms, GNU didn't use the same addressing in C as one other commercial alternative (that I don't remember the name of).
Always great to have some one who can give strait answers.
But according to my testing that I did yesterday the data is unsigned. This is somewhat a problem if you want to make some DSP calculation, as you can't calculate on unsigned data.
Ok! lets go on your word that it plays signed values. Here are some code to put in a regular project to test this.
This doesn't play a sinus wave at my place anyway. How ever, if you use an unsigned sinus waveform then the output will be a sinus layered upon a giant jitter cloud form the nice hardware.
I my reality this is a hint that it uses unsigned data. But if primer still uses signed data, can someone correct the code please. It would be very informative.
enum MENU_code Application_Ini(void) { // Ensure that the current OS version is recent enough if(strcmp(UTIL_GetVersion(), NEEDEDVERSION) < 0) { return MsgVersion(); }
// Play signed sinus wave AUDIO_SetMode(AUDIO_CIRCULAR_MODE, LG_8_BITS, FRQ_44KHZ, MONO); AUDIO_Play(sinus,256);
BufferStatus = AUDIO_PlaybackBuffer_GetStatus(LOW_EMPTY); = Low data has been added BufferStatus = AUDIO_PlaybackBuffer_GetStatus(HIGH_EMPTY); = High data has been added
BufferStatus = AUDIO_PlaybackBuffer_GetStatus(0); = Returns the buffer status
I have been looking in the code and at the moment i can't remember how 8bit stereo is working