Exemplo n.º 1
0
int main(int argc, char **argv) {
  SDL_Init(SDL_INIT_AUDIO);

  int ret = Mix_OpenAudio(0, 0, 0, 0); // we ignore all these..
  assert(ret == 0);

  sound = Mix_LoadWAV("sound.ogg");
  assert(sound);
  sound2 = Mix_LoadWAV("sound2.wav");
  assert(sound);

  int channel = play();
  printf( "Pausing Channel %d", channel );
  Mix_Pause(channel);
  int paused = Mix_Paused(channel);
  printf( "Channel %d %s", channel, paused ? "is paused" : "is NOT paused" );
  assert(paused);
  Mix_Resume(channel);
  paused = Mix_Paused(channel);
  printf( "Channel %d %s", channel, paused ? "is paused" : "is NOT paused" );
  assert(paused == 0);

  if (argc == 12121) play2(); // keep it alive

  emscripten_run_script("element = document.createElement('input');"
                        "element.setAttribute('type', 'button');"
                        "element.setAttribute('value', 'replay!');"
                        "element.setAttribute('onclick', 'Module[\"_play\"]()');"
                        "document.body.appendChild(element);");

  printf("you should hear two sounds. press the button to replay!\n");

  return 0;
}
Exemplo n.º 2
0
//resume
bool CChannel::Resume()
{
	//resume the channel
	Mix_Resume(m_Channel);
	//return
	return(true);
}
Exemplo n.º 3
0
void AppMinimized(void)
{
    stat("Game minimized or lost focus--pausing...");

#ifdef _SDL_MIXER
    Mix_Pause(-1);
    Mix_PauseMusic();
#else
    SDL_PauseAudio(1);
#endif

    for(;;)
    {
        if ((SDL_GetAppState() & VISFLAGS) == VISFLAGS)
        {
            break;
        }

        input_poll();
        SDL_Delay(20);
    }
#ifdef _SDL_MIXER
    Mix_Resume(-1);
    Mix_ResumeMusic();
#else
    SDL_PauseAudio(0);
#endif
    stat("Focus regained, resuming play...");
}
Exemplo n.º 4
0
int32_t SDLDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize,
						int32_t NumDivisions, void ( *CallBackFunc )( void ) )
{
	if (!Initialised) {
		ErrorCode = SDLErr_Uninitialised;
		return SDLErr_Error;
	}
	
	if (Playing) {
		SDLDrv_PCM_StopPlayback();
	}
    
	MixBuffer = BufferStart;
	MixBufferSize = BufferSize;
	MixBufferCount = NumDivisions;
	MixBufferCurrent = 0;
	MixBufferUsed = 0;
	MixCallBack = CallBackFunc;
	
	// prime the buffer
	MixCallBack();
    
	Mix_Resume(-1);
    
    Playing = 1;
    
	return SDLErr_Ok;
}
Exemplo n.º 5
0
void glSound::resume()
{
	if (Mix_Paused(channel))
	{
		Mix_Resume(channel);
	}
}
	void SimpleAudioEngine::resumeAllEffects()
	{
        for(int i = 0; i < NR_CHANNELS; i++)
        {
            Mix_Resume(i);
        }
	}
Exemplo n.º 7
0
void JukeBox::Resume(bool all) const
{
  const Config* cfg = Config::GetConstInstance();
  if (cfg->GetSoundEffects() || cfg->GetSoundMusic())
    Mix_Resume(-1);
  if (all)
    Mix_ResumeMusic();
}
Exemplo n.º 8
0
static mrb_value
mrb_sdl2_mixer_resume_channel(mrb_state *mrb, mrb_value self)
{
  mrb_int which;
  mrb_get_args(mrb, "i", &which);
  Mix_Resume(which);
  return mrb_nil_value();
}
Exemplo n.º 9
0
	void resume()
	{
		// Resume sounds
		Mix_Resume(-1);

		// Resume music.
		Mix_ResumeMusic();
	}
Exemplo n.º 10
0
void ChannelInternalState::ResumeAll() {
  Mix_Resume(kAllChannels);
#ifdef PINDROP_MULTISTREAM
  Mix_ResumeMusicCh(kAllChannels);
#else
  Mix_ResumeMusic();
#endif  // PINDROP_MULTISTREAM
}
Exemplo n.º 11
0
int main(int argc, char **argv) {
  SDL_Init(SDL_INIT_AUDIO);

  int ret = Mix_OpenAudio(0, 0, 0, 0); // we ignore all these..
  assert(ret == 0);

  {
      SDL_RWops * ops = SDL_RWFromFile("sound.ogg", "r");
      sound = Mix_LoadWAV_RW(ops, 0);
      SDL_FreeRW(ops);
      assert(sound);
  }

  {
      struct stat info;
      int result = stat("noise.ogg", &info);
      char * bytes = malloc( info.st_size );
      FILE * f = fopen( "noise.ogg", "rb" );
      fread( bytes, 1, info.st_size, f  );
      fclose(f);

      SDL_RWops * ops = SDL_RWFromConstMem(bytes, info.st_size);
      sound3 = Mix_LoadWAV_RW(ops, 0);
      SDL_FreeRW(ops);
      free(bytes);
  }

  {
      music = Mix_LoadMUS("the_entertainer.ogg");
  }
  
  
  sound2 = Mix_LoadWAV("sound2.wav");
  assert(sound2);

  int channel = play();
  printf( "Pausing Channel %d", channel );
  Mix_Pause(channel);
  int paused = Mix_Paused(channel);
  printf( "Channel %d %s", channel, paused ? "is paused" : "is NOT paused" );
  assert(paused);
  Mix_Resume(channel);
  paused = Mix_Paused(channel);
  printf( "Channel %d %s", channel, paused ? "is paused" : "is NOT paused" );
  assert(paused == 0);

  if (argc == 12121) play2(); // keep it alive

  emscripten_run_script("element = document.createElement('input');"
                        "element.setAttribute('type', 'button');"
                        "element.setAttribute('value', 'replay!');"
                        "element.setAttribute('onclick', 'Module[\"_play\"]()');"
                        "document.body.appendChild(element);");

  printf("you should hear two sounds. press the button to replay!\n");

  return 0;
}
Exemplo n.º 12
0
void SoundEngine::ResumeLoopedSound(int id)
{
    if (nosound)
    {
        return;
    }

    Mix_Resume(id);
}
Exemplo n.º 13
0
	static int lua_Mix_Resume(State & state){
		Stack * stack = state.stack;
		int channel = -1;
		if (stack->is<LUA_TNUMBER>(1)){
			channel = stack->to<int>(1);
		}
		Mix_Resume(channel);
		return 0;
	}
Exemplo n.º 14
0
void cAudio :: Resume_Sound( int channel /* = -1 */ ) const
{
	if( !m_sound_enabled || !m_initialised )
	{
		return;
	}

	// resume playback on all previously active channels
	Mix_Resume( channel );
}
Exemplo n.º 15
0
void cAudio :: ResumeSounds( int channel /* = -1  */ )
{
	if( !bSounds || !bInitialised )
	{
		return;
	}

	// resume playback on all previously active channels
	Mix_Resume( channel );
}
Exemplo n.º 16
0
bool	Sounds::unpause_audio_player(void)
{
	if (Mix_PausedMusic() == 1)
	{
		Mix_ResumeMusic();
		Mix_Resume(1);
		return (true);
	}
	return (false);
}
Exemplo n.º 17
0
//odgrywa dzwiek
void make_sound()
{
     if(!no_sound && !camera_mode) {
                   Mix_Resume(-1);

                   Mix_Volume(1, dps_sound_lvl * MIX_MAX_VOLUME/3);
                   Mix_Volume(2, rcs_sound_lvl * MIX_MAX_VOLUME/4);
     } else {
            Mix_Pause(-1);
     }
}
Exemplo n.º 18
0
void ChannelInternalState::RealChannelResume() {
  assert(is_real());
  if (IsStream()) {
#ifdef PINDROP_MULTISTREAM
    Mix_ResumeMusicCh(channel_id_);
#else
    Mix_ResumeMusic();
#endif  // PINDROP_MULTISTREAM
  } else {
    Mix_Resume(channel_id_);
  }
}
Exemplo n.º 19
0
void ReplayWave ( int no )
{
	switch ( s_iYGSSoundType[no] )
	{
	case YGS_SOUNDTYPE_WAV:
		Mix_Resume(no);
		break;

	case YGS_SOUNDTYPE_MUS:
		Mix_RewindMusic();
		break;
	}
}
Exemplo n.º 20
0
Arquivo: sound.c Projeto: wimh/instead
void snd_pause(int on)
{
	if (!sound_on) 
		return;
	if (on) {
		Mix_Pause(-1);
		Mix_PauseMusic();
	} else {
		Mix_Resume(-1);
		Mix_ResumeMusic();
	}
	return;
}
Exemplo n.º 21
0
void one_iter() {
  static int frames = 0;
  frames++;
  
  switch( frames ) {
    case 1:
      soundChannel = Mix_PlayChannel(-1, sound, 0);
      printf("channel = %d", soundChannel);
      assert(soundChannel != -1 && soundChannel != 0);

      noiseLoopChannel = Mix_PlayChannel(-1, noiseLoop, -1);
      printf("noiseLoopChannel = %d", noiseLoopChannel);
      assert(noiseLoopChannel != -1 && noiseLoopChannel != 0);
      // set noiseLoopChannel to half volume
      Mix_Volume(noiseLoopChannel,MIX_MAX_VOLUME/10);
      break;
    case 2:
      printf("channel %d is playing = %d", soundChannel, Mix_Playing(soundChannel));
      assert(Mix_Playing(soundChannel));
      break;
    case 30:
      Mix_Pause(soundChannel);
      Mix_PlayMusic(music, 1);
      break;
    case 31:
      assert(Mix_Paused(soundChannel));
      assert(Mix_PlayingMusic());
      break;
    case 60:
      Mix_Resume(soundChannel);
      Mix_PauseMusic();
      break;
    case 61:
      assert(Mix_Playing(soundChannel));
      assert(Mix_PausedMusic());
      break;
    case 90:
      Mix_ResumeMusic();
      break;
    case 91:
      assert(Mix_PlayingMusic());
      break;
    case 120:
      Mix_HaltChannel(soundChannel);
      Mix_HaltMusic();
#ifdef REPORT_RESULT
      REPORT_RESULT(1);
#endif
      break;
  };
}
Exemplo n.º 22
0
void cSound::resumeSound(string name)
{
	map<string, Mix_Chunk*>::iterator iterChunk = m_Chunks.find(name);
	map<string, Mix_Music*>::iterator iterMusic = m_Music.find(name);

	if (iterChunk != m_Chunks.end())
	{
		Mix_Resume(1);
	}
	else if(iterMusic != m_Music.end())
	{
		Mix_ResumeMusic();
	}
}
Exemplo n.º 23
0
void sound_on_off(roomGrid *room_grid)
{
    if (room_grid -> paused == off)
    {
        Mix_Pause(-1);
        room_grid -> paused = on;      
    }

    else if (room_grid -> paused == on)
    {
        Mix_Resume(-1);
        room_grid -> paused = off;
    }
}
Exemplo n.º 24
0
void Music::pauseResume() {
	if(tipo == SOM) {
		if(Mix_Paused(0)) {
			Mix_Resume(0);
		} else if(Mix_Playing(0)) {
			Mix_Pause(0);
		}

		if(Mix_Paused(1)) {
			Mix_Resume(1);
		} else if(Mix_Playing(1)) {
			Mix_Pause(1);
		}
	} else {
		if(Mix_PausedMusic()) {
			Mix_ResumeMusic();
		} else {
			Mix_PauseMusic();
		}
	}


}
Exemplo n.º 25
0
// ---
void SDLSound::resume ()
{
	switch (_type)
	{
		case SOUND_MUSIC:
			break;
		
		case SOUND_SFX:
			Mix_Resume (_realChannel);
			break;

		default:
			break;
	};
}
Exemplo n.º 26
0
/*
 *  call-seq:
 *    unpause  ->  self
 *
 *  Unpause the Sound, if it is currently paused. Resumes from
 *  where it was paused. See also #pause and #paused?.
 *
 *  Returns::     The receiver (self).
 *
 *  **NOTE**: Does nothing if the sound is not currently paused.
 *
 */
static VALUE rg_sound_unpause( VALUE self )
{
	RG_Sound *sound;
	Data_Get_Struct(self,  RG_Sound, sound);

	int channel = sound->channel;

	/* Make sure the sound actually belongs to the channel */
	if( _rg_sound_channel_check(sound) )
	{
		Mix_Resume( channel );
	}

	return self;
}
Exemplo n.º 27
0
/**
 * @brief Pauses all the sounds in a gorup.
 */
void sound_mix_resumeGroup( int group )
{
   int i, j;

   for (i=0; i<ngroups; i++) {
      if (groups[i].id == group) {
         for (j=groups[i].start; j<=groups[i].end; j++) {
            if (Mix_Paused(j))
               Mix_Resume(j);
         }
         return;
      }
   }

   WARN("Group '%d' not found.", group);
}
Exemplo n.º 28
0
Arquivo: digi.c Projeto: paud/d2x-xl
/* Initialise audio devices. */
int DigiInit()
{
    int i;
    i = 0;

    if (SDL_InitSubSystem(SDL_INIT_AUDIO)<0) {
        LogErr (TXT_SDL_INIT_AUDIO, SDL_GetError());
        LogErr ("\n");
        Error(TXT_SDL_INIT_AUDIO,SDL_GetError());
    }
    memset (SoundSlots, 0, sizeof (SoundSlots));
    if (gameOpts->app.bDemoData)
        gameOpts->sound.digiSampleRate = SAMPLE_RATE_11K;
#if USE_SDL_MIXER
    if (gameOpts->sound.bUseSDLMixer) {
        if (Mix_OpenAudio (gameOpts->sound.digiSampleRate, AUDIO_U8, 2, SOUND_BUFFER_SIZE * (gameOpts->sound.digiSampleRate / SAMPLE_RATE_11K)) < 0) {
            LogErr (TXT_SDL_OPEN_AUDIO, SDL_GetError());
            LogErr ("\n");
            Warning(TXT_SDL_OPEN_AUDIO, SDL_GetError());
            return 1;
        }
        Mix_Resume (-1);
        Mix_ResumeMusic ();
        Mix_AllocateChannels (MAX_SOUND_SLOTS);
    }
    else
#endif
    {
        WaveSpec.freq = gameOpts->sound.digiSampleRate;
        //added/changed by Sam Lantinga on 12/01/98 for new SDL version
        WaveSpec.format = AUDIO_U8;
        WaveSpec.channels = 2;
        //end this section addition/change - SL
        WaveSpec.samples = SOUND_BUFFER_SIZE * (gameOpts->sound.digiSampleRate / SAMPLE_RATE_11K);
        WaveSpec.callback = AudioMixCallback;
        if (SDL_OpenAudio (&WaveSpec, NULL) < 0) {
            LogErr (TXT_SDL_OPEN_AUDIO, SDL_GetError ());
            LogErr ("\n");
            Warning(TXT_SDL_OPEN_AUDIO, SDL_GetError ());
            return 1;
        }
        SDL_PauseAudio (0);
    }
    atexit (DigiClose);
    gameStates.sound.digi.bInitialized = 1;
    return 0;
}
Exemplo n.º 29
0
void pauseSound(int pause)
{
	if (game.audio == FALSE || game.sfxDefaultVolume == 0)
	{
		return;
	}

	if (pause == TRUE)
	{
		Mix_Pause(-1);
	}

	else
	{
		Mix_Resume(-1);
	}
}
Exemplo n.º 30
0
void one_iter() {
  static int frames = 0;
  frames++;
  
  switch( frames ) {
    case 1:
      soundChannel = Mix_PlayChannel(-1, sound, 0);
      printf("channel = %d", soundChannel);
      assert(soundChannel != -1 && soundChannel != 0);
      break;
    case 2:
      printf("channel %d is playing = %d", soundChannel, Mix_Playing(soundChannel));
      assert(Mix_Playing(soundChannel));
      break;
    case 30:
      Mix_Pause(soundChannel);
      Mix_PlayMusic(music, 1);
      break;
    case 31:
      assert(Mix_Paused(soundChannel));
      assert(Mix_PlayingMusic());
      break;
    case 60:
      Mix_Resume(soundChannel);
      Mix_PauseMusic();
      break;
    case 61:
      assert(Mix_Playing(soundChannel));
      assert(Mix_PausedMusic());
      break;
    case 90:
      Mix_ResumeMusic();
      break;
    case 91:
      assert(Mix_PlayingMusic());
      break;
    case 120:
      Mix_HaltChannel(soundChannel);
      Mix_HaltMusic();
      int result = 1;
      REPORT_RESULT();
      break;
  };
}