Altera_Forum
Honored Contributor
13 years agoChanging the play back rate of a buffer in C?
Hello!
I am using an Altera DE2 FPGA board and running Quartus II, Nios II (V10.1). I loaded the Terasic V1.6 demo "DE2_SD_Card_Audio." Currently, I can play a .wav file from the SD card to the Line Out. Ignoring all the other details, the C code (hello_led.c) from the demo that outputs to Line Out is: UINT16 Tmp1=0; ... Tmp1=(Buffer[i+1]<<8)|Buffer[i]; //loads the data from the SD card to Tmp1 //change the buffer rate? IOWR(AUDIO_BASE, 0, Tmp1); //sends Tmp1 data to Line Out If I were to print Tmp1, it's basically the points on a sine wave. What I want to do now is fiddle with how the sound plays by changing the play back rate (ideally I want to play the sound up or down an octave, which is just double or half the frequency). Can anyone provide some suggestions on how I can do this in the section: //change the buffer rate? Is it possible in C to write a few lines of code in that section to obtain what I'm looking for? ie. change how fast I'm reading from the Tmp1 buffer to the AUDIO_BASE. Thanks in advance! ~Sarengo