Forum Discussion
Altera_Forum
Honored Contributor
17 years agoThanks, I figured it out though.
It was because I was incrementing the value NUM within a statement: index = index+len[NUM++]; So it was taking the next value, when instead I wanted the present value and the incrementation to happen after. I also changed the max values and the unsigned integers to regular integers. Seems to work now. This is what I have: # include <Z:\try3\app_software\include\alt_up_audio.h> # define Switch (volatile char *) 0x01001020 # define MAX_DATA 480000 int main() { int len[480000]; alt_u32 audiobuf[128]; alt_u32 audiostream[MAX_DATA]; int index= 0; int ii,jj,NUM=0; // Switch 0 should be off for playback alt_up_audio_reset_audio_core(); while(1) { if ((*Switch) & 0x01) { len[NUM] = alt_up_audio_read_left_channel(audiobuf,128); if((index + len[NUM]) < MAX_DATA) // chek for data overflow { for(ii = 0; ii < len[NUM]; ii++){ audiostream[ii+index] = audiobuf[ii]; } index = index+len[NUM]; NUM=NUM+1; } } else if((*Switch) & 0x02) { index = 0; for (jj = 0; jj < NUM; jj++){ alt_up_audio_write_left_channel(audiostream+index,len[jj]); alt_up_audio_write_right_channel(audiostream+index,len[jj]); index=index+len[jj]; } NUM = 0; index = 0; } } }