Advertisement
GeeckoDev

test audio

Oct 27th, 2011
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.10 KB | None | 0 0
  1. #include <pspkernel.h>
  2. #include <pspaudio.h>
  3. #include <math.h>
  4.  
  5. int exit_callback(int arg1, int arg2, void *common) {
  6.   sceKernelExitGame();
  7.   return 0; }
  8. int CallbackThread(SceSize args, void *argp) {
  9.   int cbid;
  10.   cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
  11.   sceKernelRegisterExitCallback(cbid);
  12.   sceKernelSleepThreadCB();
  13.   return 0; }
  14. int SetupCallbacks() {
  15.   int thid = 0;
  16.   thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
  17.   if(thid >= 0) sceKernelStartThread(thid, 0, 0);
  18.   return thid; }
  19.  
  20. PSP_MODULE_INFO("App",0,1,1);
  21. PSP_HEAP_SIZE_MAX();
  22.  
  23. int main()
  24. {
  25.   SetupCallbacks();
  26.  
  27.   short pcm[32768] = {0};
  28.   int i;
  29.  
  30.   // On génère la sinusoide
  31.   for (i=0; i<32768; i++) pcm[i] = 32700*sinf(i*0.3f);
  32.  
  33.   // On réserve un canal audio
  34.   sceAudioChReserve(0, 32768, PSP_AUDIO_FORMAT_MONO);
  35.  
  36.   for (i=0; i<10; i++)
  37.   {
  38.     // On joue le sample 10x d'affilée, volume maximum
  39.     sceAudioOutputBlocking(0, 0x8000, pcm);
  40.   }
  41.  
  42.   // On libère le canal audio
  43.   sceAudioChRelease(0);
  44.  
  45.   sceKernelExitGame();
  46.   return 0;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement