Altera_Forum
Honored Contributor
11 years agoDE2-115 Will Not Output Audio
I am trying to output audio from the DE2-115 board. I have the audio and the external clock in my .qsys file, and I have been using the example C code given by the Audio core documentation. I want to create a specific tone held in an array named c, and output it to the board. I am able to open the audio device, but the code does not seem to be able to write the data to the left and right buffers. Is there a way to do this?
Here is my code: alt_up_audio_dev * audio_dev; /* used for audio record/playback */ unsigned int l_buf; unsigned int r_buf; // open the Audio port audio_dev = alt_up_audio_open_dev ("/dev/audio_0"); if ( audio_dev == NULL) alt_printf ("Error: could not open audio device \n"); else alt_printf ("Opened audio device \n"); /* read and echo audio data */ alt_up_audio_reset_audio_core(audio_dev); int count = 0; while(1) { // write audio buffer int sound_size = 50; int r_size = alt_up_audio_write_fifo_space(audio_dev, ALT_UP_AUDIO_RIGHT); int l_size = alt_up_audio_write_fifo_space(audio_dev, ALT_UP_AUDIO_LEFT); if((r_size > sound_size) && (l_size > sound_size)){ alt_up_audio_write_fifo_head(audio_dev, c, ALT_UP_AUDIO_RIGHT);//write the contents of the tone array to right buffer alt_up_audio_write_fifo_head(audio_dev, c, ALT_UP_AUDIO_LEFT); } } } Sidebar: Should the audio be memory-mapped or streaming if I already have the arrays written somewhere and I just want to output them?