Audio input from USB Stick to DAC

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Audio input from USB Stick to DAC

533 Views
oliviachristyva
Contributor III

Hi,

I am new to Embedded Software and now my task is to play an audio file from a USB stick using DAC.

I successfully played the audio file from the code using TWR- K60 and TWR-SER2 board and I got the output out of the DAC pin in TWR-K60 board(using AN4369SW). I was able to install the USB-MFS file system on the same board and its working fine . Also I integrated both the codes and both are working fine. But I dont know how to read the audio file from the USB Stick and give it to the DAC out directly without using SPI or other interface. I am working with MQX 4.2 in KDS. 

Please share your ideas.

Regards,

Olivia 

0 Kudos
Reply
1 Reply

332 Views
oliviachristyva
Contributor III

Hi guys,

I was able to read the directory from the usb stick and list it with the help of MQX user guides. Now  I need to read a particular wave file from the directory and pass it to the DMA buffer for the DAC output. Please share the fucntion to read a file from this directory using MQX and to save the contents of that file to a buffer so that I can copy it to the DMA buffer.

memset(buffer,0,100);
path_ptr = "*.*";
mode_ptr = "m";
fs_ptr = _io_get_first_valid_fs();
dir_ptr = _io_mfs_dir_open(fs_ptr, path_ptr, mode_ptr );
if (dir_ptr == NULL)
{
printf("File not found.\n");
}
else
{
while ((len = _io_mfs_dir_read(dir_ptr, buffer, 100))>0){

strcpy(USB_Files,buffer);
printf(USB_Files);

}
_io_mfs_dir_close(dir_ptr);

Regards,

Olivia

0 Kudos
Reply