Ejemplo 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;
}
Ejemplo n.º 2
0
static inline VOID M_StopMusic(VOID)
{
	if (mod)
		FMUSIC_StopSong(mod);
	if (fsoundchannel != -1 && fmus && FSOUND_IsPlaying(fsoundchannel))
		FSOUND_Stream_Stop(fmus);
}
Ejemplo n.º 3
0
void CSound::StopMID(int all, int Index)
{
	if (all)
	{	
		FMUSIC_StopAllSongs();
	}
	else
	{
		switch(Index)
		{
		case 0:
			FMUSIC_StopSong(m_BC1);
			break;
		case 1:
			FMUSIC_StopSong(m_BC2);
			break;
		case 2:
			FMUSIC_StopSong(m_BC3);
			break;
		case 3:
			FMUSIC_StopSong(m_BC5);
			break;
		case 4:
			FMUSIC_StopSong(m_BC6);
			break;
		case 5:
			FMUSIC_StopSong(m_BC8);
			break;
		case 6:
			FMUSIC_StopSong(m_BC9);
			break;
		}
	}   

}
Ejemplo n.º 4
0
//===========================================================================
// DM_FModExtStop
//===========================================================================
void DM_FModExtStop(void)
{
	if(!ext_inited)
		return;
	//ext_playing = false;
	if(module)
		FMUSIC_StopSong(module);
	if(stream)
		FSOUND_Stream_Stop(stream);
}
Ejemplo n.º 5
0
void CFMOD::StopMusic(void)
{
    if(!bfmod) return;
    if(fmusic)
    {
        FMUSIC_StopSong(fmusic);
        FMUSIC_FreeSong(fmusic);
    }
    fmusic=0;
}
Ejemplo n.º 6
0
void C4MusicFileMID::Stop(int fadeout_ms)
{
	if (mod)
	{
		FMUSIC_StopSong(mod);
		FMUSIC_FreeSong(mod);
		mod = NULL;
	}
	RemTempFile();
}
Ejemplo n.º 7
0
void C4MusicFileMOD::Stop(int fadeout_ms)
{
	if (mod)
	{
		FMUSIC_StopSong(mod);
		FMUSIC_FreeSong(mod);
		mod = NULL;
	}
	if (Data) { delete[] Data; Data = NULL; }
}
Ejemplo n.º 8
0
bool CSoundManager::StopSong(int Nr, bool Paused)
{
	if (its_Songs[Nr] == NULL)
		return false;

	SetSongVolume(Nr, its_Songs[Nr]->Volume);

	if (Paused == false)
		FMUSIC_StopSong(its_Songs[Nr]->SongData);			// Ganz anhalten ?
	else
		FMUSIC_SetPaused(its_Songs[Nr]->SongData, true);		// oder nur pausieren ?

	return true;
} // StopSong
Ejemplo n.º 9
0
static inline VOID M_FreeMusic(VOID)
{
	if (mod)
	{
		FMUSIC_StopSong(mod);
		FMUSIC_FreeSong(mod);
		mod = NULL;
	}
	if (fmus)
	{
		FSOUND_Stream_Stop(fmus);
		FSOUND_Stream_Close(fmus);
		fmus = NULL;
		fsoundchannel = -1;
	}
}
Ejemplo n.º 10
0
void glk_schannel_stop(schanid_t chan)
{
    if (!chan) {
	gli_strict_warning("schannel_stop: invalid id.");
	return;
    }

    if (chan->module)
    {
	FMUSIC_StopSong(chan->module);
	FMUSIC_FreeSong(chan->module);
	chan->module = NULL;
    }

    if (chan->sample)
    {
	FSOUND_StopSound(chan->channel);
	FSOUND_Sample_Free(chan->sample);
	chan->sample = NULL;
    }
}
Ejemplo n.º 11
0
bool CSong::Update(void)
{
	// Spielt der Song garnicht ? Dann brauchen wir ihn auch nicht zu bearbeiten =)
	// 
	if (!FMUSIC_IsPlaying(SongData))
		return false;

	// Fadet der Song grade ?
	// 
	if (FadingVolume != 0.0f)
	{
		Volume += FadingVolume SYNC;

		// Grenze Überschritten ?
		if ((FadingVolume > 0.0f &&
		 	 Volume >= FadingEnd) ||
					
			(FadingVolume < 0.0f &&
			 Volume <= FadingEnd))
		{
			// Beim Anhalten des Songs ausschalten oder pausieren ?
			if (FadingVolume < 0.0f)
			{
				if (FadingPaused == false)
					FMUSIC_StopSong(SongData);			// Ganz anhalten ?
				else
					FMUSIC_SetPaused(SongData, true);	// oder nur pausieren ?
			}

			FadingVolume = 0.0f;
			Volume		 = float(FadingEnd);
		}
		FMUSIC_SetMasterVolume(SongData, (int)(Volume*pSoundManager->its_GlobalMusicVolume/100.0f*2.55f));
	}

	return true;
} // Update
Ejemplo n.º 12
0
Archivo: Fmusic.c Proyecto: r043v/dstar
signed char FMUSIC_PlaySong(FMUSIC_MODULE *mod)
{
	int				count;
	FMUSIC_CHANNEL	*cptr;
	int				totalblocks; 

	if (!mod) 
    {
		return FALSE;
    }

	lastmodplay = mod ;
	volumeUpdateSpeed = 30 ;
	FMUSIC_StopSong(mod);

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

	// ========================================================================================================
	// INITIALIZE SOFTWARE MIXER 
	// ========================================================================================================

	FSOUND_OOMixRate    = 1.0f / (float)FSOUND_MixRate;
	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

	mix_volumerampsteps      = FSOUND_MixRate * FSOUND_VOLUMERAMP_STEPS / 44100;
	mix_1overvolumerampsteps = 1.0f / mix_volumerampsteps;
    totalblocks              = FSOUND_BufferSize / FSOUND_BlockSize;

	//=======================================================================================
	// 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;
	}

	mod->globalvolume       = mod->defaultglobalvolume;
	mod->globalWantedVolume = mod->globalvolume ;
 	mod->speed              = (int)mod->defaultspeed;
	mod->row                = 0;
	mod->order              = 0;
	mod->nextorder          = -1;
	mod->nextrow            = -1;
	mod->mixer_samplesleft  = 0;
	mod->tick               = 0;
	mod->patterndelay       = 0;
	mod->time_ms            = 0;

	FMUSIC_SetBPM(mod, mod->defaultbpm);

	memset(FMUSIC_Channel, 0, mod->numchannels * sizeof(FMUSIC_CHANNEL));
//	memset(FSOUND_Channel, 0, 256 * sizeof(FSOUND_CHANNEL));

	for (count=0; count < mod->numchannels; count++)
	{
		cptr = &FMUSIC_Channel[count];
		cptr->cptr = &FSOUND_Channel[count];
	}

	FMUSIC_PlayingSong = mod;

	FMUSIC_TimeInfo = FSOUND_Memory_Calloc(sizeof(FMUSIC_TIMMEINFO) * totalblocks);

	// ========================================================================================================
	// PREPARE THE OUTPUT
	// ========================================================================================================
	{
		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	= FSOUND_MixRate;
		pcmwf.nAvgBytesPerSec	= pcmwf.nSamplesPerSec * pcmwf.nBlockAlign; 
		pcmwf.cbSize			= 0;

		hr = waveOutOpen(&FSOUND_WaveOutHandle, WAVE_MAPPER, &pcmwf, 0, 0, 0);

		if (hr) 
        {
			return FALSE;
        }
	}

	{
		WAVEHDR	*wavehdr;
		int	length = 0;

		// CREATE AND START LOOPING WAVEOUT BLOCK
		wavehdr = &FSOUND_MixBlock.wavehdr;

		length = FSOUND_BufferSize;
		length <<= 2;	// 16bits

		FSOUND_MixBlock.data = FSOUND_Memory_Calloc(length);
		
		wavehdr->dwFlags			= WHDR_BEGINLOOP | WHDR_ENDLOOP;
		wavehdr->lpData				= (LPSTR)FSOUND_MixBlock.data;
		wavehdr->dwBufferLength		= length;
		wavehdr->dwBytesRecorded	= 0;
		wavehdr->dwUser				= 0;
		wavehdr->dwLoops			= -1;
		waveOutPrepareHeader(FSOUND_WaveOutHandle, wavehdr, sizeof(WAVEHDR));
	}

	// ========================================================================================================
	// ALLOCATE MIXBUFFER
	// ========================================================================================================

	FSOUND_MixBufferMem = (signed char *)FSOUND_Memory_Calloc((FSOUND_BufferSize << 3) + 256);
	FSOUND_MixBuffer = (signed char *)(((unsigned int)FSOUND_MixBufferMem + 15) & 0xFFFFFFF0);

	// ========================================================================================================
	// PREFILL THE MIXER BUFFER 
	// ========================================================================================================

	do 
	{
		FSOUND_Software_Fill();
	} while (FSOUND_Software_FillBlock);

	// ========================================================================================================
	// START THE OUTPUT
	// ========================================================================================================

	waveOutWrite(FSOUND_WaveOutHandle, &FSOUND_MixBlock.wavehdr, sizeof(WAVEHDR));

	{
		DWORD	FSOUND_dwThreadId;

		// ========================================================================================================
		// CREATE THREADS / TIMERS (last)
		// ========================================================================================================
		FSOUND_Software_Exit = FALSE;

		FSOUND_Software_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)FSOUND_Software_DoubleBufferThread, 0,0, &FSOUND_dwThreadId);

		SetThreadPriority(FSOUND_Software_hThread, THREAD_PRIORITY_TIME_CRITICAL);	// THREAD_PRIORITY_HIGHEST);
	}
	return TRUE;
}
Ejemplo n.º 13
0
Archivo: Fmusic.c Proyecto: r043v/dstar
signed char FMUSIC_FreeSong(FMUSIC_MODULE *mod)
{
	int count;

	if (!mod) 
		return FALSE;

	BLOCK_ON_SOFTWAREUPDATE();

	FMUSIC_StopSong(mod);

	// free samples
	if (mod->instrument)
	{
		for (count=0; count<(int)mod->numinsts; count++) 
		{
			int count2;

			FMUSIC_INSTRUMENT	*iptr = &mod->instrument[count];
			for (count2=0; count2<iptr->numsamples; count2++) 
			{
				if (iptr->sample[count2])
				{
					FSOUND_SAMPLE *sptr = iptr->sample[count2];
					FSOUND_Memory_Free(sptr->buff);
					FSOUND_Memory_Free(sptr);
				}
			}


		}
	}

	// free instruments
	if (mod->instrument)
    {
		FSOUND_Memory_Free(mod->instrument);
    }

	// free patterns
	if (mod->pattern)
	{
		for (count=0; count<mod->numpatternsmem; count++)
        {
			if (mod->pattern[count].data) 
            {
				FSOUND_Memory_Free(mod->pattern[count].data);
            }
        }

		if (mod->pattern) 
        {
			FSOUND_Memory_Free(mod->pattern);
        }
	}

	// free song
	FSOUND_Memory_Free(mod);

	return TRUE;
}
Ejemplo n.º 14
0
void Gdl_fadeAndStopSong(u32 fadeSpeed)
{	if(gzk)	{	FMUSIC_fadeSound2Zero(fadeSpeed);
				FMUSIC_StopSong(gzk);
				FMUSIC_FreeSong(gzk);
			}
}
Ejemplo n.º 15
0
void Gdl_stopSong(u32 method)
{	FMUSIC_StopSong(gzk);
	FMUSIC_FreeSong(gzk);
}
Ejemplo n.º 16
0
void SOUND_stop_song()
{
	FMUSIC_StopSong(mod);
	FMUSIC_FreeSong(mod);
}