C programs - playing MP3 files using C

 /* snd_testV1 */  
 // header files  
 #include<unistd.h>  
 #include<stdio.h>  
 #include<error.h>  
 #include<errno.h>  
 //main func  
 int main(int argc, char *argv[])  
 {  
      FILE *song;  
      FILE *snd_op;  
      char song_data[256];  
      song=fopen("/home/abishek/Music/PPRY.mp3","r");  
      snd_op=fopen("/dev/dsp","w");  
      if(song==NULL)  
       {  
        error(1,errno,"cannot open file");  
       }  
      if(snd_op==NULL)  
       {  
        error(1,errno,"cannot open player");  
       }  
      while(song_data!=NULL)  
       {  
        fgets(song_data,sizeof(song_data),song);  
        if(song_data==NULL)  
         {  
           //eof reached return  
           return 0;  
         }  
        fprintf(snd_op,"%s",song_data);  
       }  
      fclose(snd_op);  
      fclose(song);  
 }  

Comments

Popular posts from this blog

Generating 16k ROM using Xilinx IP COREGEN and simulating it in modelsim

Setting up atalanta ATPG to work on Linux

Sparse matrix - 3 tuple representation