Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- u8 audio_test()
- {
- int channel = 1;
- // Initialize ndsp
- ndspInit();
- ndspSetOutputMode(NDSP_OUTPUT_MONO);
- ndspSetOutputCount(1); // Num of buffers
- // Reading wav file
- // Allocating and reading samples
- u8* data = (u8*)linearAlloc(2048*1024);
- memset(data, 63, 2048*1024);
- if(!data)
- {
- printf("!data\n");
- return 1;
- }
- // Find the right format
- u16 ndspFormat;
- ndspFormat = NDSP_FORMAT_MONO_PCM8;
- ndspChnReset(channel);
- ndspChnSetInterp(channel, NDSP_INTERP_NONE);
- ndspChnSetRate(channel, 32000.0f);
- ndspChnSetFormat(channel, ndspFormat);
- // Create and play a wav buffer
- ndspWaveBuf waveBuf;
- memset(&waveBuf, 0, sizeof(ndspWaveBuf));
- waveBuf.data_vaddr = data;
- waveBuf.nsamples = 2048*1024;
- waveBuf.looping = true; // Loop enabled
- waveBuf.status = NDSP_WBUF_FREE;
- DSP_FlushDataCache(data, 2048*1024);
- ndspChnWaveBufAdd(channel, &waveBuf);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment