int main (int argc, char **argv) { /* Save our program name - for error messages */ set_DeadPipe_handler(DeadPipe); InitMyApp (CLASS_AUDIO, argc, argv, NULL, NULL, 0 ); LinkAfterStepConfig(); ConnectX( ASDefaultScr, PropertyChangeMask ); ConnectAfterStep ( mask_reg, 0 ); Config = CreateAudioConfig(); LOCAL_DEBUG_OUT("parsing Options ...%s",""); LoadBaseConfig (GetBaseOptions); LoadColorScheme(); LoadConfig ("audio", GetOptions); #ifdef HAVE_RPLAY_H memset( rplay_table, 0x00, sizeof(RPLAY *)*MAX_SOUNDS); #endif memset( sound_table, 0x00, sizeof(char *)*MAX_SOUNDS); if (!SetupSound ()) { show_error("Failed to initialize sound playing routines. Please check your config."); return 1; } /* * Play the startup sound. */ audio_play (EVENT_Startup); SendInfo ( "Nop", 0); HandleEvents(); return 0; }
int main(int argc, char *argv[]) { PSFINFO *pi; SetupSound(); if(!(pi=sexy_load(argv[1]))) { puts("Error loading PSF"); return(-1); } printf("Game:\t%s\nTitle:\t%s\nArtist:\t%s\nYear:\t%s\nGenre:\t%s\nPSF By:\t%s\nCopyright:\t%s\n", pi->game,pi->title,pi->artist,pi->year,pi->genre,pi->psfby,pi->copyright); { PSFTAG *recur=pi->tags; while(recur) { printf("%s:\t%s\n",recur->key,recur->value); recur=recur->next; } } sexy_execute(); return 0; }
/* To change for nonAF-sound, change SetupSound() and the last part of this function. Change LoadFile only if you need more data stored when loading. (maybe sample rate, stereo on/off, etc) */ void PlaySoundFile(char *filename, int forked) { static int sound_is_setup=FALSE; struct Sound *sound; DEBUG(D_CALLS) printf("PlaySoundFile: %s\n",filename); if (!sound_is_setup || forked) { DEBUG(D_CHECKP) printf("PSF: Connecting to AF server\n"); Zero(&InMemList, sizeof(InMemList)); if (!SetupSound()) { printf("Could not connect to sound server.\n"); return; } sound_is_setup=TRUE; } sound=(struct Sound *) LoadFile(filename); DEBUG(D_CHECKP) printf("PSF: Loaded %s into %d\n",filename, sound); if (sound==NULL) return; /* this part is sound-device dependant */ DEBUG(D_CHECKP) printf("PSF: Actually playing now!\n"); atime=AFGetTime(ac); AFPlaySamples(ac, atime+PLAY_DELAY, sound->size, (unsigned char *)sound->data); }
/** * Initialize. Setup SDL and other API's. */ void Initialize() { /* Initialize SDL */ SDL_Init(SDL_INIT_VIDEO); SDL_SetVideoMode(width, height, 0, vid_flags); SDL_WM_SetCaption(APP_NAME, APP_NAME); /* Fake Setup for GLUT */ char *myargv [1]; int myargc = 1; myargv [0] = strdup (""); glutInit(&myargc, myargv); /* Setup OpenGL */ SetupRenderingContext(); SetupMatrices(width, height); /* Setup FMOD */ SetupSound(); /* Setup game timer */ SetupTimers(); /* Seed random number */ srand(time(NULL)); }
s32 CALLBACK SPU2open(void *pDsp) { LOG_CALLBACK("SPU2open()\n"); #ifdef _WIN32 hWMain = pDsp == NULL ? NULL : *(HWND*)pDsp; if (!IsWindow(hWMain)) hWMain=GetActiveWindow(); #endif LoadConfig(); SPUCycles = SPUWorkerCycles = 0; interrupt = 0; SPUStartCycle[0] = SPUStartCycle[1] = 0; SPUTargetCycle[0] = SPUTargetCycle[1] = 0; s_nDropPacket = 0; if ( conf.options & OPTION_TIMESTRETCH ) { pSoundTouch = new soundtouch::SoundTouch(); pSoundTouch->setSampleRate(SAMPLE_RATE); pSoundTouch->setChannels(2); pSoundTouch->setTempoChange(0); pSoundTouch->setSetting(SETTING_USE_QUICKSEEK, 0); pSoundTouch->setSetting(SETTING_USE_AA_FILTER, 1); } //conf.Log = 1; g_bPlaySound = !(conf.options&OPTION_MUTE); if ( g_bPlaySound && SetupSound() != 0 ) { SysMessage("ZeroSPU2: Failed to initialize sound"); g_bPlaySound = false; } if ( g_bPlaySound ) { // initialize the audio buffers for (u32 i = 0; i < ArraySize(s_pAudioBuffers); ++i) { s_pAudioBuffers[i].pbuf = (u8*)_aligned_malloc(4 * NS_TOTAL_SIZE, 16); // 4 bytes for each sample s_pAudioBuffers[i].len = 0; } s_nCurBuffer = 0; s_nQueuedBuffers = 0; s_pCurOutput = (s16*)s_pAudioBuffers[0].pbuf; assert( s_pCurOutput != NULL); for (s32 i = 0; i < ArraySize(s_nDurations); ++i) { s_nDurations[i] = NSFRAMES*1000; } s_nTotalDuration = ArraySize(s_nDurations)*NSFRAMES*1000; s_nCurDuration = 0; // launch the thread s_bThreadExit = false; #ifdef _WIN32 s_threadSPU2 = CreateThread(NULL, 0, SPU2ThreadProc, NULL, 0, NULL); if ( s_threadSPU2 == NULL ) { return -1; } #else if ( pthread_create(&s_threadSPU2, NULL, SPU2ThreadProc, NULL) != 0 ) { SysMessage("ZeroSPU2: Failed to create spu2thread\n"); return -1; } #endif } g_nSpuInit = 1; return 0; }