void QSPCallBacks::PlayFile(QSPString file, int volume) { FMOD_SOUND *newSound; FMOD_CHANNEL *newChannel; QSPSound snd; if (SetVolume(file, volume)) return; CloseFile(file); wxString strFile(wxFileName(wxString(file.Str, file.End), wxPATH_DOS).GetFullPath()); #if defined(__WXMSW__) || defined(__WXOSX__) if (!FMOD_System_CreateSound(m_sys, wxConvFile.cWX2MB(strFile.c_str()), FMOD_SOFTWARE | FMOD_CREATESTREAM, 0, &newSound)) #else FMOD_CREATESOUNDEXINFO exInfo; memset(&exInfo, 0, sizeof(FMOD_CREATESOUNDEXINFO)); exInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); wxString dlsPath(QSPTools::GetAppPath() + QSP_MIDIDLS); wxCharBuffer dlsCharPath(wxConvFile.cWX2MB(dlsPath.c_str())); exInfo.dlsname = dlsCharPath; if (!FMOD_System_CreateSound(m_sys, wxConvFile.cWX2MB(strFile.c_str()), FMOD_SOFTWARE | FMOD_CREATESTREAM, &exInfo, &newSound)) #endif { UpdateSounds(); FMOD_System_PlaySound(m_sys, FMOD_CHANNEL_FREE, newSound, FALSE, &newChannel); snd.Channel = newChannel; snd.Sound = newSound; snd.Volume = volume; m_sounds.insert(QSPSounds::value_type(strFile.Upper(), snd)); SetVolume(file, volume); } }
int sound_init(Sound* s) { FMOD_RESULT res; if ( FMOD_OK != (res = FMOD_System_Create(&s->system)) || FMOD_OK != (res = FMOD_System_Init(s->system, 32, FMOD_INIT_NORMAL, NULL)) || FMOD_OK != (res = FMOD_System_CreateSound(s->system, "sound/xship_shoot.wav", FMOD_SOFTWARE, 0, &s->mp3[SND_XHSIP_SHOOT])) || FMOD_OK != (res = FMOD_System_CreateSound(s->system, "sound/menu_open.wav", FMOD_SOFTWARE, 0, &s->mp3[SND_MENU_OPEN])) ) return printf("FMOD error! (%d) %s\n", res, FMOD_ErrorString(res)); return 0; }
t_sound *init_sound_amb(char *path) { int i; char *path_sound; char *tmp; t_sound *sound_tab; FMOD_RESULT c; i = -1; if ((sound_tab = malloc(sizeof(t_sound) * NB_SOUND_AMB_MAX)) == NULL) return (NULL); while (++i < NB_SOUND_AMB_MAX) { FMOD_System_Create(&sound_tab[i].sys); FMOD_System_Init(sound_tab[i].sys, 1, FMOD_INIT_NORMAL, NULL); tmp = my_getstr(i, "0123456789"); path_sound = my_str_concat(tmp, FORMAT_SOUND); if ((c = FMOD_System_CreateSound (sound_tab[i].sys, my_str_concat(path, path_sound), FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &sound_tab[i].sound)) != FMOD_OK) return (NULL); printf("[*] Sound ambiance %s load\n", path_sound); free(tmp); free(path_sound); } return (sound_tab); }
FMCSound::FMCSound(const QString & filename, SOUND_SOURCE sound_source, FMOD_SYSTEM *fmod_system) : FMCSoundBase(sound_source), m_filename(filename), m_fmod_system(fmod_system), m_fmod_sound(0), m_fmod_channel(0) { MYASSERT(!filename.isEmpty()); MYASSERT(m_fmod_system != 0); MYASSERT(FMOD_System_CreateSound(m_fmod_system, filename.toLatin1().data(), FMOD_HARDWARE, 0, &m_fmod_sound) == FMOD_OK); }
void MOD_Start (char *name, qboolean midi, qboolean loop, qboolean notify, qboolean resume) { char file[MAX_QPATH]; FMOD_CREATESOUNDEXINFO exinfo; if(SND_Initialised == false) return; if(SND_MusicChannel.inuse == true) FMOD_MusicStop(); if(strlen(name) == 0) return; if(SND_FOpen(name, midi, resume) == true) { memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO)); exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); exinfo.length = SND_File.length; result = FMOD_System_CreateSound(fmod_system, (const char *)SND_File.data, FMOD_HARDWARE | FMOD_OPENMEMORY | FMOD_2D, &exinfo, &fmod_music); FMOD_ERROR(result, true, false); if(loop == true) { SND_MusicChannel.looping = true; result = FMOD_Sound_SetMode(fmod_music, FMOD_LOOP_NORMAL); FMOD_ERROR(result, true, false); } else { SND_MusicChannel.looping = false; result = FMOD_Sound_SetMode(fmod_music, FMOD_LOOP_OFF); FMOD_ERROR(result, true, false); } strcpy(file, SND_File.filename); SND_FClose(); } if(!fmod_music) { Con_Printf("Couldn't open stream %s\n", file); return; } else { if(notify == true) Con_Printf("Playing: %s...\n", file); } result = FMOD_System_GetChannel(fmod_system, 0, &SND_MusicChannel.channel); FMOD_ERROR(result, true, false); result = FMOD_System_PlaySound(fmod_system, FMOD_CHANNEL_REUSE, fmod_music, 0, &SND_MusicChannel.channel); FMOD_ERROR(result, true, false); SND_MusicChannel.inuse = true; }
//-------------Sound Effects---------------// SoundEffect::SoundEffect(char* filename) { b_enabled = true; m_sound_name = filename; m_result = FMOD_System_CreateSound(Sound::GetSystem(), m_sound_name, FMOD_SOFTWARE, 0, &m_sound); assert(m_result == FMOD_OK); }
int sound_alloc(sound** target, sound_manager* system, const char* filename, int streamed) { if (target == NULL) { debug_critical("[sound_alloc] target cannot be NULL"); return 0; } if (*target != NULL) { debug_critical("[sound_alloc] target points to non NULL handle, possible memory leak"); } *target = h_malloc(sizeof(sound)); if (system == NULL) { debug_critical("[sound_alloc] system cannot be NULL"); h_free(*target); *target = NULL; } sound* this = *target; memset(this, 0, sizeof(sound)); this->sound_system = system->system_handle; if (FMOD_System_CreateSound(this->sound_system, filename, (streamed) ? FMOD_CREATESTREAM : FMOD_CREATESAMPLE, NULL, &(this->sound_object)) != FMOD_OK) { debug_message(filename); debug_critical("[sound_alloc] failed to initialize sound, check filename"); return 0; } FMOD_Sound_SetMode(this->sound_object, FMOD_LOOP_NORMAL); return 1; }
void Sound::Load_Stream(const String& fileName) { if(fileName.Count()) return; name = fileName; FMOD_RESULT s_result = FMOD_OK; if(sound != nullptr) { s_result = FMOD_Sound_Release(sound); check_error(s_result); } s_result = FMOD_System_CreateSound(fmodSystem, fileName.Data(), FMOD_SOFTWARE | FMOD_UNICODE | FMOD_CREATESTREAM, nullptr, &sound); check_error(s_result); switch(type) { case MUSIC: FMOD_Sound_SetSoundGroup(sound, musicGroup); break; case SOUND_EFFECT: FMOD_Sound_SetSoundGroup(sound, noiseGroup); break; } }
bool Audio::Load(std::string filename, std::string name) { if (filename.length() == 0 || name.length() == 0) return false; Sample *sample = new Sample(); sample->setName(name); try { FMOD_RESULT res; res = FMOD_System_CreateSound( system, //FMOD system filename.c_str(), //filename FMOD_DEFAULT, //default audio NULL, //n/a &sample->sample); //pointer to sample if (res != FMOD_OK) { return false; } } catch (...) { return false; } samples.push_back(sample); return true; }
int fmod_createsound(char *fname, int i) { FMOD_RESULT result; result = FMOD_System_CreateSound(xsystem, fname, FMOD_SOFTWARE, 0, &sound[i]); if (ERRCHECK(result)) return 1; return 0; }
Sgame CreateGame(int id_map) { Sgame game; /* Creation du hero */ Shero Heros = CreateHero(POSITION_DEPART_HEROS_X, POSITION_DEPART_HEROS_Y,id_map,"sasha",PARQUET,DIRECTION_DEPART_HEROS); game.hero= Heros; /* Demarrage du son */ FMOD_SYSTEM *system; FMOD_SOUND *son; FMOD_System_Create(&system); FMOD_System_Init(system, 7, FMOD_INIT_NORMAL, NULL); FMOD_System_CreateSound(system, "data/music/Menutheme.mp3", FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &son); FMOD_Sound_SetLoopCount(son, -1); FMOD_System_PlaySound(system, son, NULL, 0, NULL); game.pokedex[9]=game.hero.pokemon[0]; game.pokedex[9].vu=1; game.son = son; game.system = system; game.scenario=0; /* Ajout des personnages non jouables du jeu */ addNpc(&game); return game; }
void fmode(void) { FMOD_SYSTEM *system; FMOD_SOUND *musique; FMOD_CHANNEL *channel; FMOD_RESULT resultat; char *str; str = "./graphic/Martin Garrix - Animals.mp3"; FMOD_System_Create(&system); FMOD_System_Init(system, 2, FMOD_INIT_NORMAL, NULL); resultat = FMOD_System_CreateSound(system, str, FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &musique); if (resultat != FMOD_OK) { my_printf(2, "Cannot find "); my_printf(2, "%s", str); my_printf(2, ", put this file next to the executable 'corewar'"); write(2, "\n", 1); } else { FMOD_Sound_SetLoopCount(musique, -1); FMOD_System_GetChannel(system, 9, &channel); FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, musique, 0, NULL); } }
//CSound* FMOD_SOUND* CFModExDriver::loadFmodExSound(const std::string& filename,const bool& stream){ FMOD_SOUND* tempSound; FMOD_RESULT result; // Flags by default FMOD_MODE mode = FMOD_HARDWARE | FMOD_LOOP_OFF | FMOD_2D; // FMOD_System_CreateStream == FMOD_System_CreateSound with flag FMOD_CREATESTREAM if(stream){ mode |= FMOD_CREATESTREAM ; } result = FMOD_System_CreateSound( _audioSystem, filename.c_str(), mode, 0, &tempSound ); // If could not load sound if(ERRCHECK(result)) { return 0; } //FMOD_3D FMOD_2D // else create sound //CSound* sound = new CSound(this, tempSound); return tempSound; }
int play_fiend_music(char* file, int loop) { char path[100]; char error_string[50]; if(!sound_is_on)return -1; if(strcmp(file,current_music)==0)return 1; if(strcmp(current_music,"none")!=0) { FMOD_Channel_Stop(fmod_music_channel); FMOD_Sound_Release(music_sound); } sprintf(path,"music/%s",file); if(loop) { FMOD_System_CreateSound(fmod_system, path, FMOD_SOFTWARE | FMOD_CREATESTREAM, &soundex_info, &music_sound); music_is_looping = 1; } else { FMOD_System_CreateSound(fmod_system, path, FMOD_SOFTWARE | FMOD_CREATESTREAM, &soundex_info, &music_sound); music_is_looping=0; } if(music_sound==NULL) { sprintf(error_string,"Error loading stream \"%s\" ",path); make_engine_error(error_string); return 0; } strcpy(current_music,file); speed_counter=0; FMOD_System_PlaySound(fmod_system, FMOD_CHANNEL_FREE, music_sound, 0, &fmod_music_channel); set_fiend_music_volume(fiend_music_volume); return 1; }
void Game::playPowerUp () { FMOD_SOUND *a; FMOD_CHANNEL *soundchan = NULL; FMOD_System_CreateSound (system, "data\\music\\Powerup2.wav", FMOD_DEFAULT, 0, &a); FMOD_Channel_SetChannelGroup (soundchan, soundMusic); FMOD_System_PlaySound (system, a, soundMusic, false, &soundchan); }
void Game::playSound (const char* soundName) { FMOD_SOUND *audiosound; FMOD_CHANNEL *soundchan = NULL; FMOD_System_CreateSound (system, soundName, FMOD_DEFAULT, 0, &audiosound); FMOD_Channel_SetChannelGroup (soundchan, soundMusic); FMOD_System_PlaySound(system,audiosound,soundMusic,false,&soundchan); }
Audio::audio_t Audio::chargerSon(std::string const &chemin) throw(Audio::Exc_Son) { audio_t son = 0; resultat = FMOD_System_CreateSound(_systeme, chemin.c_str(), FMOD_CREATESAMPLE | FMOD_2D | FMOD_LOOP_NORMAL, 0, &son); erreur(resultat, 4); return son; }
FMODSound::FMODSound(const std::string &name, const std::string &name_file, Engine::ISound::type type, int frequence) : _tmp(false), _name(name), _type(type), _frequence(frequence), _volume(1.0) { FMOD_System_Create(&(this->_system)); FMOD_System_Init(this->_system, 1, FMOD_INIT_NORMAL, NULL); FMOD_System_CreateSound(this->_system, name_file.c_str(), FMOD_CREATESAMPLE, 0, &(this->_sound)); }
void Init() { g_nFrameCount = 0; FMOD_System_Create(&g_System); FMOD_System_Init(g_System, 32, FMOD_INIT_NORMAL, NULL); FMOD_System_CreateSound(g_System, "run.wav", FMOD_DEFAULT, 0, &g_Sound); }
int main(void) { SDL_Surface *screen = NULL, *viseur = NULL; SDL_Event event; SDL_Rect position; FMOD_SYSTEM *system; FMOD_SOUND *tir = NULL; FMOD_RESULT resultat; int continuer = 1; /*Initiation de FMOD pour le tir du pistolet*/ FMOD_System_Create(&system); FMOD_System_Init(system, 2, FMOD_INIT_NORMAL, NULL); resultat = FMOD_System_CreateSound(system,"gun_shot.mp3",FMOD_CREATESAMPLE, 0, &tir); if(resultat != FMOD_OK) { fprintf(stderr, "Impossible de lire gun_shot.mp3"); exit(EXIT_FAILURE); } /*Initiation de la SDL*/ SDL_Init(SDL_INIT_VIDEO); SDL_ShowCursor(SDL_DISABLE); screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); SDL_WM_SetCaption("Gestion du son avec FMOD", NULL); viseur = IMG_Load("cible.png"); SDL_EnableKeyRepeat(10, 10); while(continuer) { SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: continuer = 0; break; case SDL_MOUSEBUTTONDOWN: FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, tir, 0, NULL); break; case SDL_MOUSEMOTION: position.x = event.motion.x - (viseur->w / 2); position.y = event.motion.y - (viseur->h / 2); break; } SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0)); SDL_BlitSurface(viseur, NULL, screen, &position); SDL_Flip(screen); } SDL_FreeSurface(viseur); SDL_Quit(); FMOD_Sound_Release(tir); FMOD_System_Close(system); FMOD_System_Release(system); return EXIT_SUCCESS; }
void Systems::SoundSystem::LoadSound(FMOD_SOUND* &sound, std::string filePath, float maxDist, float minDist) { FMOD_RESULT result = FMOD_System_CreateSound(m_System, filePath.c_str(), FMOD_3D | FMOD_HARDWARE , 0, &sound); if (result != FMOD_OK) { LOG_ERROR("FMOD did not load file: %s", filePath.c_str()); } FMOD_Sound_Set3DMinMaxDistance(sound, minDist, maxDist); }
Audio::audio_t Audio::chargerMusique(std::string const &chemin) throw(Audio::Exc_Son) { audio_t son = 0; resultat = FMOD_System_CreateSound(_systeme, chemin.c_str(), FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &son); erreur(resultat, 5); FMOD_Sound_SetLoopCount(son, -1); return son; }
void Sound::load() { if (loaded) { FMOD_Sound_Release(audio); } char *path = &location[0u]; FMOD_System_CreateSound(system, path, FMOD_SOFTWARE, 0, &audio); FMOD_Channel_SetChannelGroup(channel, channelGroup); FMOD_Channel_SetPaused(channel, true); loaded = true; }
Ressource * LoaderMusic::load(string &name) throw(ExceptionNoFileFound) { FMOD_SOUND *music = NULL; if ((FMOD_System_CreateSound(SoundEngine::getInstance()->getSystem(), name.c_str(), FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &music)) != FMOD_OK) { throw new ExceptionNoFileFound(); } return new Sound(name,music); }
void Java_org_fmod_playsound_Example_cBegin(JNIEnv *env, jobject thiz) { FMOD_RESULT result = FMOD_OK; result = FMOD_System_Create(&gSystem); CHECK_RESULT(result); result = FMOD_System_Init(gSystem, 32, FMOD_INIT_NORMAL, 0); CHECK_RESULT(result); result = FMOD_System_CreateSound(gSystem, "/sdcard/fmod/drumloop.wav", FMOD_DEFAULT | FMOD_LOOP_OFF, 0, &gSound[0]); CHECK_RESULT(result); result = FMOD_System_CreateSound(gSystem, "/sdcard/fmod/jaguar.wav", FMOD_DEFAULT, 0, &gSound[1]); CHECK_RESULT(result); result = FMOD_System_CreateSound(gSystem, "/sdcard/fmod/swish.wav", FMOD_DEFAULT, 0, &gSound[2]); CHECK_RESULT(result); }
Ressource * LoaderSample::load(string &name) throw(ExceptionNoFileFound) { FMOD_SOUND *sample = NULL; if ((FMOD_System_CreateSound(SoundEngine::getInstance()->getSystem(), name.c_str(), FMOD_CREATESAMPLE, 0, &sample)) != FMOD_OK) { throw new ExceptionNoFileFound(); } return new Sound(name,sample); }
bool Sound::loadSound(const std::string &path, const std::string &name) { if (FMOD_System_CreateSound(this->_system, path.c_str(), SOUND_FLAGS, NULL, &(this->_sound)) != FMOD_OK) { //std::cerr << std::string("Fail on creating fmod sound : ") << path << std::endl; return (false); } this->_name = name; return (true); }
void SoundManager::addNewSound(const std::string &sound) { FMOD_SOUND *s; FMOD_RESULT check; check = FMOD_System_CreateSound(this->_system, sound.c_str(), FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &s); if (check != FMOD_OK) std::cout << "Cannot load " << sound << std::endl; else this->_sounds[sound] = s; }
// Sound file loading (to be called before playMusic()) void SoundManager::loadMusic(std::string& musicPath) { mMusicPath = musicPath; mResult = FMOD_System_CreateSound(mSystem, mMusicPath.c_str(), FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM, 0, &mMusic); if (mResult != FMOD_OK) { std::cerr << "Unable to load " << mMusicPath.c_str() << std::endl; throw new std::runtime_error(std::string("SoundManager::loadMusic() failed to load " + mMusicPath)); } }
void se(char *path, t_music *m) { FMOD_System_Create(&m->system); FMOD_System_Init(m->system, 1, FMOD_INIT_NORMAL, NULL); if ((m->result = FMOD_System_CreateSound(m->system, path, FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &m->music)) != FMOD_OK) show_error(3); FMOD_Sound_SetLoopCount(m->music, 0); FMOD_System_PlaySound(m->system, FMOD_CHANNEL_FREE, m->music, 0, NULL); }