Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
710 Views

Changing 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
0 Kudos
1 Reply
Altera_Forum
Honored Contributor I
27 Views

Here are some options 

-simple software delay loop 

-timer interrupt with a variable interrupt frequency based upon how fast you want to set the DAC 

-Software writes samples to a FIFO and statemachine, which writes data out to a DAC at a particular output rate specified by the software 

 

http://www.dspdimension.com/admin/time-pitch-overview/
Reply