int InitSceMp3() { sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); sceUtilityLoadModule(PSP_MODULE_AV_MP3); if (sceMp3InitResource()<0) { return PSPAALIB_ERROR_SCEMP3_INIT_RESOURCE; } return PSPAALIB_SUCCESS; }
extern "C" int main(int argc, char *argv[]) { sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); sceUtilityLoadModule(PSP_MODULE_AV_SASCORE); __sceSasInit(&sasCore, 128, 32, 1, 44100); memset(pcm, 0xCC, sizeof(pcm)); checkpointNext("After init:"); testPauseVoice(&sasCore, 1, 1, "Pause without type"); testPauseVoice(&sasCore, 1, 1, "Pause twice"); testPauseVoice(&sasCore, 1, 0, "Resume without type"); testPauseVoice(&sasCore, 1, 0, "Resume twice"); testPauseVoice(&sasCore, 1, 2, "Pause 2"); testPauseVoice(&sasCore, 1, -1, "Pause -1"); testPauseVoice(&sasCore, 1, 0x80000000, "Pause 0x80000000"); __sceSasSetVoicePCM(&sasCore, 0, pcm, 256, 0); __sceSasSetADSRmode(&sasCore, 0, 7, PSP_SAS_ADSR_CURVE_MODE_LINEAR_INCREASE, PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE, PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE, PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE); __sceSasSetADSR(&sasCore, 0, 7, 0x1000, 0x1000, 0x1000, 0x1000); checkpointNext("After voice setup:"); testPauseVoice(&sasCore, 1, 1, "Pause"); testPauseVoice(&sasCore, 1, 0, "Resume"); __sceSasSetKeyOn(&sasCore, 0); checkpointNext("After key on:"); testPauseVoice(&sasCore, 1, 1, "Pause"); testPauseVoice(&sasCore, 1, 0, "Resume"); __sceSasSetKeyOff(&sasCore, 0); checkpointNext("After key off:"); testPauseVoice(&sasCore, 1, 1, "Pause"); testPauseVoice(&sasCore, 1, 0, "Resume"); __sceSasSetKeyOn(&sasCore, 0); __sceSasCore(&sasCore, samples); checkpointNext("After key on and core:"); testPauseVoice(&sasCore, 1, 1, "Pause"); int height = __sceSasGetEnvelopeHeight(&sasCore, 0); if (height < 0) { checkpoint("Height while paused: %08x", height); } memset(samples, 0xdd, sizeof(samples)); checkpoint("Core while paused: %08x", __sceSasCore(&sasCore, samples)); checkpoint("Height change: %08x", __sceSasGetEnvelopeHeight(&sasCore, 0) - height); testPauseVoice(&sasCore, 1, 0, "Resume"); return 0; }
bool JMP3::loadModules() { JLOG("loading Audio modules"); #ifdef MP3_SUPPORT int loadAvCodec = sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); if (loadAvCodec < 0) { return false; } int loadMp3 = sceUtilityLoadModule(PSP_MODULE_AV_MP3); if (loadMp3 < 0) { return false; } JLOG("Audio modules loaded"); #endif return true; }
int loadNetCommon() { if (isImported(sceUtilityLoadNetModule)) return sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON); else if (isImported(sceUtilityLoadModule)) return sceUtilityLoadModule(PSP_MODULE_NET_COMMON); else return SCE_KERNEL_ERROR_ERROR; }
static int load_util(int module) { #ifdef UTILITY_AV_AVCODEC_PATH SceUID ret; #endif dbg_printf("Loading 0x%08X\n", module); if (isImported(sceUtilityLoadModule)) return sceUtilityLoadModule(module); else if (module <= PSP_MODULE_NET_SSL && isImported(sceUtilityLoadNetModule)) return sceUtilityLoadNetModule(module + PSP_NET_MODULE_COMMON - PSP_MODULE_NET_COMMON); else if (module == PSP_MODULE_USB_PSPCM && isImported(sceUtilityLoadUsbModule)) return sceUtilityLoadUsbModule(PSP_USB_MODULE_PSPCM); else if (module <= PSP_MODULE_USB_GPS && isImported(sceUtilityLoadUsbModule)) return sceUtilityLoadUsbModule(module + PSP_USB_MODULE_MIC - PSP_MODULE_USB_MIC); else if (module <= PSP_MODULE_AV_G729 && isImported(sceUtilityLoadAvModule)) return sceUtilityLoadAvModule(module + PSP_MODULE_AV_AVCODEC - PSP_AV_MODULE_AVCODEC); else #ifdef UTILITY_AV_AVCODEC_PATH if (module == PSP_MODULE_AV_AVCODEC) { ret = sceKernelLoadModule(UTILITY_AV_AVCODEC_PATH, 0, NULL); return ret < 0 ? ret : sceKernelStartModule(ret, 0, NULL, NULL, NULL); } else #endif #ifdef UTILITY_AV_SASCORE_PATH if (module == PSP_MODULE_AV_SASCORE) { ret = sceKernelLoadModule(UTILITY_AV_SASCORE_PATH, 0, NULL); return ret < 0 ? ret : sceKernelStartModule(ret, 0, NULL, NULL, NULL); } else #endif #ifdef UTILITY_AV_ATRAC3PLUS_PATH if (module == PSP_MODULE_AV_ATRAC3PLUS) { ret = sceKernelLoadModule(UTILITY_AV_ATRAC3PLUS_PATH, 0, NULL); return ret < 0 ? ret : sceKernelStartModule(ret, 0, NULL, NULL, NULL); } else #endif #ifdef UTILITY_AV_MPEGBASE_PATH if (module == PSP_MODULE_AV_MPEGBASE) { ret = sceKernelLoadModule(UTILITY_AV_MPEGBASE_PATH, 0, NULL); return ret < 0 ? ret : sceKernelStartModule(ret, 0, NULL, NULL, NULL); } else #endif return SCE_KERNEL_ERROR_ERROR; }
void load_utils() { int ret; int module; unsigned i; if (isImported(sceUtilityLoadModule)) { // Load modules in order if (!globals->isEmu || sceNetIsImported) for(i = 0; i < sizeof(netModules) / sizeof(int); i++) { ret = sceUtilityLoadModule(netModules[i]); if (ret < 0) dbg_printf("%s: Loading 0x%08X failed 0x%08X\n", __func__, netModules[i], ret); } for(i = 0; i < sizeof(modules) / sizeof(int); i++) { ret = sceUtilityLoadModule(modules[i]); if (ret < 0) dbg_printf("%s: Loading 0x%08X failed 0x%08X\n", __func__, modules[i], ret); } ret = sceUtilityLoadModule(PSP_MODULE_AV_MP3); if (ret < 0) dbg_printf("%s: Loading 0x%08X failed 0x%08X\n", __func__, PSP_MODULE_AV_MP3, ret); } else { if (isImported(sceUtilityLoadNetModule)) for (module = 1; module <= 7; module++) { ret = sceUtilityLoadNetModule(module); if (ret < 0) dbg_printf("%s: Loading net module %d failed 0x%08X\n", __func__, module, ret); } if (isImported(sceUtilityLoadUsbModule)) for (module = 1; module <= 5; module++) { ret = sceUtilityLoadUsbModule(module); if (ret < 0) dbg_printf("%s: Loading USB module %d failed 0x%08X\n", __func__, module, ret); } if (isImported(sceUtilityLoadAvModule)) for (module = 1; module <= 7; module++) { ret = sceUtilityLoadAvModule(module); dbg_printf("%s: Loading AV module %d failed 0x%08X\n", __func__, module, ret); } else { #ifdef UTILITY_AV_AVCODEC_PATH avcodec_modid = sceKernelLoadModule(UTILITY_AV_AVCODEC_PATH, 0, NULL); sceKernelStartModule(avcodec_modid, 0, NULL, NULL, NULL); #endif #ifdef UTILITY_AV_SASCORE_PATH sascore_modid = sceKernelLoadModule(UTILITY_AV_SASCORE_PATH, 0, NULL); sceKernelStartModule(sascore_modid, 0, NULL, NULL, NULL); #endif #ifdef UTILITY_AV_ATRAC3PLUS_PATH atrac3plus_modid = sceKernelLoadModule(UTILITY_AV_ATRAC3PLUS_PATH, 0, NULL); sceKernelStartModule(atrac3plus_modid, 0, NULL, NULL, NULL); #endif #ifdef UTILITY_AV_MPEGBASE_PATH mpegbase_modid = sceKernelLoadModule(UTILITY_AV_MPEGBASE_PATH, 0, NULL); sceKernelStartModule(mpegbase_modid, 0, NULL, NULL, NULL); #endif } } }
/* main routine */ int main(int argc, char *argv[]) { SceCtrlData pad; //init screen and callbacks pspDebugScreenInit(); pspDebugScreenClear(); SetupCallbacks(); // Setup Pad sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(0); // Load modules int status = sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); if (status<0) { ERRORMSG("ERROR: sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC) returned 0x%08X\n", status); } status = sceUtilityLoadModule(PSP_MODULE_AV_MP3); if (status<0) { ERRORMSG("ERROR: sceUtilityLoadModule(PSP_MODULE_AV_MP3) returned 0x%08X\n", status); } // Open the input file int fd = sceIoOpen( MP3FILE, PSP_O_RDONLY, 0777 ); if (fd<0) { ERRORMSG("ERROR: Could not open file '%s' - 0x%08X\n", MP3FILE, fd); } // Init mp3 resources status = sceMp3InitResource(); if (status<0) { ERRORMSG("ERROR: sceMp3InitResource returned 0x%08X\n", status); } // Reserve a mp3 handle for our playback SceMp3InitArg mp3Init; mp3Init.mp3StreamStart = 0; mp3Init.mp3StreamEnd = sceIoLseek32( fd, 0, SEEK_END ); mp3Init.unk1 = 0; mp3Init.unk2 = 0; mp3Init.mp3Buf = mp3Buf; mp3Init.mp3BufSize = sizeof(mp3Buf); mp3Init.pcmBuf = pcmBuf; mp3Init.pcmBufSize = sizeof(pcmBuf); int handle = sceMp3ReserveMp3Handle( &mp3Init ); if (handle<0) { ERRORMSG("ERROR: sceMp3ReserveMp3Handle returned 0x%08X\n", handle); } // Fill the stream buffer with some data so that sceMp3Init has something to work with fillStreamBuffer( fd, handle ); status = sceMp3Init( handle ); if (status<0) { ERRORMSG("ERROR: sceMp3Init returned 0x%08X\n", status); } int channel = -1; int samplingRate = sceMp3GetSamplingRate( handle ); int numChannels = sceMp3GetMp3ChannelNum( handle ); int lastDecoded = 0; int volume = PSP_AUDIO_VOLUME_MAX; int numPlayed = 0; int paused = 0; int lastButtons = 0; int loop = 0; while (isrunning) { sceDisplayWaitVblankStart(); pspDebugScreenSetXY(0, 0); printf("PSP Mp3 Sample v1.0 by Raphael\n\n"); printf("Playing '%s'...\n", MP3FILE); printf(" %i Hz\n", samplingRate); printf(" %i kbit/s\n", sceMp3GetBitRate( handle )); printf(" %s\n", numChannels==2?"Stereo":"Mono"); printf(" %s\n\n", loop==0?"No loop":"Loop"); int playTime = samplingRate>0?numPlayed / samplingRate:0; printf(" Playtime: %02i:%02i\n", playTime/60, playTime%60 ); printf("\n\n\nPress CIRCLE to Pause/Resume playback\nPress TRIANGLE to reset playback\nPress CROSS to switch loop mode\nPress SQUARE to stop playback and quit\n"); if (!paused) { // Check if we need to fill our stream buffer if (sceMp3CheckStreamDataNeeded( handle )>0) { fillStreamBuffer( fd, handle ); } // Decode some samples short* buf; int bytesDecoded; int retries = 0; // We retry in case it's just that we reached the end of the stream and need to loop for (; retries<1; retries++) { bytesDecoded = sceMp3Decode( handle, &buf ); if (bytesDecoded>0) break; if (sceMp3CheckStreamDataNeeded( handle )<=0) break; if (!fillStreamBuffer( fd, handle )) { numPlayed = 0; } } if (bytesDecoded<0 && bytesDecoded!=0x80671402) { ERRORMSG("ERROR: sceMp3Decode returned 0x%08X\n", bytesDecoded); } // Nothing more to decode? Must have reached end of input buffer if (bytesDecoded==0 || bytesDecoded==0x80671402) { paused = 1; sceMp3ResetPlayPosition( handle ); numPlayed = 0; } else { // Reserve the Audio channel for our output if not yet done if (channel<0 || lastDecoded!=bytesDecoded) { if (channel>=0) sceAudioSRCChRelease(); channel = sceAudioSRCChReserve( bytesDecoded/(2*numChannels), samplingRate, numChannels ); } // Output the decoded samples and accumulate the number of played samples to get the playtime numPlayed += sceAudioSRCOutputBlocking( volume, buf ); } } sceCtrlPeekBufferPositive(&pad, 1); if (pad.Buttons!=lastButtons) { if (pad.Buttons & PSP_CTRL_CIRCLE) { paused ^= 1; } if (pad.Buttons & PSP_CTRL_TRIANGLE) { // Reset the stream and playback status sceMp3ResetPlayPosition( handle ); numPlayed = 0; } if (pad.Buttons & PSP_CTRL_CROSS) { loop = (loop==0?-1:0); status = sceMp3SetLoopNum( handle, loop ); if (status<0) { ERRORMSG("ERROR: sceMp3SetLoopNum returned 0x%08X\n", status); } } if (pad.Buttons & PSP_CTRL_SQUARE) { break; } lastButtons = pad.Buttons; } } // Cleanup time... if (channel>=0) sceAudioSRCChRelease(); status = sceMp3ReleaseMp3Handle( handle ); if (status<0) { ERRORMSG("ERROR: sceMp3ReleaseMp3Handle returned 0x%08X\n", status); } status = sceMp3TermResource(); if (status<0) { ERRORMSG("ERROR: sceMp3TermResource returned 0x%08X\n", status); } status = sceIoClose( fd ); if (status<0) { ERRORMSG("ERROR: sceIoClose returned 0x%08X\n", status); } sceKernelExitGame(); return 0; }
int InitAt3() { sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); sceUtilityLoadModule(PSP_MODULE_AV_ATRAC3PLUS); return PSPAALIB_SUCCESS; }
// Loads and registers exports from an utility module SceLibraryEntryTable *load_export_util(UtilModInfo *util_mod, const char *lib) { SceLibraryEntryTable *exports; int *p; int ret, nid; if (util_mod == NULL || lib == NULL) return NULL; dbg_printf("Loading utility module for library %s\n", lib); //force load PSP_MODULE_AV_AVCODEC if we request a specific audio module if (util_mod->id > PSP_MODULE_AV_AVCODEC && util_mod->id <= PSP_MODULE_AV_G729) { dbg_printf("Force-Loading AVCODEC\n"); if (isImported(sceUtilityLoadModule)) sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); else if (isImported(sceUtilityLoadAvModule)) sceUtilityLoadAvModule(PSP_AV_MODULE_AVCODEC); } else if(util_mod->id == PSP_MODULE_NET_HTTP) { dbg_printf("Force-Loading HTTP\n"); if (isImported(sceUtilityLoadModule)) { sceUtilityLoadModule(PSP_MODULE_NET_COMMON); sceUtilityLoadModule(PSP_MODULE_NET_INET); sceUtilityLoadModule(PSP_MODULE_NET_PARSEURI); sceUtilityLoadModule(PSP_MODULE_NET_PARSEHTTP); } else if (isImported(sceUtilityLoadNetModule)) { sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON); sceUtilityLoadNetModule(PSP_NET_MODULE_INET); sceUtilityLoadNetModule(PSP_NET_MODULE_PARSEURI); sceUtilityLoadNetModule(PSP_NET_MODULE_PARSEHTTP); } } ret = load_util(util_mod->id); if (ret < 0 && ret != 0x80111102) return NULL; #ifndef DISABLE_UNLOAD_UTILITY_MODULES #ifdef UTILITY_UNLOAD_MODULE_FILE if (!ret) ret = util_mod->id; #endif // PSP_MODULE_AV_AVCODEC -> cast syscall of sceAudiocodec and sceVideocodec // PSP_MODULE_AV_MP3 -> On 6.20 OFW, libmp3 has a bug when unload it. if ((util_mod->id != PSP_MODULE_AV_AVCODEC || globals->isEmu) && (util_mod->id != PSP_MODULE_AV_MP3 || globals->module_sdk_version > 0x06020010)) { #ifdef UTILITY_UNLOAD_MODULE_FILE add_util_table(ret); #else add_util_table(util_mod->id); #endif } #endif // Get module exports exports = find_exports(util_mod->name, lib); if (exports == NULL) { dbg_printf("->ERROR: could not find module exports for %s\n", util_mod->name); #ifndef DISABLE_UNLOAD_UTILITY_MODULES #ifdef UTILITY_UNLOAD_MODULE_FILE unload_util(ret); rm_util_table(ret); #else unload_util(util_mod->id); rm_util_table(ret); #endif #endif return NULL; } dbg_printf("Number of export functions: %d\n", exports->stubcount); dbg_printf("Pointer to exports: 0x%08X\n", (int)exports->entrytable); switch (util_mod->id) { case PSP_MODULE_NET_INET: if (util_mod == &net_apctl) nid = 0xB3EDD0EC; // sceNetApctlTerm else if (util_mod == &net_resolver) nid = 0x6138194A; // sceNetResolverTerm else if (util_mod == &net_inet) nid = 0xA9ED66B9; // sceNetInetTerm else return exports; break; case PSP_MODULE_NET_COMMON: nid = 0x281928A9; // sceNetTerm break; default: return exports; } for (p = (int *)exports->entrytable; (int)p < (int)exports->entrytable + exports->stubcount; p++) if (*p == nid) { net_term_func[net_term_num] = (void *)p[exports->stubcount]; net_term_num++; break; } return exports; }
extern "C" int main(int argc, char *argv[]) { sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); sceUtilityLoadModule(PSP_MODULE_AV_SASCORE); __sceSasInit(&sasCore, 64, 32, 1, 44100); for (size_t i = 0; i < ARRAY_SIZE(pcm); ++i) { pcm[i] = 0x7FFF; } testAttackCurve("Attack linear increase 0x1:", PSP_SAS_ADSR_CURVE_MODE_LINEAR_INCREASE, 1); testAttackCurve("Attack linear increase 0x1000000:", PSP_SAS_ADSR_CURVE_MODE_LINEAR_INCREASE, 0x1000000); testAttackCurve("Attack linear increase 0x100000:", PSP_SAS_ADSR_CURVE_MODE_LINEAR_INCREASE, 0x100000); testAttackCurve("Attack linear decrease 0x1:", PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE, 1); testAttackCurve("Attack linear decrease 0x100000:", PSP_SAS_ADSR_CURVE_MODE_LINEAR_DECREASE, 0x100000); testAttackCurve("Attack linear bent 0x1:", PSP_SAS_ADSR_CURVE_MODE_LINEAR_BENT, 1); testAttackCurve("Attack linear bent 0x100000:", PSP_SAS_ADSR_CURVE_MODE_LINEAR_BENT, 0x100000); testAttackCurve("Attack exponent rev 0x1:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 1); testAttackCurve("Attack exponent rev 0x100000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 0x100000); testAttackCurve("Attack exponent 0x1:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 1); testAttackCurve("Attack exponent 0x5:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 5); testAttackCurve("Attack exponent 0x0:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0); testAttackCurve("Attack exponent 0x10:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x10); testAttackCurve("Attack exponent 0x100:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x100); testAttackCurve("Attack exponent 0x1000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x1000); testAttackCurve("Attack exponent 0x10000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x10000); testAttackCurve("Attack exponent 0x100000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x100000); testAttackCurve("Attack exponent 0x1000000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x1000000); testAttackCurve("Attack exponent 0x10000000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x10000000); testAttackCurve("Attack direct 0x1:", PSP_SAS_ADSR_CURVE_MODE_DIRECT, 1); testAttackCurve("Attack direct 0x100000:", PSP_SAS_ADSR_CURVE_MODE_DIRECT, 0x100000); testAttackCurve("Attack exponent 1:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 1); testAttackCurve("Attack exponent 5:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 5); testAttackCurve("Attack exponent 9:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 9); testAttackCurve("Attack exponent 13:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 13); testAttackCurve("Attack exponent 17:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 17); testAttackCurve("Attack exponent 33:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 33); testAttackCurve("Attack exponent 48:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 48); testAttackCurve("Attack exponent 49:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 49); testAttackCurve("Attack exponent 65:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 65); testAttackCurve("Attack exponent 100:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 100); testAttackCurve("Attack exponent 400:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 400); testAttackCurve("Attack exponent 800:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 800); testAttackCurve("Attack exponent 0x100000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x100000); testDecayCurve("Decay exponent 0:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 0); testDecayCurve("Decay exponent 1:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 1); testDecayCurve("Decay exponent 2:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 2); testDecayCurve("Decay exponent 3:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 3); testDecayCurve("Decay exponent 4:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 4); testDecayCurve("Decay exponent 5:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 5); testDecayCurve("Decay exponent 6:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 6); testDecayCurve("Decay exponent 7:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 7); testDecayCurve("Decay exponent 8:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 8); testDecayCurve("Decay exponent 9:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 9); testDecayCurve("Decay exponent 17:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 17); testDecayCurve("Decay exponent 0x100000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 0x100000); testAttackCurve("Attack exponent 0x10000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x10000); testDecayCurve("Decay exponent 0x10000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 0x10000); testAttackCurve("Attack exponent 0x1000000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x1000000); testDecayCurve("Decay exponent 0x1000000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 0x1000000); testAttackCurve("Attack exponent 0x40000000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x40000000); testDecayCurve("Decay exponent 0x40000000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 0x40000000); testAttackCurve("Attack exponent 0x60000000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x60000000); testDecayCurve("Decay exponent 0x60000000:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 0x60000000); testAttackCurve("Attack exponent 0x7FFFFFFF:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 0x7FFFFFFF); testAttackCurve("Attack exponent 1:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT, 1); testDecayCurve("Decay exponent 0x7FFFFFFF:", PSP_SAS_ADSR_CURVE_MODE_EXPONENT_REV, 0x7FFFFFFF); return 0; }
int main(int argc, char *argv[]) { sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); sceUtilityLoadModule(PSP_MODULE_AV_ATRAC3PLUS); checkpointNext("sceAtracReinit ID usage:"); checkpoint(" Initial ids:"); checkpointIds(); checkpoint(" sceAtracReinit(2, 2): %08x", sceAtracReinit(2, 2)); checkpointIds(); checkpoint(" sceAtracReinit(3, 1): %08x", sceAtracReinit(3, 1)); checkpointIds(); checkpoint(" sceAtracReinit(999, 0): %08x", sceAtracReinit(999, 0)); checkpointIds(); checkpoint(" sceAtracReinit(0, 999): %08x", sceAtracReinit(0, 999)); checkpointIds(); checkpoint(" sceAtracReinit(999, 999): %08x", sceAtracReinit(0, 999)); checkpointIds(); checkpoint(" sceAtracReinit(0, 0): %08x", sceAtracReinit(0, 0)); checkpointIds(); checkpoint(" sceAtracReinit(0, 0): %08x", sceAtracReinit(0, 0)); checkpointIds(); checkpoint(" sceAtracReinit(0, -1): %08x", sceAtracReinit(0, -1)); checkpointIds(); checkpoint(" sceAtracReinit(0, -1): %08x", sceAtracReinit(0, -1)); checkpointIds(); checkpointNext("sceAtracReinit while open:"); checkpoint(" Reset: %08x", sceAtracReinit(2, 2)); int orig = sceAtracGetAtracID(0x1001); checkpoint(" With allocated, just one: %08x", sceAtracReinit(1, 0)); checkpoint(" With allocated, free: %08x", sceAtracReinit(0, 0)); sceAtracReleaseAtracID(orig); checkpointNext("ID reuse:"); checkpoint(" Reset: %08x", sceAtracReinit(6, 0)); checkpointIds(); int reuse[6]; size_t i; for (i = 0; i < ARRAY_SIZE(reuse) - 1; ++i) { reuse[i] = sceAtracGetAtracID(0x1001); } checkpoint(" Allocated #0-#4 (#5 still free)"); checkpoint(" Release #3: %08x", sceAtracReleaseAtracID(reuse[3])); checkpoint(" Allocate new: %s", sceAtracGetAtracID(0x1001) == reuse[3] ? "#3" : "different"); for (i = 0; i < ARRAY_SIZE(reuse) - 1; ++i) { sceAtracReleaseAtracID(reuse[i]); } return 0; }