예제 #1
0
CSoundManager::~CSoundManager()
{
	Protokoll.WriteText("-> Shutting down Sound Manager\n", false);

	FMUSIC_StopAllSongs();

	// Songs freigeben
	//
	for (int i=0; i<MAX_SONGS; i++)
		if (its_Songs[i] != NULL)
		{
			delete(its_Songs[i]);	// Freigeben
			its_Songs[i] = NULL;
		}

	its_LoadedSongs = 0;

	// Sounds freigeben
	for (int i=0; i<MAX_SOUNDS; i++)
		if (its_Sounds[i] != NULL)
		{
			delete(its_Sounds[i]);	// Freigeben
			its_Sounds[i] = NULL;
		}

	its_LoadedSounds = 0;

	// FSOUND beenden
	//
	FSOUND_Close();

}; // Desktruktor
예제 #2
0
파일: s_fmod.c 프로젝트: HipsterLion/SRB2
EXPORT void HWRAPI(Shutdown) (void)
{
	DBG_Printf("Shuting down FMOD\n");
	FSOUND_Sample_Free(blankfmsample);
	DBG_Printf("Shutdown of FMOD done\n");
	FSOUND_Close();
}
예제 #3
0
//close sound system if it initialized correctly
CAudioManager::~CAudioManager(){
  if(m_bValidAudio == true){

    for(int i = 0; i < m_AudioClip.size(); i++)
      FSOUND_Sample_Free(m_AudioClip[i].handle);

    FSOUND_Close();
  }
}
예제 #4
0
파일: Main.cpp 프로젝트: Dangr8/Cities3D
int main()
{
    FMUSIC_MODULE *mod = NULL;

    if (FSOUND_GetVersion() < FMOD_VERSION)
    {
        printf("Error : You are using the wrong DLL version!  You should be using FMOD %.02f\n", FMOD_VERSION);
        exit(1);
    }
    
    /*
        INITIALIZE
    */
    if (!FSOUND_Init(32000, 64, 0))
    {
        printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
        exit(1);
    }

  
    /*
        LOAD SONG
    */
    mod = FMUSIC_LoadSong("../../media/invtro94.s3m");
    if (!mod)
    {
        printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
        exit(1);
    }
    FMUSIC_PlaySong(mod);   

    /*
        UPDATE INTERFACE
    */

    printf("Press any key to quit\n");
    printf("=========================================================================\n");
    printf("Playing %s...\n", FMUSIC_GetName(mod));
    do
    {
        printf("order = %d/%d, row = %d/%d channels playing = %d cpu usage = %.02f%%     \r", FMUSIC_GetOrder(mod), FMUSIC_GetNumOrders(mod), FMUSIC_GetRow(mod), FMUSIC_GetPatternLength(mod, FMUSIC_GetOrder(mod)), FSOUND_GetChannelsPlaying(), FSOUND_GetCPUUsage());
        Sleep(10);
    } while (!kbhit());

    getch();

    printf("\n");

    /*
        FREE SONG AND SHUT DOWN
    */

    FMUSIC_FreeSong(mod);
    FSOUND_Close();

    return 0;
}
예제 #5
0
//================================================================================================//
Engine::~Engine(void)
{
	gLog.OutPut("\n[Engine Shutdown]\n");
	ilShutDown();
	FSOUND_Close();  
	SDL_Quit();
	SaveScores();
	gLog.OutPut("Complete...\n\n");
}
예제 #6
0
파일: c_fmod.cpp 프로젝트: jbworley/dlstorm
void CFMOD::ShutDownSound(void)
{
    if(!bfmod) return;

    DeleteAllSamples();

    StopAudio();
    FSOUND_Close();

}
예제 #7
0
//Funcoes do menu      
void MenuSom(int op)
{
   switch(op) {
              case 0:
                     { FSOUND_Close(); }
                     break;
              } 
                
    glutPostRedisplay();
}  
예제 #8
0
	CAudio::~CAudio(){
		Stop();
		for(AudioDataItem pos = AudioData.begin(); pos != AudioData.end(); ++pos){
			if(pos->second){
				pos->second->Close();
				delete pos->second;
			}
		}
		AudioData.clear();
		FSOUND_Close();
	}
예제 #9
0
//===========================================================================
// DM_FModShutdown
//===========================================================================
void DM_FModShutdown(void)
{
	if(!inited)
		return;
	inited = false;

	// Shut down the interfaces.
	DM_FModExtShutdown();
	DM_FModCDShutdown();

	FSOUND_Close();
}
bool SoundManager2::destroy( void ){
    stopMusic();
    FSOUND_Sample_Free (musicHandle);
    FSOUND_Sample_Free (swapMusicHandle);
    FSOUND_Close();

    if(isDebug()){
        printf("SoundManager Destroyed");
    }

    return true;
}
예제 #11
0
// Deletes all Audios in the map container
HamurAudioManager::~HamurAudioManager()
{
    // Delete all
	ClearAll();

	// Shuts down the WHOLE FMOD Sound System.
	// This also closes down the sample management system, freeing all MANAGED samples loaded 
	// (unless they were allocated with the FSOUND_UNMANAGED flag).
	// Streams are not freed. You must close them yourself.
	// CD Tracks are stopped.
	FSOUND_Close();

    HAMURLOG->WriteTerminateLog("HamurAudioManager");
}
void ReleaseAll(void)
{
	if (graphicInstance != NULL) {
		fnt_menu.close();
		fnt_menus.close();
		fnt_cool.close();
		fnt_rpg.close();

		pbk_inter.close();

		LGXpaker.closePaker();

		if (videoA != NULL) {
			videoA->Release();
			videoA = NULL;
		}


		if (systemSurface != NULL) {
			systemSurface->Release();
			systemSurface = NULL;
		}

		if (primSurface != NULL) {
			primSurface->Release();
			primSurface = NULL;
		}

		DDCloseDirectDraw();
	}

	freeTxtData();
	freeMathsFunctions();

	mbk_inter.close();
	mbk_interl.close();

	FSOUND_Close();

	in.close();

	ChangeDisplaySettings(NULL, 0);

}
void LLAudioEngine_FMOD::shutdown()
{
	if (mWindDSP)
	{
		FSOUND_DSP_SetActive(mWindDSP,false);
		FSOUND_DSP_Free(mWindDSP);
	}

	stopInternetStream();

	LLAudioEngine::shutdown();
	
	llinfos << "LLAudioEngine_FMOD::shutdown() closing FMOD" << llendl;
	FSOUND_Close();
	llinfos << "LLAudioEngine_FMOD::shutdown() done closing FMOD" << llendl;

	delete mListenerp;
	mListenerp = NULL;
}
예제 #14
0
Menu::~Menu()
{
  // Destory Bitmaps
  destroy_bitmap( buffer);
  destroy_bitmap( menu);
  destroy_bitmap( menuselect);
  destroy_bitmap( help);
  destroy_bitmap( cursor[0]);
  destroy_bitmap( cursor[1]);
  destroy_bitmap( levelSelectLeft);
  destroy_bitmap( levelSelectRight);
  destroy_bitmap( levelSelectNumber);

  // Destory Samples
  destroy_sample( click);
  destroy_sample( intro);

  // Fade out
  highcolor_fade_out(16);

  // Clean up fmod
  FSOUND_Close();
}
int		put_song_bcast(t_sdl *sdl, int x, int y)
{
  FSOUND_SAMPLE	*turkey;

  FSOUND_Init(44100, 32, 0);
  sdl->game.rec.x = (x - sdl->scrollX) * MAP_W + 30;
  sdl->game.rec.y = (y - sdl->scrollY) * MAP_H + HEADER_MENU + 10;
  sdl->game.rec.h = 17;
  sdl->game.rec.w = 17;
  xSDL_BlitSurface(sdl->game.bcast, NULL, sdl->screen, &sdl->game.rec);
  SDL_UpdateRects(sdl->screen, 1, &sdl->game.rec);
  if ((turkey = FSOUND_Sample_Load(FSOUND_FREE, "src_graphic/sound/gobble.wav",
				   0, 0, 0)) == NULL)
    {
      my_printf("Warning: Sound loading failled\n");
      SDL_Delay(1000);
      return (0);
    }
  FSOUND_PlaySound(FSOUND_FREE, turkey);
  SDL_Delay(1000);
  FSOUND_Sample_Free(turkey);
  FSOUND_Close();
  return (1);
}
예제 #16
0
/*
[
    [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;
}
예제 #17
0
FMODEngine::~FMODEngine(void)
{	
	FSOUND_Close();
}
예제 #18
0
/*
[
    [DESCRIPTION]

    [PARAMETERS]
 
    [RETURN_VALUE]

    [REMARKS]

    [SEE_ALSO]
]
*/
int main()
{
    FSOUND_SAMPLE *samp1 = 0, *samp2 = 0;
    int key;
    int eqid1,eqid2;
   
    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;
    }

     /*
        INITIALIZE
    */
    FSOUND_SetBufferSize(100);  /* This is nescessary to get FX to work on output buffer */
    if (!FSOUND_Init(44100, 32, FSOUND_INIT_ENABLESYSTEMCHANNELFX))
    {
        printf("Error!\n");
        printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
        return 1;
    }

    /*
        LOAD SAMPLES
    */

    /* PCM,44,100 Hz, 8 Bit, Mono */
    samp1 = FSOUND_Sample_Load(FSOUND_FREE, "../../media/drumloop.wav", FSOUND_2D, 0, 0);
    if (!samp1)
    {
        printf("Error!\n");
        printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
        return 1;
    }
    FSOUND_Sample_SetMode(samp1, FSOUND_LOOP_OFF);

    /* PCM,44,100 Hz, 16 Bit, Stereo */
    samp2 = FSOUND_Sample_Load(FSOUND_FREE, "../../media/jules.mp3", FSOUND_HW2D | FSOUND_ENABLEFX, 0, 0);
    if (!samp2)
    {
        printf("Error!\n");
        printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
        return 1;
    }

    /*
        DISPLAY HELP
    */

    printf("FSOUND Output Method : ");
    switch (FSOUND_GetOutput())
    {
        case FSOUND_OUTPUT_NOSOUND:  printf("FSOUND_OUTPUT_NOSOUND\n"); break;
        case FSOUND_OUTPUT_WINMM:    printf("FSOUND_OUTPUT_WINMM\n"); break;
        case FSOUND_OUTPUT_DSOUND:   printf("FSOUND_OUTPUT_DSOUND\n"); break;
        case FSOUND_OUTPUT_ASIO:     printf("FSOUND_OUTPUT_ASIO\n"); break;
        case FSOUND_OUTPUT_OSS:      printf("FSOUND_OUTPUT_OSS\n"); break;
        case FSOUND_OUTPUT_ALSA:     printf("FSOUND_OUTPUT_ALSA\n"); break;
        case FSOUND_OUTPUT_ESD:      printf("FSOUND_OUTPUT_ESD\n"); break;
    };

    printf("FSOUND Mixer         : ");
    switch (FSOUND_GetMixer())
    {
        case FSOUND_MIXER_QUALITY_FPU:    printf("FSOUND_MIXER_QUALITY_FPU\n"); break;
        case FSOUND_MIXER_QUALITY_MMXP5:  printf("FSOUND_MIXER_QUALITY_MMXP5\n"); break;
        case FSOUND_MIXER_QUALITY_MMXP6:  printf("FSOUND_MIXER_QUALITY_MMXP6\n"); break;
    };
    printf("FSOUND Driver        : %s\n", FSOUND_GetDriverName(FSOUND_GetDriver()));

    printf("=========================================================================\n");
    printf("Press 1       Play SOFTWARE sound affected by following reverb dsp unit (wet)\n");
    printf("      2       Play SOFTWARE sound unaffected by following reverb dsp unit (dry)\n");
    if (FSOUND_GetOutput() == FSOUND_OUTPUT_DSOUND)
    {
        printf("      3       Play HARDWARE FX enabled sound using Direct X 8 (echo+flange)\n");
        printf("      4       Set EQ on global software output to be affect by DX8 FX\n");
        printf("              Press 1 or 2 to hear the effect (3 is unaffected)\n");
        printf("      5       Turn off EQ on global software output\n");
    }
    printf("      ESC     Quit\n");
    printf("=========================================================================\n");

    /*
        SET UP DSPS!
    */

    SetupReverb();

    /*
        Note if we are using a dsp unit for playing sounds, callback and parameter are ignored!
    */
    DrySFXUnit = FSOUND_DSP_Create(NULL, FSOUND_DSP_DEFAULTPRIORITY_USER+100, 0);
    FSOUND_DSP_SetActive(DrySFXUnit, TRUE);

    /*
        You must pause the software output before getting the FX handle on it.
    */
    if (FSOUND_GetOutput() == FSOUND_OUTPUT_DSOUND)
    {
        FSOUND_SetPaused(FSOUND_SYSTEMCHANNEL, TRUE);

        eqid1 = FSOUND_FX_Enable(FSOUND_SYSTEMCHANNEL, FSOUND_FX_PARAMEQ);
        eqid2 = FSOUND_FX_Enable(FSOUND_SYSTEMCHANNEL, FSOUND_FX_PARAMEQ);

        FSOUND_SetPaused(FSOUND_SYSTEMCHANNEL, FALSE);
    }

    /*
        START PLAYING!
    */

    do
    {
        key = 0;
        printf("channels playing = %d cpu usage = %.02f%%\r", FSOUND_GetChannelsPlaying(), FSOUND_GetCPUUsage());

        if (kbhit())
        {
            key = getch();


            if (key == '1') 
            {
                int channel = FSOUND_PlaySound(FSOUND_FREE, samp1);
            }
            if (key == '2') 
            {
                FSOUND_PlaySoundEx(FSOUND_FREE, samp1, DrySFXUnit, FALSE);
            }
            if (FSOUND_GetOutput() == FSOUND_OUTPUT_DSOUND)
            {       
                if (key == '3') 
                {
                    static int  fxchannel = FSOUND_FREE;
                    static int  echoid = -1, echoid2 = -1,flangeid = -1, firsttime;

                    if (fxchannel == FSOUND_FREE)
                    {
                        firsttime = TRUE;
                    }
                    else
                    {
                        firsttime = FALSE;
                    }

                    fxchannel = FSOUND_PlaySoundEx(fxchannel, samp2, DrySFXUnit, TRUE);     

                    /* 
                       NOTE! Even though it is for hardware FX, set it to a DrySFXUnit just 
                       in case a non hardware output mode has been selected (such as 
                       WINMM/Linux etc) and it actually drops back to 100% software 
                     */

                    FSOUND_SetVolume(fxchannel, 120); /* turn it down a bit! */
                
                    if (firsttime)
                    {
                        echoid   = FSOUND_FX_Enable(fxchannel, FSOUND_FX_ECHO);
                        echoid2  = FSOUND_FX_Enable(fxchannel, FSOUND_FX_ECHO);
                        flangeid = FSOUND_FX_Enable(fxchannel, FSOUND_FX_FLANGER);
                    }

                    FSOUND_SetPaused(fxchannel, FALSE);

                    FSOUND_FX_SetEcho(echoid,  80.0f, 70.0f, 100.0f, 100.0f, TRUE);
                    FSOUND_FX_SetEcho(echoid2,  100, 70.0f, 10, 10, FALSE);
                }
                if (key == '4')
                {
                    FSOUND_FX_SetParamEQ(eqid1, 8000, 36, -15);
                    FSOUND_FX_SetParamEQ(eqid2, 16000, 36, -15);
                }
                if (key == '5')
                {
                    FSOUND_FX_SetParamEQ(eqid1, 8000, 15, 0);
                    FSOUND_FX_SetParamEQ(eqid2, 8000, 15, 0);
                }
            }
        }
        Sleep(10);

    } while (key != 27);

    printf("\n");

    /*
        CLEANUP AND SHUTDOWN
    */

    FSOUND_DSP_Free(DrySFXUnit);    

    CloseReverb();

    FSOUND_Sample_Free(samp1);
    FSOUND_Sample_Free(samp2);

    FSOUND_Close();
   
    return 0;
}
예제 #19
0
//Chamada do main
int main(void)
{
//Inicia o som

    FSOUND_SAMPLE *samp1 = 0; //cria um ponteiro para armazenar o som em memória
    if (FSOUND_GetVersion() < FMOD_VERSION) // verificação da versão do fmod caso a versão do FSOUND for menor que a do FMOD retorna uma menssagem de erro
    {
        printf("Error : You are using the wrong DLL version!  You should be using FMOD %.02f\n", FMOD_VERSION);
        return 1;
    }
    //    Seleciona a saída de audio
    FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);

    //    Seleção do driver
   FSOUND_GetOutput(); // indentifica o tipo de saida
   FSOUND_GetMixer(); // indentifica o mixer
   FSOUND_SetDriver(0); // seta o driver de som que vai ser usado

    //    Inicializando o FMOD
    if (!FSOUND_Init(44100, 32, FSOUND_INIT_GLOBALFOCUS)) // se o valor do FSOUND_Init for 0 execute o tratamento de erro
    {
        printf("Error!\n");
        printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
        return 1;
    }

    // Carrengando o Sample
    // PCM,44,100 Hz, 32 Bit, Mono ou uma mp3 ou outros formatos suportados pelo fmod
    samp1 = FSOUND_Sample_Load(FSOUND_UNMANAGED, "topgear.ogg", FSOUND_NORMAL | FSOUND_HW2D, 0, 0); 
    if (!samp1)
    {
        printf("Error!\n");
        printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
        return 1;
    }

   // Aqui fala qual maneira o sample ira tocar caso falhe excute o tratamento de erro
    if(!FSOUND_Sample_SetMode(samp1, FSOUND_LOOP_NORMAL))// o loop normal toca a musica continuamente ate o programa fechar
   {
   printf("Error!\n");   
    printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
   }
   // Aqui sera tocado o sample ,caso falhe, execute o tratamento de erro
   if(!FSOUND_PlaySound(FSOUND_FREE, samp1))
   {
   printf("Error!\n");   
   printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
   }
    //Fim do codigo do som \\o  \o/   o//\o/
    //Sleep(10000);  // executa o som durante 10 segundos     (Essa funcao esta desativada no Street Frog)
    printf ("Jogo desenvolvido como Projeto Final para a Disciplina de Computacao Grafica");
    printf ("\nUFRN - CT - DCA");
    printf ("\nPor Claudio Henrique | Paulo Bruno | Thaisa Ramos");
    //printf ("\n");


    //E por fim a chamada para o OpenGL
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB); //Modo para nao exibir rastros na tela
    glutInitWindowSize (890, 550); //Tamanho da janela
    glutInitWindowPosition (50, 50);  //Localizacao inicial da janela
	glutCreateWindow("Ajude o menino a chegar em casa"); //Nome da janela
    glutKeyboardFunc(Teclado); //Chama as funcoes do teclado
    glutSpecialFunc(Mover);  //Chama as funcoes especias do teclado (setas de movimento)
	Inicializa(); 
	iniciaText();
	glutDisplayFunc(Desenha); //Chama o desenho
	glutReshapeFunc(AlteraTamanhoJanela); //Correcao de largura e altura para a janela
    glutTimerFunc(10,movimentar,1);       //Chamada de movimento do carro
    glutTimerFunc(10,movimentacarro,1);   //Chamada de movimento do carro
    glutTimerFunc(10,movimentacarro2,1);  //Chamada de movimento do carro
    glutTimerFunc(10,movermad,1);         //Chamada de movimento da madeira
    glutTimerFunc(10,movermad1,1);        //Chamada de movimento da madeira
    glutTimerFunc(10,movermad2,1);        //Chamada de movimento da madeira
    glutMouseFunc(GerenciaMouse);         //Ativa o botao direito
	glutMainLoop();
	//Final das funcoes do OpenGL
	
    //    limpando a memoria e fechando o fmod (Som)
    FSOUND_Sample_Free(samp1); // limpa a memoria ultilizada pelo ponteiro do sample
    FSOUND_Close();  // encerra a API FMOD

}
예제 #20
0
int main(int argc, char *argv[])
{
    SDL_Event event;
    int continuer = 1;

    SDL_Init(SDL_INIT_VIDEO);
    FSOUND_Init(44100, 32, FSOUND_NORMAL);
    atexit(SDL_Quit);
    SDL_WM_SetCaption("Sphere Quantique", NULL);
    SDL_SetVideoMode(1280/*glutGet(GLUT_SCREEN_WIDTH)*/,720/*glutGet(GLUT_SCREEN_HEIGHT)*/, 32, SDL_OPENGL | SDL_NOFRAME/*| SDL_FULLSCREEN*/);

    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    gluPerspective(70,(double)glutGet(GLUT_SCREEN_WIDTH)/glutGet(GLUT_SCREEN_HEIGHT),1,1000);
    glEnable(GL_DEPTH_TEST);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glFlush();
    SDL_GL_SwapBuffers();

    srand(time(NULL));
    for(int i=0;i<MAX_BALL;i++){

        int r_x = rand()%(50-1)+10;

        int r_y = rand()%(50-1)+10;

        int r_z = rand()%(50-1)+10;


        int ax_1 = rand()%2;

        int ax_2 = rand()%2;


        int angl = rand()%360;

        int R = rand()%256;
        int G = rand()%256;
        int B = rand()%256;

        sphere[i] = init_sphere(sphere[i],0,0,0,r_x,r_y,r_z,ax_1,ax_2,angl,R,G,B);

    }




//SDL_Delay(10000);

    while(continuer)
    {
        SDL_PollEvent(&event);
        switch(event.type)
        {   case SDL_QUIT:
                continuer = 0;
                break;
            case SDL_KEYDOWN:
                 switch(event.key.keysym.sym)
                 {   case SDLK_ESCAPE:
                          continuer = 0;
                          break;
                    case SDLK_w:
                        cam_x += 1;
                        cam_px += 1;
                        break;
                    case SDLK_a:

                        break;
                    case SDLK_d:

                        break;
                    case SDLK_s:
                        cam_x -= 1;
                        cam_px -= 1;
                        break;
                     default:break;
                 }
                 break;
        }
        Dessiner();

        SDL_Delay(10);

    }

    FSOUND_Close();

    return 0;
}
예제 #21
0
/*
[
	[DESCRIPTION]

	[PARAMETERS]
 
	[RETURN_VALUE]

	[REMARKS]

	[SEE_ALSO]
]
*/
void main(int argc, char *argv[])
{
#ifdef USEFMOD
	FMUSIC_MODULE *mod;

#ifndef USEMEMLOAD
	FSOUND_File_SetCallbacks(fileopen, fileclose, fileread, fileseek, filetell);
#else
	FSOUND_File_SetCallbacks(memopen, memclose, memread, memseek, memtell);
#endif
#endif

	if (argc < 2)
	{
		printf("-------------------------------------------------------------\n");
		printf("MINIFMOD example XM player.\n");
		printf("Copyright (c) Firelight Multimedia, 2000.\n");
		printf("-------------------------------------------------------------\n");
		printf("Syntax: simplest infile.xm\n\n");
		return;
	}


#ifdef USEFMOD
	// ==========================================================================================
	// INITIALIZE
	// ==========================================================================================
	if (!FSOUND_Init(44100, 0))
	{
		printf("Error upon initialization\n");
		return;
	}

	// ==========================================================================================
	// LOAD SONG
	// ==========================================================================================
	mod = FMUSIC_LoadSong(argv[1], NULL); //sampleloadcallback);
	if (!mod)
	{
		printf("Error loading song\n");
		return;
	}

	// ==========================================================================================
	// PLAY SONG
	// ==========================================================================================
	FMUSIC_PlaySong(mod);
#endif

	printf("Press any key to quit\n");
	printf("=========================================================================\n");
	printf("Playing song...\n");

	{
		char key = 0;
		do
		{
			int		ord = 0, row = 0;
			float	mytime = 0;
			if (kbhit())
			{
				key = getch();
			}

#ifdef USEFMOD
			ord = FMUSIC_GetOrder(mod);
			row = FMUSIC_GetRow(mod);
			mytime = (float)FMUSIC_GetTime(mod) / 1000.0f;
#endif

			printf("ord %2d row %2d seconds %5.02f %s      \r", ord, row, mytime, (row % 8 ? "    " : "TICK"));

		} while (key != 27);
	}


	printf("\n");

#ifdef USEFMOD
	FMUSIC_FreeSong(mod);
	FSOUND_Close();
#endif
}
예제 #22
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, 
	LPSTR lpCmdLine, int nCmdShow)
{
	USES_CONVERSION;

	//
	// Resolve UNICOWS's thunk (required)
	//

	::DefWindowProc (NULL, 0, 0, 0);

	//
	// Load the application name
	//

	::LoadString (_Module .GetResourceInstance (),
		IDR_NWNEXPLORER, g_szAppName, _countof (g_szAppName));

	//
	// Test for FMOD
	//

	g_hFMODLibrary = ::LoadLibrary (_T ("FMOD.DLL"));

	//
	// Initialize FMOD
	//

	if (g_hFMODLibrary != NULL)
	{
		if (FSOUND_GetVersion () < FMOD_VERSION)
		{
			//FIXME
		}
		if (!FSOUND_Init (44100, 32, FSOUND_INIT_GLOBALFOCUS))
		{
			//FIXME
			FSOUND_Close ();
			return 0;
		}
	}

	//
	// Create our image lists
	//

	{
		CDC dcMem;
		dcMem .CreateCompatibleDC (NULL);
		if (dcMem .GetDeviceCaps (BITSPIXEL) > 8)
		{
			g_ilSmall .Create (16, 16, ILC_COLOR16 | ILC_MASK, 16, 16);
			g_ilLarge .Create (24, 24, ILC_COLOR16 | ILC_MASK, 16, 16);
			CBitmap bmSmall;
			bmSmall .LoadBitmap (IDB_TOOLBAR_16_256COLOR);
			g_ilSmall .Add (bmSmall, RGB (255, 0, 255));
			CBitmap bmLarge;
			bmLarge .LoadBitmap (IDB_TOOLBAR_24_256COLOR);
			g_ilLarge .Add (bmLarge, RGB (255, 0, 255));
		}
		else
		{
			g_ilSmall .Create (16, 16, ILC_COLOR | ILC_MASK, 16, 16);
			g_ilLarge .Create (24, 24, ILC_COLOR | ILC_MASK, 16, 16);
			CBitmap bmSmall;
			bmSmall .LoadBitmap (IDB_TOOLBAR_16_16COLOR);
			g_ilSmall .Add (bmSmall, RGB (255, 0, 255));
			CBitmap bmLarge;
			bmLarge .LoadBitmap (IDB_TOOLBAR_24_16COLOR);
			g_ilLarge .Add (bmLarge, RGB (255, 0, 255));
		}
		g_ilSmall .SetBkColor (::GetSysColor (COLOR_3DFACE));
		g_ilLarge .SetBkColor (::GetSysColor (COLOR_3DFACE));
	}

	//
	// Enable leak checking
	//

#if defined (_DEBUG)
	_CrtSetDbgFlag (_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
#endif

	//
	// Initialize ATL
	//

	_Module.Init (ObjectMap, hInstance);

	//
	// Initialize the printer
	//

	g_sPrinter .OpenDefaultPrinter ();
	g_sDevMode .CopyFromPrinter (g_sPrinter);

	//
	// Validate the version of the common controls
	//

	DWORD dwComCtlMajor, dwComCtlMinor;
	if (!GetDllVersion (TEXT ("comctl32.dll"), 
	    dwComCtlMajor, dwComCtlMinor) || dwComCtlMajor < 5 ||
		(dwComCtlMajor == 5 && dwComCtlMinor < 80))
	{
		::MessageBox (NULL, 
			_T ("You are running an old version of comctl32.dll.\r\n")
			_T ("Please download a new version from:\r\n\r\n")
			_T ("http://www.torlack.com/other/50comupd.exe")
			, g_szAppName, MB_OK | MB_ICONHAND);
		return 0;
	}

	//
	// Initialize the common controls
	//

    INITCOMMONCONTROLSEX icex;    
	typedef WINCOMMCTRLAPI BOOL WINAPI _x (LPINITCOMMONCONTROLSEX); 
	_x *px;
	HINSTANCE hComCtl = LoadLibraryA ("comctl32.dll");
	px = (_x *) GetProcAddress (hComCtl, "InitCommonControlsEx");
	bool fWorked = false;
	if (px != NULL)
	{
		icex .dwSize = sizeof (INITCOMMONCONTROLSEX);
		icex .dwICC = ICC_WIN95_CLASSES | ICC_DATE_CLASSES | 
			ICC_USEREX_CLASSES | ICC_COOL_CLASSES;
		fWorked = (*px) (&icex) != 0;
	}
	if (!fWorked)
	{
		::MessageBox (NULL, 
	        _T ( "Unable to initialize COMCTL32.DLL"), 
			g_szAppName, MB_OK | MB_ICONHAND);
		return 0;
	}

	//
	// Create the message loop
	//

	CMyMessageLoop theLoop;
	_Module .AddMessageLoop (&theLoop);

	//
	// Create the window
	//

	CMainWnd sMainWnd;
	g_hWndMain = sMainWnd .Create ();
	if (g_hWndMain == NULL)
	{
		CString str (MAKEINTRESOURCE (IDS_ERR_MAIN_WINDOW));
		::MessageBox (NULL, str, g_szAppName, MB_OK | MB_ICONHAND);
		return 0;
	}

	//
	// Pump messages
	//

	theLoop .Run ();
	_Module .RemoveMessageLoop ();

	//
	// Delete the palettes
	//

	for (int i = 0; i < _countof (g_apPalettes); i++)
	{
		if (g_apPalettes [i])
			delete [] g_apPalettes [i];
	}

	//
	// Close up printer (Not required, but keeps Purify happy)
	//

	g_sPrinter .ClosePrinter ();
	g_sDevMode .Detach ();

	//
	// Close FMOD
	//

	if (g_hFMODLibrary != NULL)
	{
		FSOUND_Close ();
	}

	//
	// Terminate the module
	//

	_Module .Term ();
	return 0;
}
예제 #23
0
int CMusikPlayer::InitializeFMOD( int nFunction )
{
	if ( ( nFunction == FMOD_INIT_RESTART ) || ( nFunction == FMOD_INIT_STOP ) )
		Shutdown( false );
	FSOUND_Close();


	//---------------------//
	//--- setup driver	---//
	//---------------------//
	if ( ( nFunction == FMOD_INIT_START ) || ( nFunction == FMOD_INIT_RESTART ) )
	{
		//-----------------//
		//--- windows	---//
		//-----------------//
		#if defined(__WXMSW__)
			if ( wxGetApp().Prefs.nSndOutput == 0 )
			{
				if( FSOUND_SetOutput( FSOUND_OUTPUT_DSOUND ) == FALSE )
					return FMOD_INIT_ERROR_DSOUND;
			}
			else if ( wxGetApp().Prefs.nSndOutput == 1 )
			{
				if ( FSOUND_SetOutput( FSOUND_OUTPUT_WINMM ) == FALSE )
					return FMOD_INIT_ERROR_WINDOWS_WAVEFORM;
			}
			else if ( wxGetApp().Prefs.nSndOutput == 2 )
			{
				if ( FSOUND_SetOutput( FSOUND_OUTPUT_ASIO ) == FALSE )
					return FMOD_INIT_ERROR_ASIO;
			}
		//-----------------//
		//--- linux		---//
		//-----------------//
		#elif defined (__WXGTK__)
			if ( wxGetApp().Prefs.nSndOutput == 0 )
			{
				if( FSOUND_SetOutput( FSOUND_OUTPUT_OSS ) == FALSE )
					return FMOD_INIT_ERROR_OSS;
			}
			else if ( wxGetApp().Prefs.nSndOutput == 1 )
			{
				if ( FSOUND_SetOutput( FSOUND_OUTPUT_ESD ) == FALSE )
					return FMOD_INIT_ERROR_ESD;
			}
			else if ( wxGetApp().Prefs.nSndOutput == 2 )
			{
				if ( FSOUND_SetOutput( FSOUND_OUTPUT_ALSA ) == FALSE )
					return FMOD_INIT_ERROR_ALSA;
			}
		#elif defined (__WXMAC__)
			if( FSOUND_SetOutput( FSOUND_OUTPUT_MAC ) == FALSE )
				return FMOD_INIT_ERROR_MAC;
		#endif
		if(wxGetApp().Prefs.nSndDevice > 0)
		{
		//---------------------//
		//--- setup device	---//
		//---------------------//
			if (  FSOUND_SetDriver( wxGetApp().Prefs.nSndDevice ) == FALSE )
				return FMOD_INIT_ERROR_DEVICE_NOT_READY;
		}

		// initialize system
#ifdef __WXMAC__
		FSOUND_SetBufferSize( 1000 );
#else        
		FSOUND_SetBufferSize( 100 );
#endif        
		InitFMOD_NetBuffer();	
		InitFMOD_ProxyServer();
		if ( FSOUND_Init( wxGetApp().Prefs.nSndRate , wxGetApp().Prefs.nSndMaxChan, 0 ) == FALSE )
			return FMOD_INIT_ERROR_INIT;
//		wxGetApp().Prefs.nSndOutput = FSOUND_GetOutput();
	}
	return FMOD_INIT_SUCCESS;
}
예제 #24
0
파일: SRB2MP.c 프로젝트: HipsterLion/SRB2
static inline VOID M_ShutdownMusic(VOID)
{
	M_FreeMusic();
	FSOUND_Close();
	//remove(musicfile); // Delete the temp file
}
예제 #25
0
파일: Main.cpp 프로젝트: samiam123/Voodoo
/*
[
    [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;
}
예제 #26
0
int main() { FSOUND_Close(); }
예제 #27
0
/// <summary>   Destructor. </summary>
CSound::~CSound()
{
    //  Safely close FSound
	FSOUND_Close();
}
예제 #28
0
파일: Main.cpp 프로젝트: samiam123/Voodoo
/*
[
    [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;
}
예제 #29
0
파일: fsound.c 프로젝트: carloscm/dacube2
int FSOUND_Init(int mixrate, int vcmmode)
{
  int count;

  if (!FSOUND_File_OpenCallback || !FSOUND_File_CloseCallback || !FSOUND_File_ReadCallback || !FSOUND_File_SeekCallback || !FSOUND_File_TellCallback)
    return FALSE;

  // =========================================================================
  //  CLOSE IT DOWN FIRST IF IT IS ALREADY OPEN
  // =========================================================================
  FSOUND_Close();

  // =========================================================================
  //  SET SOME DEFAULTS
  // =========================================================================
  FSOUND_MixRate = mixrate;
  {
#ifdef __LINUX__
    int temp;
    // =======================================================================
    // INITIALIZE OSS
    // =======================================================================
    if ((FSOUND_FileDSP = open("/dev/dsp", O_WRONLY)) == -1)
      return(FALSE);
    temp = 16;
    ioctl(FSOUND_FileDSP, SNDCTL_DSP_SAMPLESIZE, &temp);
    if (temp != 16)
    {
      FSOUND_Close();
      return(FALSE);
    }
    temp = 1;
    ioctl(FSOUND_FileDSP, SNDCTL_DSP_STEREO, &temp);
    if (temp != 1)
    {
      FSOUND_Close();
      return(FALSE);
    }
    temp = mixrate;
    ioctl(FSOUND_FileDSP, SNDCTL_DSP_SPEED, &temp);
    if (temp != mixrate)
    {
      FSOUND_Close();
      return(FALSE);
    }
    temp = (FSOUND_NUMFRAGS<<16)+FSOUND_FRAGSIZE;
    ioctl(FSOUND_FileDSP, SNDCTL_DSP_SETFRAGMENT, &temp);
    if ((temp & 0xFFFF)  != FSOUND_FRAGSIZE)
    {
      FSOUND_Close();
      return(FALSE);
    }

#endif
#ifdef __WIN32__
    WAVEFORMATEX pcmwf;
    UINT hr;
    // =======================================================================
    // INITIALIZE WAVEOUT
    // =======================================================================
    pcmwf.wFormatTag        = WAVE_FORMAT_PCM;
    pcmwf.nChannels         = 2;
    pcmwf.wBitsPerSample    = 16;
    pcmwf.nBlockAlign       = pcmwf.nChannels * pcmwf.wBitsPerSample / 8;
    pcmwf.nSamplesPerSec    = mixrate;
    pcmwf.nAvgBytesPerSec   = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign;
    pcmwf.cbSize            = 0;
    hr = waveOutOpen(&FSOUND_WaveOutHandle, WAVE_MAPPER, &pcmwf, 0, 0, 0);
    if (hr)
      return(FALSE);
#endif
  }

  // =========================================================================
  // INITIALIZE SOFTWARE MIXER
  // =========================================================================
  FSOUND_OOMixRate = 1.0f / (float)mixrate;
#ifdef __LINUX__
  FSOUND_BlockSize = 1 << FSOUND_FRAGSIZE;    // Number of *samples*
  FSOUND_BufferSize = FSOUND_BlockSize;        // in linux oss do double-buffering
#endif
#ifdef __WIN32__
  FSOUND_BlockSize = ((FSOUND_MixRate * FSOUND_LATENCY / 1000) + 3) & 0xFFFFFFFC; // Number of *samples*
  FSOUND_BufferSize = FSOUND_BlockSize * (FSOUND_BufferSizeMs / FSOUND_LATENCY);  // make it perfectly divisible by granularity
  FSOUND_BufferSize <<= 1;        // double buffer
#endif

  mix_volumerampsteps = FSOUND_MixRate * FSOUND_VOLUMERAMP_STEPS / 44100;
  mix_1overvolumerampsteps = 1.0f / mix_volumerampsteps;

  // =========================================================================
  // ALLOC GLOBAL CHANNEL POOL
  // =========================================================================
  memset(FSOUND_Channel, 0, sizeof(FSOUND_CHANNEL) * 256);

  // =========================================================================
  // SET UP CHANNELS
  // =========================================================================
  for (count = 0; count < 256; count++)
  {
    FSOUND_Channel[count].index = count;
    FSOUND_Channel[count].speedhi = 1;
  }

  return(TRUE);
}
예제 #30
0
파일: jeu.c 프로젝트: ulricheza/Isima
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);
      
}