bool sound_init(void) { // set the pxt_dir variable #ifndef CONFIG_CURRENT_DIR const char *pxt_dir_1 = getenv("HOME"); const char *pxt_dir_2 = "/.joynxengine/pxt/"; pxt_dir = (char*) malloc((strlen(pxt_dir_1) + strlen(pxt_dir_2) + 1) * sizeof(char)); sprintf(pxt_dir, "%s%s", pxt_dir_1, pxt_dir_2); #else const char *pxt_dir_1 = "./pxt/"; pxt_dir = (char*) malloc((strlen(pxt_dir_1) + 1) * sizeof(char)); sprintf(pxt_dir, "%s", pxt_dir_1); #endif // set the org_dir variable #ifndef CONFIG_CURRENT_DIR const char *org_dir_1 = getenv("HOME"); const char *org_dir_2 = "/.joynxengine/org/"; org_dir = (char*) malloc((strlen(org_dir_1) + strlen(org_dir_2) + 1) * sizeof(char)); sprintf(org_dir, "%s%s", org_dir_1, org_dir_2); #else const char *org_dir_1 = "./org/"; org_dir = (char*) malloc((strlen(org_dir_1) + 1) * sizeof(char)); sprintf(org_dir, "%s", org_dir_1); #endif // set the sndcache variable #ifndef CONFIG_CURRENT_DIR const char *sndcache_1 = getenv("HOME"); const char *sndcache_2 = "/.joynxengine/sndcache.pcm"; sndcache = (char*) malloc((strlen(sndcache_1) + strlen(sndcache_2) + 1) * sizeof(char)); sprintf(sndcache, "%s%s", sndcache_1, sndcache_2); #else const char *sndcache_1 = "sndcache.pcm"; sndcache = (char*) malloc((strlen(sndcache_1) + 1) * sizeof(char)); sprintf(sndcache, "%s", sndcache_1); #endif // set the org_wavetable variable #ifndef CONFIG_CURRENT_DIR const char *org_wavetable_1 = getenv("HOME"); const char *org_wavetable_2 = "/.joynxengine/wavetable.dat"; org_wavetable = (char*) malloc((strlen(org_wavetable_1) + strlen(org_wavetable_2) + 1) * sizeof(char)); sprintf(org_wavetable, "%s%s", org_wavetable_1, org_wavetable_2); #else const char *org_wavetable_1 = "wavetable.dat"; org_wavetable = (char*) malloc((strlen(org_wavetable_1) + 1) * sizeof(char)); sprintf(org_wavetable, "%s", org_wavetable_1); #endif if (SSInit()) return 1; if (pxt_init()) return 1; if (pxt_LoadSoundFX(pxt_dir, sndcache, NUM_SOUNDS)) return 1; if (org_init(org_wavetable, pxt_dir, ORG_VOLUME)) { staterr("Music failed to initialize"); return 1; } return 0; }
bool sound_init(void) { if (SSInit()) return 1; if (pxt_init()) return 1; if (pxt_LoadSoundFX(pxt_dir, sndcache, NUM_SOUNDS)) return 1; if (org_init(org_wavetable, pxt_dir, ORG_VOLUME)) { staterr("Music failed to initialize"); return 1; } return 0; }
int SDL_main(int argc, char *argv[]) { stat("Entering main loop"); testblit(); if (SSInit()) return 1; if (pxt_init()) return 1; if (pxt_LoadSoundFX(pxt_dir, sndcache, 0x75)) { printf("Can't load\n"); return 1; } if (org_init(org_wavetable, pxt_dir, ORG_VOLUME)) { staterr("Music failed to initialize"); return 1; } music(19); while(!quitting) { org_run(); SDL_Event pie; if (SDL_PollEvent(&pie)) { if (pie.type == SDL_KEYDOWN) { if(pie.key.keysym.sym == SDLK_F3) quitting = true; else if(pie.key.keysym.sym == SDLK_BTN_A) pxt_Play(-1, 1, 1); else if(pie.key.keysym.sym == SDLK_BTN_B) org_stop(); else if(pie.key.keysym.sym == SDLK_BTN_Y) music(random(1,42)); } } } pxt_freeSoundFX(); SSClose(); return 0; }
bool sound_init(void) { pxt_dir = "pxt/"; org_dir = "org/"; sndcache = "sndcache.pcm"; org_wavetable = "wavetable.dat"; if (SSInit()) return 1; if (pxt_init()) return 1; if (pxt_LoadSoundFX(pxt_dir, sndcache, NUM_SOUNDS)) return 1; if (org_init(org_wavetable, pxt_dir, ORG_VOLUME)) { staterr("Music failed to initialize"); return 1; } return 0; }