Technical discussions about the TI C54x DSPs (including the c5401, c5402, c5402a, c5404, c5407, c5409, c5409a, c5410, c5410a, c5416, c5420, c5421, c5441, c549, c5470 and c5471).
|
Hello all, I am trying to output wav sample from the dsk
c5402 speaker.
i'm using the AD50 APIs in a C program, and i
call the codec_cont_play function after filling the ping pong buffers with some
PCM values.
those PCM values were taken from a wav file, we
made it using microsoft sound recorder and we choose the sampling rate to
be 8 Khz
there is another function that i call, it is
called codec_sample_rate, and i gave it 8Khz as a parameter,
I didn't find any documentation of the AD50
API, so i couldn't figure out exactly how each function works.
what i know so far is as follows, the
codec_cont_play function enables an ISR, which is called continously (i don't
know at what rate) whenever the ping pong buffer contains new
data.
I'm not sure what the codec_sample_rate
function do, but i hope it has something to do with the rate with which the PCM
samples are sent to the D/A.
I hope i'm not bothering you, thank you a
lot.
this is the c code which do what is described
above, and the PCM values are attached to this mail.
#include <wav4.h>
#define
BUF_SIZE
17000
#define TABLE_SIZE &nbs p; 8500 &nbs p; s16
toneBuf[2][BUF_SIZE];
s16 *pBuf[2]; if ((hCod = codec_open(HANDSET_CODEC)) ==
0)
{ printf("codec_open() failed\n"); return(ERROR); } /* synthesize tone */ genTone(toneBuf[0], BUF_SIZE, BOTH); genTone(toneBuf[1], BUF_SIZE, BOTH); if (codec_sample_rate(hCod,SR_8000) == ERROR) return (ERROR); if (codec_dac_mode(hCode,DAC_MODE_16BIT) ==
ERROR)
return (ERROR);
if (codec_cont_play(hCod, MODE_INT, toneBuf[0], toneBuf[1], BUF_SIZE, 0, &bufStatus) == ERROR) { /* printf("Error playing buffer to codec\n"); */ return (ERROR); } /* wait for first buffer to be done */ while (*bufStatus); while(1)
{ /* fill buffer and setup for next buffer */ genTone(toneBuf[bufNum], BUF_SIZE, BOTH); bufNum ^= 1; /* wait for buffer to be empty
*/
while (*bufStatus != bufNum); } } static void genTone(s16 *pBuf, u16 size, u16 ch) { u16 i = 0; s16 temp; for (i=0; i<100; i++) { /* index = round-off, grab bit 7 through 14, and shift right by 7 */ temp = wav[ ((sig.offset + 0x0040) & INTEGER_PART) >> 7 ]; /*temp = wav[i];*/ if ( (ch == LEFT) || (ch == BOTH) ) pBuf[i] = 1 * temp; else pBuf[i] = 0; ++i; if ( (ch == RIGHT) || (ch == BOTH)
)
pBuf[i] = 1 * temp; else pBuf[i] = 0; sig.offset += 1; } } | |||
|