int alogg_play_ex_oggstream(ALOGG_OGGSTREAM *ogg, int buffer_len, int vol, int pan, int speed) {
  int samples;
 
  /* continue only if we are not already playing it */
  if (alogg_is_playing_oggstream(ogg))
    return ALOGG_OK;

  /* check the buffer is big enough*/
  if (buffer_len < 4096)
    return ALOGG_PLAY_BUFFERTOOSMALL;
   
  /* create a new audiostream and play it */
  samples = buffer_len / (ogg->stereo ? 2 : 1) / 2; /* / 2 = 16 bits samples */
  ogg->audiostream = play_audio_stream(samples, 16, ogg->stereo, ogg->freq, vol, pan);
  ogg->audiostream_buffer_len = samples * (ogg->stereo ? 2 : 1) * 2; /* * 2 = 16 bits samples */

  ogg->wait_for_audio_stop = 0;

  if (speed != 1000)
    adjust_sample(ogg->audiostream->samp, vol, pan, speed, TRUE);

  /* if the user asked for autopolling, install the interrupt now */
  if (ogg->auto_polling) {
    LOCK_FUNCTION(alogg_autopoll_oggstream);
    install_param_int(&alogg_autopoll_oggstream, (void *)ogg, ogg->auto_poll_speed);
  }

  return ALOGG_OK;
}
void alogg_adjust_oggstream(ALOGG_OGGSTREAM *ogg, int vol, int pan, int speed) {
  /* return if we are not playing */
  if (!alogg_is_playing_oggstream(ogg))
    return;

  /* adjust the sample */
  adjust_sample(ogg->audiostream->samp, vol, pan, speed, TRUE);
}
Exemple #3
0
void alogg_adjust_ogg(ALOGG_OGG *ogg, int vol, int pan, int speed, int loop) {
  /* return if we are not playing */
  if (!alogg_is_playing_ogg(ogg))
    return;

  /* adjust the sample */
  adjust_sample(ogg->audiostream->samp, vol, pan, speed, TRUE);
  ogg->loop = loop;
}
void PlayerComponent::update()
{
  if( game.level.roster.get( parent ).x < -840 )
  {
    if( game.level.roster.get( parent ).y < -259 )
      game.endTime = game.timer.time;
  }
  else if( game.level.roster.get( parent ).x > 3584 )
  {
    if( game.level.roster.get( parent ).y > 1980 )
      game.endTime = game.timer.time;
  }

  windVol += double( rand() % 400 ) / 100.0 - ( windVol > 50 ? 2.0 : 0.0 );
  windPan += double( rand() % 200 ) / 100.0 - 1.0;
  windFreq += double( rand() % 400 ) / 100.0 - 2.0;

  adjust_sample( wind, windVol, windPan, windFreq, 1 );

  if( deathCounter > 0 )
    deathCounter--;

  else if( transformCounter > 0 )
    transformCounter--;

  else
  {
    handleAnimation();
    handleControls();
  }

  if( deathCounter == -1 )
  {
    game.level.roster.get( parent ).y += yVel;
    game.level.roster.get( parent ).x += xVel;
  }

  for( int i = 0; i < game.level.deathBodies.size(); i++ )
    if( game.level.roster.get( parent ).body.
        testCollision( game.level.deathBodies[ i ] ).GetMagnitudeSquared() > 0.0001 &&
        deathCounter == -1 )
    {
      deathCounter = 60;
      play_sample( die, 255,128, 7000, 0 );
      game.level.roster.get( parent ).sprite.setAnimation( "die" );
    }

  if( deathCounter == 0 )
  {
    game.level.roster.get( parent ).x = startX;
    game.level.roster.get( parent ).y = startY;

    deathCounter = -1;
  }
}
Exemple #5
0
/**
 * Alters the parameters of a sample while it is playing (useful for
 * manipulating looped sounds). You can alter the volume, pan, and
 * frequency, and can also clear the loop flag, which will stop the
 * sample when it next reaches the end of its loop. The values of the
 * parameters are just like those of #play. If there are
 * several copies of the same sample playing, this will adjust the
 * first one it comes across. If the sample is not playing it has no
 * effect.
 */
static VALUE sample_adjust(int argc, VALUE *argv, VALUE self) {
  VALUE vol, pan, freq, loop;
  SAMPLE *sample;
  Data_Get_Struct(self, SAMPLE, sample);
  rb_scan_args(argc, argv, "04", &vol, &pan, &freq, &loop);  
  adjust_sample(sample, 
	      RTEST(vol)  ? NUM2INT(vol) : 127, 
	      RTEST(pan)  ? NUM2INT(pan) : 127, 
	      RTEST(freq) ? NUM2INT(freq) : 1000, 
	      RTEST(loop));
  return self;
}
Exemple #6
0
void som::ajustar(int vol, int pan, int freq, int loop)
{
	if (tipo == T_WAV)
	{
		if(!smp) 
			return;
		adjust_sample(smp, vol,  pan, freq, loop);
		volume = vol;
		posicao = pan;
		frequencia = freq;
	} else if (tipo == T_MID)
	{
		egl_erro("Não é possível ajustar um som no formato MIDI");
		egl_debug = true;
	}
}
Exemple #7
0
int playGame()
{
	int tempx = current.getPosX(); //Temp variables for position
	int tempy = current.getPosY();

	if (keyboard_counter > 0 && keypressed()) //Keyboard Delay
	{
		if (key[KEY_LEFT]) //Move to the left
		{
			if (noCollision(current, tempx - 1, tempy)) //Checks collisions with the left movement
			{
				tempx--; //If there is not collision move the piece
				current.setPosX(tempx);
			}
		}
			
		if (key[KEY_RIGHT])
		{
			if (noCollision(current, tempx + 1, tempy))
			{
				tempx++;
				current.setPosX(tempx);
			}
		}
		
		if (key[KEY_DOWN])
		{
			if (noCollision(current, tempx, tempy + 1))
			{
				tempy++;
				current.setPosY(tempy);
			}
		}
		
		if (key[KEY_UP]) //Rotate the piece to the right
		{	
			/*Create a temp piece for the request rotation*/

			cPiece temp;
				
			temp.type = current.type;
			temp.rotation = rotateBlock(1, current.rotation);
				
			cleanPiece(temp);
			changePiece(temp, temp.type, temp.rotation);
			temp.setPosX(current.getPosX());
			temp.setPosY(current.getPosY());
				
			if (noCollision(temp, temp.getPosX(), temp.getPosY())) //Checks collision for the temp piece
			{
				//If there is not collision, the real falling(current) piece rotates to the right
				current.rotation = rotateBlock(1, current.rotation);
				cleanPiece(current);
				changePiece(current, current.type, current.rotation);
			}
		}

		if (key[KEY_T]) //Up the volume of the music
		{
			volume[0]+= 5;
			if (volume[0] > 255){
				volume[0] = 255;}

			options[4].d2 = volume[0];
			adjust_sample(sound[0], volume[0], 128, 1000, TRUE);
			adjust_sample(sound[1], volume[0], 128, 1000, TRUE);
		}

		if (key[KEY_G]) //Down the volume of the music
		{
			volume[0]-= 5;
			if (volume[0] < 0){
				volume[0] = 0;}

			options[4].d2 = volume[0];
			adjust_sample(sound[0], volume[0], 128, 1000, TRUE);
			adjust_sample(sound[1], volume[0], 128, 1000, TRUE);
		}

		if (key[KEY_Y]) //Up the volume of the sound effects
		{
			volume[1]+= 5;
			if (volume[1] > 255){
				volume[1] = 255;}

			options[6].d2 = volume[1];
			adjust_sample(sound[2], volume[1], 128, 1000, TRUE);
			adjust_sample(sound[3], volume[1], 128, 1000, TRUE);
		}

		if (key[KEY_H]) //Down the volume of the sound effects
		{
			volume[1]-= 5;
			if (volume[1] < 0){
				volume[1] = 0;}

			options[6].d2 = volume[1];
			adjust_sample(sound[2], volume[1], 128, 1000, TRUE);
			adjust_sample(sound[3], volume[1], 128, 1000, TRUE);
		}

	keyboard_counter--;
	}

    fpscount++;
	
	if (ticks > speed) 
	{
		tempx = current.getPosX();
		tempy = current.getPosY();
		
		if (noCollision(current, tempx, tempy + 1)) //Checks collision for the falling
		{
			tempy++;
			current.setPosY(tempy);
		}
		
		else
		{
			play_sample(sound[2], volume[1], 128, 1000, FALSE);
			putBlock(current, tempx, tempy); //Put block on the board

			possibleRows(); //Check if a row is fill

			if (gameOver()) //Checks if the game is over
			{
				quitgame = 1;
			}
			
			else
				createBlock(current, next); //If the game it's not over create new pieces

		}

		ticks = 0;

	}

	return quitgame;
}
Exemple #8
0
void UpdateOptions()
{
    if(optionsInit)
    {
        mouse.x = mouse_x;mouse.y = mouse_y;
        mouseBPrev = mouseB;
        mouseB = mouse_b;

        if(ABB(mouse,backButt) && mouseB == 1)
        {
            hFile = HeroF->str;
            zFile = ZombieF->str;
            SaveConfig("config.cfg");

            GameState = MAINMENU;
        }
        if(ABB(mouse,fxPlus) && mouseB == 1)
        {
            fxVol = Clamp(0,fxVol+1,255);
            fxAm.w = fxVol;
        }
        if(ABB(mouse,fxMinus) && mouseB == 1)
        {
            fxVol = Clamp(0,fxVol-1,255);
            fxAm.w = fxVol;
        }
        if(ABB(mouse,musPlus) && mouseB == 1)
        {
            musicVol = Clamp(0,musicVol+1,255);
            adjust_sample(bgMusic,musicVol,127,1000,1);
            musAm.w = musicVol;
        }
        if(ABB(mouse,musMinus) && mouseB == 1)
        {
            musicVol = Clamp(0,musicVol-1,255);
            adjust_sample(bgMusic,musicVol,127,1000,1);
            musAm.w = musicVol;
        }

        if(ABB(mouse,zombieNext) && mouseB == 0 && mouseBPrev == 1)
        {
            if(ZombieF->next) ZombieF = ZombieF->next;
        }
        if(ABB(mouse,zombiePrev) && mouseB == 0 && mouseBPrev == 1)
        {
            if(ZombieF->prev) ZombieF = ZombieF->prev;
        }
        if(ABB(mouse,heroNext) && mouseB == 0 && mouseBPrev == 1)
        {
            if(HeroF->next) HeroF = HeroF->next;
        }
        if(ABB(mouse,heroPrev) && mouseB == 0 && mouseBPrev == 1)
        {
            if(HeroF->prev) HeroF = HeroF->prev;
        }
    }
    else
    {
        InitOptions();
    }
}