Guest User

Untitled

a guest
Feb 24th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. u8 audio_test()
  2. {
  3.     int channel = 1;
  4.    
  5.     // Initialize ndsp
  6.     ndspInit();
  7.    
  8.     ndspSetOutputMode(NDSP_OUTPUT_MONO);
  9.     ndspSetOutputCount(1); // Num of buffers
  10.    
  11.     // Reading wav file
  12.  
  13.    
  14.     // Allocating and reading samples
  15.     u8* data = (u8*)linearAlloc(2048*1024);
  16.     memset(data, 63, 2048*1024);
  17.    
  18.     if(!data)
  19.     {
  20.         printf("!data\n");
  21.         return 1;
  22.     }
  23.  
  24.     // Find the right format
  25.     u16 ndspFormat;
  26.    
  27.     ndspFormat = NDSP_FORMAT_MONO_PCM8;
  28.    
  29.     ndspChnReset(channel);
  30.     ndspChnSetInterp(channel, NDSP_INTERP_NONE);
  31.     ndspChnSetRate(channel, 32000.0f);
  32.     ndspChnSetFormat(channel, ndspFormat);
  33.    
  34.     // Create and play a wav buffer
  35.     ndspWaveBuf waveBuf;
  36.     memset(&waveBuf, 0, sizeof(ndspWaveBuf));
  37.    
  38.     waveBuf.data_vaddr = data;
  39.     waveBuf.nsamples = 2048*1024;
  40.     waveBuf.looping = true; // Loop enabled
  41.     waveBuf.status = NDSP_WBUF_FREE;
  42.    
  43.     DSP_FlushDataCache(data, 2048*1024);
  44.    
  45.     ndspChnWaveBufAdd(channel, &waveBuf);
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment