예제 #1
0
/*
[
    [DESCRIPTION]

    [PARAMETERS]
 
    [RETURN_VALUE]

    [REMARKS]

    [SEE_ALSO]
]
*/
void SetupReverb()
{
    /*
        REVERB SETUP
    */
    /* something to fiddle with. */
    int delay[REVERB_NUMTAPS]     = { 131, 149, 173, 211, 281, 401, 457};    /* prime numbers make it sound cool! */
    int volume[REVERB_NUMTAPS]    = { 120, 100,  95,  90,  80,  60,  50};
    int pan[REVERB_NUMTAPS]       = { 100, 128, 128, 152, 128, 100, 152};
    int count;

    for (count=0; count< REVERB_NUMTAPS; count++)
    {
        DSP_ReverbTap[count].delayms        = delay[count];    
        DSP_ReverbTap[count].volume         = volume[count];
        DSP_ReverbTap[count].pan            = pan[count];
        DSP_ReverbTap[count].historyoffset  = 0;
        DSP_ReverbTap[count].historylen     = (DSP_ReverbTap[count].delayms * 44100 / 1000);
        if (DSP_ReverbTap[count].historylen < FSOUND_DSP_GetBufferLength())
        {
            DSP_ReverbTap[count].historylen = FSOUND_DSP_GetBufferLength();    /* just in case our calc is not the same. */
        }

        DSP_ReverbTap[count].historybuff    = (char *)calloc(DSP_ReverbTap[count].historylen, 4);    /* * 4 is for 16bit stereo (mmx only) */
        DSP_ReverbTap[count].workarea       = NULL;
        DSP_ReverbTap[count].Unit           = FSOUND_DSP_Create(&DSP_ReverbCallback, FSOUND_DSP_DEFAULTPRIORITY_USER+20+(count*2), &DSP_ReverbTap[count]);

        FSOUND_DSP_SetActive(DSP_ReverbTap[count].Unit, TRUE);
    }
}
예제 #2
0
void CMusikPlayer::InitDSP()
{
	if ( !m_DSP )
		m_DSP = FSOUND_DSP_Create( &dspcallback, FSOUND_DSP_DEFAULTPRIORITY_USER, 0 );			

	if ( m_DSP )
		FSOUND_DSP_SetActive( m_DSP, wxGetApp().Prefs.bUseEQ );
}
예제 #3
0
void CMusikPlayer::ActivateDSP()
{
	if ( m_DSP )
	{
		if(wxGetApp().Prefs.bUseEQ)
		{
			g_FX.InitEQ(wxGetApp().Prefs.nSndRate);
		}
		FSOUND_DSP_SetActive( m_DSP, wxGetApp().Prefs.bUseEQ );
	}
}
void LLAudioEngine_FMOD::cleanupWind()
{
	if (mWindDSP)
	{
		FSOUND_DSP_SetActive(mWindDSP, false);
		FSOUND_DSP_Free(mWindDSP);
		mWindDSP = NULL;
	}

	delete mWindGen;
	mWindGen = NULL;
}
bool LLAudioEngine_FMOD::initWind()
{
	if (!mWindGen)
	{
		bool enable;
		
		switch (FSOUND_GetMixer())
		{
			case FSOUND_MIXER_MMXP5:
			case FSOUND_MIXER_MMXP6:
			case FSOUND_MIXER_QUALITY_MMXP5:
			case FSOUND_MIXER_QUALITY_MMXP6:
				enable = (typeid(MIXBUFFERFORMAT) == typeid(S16));
				break;
			case FSOUND_MIXER_BLENDMODE:
				enable = (typeid(MIXBUFFERFORMAT) == typeid(S32));
				break;
			case FSOUND_MIXER_QUALITY_FPU:
				enable = (typeid(MIXBUFFERFORMAT) == typeid(F32));
				break;
			default:
				// FSOUND_GetMixer() does not return a valid mixer type on Darwin
				LL_INFOS("AppInit") << "Unknown FMOD mixer type, assuming default" << LL_ENDL;
				enable = true;
				break;
		}
		
		if (enable)
		{
			mWindGen = new LLWindGen<MIXBUFFERFORMAT>(FSOUND_GetOutputRate());
		}
		else
		{
			LL_WARNS("AppInit") << "Incompatible FMOD mixer type, wind noise disabled" << LL_ENDL;
		}
	}

	mNextWindUpdate = 0.0;

	if (mWindGen && !mWindDSP)
	{
		mWindDSP = FSOUND_DSP_Create(&windCallback, FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT + 20, mWindGen);
	}
	if (mWindDSP)
	{
		FSOUND_DSP_SetActive(mWindDSP, true);
		return true;
	}
	
	return false;
}
예제 #6
0
void LLAudioEngine_FMOD::initWind()
{
	mWindGen = new LLWindGen<MIXBUFFERFORMAT>;

	if (!gWindDSP)
	{
		gWindDSP = FSOUND_DSP_Create(&windCallback, FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT + 20, mWindGen);
	}
	if (gWindDSP)
	{
		FSOUND_DSP_SetActive(gWindDSP, true);
	}
	mNextWindUpdate = 0.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;
}
예제 #8
0
파일: main.c 프로젝트: Dangr8/Cities3D
void SetupReverb()
{
	/*
	    REVERB SETUP
	*/
	/* something to fiddle with. */
	int delay[REVERB_NUMTAPS]	= { 131, 149, 173, 211, 281, 401, 457};	/* prime numbers make it sound good! */
	int volume[REVERB_NUMTAPS]	= { 120, 100,  95,  90,  80,  60,  50};
	int pan[REVERB_NUMTAPS]		= { 100, 128, 128, 152, 128, 100, 152};
	int count;

	for (count=0; count< REVERB_NUMTAPS; count++)
	{
		DSP_ReverbTap[count].delayms		= delay[count];	
		DSP_ReverbTap[count].volume			= volume[count];
		DSP_ReverbTap[count].pan			= pan[count];
		DSP_ReverbTap[count].historyoffset	= 0;
		DSP_ReverbTap[count].historylen		= (DSP_ReverbTap[count].delayms * 44100 / 1000);
		if (DSP_ReverbTap[count].historylen < FSOUND_DSP_GetBufferLength())
			DSP_ReverbTap[count].historylen = FSOUND_DSP_GetBufferLength();	/* just in case our calc is not the same. */

#ifdef __MACH__
        DSP_ReverbTap[count].historybuff    = (char *)calloc(DSP_ReverbTap[count].historylen, 4);
#else
		if (MPLibraryIsLoaded())
		{
		    DSP_ReverbTap[count].historybuff	= (char *)MPAllocateAligned(DSP_ReverbTap[count].historylen * 4,
		                                                    kMPAllocateDefaultAligned, kMPAllocateClearMask);	/* * 4 is for 16bit stereo (mmx only) */
		}
		if (!DSP_ReverbTap[count].historybuff)
		{
		    printf("Memory not allocated!");
		    exit (EXIT_FAILURE);
		}
#endif
		
		DSP_ReverbTap[count].workarea		= NULL;
		DSP_ReverbTap[count].Unit			= FSOUND_DSP_Create(&DSP_ReverbCallback, FSOUND_DSP_DEFAULTPRIORITY_USER+20+(count*2),	(void *)&DSP_ReverbTap[count]);

		FSOUND_DSP_SetActive(DSP_ReverbTap[count].Unit, TRUE);
	}
}
예제 #9
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;
}
예제 #10
0
void CMusikPlayer::ActivateDSP()
{
	FSOUND_DSP_SetActive( m_DSP, wxGetApp().Prefs.bUseEQ );
}
예제 #11
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;
}
예제 #12
0
파일: Week1.c 프로젝트: daeken/Straylight
void init() {
	GLUquadricObj *quadric;
	int i, numInsts;
	GLfloat position[] = {0.0f, 25.0f, -ZOOM*0.9, 1.0f};
	GLfloat specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
	GLfloat ambient[] = {0.4f, 0.4f, 0.4f};
	
	glClearColor(0.0, 0.0, 0.0, 1.0);
	glClearDepth(1.0);
	glDepthFunc(GL_LESS);
	glEnable(GL_DEPTH_TEST);
	glShadeModel(GL_SMOOTH);
	
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	glEnable(GL_BLEND);
	
	glLightfv(
			GL_LIGHT0, 
			GL_POSITION, 
			position
		);
	glLightfv(
			GL_LIGHT0, 
			GL_AMBIENT,  
			ambient
		);
	glLightfv(
			GL_LIGHT0, 
			GL_SPECULAR, 
			specular
		);
	
	glEnable(GL_LIGHT0);
	glEnable(GL_LIGHTING);
	glEnable(GL_COLOR_MATERIAL);
	glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
	glMateriali(GL_FRONT, GL_SHININESS, 255);
	
	sphere = glGenLists(1);
	glNewList(sphere, GL_COMPILE);
	
	quadric = gluNewQuadric();
	gluQuadricNormals(quadric, GLU_SMOOTH);
	gluQuadricTexture(quadric, GL_FALSE);
	gluSphere(quadric, RADIUS, 32, 32);
	gluDeleteQuadric(quadric);
	
	glEndList();
	
	for(i = 0; i < DROPCOUNT; ++i)
		drops[i].offset = -1;
	
	FSOUND_Init(44100, 64, FSOUND_INIT_USEDEFAULTMIDISYNTH);
	song = FMUSIC_LoadSong(SONG);
	if(song == NULL)
		song = FMUSIC_LoadSong("Obj\\" SONG);
	FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), TRUE);
	FMUSIC_SetMasterVolume(song, 256);
	
	srand(0xDEADBEEF);
	
	numInsts = FMUSIC_GetNumInstruments(song);
	instrumentOffsets = (int *) malloc(sizeof(int) * numInsts);
	for(i = 0; i < numInsts; ++i) {
		FMUSIC_SetInstCallback(song, instrumentCallback, i);
		instrumentOffsets[i] = rand() % (GRID_HEIGHT * GRID_WIDTH);
	}
	
	FMUSIC_PlaySong(song);
	
	setText("STRAYLIGHT");
}
예제 #13
0
파일: main.c 프로젝트: Dangr8/Cities3D
/*
[
	[DESCRIPTION]

	[PARAMETERS]
 
	[RETURN_VALUE]

	[REMARKS]

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

 	/*
	    INITIALIZE
	*/
	if (!FSOUND_Init(44100, 32, 0))
	{
		printf("Error!\n");
		printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
		return 1;
	}

	/*
	    LOAD SAMPLES
	*/

	/* PCM,44,100 Hz, 8 Bit, Mono */
#if defined(__MACH__) || defined(WIN32)
	samp1 = FSOUND_Sample_Load(FSOUND_FREE, "../../media/drumloop.wav", FSOUND_2D, 0, 0);
#else
	samp1 = FSOUND_Sample_Load(FSOUND_FREE, ":::media:drumloop.wav", FSOUND_2D, 0, 0);
#endif
	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 */
#if defined(__MACH__) || defined(WIN32)
	samp2 = FSOUND_Sample_Load(FSOUND_FREE, "../../media/jules.mp3", FSOUND_HW2D | FSOUND_ENABLEFX, 0, 0);
#else
	samp2 = FSOUND_Sample_Load(FSOUND_FREE, ":::media:jules.mp3", FSOUND_HW2D | FSOUND_ENABLEFX, 0, 0);
#endif
	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;
		case FSOUND_OUTPUT_MAC:		printf("FSOUND_OUTPUT_MAC\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");
	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);


	/*
	    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);
			}
		}
		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;
}