Ejemplo n.º 1
0
static inline VOID M_SetVolume(int volume)
{
	if (mod && FMUSIC_GetType(mod) != FMUSIC_TYPE_NONE)
		FMUSIC_SetMasterVolume(mod, volume);
	if (fsoundchannel  != -1)
		FSOUND_SetVolume(fsoundchannel, volume);
}
Ejemplo n.º 2
0
void CSoundManager::SetSongVolume(int Nr, float Volume)
{
	if (false == InitSuccessfull)
		return;

	its_Songs[Nr]->Volume = Volume;
	FMUSIC_SetMasterVolume(its_Songs[Nr]->SongData, (int)(Volume*its_GlobalMusicVolume/100.0f*2.55f));
} // SetSongVolume
Ejemplo n.º 3
0
void glk_schannel_set_volume(schanid_t chan, glui32 vol)
{
    if (!chan) {
	gli_strict_warning("schannel_set_volume: invalid id.");
	return;
    }
    chan->volume = vol;
    if (chan->module)
	FMUSIC_SetMasterVolume(chan->module, chan->volume / 256);
    if (chan->sample)
	FSOUND_SetVolume(chan->channel, chan->volume / 256);
}
Ejemplo n.º 4
0
char CFMOD::PlayMusic(char* szFilename)
{
    if(!bfmod) return 0;
    StopMusic();
    fmusic=FMUSIC_LoadSong(szFilename);
    if(fmusic)
    {
        FMUSIC_SetMasterVolume(fmusic,mvol);
        return FMUSIC_PlaySong(fmusic);
    }
    return 0;
}
Ejemplo n.º 5
0
//===========================================================================
// DM_FModExtStartPlaying
//===========================================================================
void DM_FModExtStartPlaying(void)
{
	if(module)
	{
		FMUSIC_SetMasterVolume(module, ext_volume);
		FMUSIC_PlaySong(module);
	}
	if(stream)
	{
		stream_channel = FSOUND_Stream_Play(FSOUND_FREE, stream);
	}
	//  ext_playing = true;
	//  ext_start_time = Sys_GetTime();
}
Ejemplo n.º 6
0
//===========================================================================
// DM_FModExtSet
//===========================================================================
void DM_FModExtSet(int property, float value)
{
	if(!ext_inited)
		return;
	switch (property)
	{
	case MUSIP_VOLUME:
		// This affects streams.
		FSOUND_SetSFXMasterVolume(ext_volume = value * 255 + 0.5);
		if(module)
			FMUSIC_SetMasterVolume(module, ext_volume);
		break;
	}
}
Ejemplo n.º 7
0
/// <summary>   Plays music </summary>
///
/// <param name="Index">    Music index </param>
void CSound::PlaYMID(int Index)
{
    //  Upon verifying the user has music enabled start playing song
	if (p->Options->music == 1)
	{
        //  Select the music based upon index
		switch(Index)
		{
		case 0:
            //  Sets a songs master volume
			FMUSIC_SetMasterVolume(m_BC1, 75);
            //  Starts a song playing
			FMUSIC_PlaySong(m_BC1);
			break;
		case 1:
			FMUSIC_SetMasterVolume(m_BC2, 75);
			FMUSIC_PlaySong(m_BC2);
			break;
		case 2:
			FMUSIC_SetMasterVolume(m_BC3, 75);
			FMUSIC_PlaySong(m_BC3);
			break;
		case 3:
			FMUSIC_SetMasterVolume(m_BC5, 75);
			FMUSIC_PlaySong(m_BC5);
			break;
		case 4:
			FMUSIC_SetMasterVolume(m_BC6, 75);
			FMUSIC_PlaySong(m_BC6);
			break;
		case 5:
			FMUSIC_SetMasterVolume(m_BC8, 75);
			FMUSIC_PlaySong(m_BC8);
			break;
		case 6:
			FMUSIC_SetMasterVolume(m_BC9, 75);
			FMUSIC_PlaySong(m_BC9);
			break;
		}
	}
}
Ejemplo n.º 8
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.º 9
0
glui32 glk_schannel_play_ext(schanid_t chan, glui32 snd, glui32 repeats, glui32 notify)
{
    FILE *file;
    long pos, len;
    glui32 type;
    char *buf;
    int offset = 0;
    int i;

    if (!chan) {
	gli_strict_warning("schannel_play_ext: invalid id.");
	return 0;
    }

    /* stop previous noise */
    glk_schannel_stop(chan);

    if (repeats == 0)
	return 1;

    /* load sound resource into memory */

    if (!giblorb_is_resource_map())
    {
	char name[1024];

	sprintf(name, "%s/SND%ld", gli_workdir, snd); 

	file = fopen(name, "rb");
	if (!file)
	    return 0;

	fseek(file, 0, SEEK_END);
	len = ftell(file);

	buf = malloc(len);
	if (!buf) {
	    fclose(file);
	    return 0;
	}

	fseek(file, 0, 0);
	fread(buf, 1, len, file);
	fclose(file);

	/* identify by file magic the two types that fmod can do... */

	type = 0;	/* unidentified */

	/* AIFF */
	if (len > 4 && !memcmp(buf, "FORM", 4))		
	    type = giblorb_ID_FORM;

	/* WAVE */
	if (len > 4 && !memcmp(buf, "WAVE", 4))
	    type = giblorb_ID_WAVE;

	/* MIDI */
	if (len > 4 && !memcmp(buf, "MThd", 4))
	    type = giblorb_ID_MIDI;

	/* Ogg Vorbis */
	if (len > 4 && !memcmp(buf, "OggS", 4))
	    type = giblorb_ID_OGG;

	/* s3m */
	if (len > 0x30 && !memcmp(buf + 0x2c, "SCRM", 4))
	    type = giblorb_ID_MOD;

	/* XM */
	if (len > 20 && !memcmp(buf, "Extended Module: ", 17))
	    type = giblorb_ID_MOD;

	/* MOD */
	if (len > 1084)
	{
	    char resname[4];
	    memcpy(resname, buf + 1080, 4);
	    if (!strcmp(resname+1, "CHN") ||	/* 4CHN, 6CHN, 8CHN */
		    !strcmp(resname+2, "CN") ||	 /* 16CN, 32CN */
		    !strcmp(resname, "M.K.") || !strcmp(resname, "M!K!") ||
		    !strcmp(resname, "FLT4") || !strcmp(resname, "CD81") ||
		    !strcmp(resname, "OKTA") || !strcmp(resname, "    "))
		type = giblorb_ID_MOD;
	}

	if (!memcmp(buf, "\377\372", 2))	/* mp3 */
	    type = giblorb_ID_MP3;

	/* look for RIFF (future boy has broken resources...?) */
	if (len > 128 && type == 0)
	    for (i = 0; i < 124; i++)
		if (!memcmp(buf+i, "RIFF", 4))
		{
		    offset = i;
		    type = giblorb_ID_WAVE;
		    break;
		}

	if (type == 0)
	    type = giblorb_ID_MP3;
    }

    else
    {
	giblorb_get_resource(giblorb_ID_Snd, snd, &file, &pos, &len, &type);
	if (!file)
	    return 0;

	buf = malloc(len);
	if (!buf)
	    return 0;

	fseek(file, pos, 0);
	fread(buf, 1, len, file);
    }

    switch (type)
    {
    case giblorb_ID_FORM:
    case giblorb_ID_WAVE:
    case giblorb_ID_MP3:
	chan->sample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buf + offset,
		FSOUND_NORMAL|FSOUND_LOADMEMORY, 0, len);
	if (!chan->sample) { free(buf); return 0; }
	if (repeats != 1)
	    FSOUND_Sample_SetMode(chan->sample, FSOUND_LOOP_NORMAL);
	else
	    FSOUND_Sample_SetMode(chan->sample, FSOUND_LOOP_OFF);
	chan->channel = FSOUND_PlaySound(FSOUND_FREE, chan->sample);
	FSOUND_SetVolume(chan->channel, chan->volume / 256);
	FSOUND_SetPaused(chan->channel, 0);
	break;

    case giblorb_ID_MOD:
    case giblorb_ID_MIDI:
	chan->module = FMUSIC_LoadSongEx(buf, 0, len, FSOUND_LOADMEMORY, 0, 0);
	if (!chan->module) { free(buf); return 0; }
	if (repeats != 1)
	    FMUSIC_SetLooping(chan->module, 1);
	else
	    FMUSIC_SetLooping(chan->module, 0);
	FMUSIC_SetMasterVolume(chan->module, chan->volume / 256);
	FMUSIC_PlaySong(chan->module);
	break;

    default:
	gli_strict_warning("schannel_play_ext: unknown resource type.");
    }

    free(buf);

    return 1;
}
Ejemplo n.º 10
0
void CFMOD::SetMusicVolume(float f)
{
    if(!bfmod) return;
    mvol=(unsigned char)f;
    FMUSIC_SetMasterVolume(fmusic,mvol);
}
Ejemplo n.º 11
0
void C4MusicFileMOD::SetVolume(int iLevel)
{
	FMUSIC_SetMasterVolume(mod, (int) ((iLevel * 255) / 100));
}
Ejemplo n.º 12
0
void C4MusicFileMID::SetVolume(int iLevel)
{
	FMUSIC_SetMasterVolume(mod, BoundBy((iLevel * 256) / 100, 0, 255));
}
Ejemplo n.º 13
0
void CSoundManager::SetAbsoluteSongVolume(int Nr, float Volume)
{	
	its_Songs[Nr]->Volume = Volume;
	FMUSIC_SetMasterVolume(its_Songs[Nr]->SongData, (int)(Volume));
} // SetSongVolume
Ejemplo n.º 14
0
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");
}
Ejemplo n.º 15
0
void playMusic(FMUSIC_MODULE *handle, bool loop)
{
	FMUSIC_PlaySong(handle);
	FMUSIC_SetMasterVolume(handle, DEF_VOLUME);
	FMUSIC_SetLooping(handle, loop);
}