2014-12-02 06:58 PM
2014-12-02 11:24 PM
Hi,
It seems that your code is trying to read from the file the same number of data that you output to the DAC, which is abviously wrong, since the MP3 data is compressed. Long time ago, I have used Libmad on the STM32F4. You can find my old code here : http://jjmz.free.fr/?p=210 JJ2014-12-03 01:12 AM
Hi,
Thanks for your kind reply! May I know is your code compiled under the Linux platform instead of the IAR? Cause I am facing a lot of problem in IAR. Can you please advise which platform is more suitable?Thanks a lot.Sincerely,Kwan2014-12-03 05:17 AM
Yes it was compiled under Linux, with Gnu GCC Arm embedded ( https://launchpad.net/gcc-arm-embedded ). The basis was also the WAV example from the STM32F4 discovery platform.
2014-12-03 07:54 AM
May I know is it applicable to run this under the FreeRTOS? Thanks a lot.
2014-12-03 08:08 PM
Hello,
May I know what is this function ''Audio_MAL_Play(wave_buf0, wave_buf1, 4*1152);''doing in the mad.c (the ''enum mad_flow output'') there. Cause I don't see there is any function like this in the original code there. And, which function are you using for playing the sound out to the codec? Thanks in advance.Sincerely,Kwan2014-12-03 10:59 PM
Maybe I should have pointed you to http://jjmz.free.fr/?p=91
as it was the closest to the wav example. Then I progressively adapted the code to use ChibiOS functions instead of the SPL functions. Some maybe (and honestly I don't remember) the function is a ChibiOS provided one (I have not included ChibiOS in the ar file). Concerning your previous question : yes I think that FreeRTOS would be o too.2014-12-04 12:43 AM
Hello,
I done implement the part as given by the first example, but still no sound coming out from the audio port. I think I stuck somewhere around the output part there. After reading through the first and second example given, I still a bit confusing in the output part regarding how to switch the buffer. Here are my code for the output part:-enum
mad_flow output(
void
*data,
struct
mad_header
const
*header,
struct
mad_pcm *pcm)
{
unsigned
int
nchannels, nsamples;
mad_fixed_t
const
*left_ch, *right_ch;
signed sample;
uint16_t *output=wavebuffer_1;
uint16_t *write_buf;
int
i;
nchannels = pcm->channels;
nsamples = pcm->length;
left_ch = pcm->samples[0];
right_ch = pcm->samples[1];
output = wavebuffer_0;
write_buf = output;
while
(nsamples--)
{
sample = scale(*left_ch++);
*output++ = sample;
if
(nchannels == 2) sample = scale(*right_ch++);
*output++=sample;
}
if
(playing==0)
{
BSP_AUDIO_OUT_Play((uint16_t*)&wavebuffer_1, 4*1152);
playing = 1;
}
else
{
BSP_AUDIO_OUT_Play((uint16_t*)&wavebuffer_0, 4*1152);
playing = 0;
}
return
MAD_FLOW_CONTINUE;
}
May I know what is my mistake over here? Thanks a lot. Your kindness is really sincerely appreciated.
Sincerely,
Kwan
2014-12-04 12:54 AM
Hello,
This is my full project -> https://www.dropbox.com/s/dko2oo4ux3lut9x/Audio_playback_and_record.zip?dl=0I have done implementing it in FreeRTOS before going for the mp3 decoding. The two main C files for decoding and playing the mp3 are in the mad.c and waveplayer.c.