CSoundManager::~CSoundManager() { // On libère tous les canaux for (int Canal = CANAL_NULL; Canal < CANAL_MAX; Canal++) if (m_pSon[Canal]) FSOUND_Stream_Close (m_pSon[Canal]); }
// Lecture des sons. Ils sont lu par streaming c'est à dire qu'ils sont chargés pendant la lecture. void CSoundManager::Jouer ( std::string const & Filename, ECanaux Canal, bool bLoop ) { if (!m_bCanauxJeu && Canal != CANAL_MUSIQUE) return; if (m_pSon[Canal]) FSOUND_Stream_Close (m_pSon[Canal]); // Si bLoop == true alors le son boucle. if (bLoop) { FSOUND_SetLoopMode (0, FSOUND_LOOP_NORMAL); m_pSon[Canal] = FSOUND_Stream_Open((DIRECTORY + Filename).c_str(), FSOUND_LOOP_NORMAL, 0, 0); FSOUND_SetVolume (Canal, 64); FSOUND_SetVolumeAbsolute (Canal, 64); } // Sinon il est jouer une seule fois. else { m_pSon[Canal] = FSOUND_Stream_Open((DIRECTORY + Filename).c_str(), FSOUND_NORMAL, 0, 0); FSOUND_SetVolume (Canal, 255); FSOUND_SetVolumeAbsolute (Canal, 255); } FSOUND_Stream_Play (Canal, m_pSon[Canal]); }
bool Ambient::update(Time deltaT) { if(baseBuffer == NULL || base == NULL || baseChannel == -1) return false; if(isActive == false && currentVolume == 0 && targetVolume == 0) { checkFMODError(FSOUND_Stream_Stop(base)); checkFMODError(FSOUND_Stream_Close(base)); return false; } if(currentVolume != targetVolume) { float fadeStep = deltaT * 1.0 / MAGIC_FADE_TIME_SECONDS; if(fadeStep > abs(targetVolume - currentVolume)) currentVolume = targetVolume; else if(currentVolume > targetVolume) currentVolume -= fadeStep; else currentVolume += fadeStep; } int channelVolume = clamp(static_cast<int>(currentVolume * MAGIC_AMBIENT_VOLUME * 255), 0, 255); checkFMODError(FSOUND_SetVolume(baseChannel, channelVolume)); runningTime -= deltaT; if(runningTime <= 0) { targetVolume = 0; runningTime = 0; } return true; }
bool CMusicChannelFMod::playStream() { if (FSOUND_Stream_GetOpenState(_MusicStream) == -3) { nlwarning("NLSOUND FMod Driver: stream failed to open. (file not found, out of memory or other error)"); FSOUND_Stream_Close(_MusicStream); _MusicStream = NULL; return false; } // Start playing if ((_MusicChannel = FSOUND_Stream_PlayEx(FSOUND_FREE, _MusicStream, NULL, true)) == -1) return false; // stereo pan (as reccomended) FSOUND_SetPan(_MusicChannel, FSOUND_STEREOPAN); // update volume int vol255 = (int)(_Gain * 255.0f); FSOUND_SetVolumeAbsolute(_MusicChannel, vol255); // Set a callback to know if stream has ended _CallBackEnded = false; FSOUND_Stream_SetEndCallback(_MusicStream, streamEndCallBack, static_cast<void *>(this)); // unpause FSOUND_SetPaused(_MusicChannel, false); return true; }
World::~World() { if (mp3file) { FSOUND_Stream_Stop( mp3file ); FSOUND_Stream_Close( mp3file ); } }
bool FMODStreamOut::Close() { bool bRes = true; if(StreamPointer) bRes = FSOUND_Stream_Close(StreamPointer) > 0; StreamPointer = NULL; return bRes; }
/////////////////////////////////////////////////////////////////////////////// //stopmusic will stop the currently playing song pointed to by CurrentSong. /////////////////////////////////////////////////////////////////////////////// int CSound::Stopmusic() { FSOUND_Stream_Stop(CurrentSong); FSOUND_Stream_Close(CurrentSong); if (CurrentSong != NULL) CurrentSong = NULL; return 0; }
void C4MusicFileMP3::Stop(int fadeout_ms) { if (stream) { FSOUND_Stream_Close(stream); stream = NULL; } if (Data) { delete[] Data; Data = NULL; } }
void SoundSystem::stopMusic() { if(musicStream) { FSOUND_Stream_Stop(musicStream); FSOUND_Stream_Close(musicStream); musicStream=0; } }
void Title::Cleanup() { SDL_FreeSurface(image1); SDL_FreeSurface(image2); SDL_FreeSurface(fondu); FSOUND_Sample_Free(sonCurseurDeplacement); FSOUND_Sample_Free(sonCurseurValider); FSOUND_Stream_Close(musique1); }
void C4MusicFileOgg::Stop(int fadeout_ms) { if (stream) { FSOUND_Stream_Close(stream); stream = NULL; } if (Data) { delete[] Data; Data = NULL; } Playing = false; }
//=========================================================================== // DM_FModExtReset //=========================================================================== void DM_FModExtReset(void) { // Get rid of old module/stream. if(module) FMUSIC_FreeSong(module); if(stream) FSOUND_Stream_Close(stream); module = 0; stream = 0; stream_channel = -1; }
void CMusicChannelFMod::updateWaitingForClose() { std::list<FSOUND_STREAM*>::iterator it= _WaitingForClose.begin(); while (it != _WaitingForClose.end()) { // try to stop, will fail if still loading bool ok = FSOUND_Stream_Stop(*it) != 0; if (ok) ok = FSOUND_Stream_Close(*it) !=0; // erase from list, or next if (ok) it = _WaitingForClose.erase(it); else ++it; } }
/// Play from memory. bool CMusicChannelFMod::playSync(const std::string &filepath, bool loop) { CIFile ifile; ifile.allowBNPCacheFileOnOpen(false); ifile.setCacheFileOnOpen(false); ifile.open(filepath); // try to load the music in memory uint32 fs = ifile.getFileSize(); if (!fs) { nlwarning("NLSOUND FMod Driver: Empty music file"); return false; } // read Buffer nlassert(!_MusicBuffer); _MusicBuffer = new uint8[fs]; try { ifile.serialBuffer(_MusicBuffer, fs); } catch (...) { nlwarning("NLSOUND FMod Driver: Error while reading music file"); delete[] _MusicBuffer; _MusicBuffer = NULL; return false; } // open FMOD stream _MusicStream = FSOUND_Stream_Open((const char*)_MusicBuffer, FSOUND_2D | FSOUND_LOADMEMORY | (loop ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF), 0, fs); if (!_MusicStream) { nlwarning("NLSOUND FMod Driver: Error while creating the FMOD stream for music file"); delete[] _MusicBuffer; _MusicBuffer = NULL; return false; } if (!playStream()) { nlwarning("NLSOUND FMod Driver: Error While trying to play sync music file"); FSOUND_Stream_Close(_MusicStream); _MusicStream = NULL; delete[] _MusicBuffer; _MusicBuffer = NULL; return false; } return true; }
void LecteurAudio::nouveauTitre(QString titre, QString fichier) { // Si un fichier etait en cours de lecture, on le ferme if (fluxAudio) { // Si la fermeture s'est mal passee on affiche un message if (!FSOUND_Stream_Close(fluxAudio)) { qWarning("Probleme a la fermeture d'un flux audio (nouveauTitre - LecteurAudio.cpp)"); return; } } // On affiche le titre du nouveau morceau afficheurTitre->setText(titre); afficheurTitre->setCursorPosition(0); afficheurTitre->setToolTip(fichier); // Ouverture du nouveau fichier fluxAudio = FSOUND_Stream_Open(fichier.toLatin1().data(), FSOUND_NORMAL, 0, 0); if (!fluxAudio) { qWarning("Impossible d'ouvrir le fichier audio (nouveauTitre - LecteurAudio.cpp)"); return; } // Mise en place de la fonction de callback appelee en fin de lecture if (!FSOUND_Stream_SetEndCallback(fluxAudio, finTitre, this)) { qWarning("Impossible d'initialiser la fonction de callback de fin de lecture (nouveauTitre - LecteurAudio.cpp)"); return; } // Mise en place de la fonction de callback appelee a chaque passage sur un TAG if (!FSOUND_Stream_SetSyncCallback(fluxAudio, passageTag, this)) { qWarning("Impossible d'initialiser la fonction de callback de passage sur un TAG (nouveauTitre - LecteurAudio.cpp)"); return; } // On ajoute tous les tag indicateurs de temps, a chaque seconde du morceau ajouterTags(); // On recupere la duree totale du fichier int dureeMs = FSOUND_Stream_GetLengthMs(fluxAudio); // Initialisation du selecteur de temps positionTemps->setMaximum(dureeMs); // On met le lecteur a l'arret arreter(); }
static inline VOID M_FreeMusic(VOID) { if (mod) { FMUSIC_StopSong(mod); FMUSIC_FreeSong(mod); mod = NULL; } if (fmus) { FSOUND_Stream_Stop(fmus); FSOUND_Stream_Close(fmus); fmus = NULL; fsoundchannel = -1; } }
bool LLAudioStreamFMOD::stopStream() { if (mInternetStream) { int read_percent = 0; int status = 0; int bitrate = 0; unsigned int flags = 0x0; FSOUND_Stream_Net_GetStatus(mInternetStream, &status, &read_percent, &bitrate, &flags); bool close = true; switch (status) { case FSOUND_STREAM_NET_CONNECTING: close = false; break; case FSOUND_STREAM_NET_NOTCONNECTED: case FSOUND_STREAM_NET_BUFFERING: case FSOUND_STREAM_NET_READY: case FSOUND_STREAM_NET_ERROR: default: close = true; } if (close) { FSOUND_Stream_Close(mInternetStream); mInternetStream = NULL; return true; } else { return false; } } else { return true; } }
~win_movie_Rec() { if(bAudio) { #ifdef SND_USE_FMOD if(fmod_stream) FSOUND_Stream_Close(fmod_stream); #endif acmStreamUnprepareHeader(acmStream,&audioStreamHeader,0); acmStreamClose(acmStream,0); delete[] audioDecoded; delete[] audioEncoded; AVIStreamRelease(audioStream); } if(bDecompStarted) ICDecompressEnd(hIC); if(hIC) ICClose(hIC); if(outdata) GlobalFreePtr(outdata); if(indata) GlobalFreePtr(indata); if(stream) AVIStreamRelease(stream); if(avi) AVIFileRelease(avi); if(img) { FreeImageHandle(imgHandle); delete img; } if(handle != 0) Handle::free(HANDLE_TYPE_MOVIE,handle); }
/* [ [DESCRIPTION] [PARAMETERS] [RETURN_VALUE] [REMARKS] [SEE_ALSO] ] */ int main(int argc, char *argv[]) { FSOUND_STREAM *stream; int read_percent = 0, i, driver = 0, channel = -1, status = 0, openstate, bitrate; unsigned int flags; char s[256] = ""; char key; if (FSOUND_GetVersion() < FMOD_VERSION) { printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION); return 1; } if ((argc < 2) || (strnicmp(argv[1], "http:", 5))) { printf("-------------------------------------------------------------\n"); printf("FMOD netstream example.\n"); printf("Copyright (c) Firelight Technologies Pty, Ltd, 1999-2004.\n"); printf("-------------------------------------------------------------\n"); printf("Syntax: netstream <url>\n"); printf("Example: netstream http://www.fmod.org/stream.mp3\n\n"); return 1; } #if defined(WIN32) || defined(_WIN64) || defined(__CYGWIN32__) || defined(__WATCOMC__) FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND); #elif defined(__linux__) FSOUND_SetOutput(FSOUND_OUTPUT_OSS); #endif // ========================================================================================== // SELECT DRIVER // ========================================================================================== printf("---------------------------------------------------------\n"); switch (FSOUND_GetOutput()) { case FSOUND_OUTPUT_NOSOUND: printf("NoSound"); break; case FSOUND_OUTPUT_WINMM: printf("Windows Multimedia Waveout"); break; case FSOUND_OUTPUT_DSOUND: printf("Direct Sound"); break; case FSOUND_OUTPUT_A3D: printf("A3D"); break; case FSOUND_OUTPUT_OSS: printf("Open Sound System"); break; case FSOUND_OUTPUT_ESD: printf("Enlightenment Sound Daemon"); break; case FSOUND_OUTPUT_ALSA: printf("ALSA"); break; }; printf(" Driver list\n"); printf("---------------------------------------------------------\n"); for (i=0; i < FSOUND_GetNumDrivers(); i++) { printf("%d - %s\n", i+1, FSOUND_GetDriverName(i)); } printf("---------------------------------------------------------\n"); printf("Press a corresponding number or ESC to quit\n"); do { key = getch(); if (key == 27) exit(0); driver = key - '1'; } while (driver < 0 || driver >= FSOUND_GetNumDrivers()); FSOUND_SetDriver(driver); // ========================================================================================== // INITIALIZE // ========================================================================================== if (!FSOUND_Init(44100, 32, 0)) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); FSOUND_Close(); return 1; } /* Internet streams can work with a much smaller stream buffer than normal streams because they use another level of buffering on top of the stream buffer. */ FSOUND_Stream_SetBufferSize(100); /* Here's where we set the size of the network buffer and some buffering parameters. In this case we want a network buffer of 64k, we want it to prebuffer 60% of that when we first connect, and we want it to rebuffer 80% of that whenever we encounter a buffer underrun. */ FSOUND_Stream_Net_SetBufferProperties(64000, 60, 80); /* Open the stream using FSOUND_NONBLOCKING because the connect/buffer process might take a long time */ stream = FSOUND_Stream_Open(argv[1], FSOUND_NORMAL | FSOUND_NONBLOCKING, 0, 0); if (!stream) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); FSOUND_Close(); return 1; } printf("\nPress ESC to quit...\n\n"); key = 0; do { if (kbhit()) { key = getch(); } /* Play the stream if it's not already playing */ if (channel < 0) { channel = FSOUND_Stream_PlayEx(FSOUND_FREE, stream, NULL, TRUE); FSOUND_SetPaused(channel, FALSE); if (channel != -1) { FSOUND_Stream_Net_SetMetadataCallback(stream, metacallback, 0); } } openstate = FSOUND_Stream_GetOpenState(stream); if ((openstate == -1) || (openstate == -3)) { printf("\nERROR: failed to open stream!\n"); printf("SERVER: %s\n", FSOUND_Stream_Net_GetLastServerStatus()); break; } FSOUND_Stream_Net_GetStatus(stream, &status, &read_percent, &bitrate, &flags); /* Show how much of the net buffer is used and what the status is */ if (metanum) { printf("%s - %s\n", artist, title); metanum = 0; } s[0] = 0; strncat(s, bar, (read_percent >> 1) + (read_percent & 1)); strncat(s, nobar, (100 - read_percent) >> 1); printf("|%s| %d%% %s\r", s, read_percent, status_str[status]); Sleep(16); } while (key != 27); printf("\n"); FSOUND_Stream_Close(stream); FSOUND_Close(); return 0; }
void LecteurAudio::joueurNouveauFichier(QString nomFichier) { // Si un fichier etait en cours de lecture, on le ferme if (fluxAudio) { // Si la fermeture s'est mal passee on affiche un message if (!FSOUND_Stream_Close(fluxAudio)) { qWarning("Probleme a la fermeture d'un flux audio (joueurNouveauFichier - LecteurAudio.cpp)"); return; } } // Si le nom de fichier est vide, il faut arreter le lecteur if (nomFichier.isEmpty()) { // On efface l'afficheur de titre afficheurTitre->clear(); afficheurTitre->setToolTip(tr("Aucun titre")); // On met le lecteur a l'arret etatActuel = arret; // On sort de la fonction return; } // Creation du chemin complet du fichier QString chemin(G_dossierMusiquesJoueur + "/" + nomFichier); // Ouverture du nouveau fichier fluxAudio = FSOUND_Stream_Open(chemin.toLatin1().data(), FSOUND_NORMAL, 0, 0); // Si l'ouverture s'est mal passee on affiche un message if (!fluxAudio) { qWarning("Impossible d'ouvrir le fichier audio (joueurNouveauFichier - LecteurAudio.cpp)"); // On affiche le message en clair afficheurTitre->setEchoMode(QLineEdit::Normal); // Changement de la couleur du texte en rouge QPalette palette(afficheurTitre->palette()); palette.setColor(QPalette::Normal, QPalette::Text, Qt::red); afficheurTitre->setPalette(palette); // On affiche le titre du nouveau morceau en rouge (indique que le fichier n'est pas present ou impossible a ouvrir) afficheurTitre->setText(nomFichier + tr(" : fichier introuvable ou impossible à ouvrir")); afficheurTitre->setCursorPosition(0); afficheurTitre->setToolTip(tr("Fichier introuvable ou impossible à ouvrir : ") + chemin); // On quitte la fonction return; } // Si l'ouverture du fichier s'est bien passee on ecrit en noir avec des asterisques else { // On masque le titre afficheurTitre->setEchoMode(QLineEdit::Password); // On ecrit en noir QPalette palette(afficheurTitre->palette()); palette.setColor(QPalette::Normal, QPalette::Text, Qt::black); afficheurTitre->setPalette(palette); } // On affiche le titre du nouveau morceau afficheurTitre->setText(nomFichier); afficheurTitre->setCursorPosition(0); afficheurTitre->setToolTip(tr("Titre masqué")); // On met le lecteur a l'arret etatActuel = arret; // La lecture reprend depuis le debut joueurPositionTemps = 0; }
void LecteurAudio::supprimerTitre() { // On recupere la liste des element selectionnes (il ne peut y en avoir qu'un seul au maximum) QList<QListWidgetItem *> titreSelectionne = listeTitres->selectedItems(); // Si aucun titre n'est selectionne, on quitte la fonction if (titreSelectionne.isEmpty()) return; // On recupere le numero de la ligne dans la liste des titres int ligne = listeTitres->row(titreSelectionne[0]); // On supprime l'element de la liste des titres et des chemins listeTitres->takeItem(ligne); listeChemins.takeAt(ligne); // On regarde si le titre supprime etait le titre en cours if (ligne == titreCourant) { // On ferme le titre qui etait dans le lecteur if (!FSOUND_Stream_Close(fluxAudio)) { qWarning("Probleme a la fermeture d'un flux audio (supprimerTitre - LecteurAudio.cpp)"); return; } // On met le flux audio a NULL fluxAudio = 0; // On regarde s'il existe un titre apres celui qui vient d'etre supprime // Si oui, il devient le nouveau titre en cours if (titreCourant < listeChemins.size()) { // On envoie le nouveau titre aux lecteurs des joueurs emettreCommande(nouveauMorceau, listeTitres->item(titreCourant)->text()); // Insertion du nouveau titre dans le lecteur nouveauTitre(listeTitres->item(titreCourant)->text(), listeChemins[titreCourant]); } // Sinon on regarde s'il y a un titre avant : celui-ci devient le titre en cours else if (titreCourant != 0) { titreCourant--; // On envoie le nouveau titre aux lecteurs des joueurs emettreCommande(nouveauMorceau, listeTitres->item(titreCourant)->text()); // Insertion du nouveau titre dans le lecteur nouveauTitre(listeTitres->item(titreCourant)->text(), listeChemins[titreCourant]); } // Sinon, on vient de supprimer le dernier element : on arrete le lecteur et on decoche les boutons else { // On envoie un titre vide aux lecteurs des joueurs pour qu'ils s'arretent emettreCommande(nouveauMorceau, ""); // On arrete le lecteur arreter(); // L'afficheur de titre est nettoye afficheurTitre->clear(); afficheurTitre->setToolTip(""); // Le temps est mis a 0 positionTemps->setRange(0, 0); // Les boutons sont desactives actionLecture->setEnabled(false); actionPause->setEnabled(false); actionStop->setEnabled(false); actionBoucle->setEnabled(false); actionUnique->setEnabled(false); actionSupprimer->setEnabled(false); positionTemps->setEnabled(false); } } // Si le titre supprime se trouvait avant le titre courant, celui-ci remonte d'une place else if (ligne < titreCourant) titreCourant--; }
/** Closes the stream * * @returns boolean true or false, in this case, true only since you ignore any error condition */ bool FMODStreamBuffer::Close(void) { if(FSOUND_Stream_Close(m_stream) == 1) return true; return false; }
/* [ [DESCRIPTION] [PARAMETERS] [RETURN_VALUE] [REMARKS] [SEE_ALSO] ] */ int main() { FSOUND_STREAM *stream; FSOUND_DSPUNIT *dsp1,*dsp2; char key; if (FSOUND_GetVersion() < FMOD_VERSION) { printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION); return 1; } printf("-------------------------------------------------------------\n"); printf("FSOUND Streamer example.\n"); printf("Copyright (c) Firelight Technologies Pty, Ltd, 2001-2004.\n"); printf("-------------------------------------------------------------\n"); printf("---------------------------------------------------------\n"); printf("Output Type\n"); printf("---------------------------------------------------------\n"); #if defined(WIN32) || defined(_WIN64) || defined(__CYGWIN32__) || defined(__WATCOMC__) printf("1 - Direct Sound\n"); printf("2 - Windows Multimedia Waveout\n"); printf("3 - ASIO\n"); #elif defined(__linux__) printf("1 - OSS - Open Sound System\n"); printf("2 - ESD - Elightment Sound Daemon\n"); printf("3 - ALSA 0.9 - Advanced Linux Sound Architecture\n"); #endif printf("4 - NoSound\n"); printf("---------------------------------------------------------\n"); // print driver names printf("Press a corresponding number or ESC to quit\n"); do { key = getch(); } while (key != 27 && key < '1' && key > '4'); switch (key) { #if defined(WIN32) || defined(_WIN64) || defined(__CYGWIN32__) || defined(__WATCOMC__) case '1' : FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND); break; case '2' : FSOUND_SetOutput(FSOUND_OUTPUT_WINMM); break; case '3' : FSOUND_SetOutput(FSOUND_OUTPUT_ASIO); break; #elif defined(__linux__) case '1' : FSOUND_SetOutput(FSOUND_OUTPUT_OSS); break; case '2' : FSOUND_SetOutput(FSOUND_OUTPUT_ESD); break; case '3' : FSOUND_SetOutput(FSOUND_OUTPUT_ALSA); break; #endif case '4' : FSOUND_SetOutput(FSOUND_OUTPUT_NOSOUND); break; default : exit(0); } // ========================================================================================== // SELECT DRIVER // ========================================================================================== { int i,driver=0; char key; // The following list are the drivers for the output method selected above. printf("---------------------------------------------------------\n"); switch (FSOUND_GetOutput()) { case FSOUND_OUTPUT_NOSOUND: printf("NoSound"); break; case FSOUND_OUTPUT_WINMM: printf("Windows Multimedia Waveout"); break; case FSOUND_OUTPUT_DSOUND: printf("Direct Sound"); break; case FSOUND_OUTPUT_ASIO: printf("ASIO"); break; case FSOUND_OUTPUT_OSS: printf("Open Sound System"); break; case FSOUND_OUTPUT_ESD: printf("Enlightment Sound Daemon"); break; case FSOUND_OUTPUT_ALSA: printf("Alsa"); break; }; printf(" Driver list\n"); printf("---------------------------------------------------------\n"); for (i=0; i < FSOUND_GetNumDrivers(); i++) { printf("%d - %s\n", i+1, FSOUND_GetDriverName(i)); // print driver names } printf("---------------------------------------------------------\n"); // print driver names printf("Press a corresponding number or ESC to quit\n"); do { key = getch(); if (key == 27) exit(0); driver = key - '1'; } while (driver < 0 || driver >= FSOUND_GetNumDrivers()); FSOUND_SetDriver(driver); // Select sound card (0 = default) } // ========================================================================================== // INITIALIZE // ========================================================================================== if (!FSOUND_Init(44100, 16, 0)) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); return 1; } // ========================================================================================== // CREATE USER STREAM // ========================================================================================== stream = FSOUND_Stream_Create(streamcallback, 6*2048, FSOUND_NORMAL | FSOUND_16BITS | FSOUND_STEREO, 44100, (void *)12345); if (!stream) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); return 1; } FSOUND_Stream_SetEndCallback(stream, endcallback, 0); dsp1 = FSOUND_Stream_CreateDSP(stream, dspcallback, 0, 0); // priority 0 = it comes first in dsp chain. dsp2 = FSOUND_Stream_CreateDSP(stream, dspcallback, 1, 0); // priority 1 = it comes last printf("Press any key to quit\n"); printf("=========================================================================\n"); printf("Playing stream...\n"); // ========================================================================================== // PLAY STREAM // ========================================================================================== if (FSOUND_Stream_Play(FSOUND_FREE, stream) == -1) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); return 1; } printf("******* Hit a key to active stream DSP unit #1 to halve the stream volume.\n"); getch(); FSOUND_DSP_SetActive(dsp1, 1); printf("******* Now hit a key to active stream DSP unit #2 to quarter the stream volume.\n"); getch(); FSOUND_DSP_SetActive(dsp2, 1); printf("******* How hit a key to finish.\n"); getch(); printf("\n"); FSOUND_DSP_Free(dsp1); FSOUND_DSP_Free(dsp2); FSOUND_Stream_Close(stream); FSOUND_Close(); return 0; }
int main(int argc, char ** argv) { int finp = 0,first = 1; SDL_Surface * menu = NULL; SDL_Surface * ecran = NULL; SDL_Rect position_menu; SDL_Event event; FSOUND_STREAM * musique = NULL; SDL_Init(SDL_INIT_VIDEO); TTF_Init(); FSOUND_Init(44100,32,0); ecran = SDL_SetVideoMode(800,800,32,SDL_HWSURFACE | SDL_DOUBLEBUF); if(ecran == NULL) exit(EXIT_FAILURE); SDL_WM_SetCaption("Prozet zz1",NULL); menu = IMG_Load("./dessin/menu.jpg"); if(menu == NULL) exit(EXIT_FAILURE); position_menu.x = 0; position_menu.y = 0; musique = FSOUND_Stream_Open("./son/jourdefoot.mp3",0,0,0); if(musique == NULL) exit(EXIT_FAILURE); while(finp == 0) { if(first == 1) { SDL_BlitSurface(menu,NULL,ecran,&position_menu); SDL_Flip(ecran); FSOUND_Stream_Play(FSOUND_FREE,musique); first = 0; } SDL_WaitEvent(&event); switch(event.type) { case SDL_QUIT: finp = 1; break; case SDL_MOUSEBUTTONDOWN: if(event.button.button == SDL_BUTTON_LEFT) { if(event.button.x >= 250 && event.button.x <= 550) { if(event.button.y >= 300 && event.button.y <= 400) { FSOUND_Stream_Stop(musique); mode_solo(ecran); first = 1; } else { if(event.button.y >= 450 && event.button.y <= 550) { FSOUND_Stream_Stop(musique); mode_local_serveur(ecran); first = 1; } else { if(event.button.y >= 600 && event.button.y <= 700) { FSOUND_Stream_Stop(musique); mode_local_client(ecran); first = 1; } } } } } break; } } FSOUND_Stream_Stop(musique); FSOUND_Stream_Close(musique); FSOUND_Close(); SDL_FreeSurface(menu); SDL_FreeSurface(ecran); TTF_Quit(); SDL_Quit(); return(EXIT_SUCCESS); }
int main ( int argc, char* args[] ) { init(); srand(time(NULL)); int FPS = 0; ///////GLOBAL LOADING tex_spikes = loadTexture("data/gfx/Spikes.png"); tex_block1 = loadTexture("data/gfx/block1.png"); tex_menu = loadTexture("data/gfx/menu.png"); tex_playgame = loadTexture("data/gfx/playgame.png"); tex_selectlevel = loadTexture("data/gfx/selectlevel.png"); tex_editor = loadTexture("data/gfx/editor.png"); tex_exit = loadTexture("data/gfx/exitmenu.png"); tex_player1 = loadTexture("data/gfx/player.png"); tex_door = loadTexture("data/gfx/door.png"); tex_font = loadTexture("data/gfx/font.png"); tex_done = loadTexture("data/gfx/ok.png"); tex_gold = loadTexture("data/gfx/gold.png"); tex_silver = loadTexture("data/gfx/silver.png"); tex_bronze = loadTexture("data/gfx/bronze.png"); tex_eyes = loadTexture("data/gfx/playgame.png"); tex_arrow = loadTexture("data/gfx/arrow.png"); tex_info = loadTexture("data/gfx/info.png"); ///////soundsss sample_playerJump = FSOUND_Sample_Load(FSOUND_UNMANAGED,"data/sfx/jump.wav",0,0,0); FSOUND_Sample_SetDefaults(sample_playerJump, -1,100,-1,-1); sample_playerHit = FSOUND_Sample_Load(FSOUND_UNMANAGED,"data/sfx/hit.wav",0,0,0); FSOUND_Sample_SetDefaults(sample_playerHit, -1,100,-1,-1); sample_playerForce = FSOUND_Sample_Load(FSOUND_UNMANAGED,"data/sfx/force.wav",0,0,0); FSOUND_Sample_SetDefaults(sample_playerForce, -1,100,-1,-1); song2 = FSOUND_Stream_Open( "data/music/Random-SitgesSavepoint.mp3",FSOUND_LOOP_NORMAL,0,0); FSOUND_Stream_Play( 1, song2 ); FSOUND_Stream_SetLoopCount(song2,-1); //FSOUND_SetVolume(1,80); std::ifstream file ("data/levels/score.lvl"); while ( !file.eof() ) { o_scores.push_back(new Score()); file >> o_scores.back()->i_number; file >> o_scores.back()->b_unlocked; file >> o_scores.back()->i_highScore; file >> o_scores.back()->i_B; file >> o_scores.back()->i_S; file >> o_scores.back()->i_G; } file.close(); //o_scores.pop_back(); gameState = new StateMenu(); currentGameState = STATE_MENU; /* for ( int n = 0; n < 100; n++ ) { o_scores.push_back( new Score () ); o_scores.back()->b_unlocked = true; o_scores.back()->i_highScore = 0; o_scores.back()->i_B = 0; o_scores.back()->i_G = 0; o_scores.back()->i_S = 0; }*/ //saving FPSA = SDL_GetTicks(); while ( nextGameState != STATE_EXIT ) { FPS = SDL_GetTicks(); gameState->handleEvents(); gameState->logic(); FPSA = SDL_GetTicks(); gameState->render(); changeGameState(); //////////////////////////// if ( (SDL_GetTicks() - FPS) < 1000/60 ) { //SDL_Delay( ( 1000/60) - (SDL_GetTicks() - FPS) ); } SDL_Delay(2); } FSOUND_Stream_Close(song2); FSOUND_Close(); return 0; }
void Free() { if (m) FSOUND_Stream_Close( m ); m = NULL; }
/* [ [DESCRIPTION] main entry point into streamer example. [PARAMETERS] 'argc' Number of command line parameters. 'argv' Parameter list [RETURN_VALUE] void [REMARKS] [SEE_ALSO] ] */ int main(int argc, char *argv[]) { FSOUND_STREAM *stream; FSOUND_SAMPLE *sptr; char key; if (FSOUND_GetVersion() < FMOD_VERSION) { printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION); return 1; } if (argc < 2) { printf("-------------------------------------------------------------\n"); printf("FMOD Streamer example.\n"); printf("Copyright (c) Firelight Technologies Pty, Ltd, 1999-2004.\n"); printf("-------------------------------------------------------------\n"); printf("Syntax: stream infile.[mp2 mp3 wav ogg wma asf]\n\n"); return 1; } #if defined(WIN32) || defined(_WIN64) || defined(__CYGWIN32__) || defined(__WATCOMC__) FSOUND_SetOutput(FSOUND_OUTPUT_WINMM); #elif defined(__linux__) FSOUND_SetOutput(FSOUND_OUTPUT_OSS); #endif // Set custom file callbacks? This doesnt have to be done, its just here as an example. FSOUND_File_SetCallbacks(myopen, myclose, myread, myseek, mytell); // ========================================================================================== // SELECT DRIVER // ========================================================================================== { long i,driver=0; char key; // The following list are the drivers for the output method selected above. printf("---------------------------------------------------------\n"); switch (FSOUND_GetOutput()) { case FSOUND_OUTPUT_NOSOUND: printf("NoSound"); break; case FSOUND_OUTPUT_WINMM: printf("Windows Multimedia Waveout"); break; case FSOUND_OUTPUT_DSOUND: printf("Direct Sound"); break; case FSOUND_OUTPUT_A3D: printf("A3D"); break; case FSOUND_OUTPUT_OSS: printf("Open Sound System"); break; case FSOUND_OUTPUT_ESD: printf("Enlightenment Sound Daemon"); break; case FSOUND_OUTPUT_ALSA: printf("ALSA"); break; }; printf(" Driver list\n"); printf("---------------------------------------------------------\n"); for (i=0; i < FSOUND_GetNumDrivers(); i++) { printf("%d - %s\n", i+1, FSOUND_GetDriverName(i)); // print driver names } printf("---------------------------------------------------------\n"); // print driver names printf("Press a corresponding number or ESC to quit\n"); do { key = getch(); if (key == 27) exit(0); driver = key - '1'; } while (driver < 0 || driver >= FSOUND_GetNumDrivers()); FSOUND_SetDriver(driver); // Select sound card (0 = default) } // ========================================================================================== // INITIALIZE // ========================================================================================== if (!FSOUND_Init(44100, 32, 0)) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); FSOUND_Close(); return 1; } FSOUND_Stream_SetBufferSize(1000); // ========================================================================================== // OPEN STREAM (use #if 1 for streaming from memory) // ========================================================================================== #if 0 { FILE *fp; int length; char *data; fp = fopen(argv[1], "rb"); if (!fp) { printf("Error!\n"); printf("File Not Found\n"); FSOUND_Close(); return 1; } fseek(fp, 0, SEEK_END); length = ftell(fp); fseek(fp, 0, SEEK_SET); data = (char *)malloc(length); fread(data, length, 1, fp); fclose(fp); stream = FSOUND_Stream_Open(data, FSOUND_NORMAL | FSOUND_MPEGACCURATE | FSOUND_LOADMEMORY, 0, length); // The memory pointer MUST remain valid while streaming! } #else if (!strnicmp(argv[1], "http:", 5)) { printf("Connecting to %s, please wait (this may take some time)....\n", argv[1]); } stream = FSOUND_Stream_Open(argv[1], FSOUND_NORMAL | FSOUND_MPEGACCURATE, 0, 0); if (!stream) { printf("Error!\n"); printf("%s\n", FMOD_ErrorString(FSOUND_GetError())); FSOUND_Close(); return 1; } #endif // ========================================================================================== // SET AN END OF STREAM CALLBACK AND RIFF SYNCH POINTS CALLBACK // ========================================================================================== FSOUND_Stream_SetEndCallback(stream, endcallback, 0); FSOUND_Stream_SetSyncCallback(stream, endcallback, 0); printf("=========================================================================\n"); printf("Press SPACE to pause/unpause\n"); printf("Press 'f' to fast forward 2 seconds\n"); printf("Press ESC to quit\n"); printf("=========================================================================\n"); printf("Playing stream...\n\n"); sptr = FSOUND_Stream_GetSample(stream); if (sptr) { int freq; FSOUND_Sample_GetDefaults(sptr, &freq, NULL, NULL, NULL); printf("Name : %s\n", FSOUND_Sample_GetName(sptr)); printf("Frequency : %d\n\n", freq); } key = 0; do { if (channel < 0) { // ========================================================================================== // PLAY STREAM // ========================================================================================== channel = FSOUND_Stream_PlayEx(FSOUND_FREE, stream, NULL, TRUE); FSOUND_SetPaused(channel, FALSE); } if (kbhit()) { key = getch(); if (key == ' ') { FSOUND_SetPaused(channel, !FSOUND_GetPaused(channel)); } if (key == 'f') { FSOUND_Stream_SetTime(stream, FSOUND_Stream_GetTime(stream) + 2000); } } printf("pos %6d/%6d time %02d:%02d/%02d:%02d cpu %5.02f%% \r", FSOUND_Stream_GetPosition(stream), FSOUND_Stream_GetLength(stream), FSOUND_Stream_GetTime(stream) / 1000 / 60, FSOUND_Stream_GetTime(stream) / 1000 % 60, FSOUND_Stream_GetLengthMs(stream) / 1000 / 60, FSOUND_Stream_GetLengthMs(stream) / 1000 % 60, FSOUND_GetCPUUsage()); Sleep(10); } while (key != 27); printf("\n"); FSOUND_Stream_Close(stream); FSOUND_Close(); return 0; }
MusicStream::~MusicStream() { FSOUND_Stream_Close(music); }