Exemplo n.º 1
0
// 20110501/supah: replaced this for non-console windowed version :) 
//int main(int argc, char* argv[]) {
int PASCAL WinMain(HINSTANCE hi, HINSTANCE pi, LPSTR cmd, int show) { 

	Window			window(RESX, RESY, BPP, TITLE, FULLSCREEN);
	GLContext		glc(window);
	EffectPlayer	effectPlayer;

	glc.setDefaultParameters();

	FSOUND_File_SetCallbacks(memopen, memclose, memread, memseek, memtell);
	FMUSIC_MODULE* mod = FMUSIC_LoadSong("", 0);
	FMUSIC_PlaySong(mod);

	float startTime = (float) FMUSIC_GetTime(mod); // timeGetTime();
	while(window.active() && effectPlayer.isRunning()) {

		//float time	= (float)timeGetTime() - startTime;
		float time = FMUSIC_GetTime(mod) - startTime;

		effectPlayer.run(time);

		glc.flush();
	}

	FMUSIC_StopSong(mod);

	return 0;
}
Exemplo n.º 2
0
int SOUND_init()
{

	

#ifdef USEFMOD

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


	if(!DirectSoundInit())
	{
		MessageBox(0,"error al iniciar DS","ERROR",MB_OK);
	}
	return 1;

}
Exemplo n.º 3
0
void init()
{
	memset(lastfilename,0,256);
	memset(musfilename,0,40);
	initGUI();
	sprintf(scenelist->name,"Default");
	memset(tooltip,0,256);
	memset(defaulttooltip,0,256);
	sprintf(defaulttooltip,"a.D.D.i.c.t. (c) BoyC 2002");
	actualtexture=texturelist;
	lasttexture=texturelist;
	memset(texturelist,0,sizeof(tTexture));
	texturelist->next=NULL;
	sprintf(texturelist->name,"Default");
	memset(cursorstring,0,256);
	for (x=0;x<=7;x++) modellsubmenu[x]=0;
	init3dengine();
	InitModellerGUI();
	BuildFont();
	BuildFont2();
	BuildFontSmall();
	inittextureengine();
	generatedtexture.init();
	buffertexture.init();
	memset(pretextures,0,sizeof(pretextures));
	memset(texdata,0,sizeof(texdata));
	memset(texsubmenu,0,sizeof(texsubmenu));
	texdata[0][3].command[3]=4;
	texdata[0][5].command[3]=14;
	texdata[0][5].command[4]=100;
	texdata[0][6].command[3]=30;
	texdata[1][1].command[2]=128;
	texdata[2][4].command[3]=128;
	texdata[3][2].command[2]=128;
	texdata[3][4].command[4]=255;
	texdata[3][6].c.param1=255;
	texdata[3][6].c.param3=255;
	texdata[3][6].c.param5=255;
	glGenTextures(1,&mattexture);
	glBindTexture(GL_TEXTURE_2D,mattexture);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,generatedtexture.layers[0]);
	for (x=0;x<4;x++)
	{
		glGenTextures(1,&(prelayers[x]));
		glBindTexture(GL_TEXTURE_2D,prelayers[x]);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
		glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,generatedtexture.layers[x]);
	}
	for (x=0;x<4;x++)
	{
		glGenTextures(1,&(texlayers[x]));
		glBindTexture(GL_TEXTURE_2D,texlayers[x]);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
		glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,generatedtexture.layers[x]);
	}
	for (x=0;x<4;x++)
	{
		glGenTextures(1,&alayers[x]);
		glBindTexture(GL_TEXTURE_2D,alayers[x]);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
		glTexImage2D(GL_TEXTURE_2D,0,4,256,256,0,GL_RGBA,GL_UNSIGNED_BYTE,generatedtexture.layers[x]);
	}
	glGenTextures(1,&background);
	glBindTexture(GL_TEXTURE_2D, background);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	
	commandnames[DD_fractal]     ="Fractal    ";
	commandnames[DD_plasma]      ="Plasma     ";
	commandnames[DD_cells]       ="Cells      ";
	commandnames[DD_envmap]      ="Envmap     ";
	commandnames[DD_subplasm]    ="Subplasma  ";
	commandnames[DD_clear]       ="Clear      ";
	commandnames[DD_text]        ="Text       ";
	commandnames[DD_sindist]     ="SinDist    ";
	commandnames[DD_offset]      ="Offset     ";
	commandnames[DD_twirl]       ="Twirl      ";
	commandnames[DD_blur]        ="Blur       ";
	commandnames[DD_map]         ="MapDist    ";
	commandnames[DD_dirblur]     ="DirBlur    ";
	commandnames[DD_xchng]       ="Xchange    ";
	commandnames[DD_copy]        ="Copy       ";
	commandnames[DD_mix]         ="Mix        ";
	commandnames[DD_mul]         ="Mul        ";
	commandnames[DD_add]         ="Add        ";
	commandnames[DD_max]         ="Max        ";
	commandnames[DD_contrast]    ="Contrast   ";
	commandnames[DD_invert]      ="Invert     ";
	commandnames[DD_shade]       ="Shade      ";
	commandnames[DD_bright]      ="Brighten   ";
	commandnames[DD_sincol]      ="Color Sine ";
	commandnames[DD_scale]       ="Scale      ";
	commandnames[DD_hsv]         ="HSV        ";
	commandnames[DD_colorize]    ="Colorize   ";
	commandnames[DD_mixmap]      ="MixMap     ";
	commandnames[DD_emboss]      ="Emboss     ";
	commandnames[DD_stored]      ="Stored     ";

	initkeyframergui();
	FSOUND_File_SetCallbacks(memopen, memclose, memread, memseek, memtell);
	FSOUND_Init(44100,32);
}
Exemplo n.º 4
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
}
Exemplo n.º 5
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 Technologies, 2000-2004.\n");
		printf("-------------------------------------------------------------\n");
		printf("Syntax: simplest infile.xm\n\n");
		return;
	}


#ifdef USEFMOD

#if USE_XAUDIO2_ENGINE
	// Init FMod XAudio2 Driver
	FMUSIC_XAudio2_Init();
#endif

	// ==========================================================================================
	// 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 Esc 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 != VK_ESCAPE);
	}


	printf("\n");

#ifdef USEFMOD
	FMUSIC_FreeSong(mod);
#endif
}
Exemplo n.º 6
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


#ifdef USEFMOD

	// ==========================================================================================
	// LOAD SONG
	// ==========================================================================================
	mod = FMUSIC_LoadSong(MAKEINTRESOURCE(CHIPTUNE_MUS), 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);
#endif
}
Exemplo n.º 7
0
void initsb(char dadigistat, char damusistat, long dasamplerate, char danumspeakers, char dabytespersample, char daintspersec, char daquality)
{
	char *s;
	int i,j;
	
	if (fmod_inited) return;
	fmod_inited = 0;

	if (dasamplerate < 6000) dasamplerate = 6000;
	else if (dasamplerate > 48000) dasamplerate = 48000;

	musicstat = damusistat;
	
	printOSD("Initialising FMOD...\n");

	/* We're going to be requesting certain things from our audio
	   device, so we set them up beforehand */
	int audio_rate = 22050;
	Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */
	int audio_channels = 2;
	int audio_buffers = 4096;

	if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
		initprintf("Unable to open audio!\n");
		return;
	}

	/* If we actually care about what we got, we can ask here.  In this
	   program we don't, but I'm showing the function call here anyway
	   in case we'd want to know later. */
	Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
	
	fmod_inited = 1;

#if 0
	printOSD("  Linked version: %.02f\n", FMOD_VERSION);
	printOSD("  DLL version: %.02f\n", FSOUND_GetVersion());

	if (FSOUND_GetVersion() < FMOD_VERSION) {
		printOSD("  ... Failure: FMOD DLL too old! Sound disabled.\n");
		return;
	}
	
	printOSD("  Samplerate: %d hz\n", dasamplerate);

	//FSOUND_SetOutput(FSOUND_OUTPUT_ASIO);

	if (FSOUND_Init(dasamplerate, NUMCHANNELS, 0)) {
		printOSD("  ... Success\n");
		fmod_inited = 1;
	} else {
		printOSD("  ... Failure: %s\n", FMOD_ErrorString(FSOUND_GetError()));
	}

	switch (FSOUND_GetOutput()) {
		case FSOUND_OUTPUT_NOSOUND: s = "No Sound"; break;
		case FSOUND_OUTPUT_WINMM: s = "WINMM"; break;
		case FSOUND_OUTPUT_DSOUND: s = "DirectSound"; break;
		case FSOUND_OUTPUT_OSS: s = "OSS"; break;
		case FSOUND_OUTPUT_ESD: s = "ESound"; break;
		case FSOUND_OUTPUT_ALSA: s = "ALSA"; break;
		case FSOUND_OUTPUT_ASIO: s = "ASIO"; break;
		default: s = "Other"; break;
	}
	printOSD("Using FMOD \"%s\" output driver\n", s);

	FSOUND_File_SetCallbacks(
			(FSOUND_OPENCALLBACK)f_open,
			(FSOUND_CLOSECALLBACK)f_close,
			(FSOUND_READCALLBACK)f_read,
			(FSOUND_SEEKCALLBACK)f_seek,
			(FSOUND_TELLCALLBACK)f_tell);
	//FSOUND_SetMemorySystem(fmod_cache, fmod_cachelen, NULL, NULL, NULL);
#endif
	loadwaves();

	for (i=0; i<NUMCHANNELS; i++) channels[i] = -1;
}
Exemplo n.º 8
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;
}