Exemple #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;
}
Exemple #2
0
//pause
bool CChannel::Pause()
{
	//pause the channel
	Mix_Pause(m_Channel);
	//return true
	return(true);
}
Exemple #3
0
/*
====================================================================
Modify audio
====================================================================
*/
void audio_enable( int enable )
{
    if ( !audio_ok ) return;
    audio_enabled = enable;
    if ( !enable )
        Mix_Pause( -1 ); /* stop all sound channels */
}
Exemple #4
0
void glSound::pause()
{
	if (Mix_Playing(channel))
	{
		Mix_Pause(channel);
	}
}
Exemple #5
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...");
}
Exemple #6
0
/* Initialise audio */
int digi_mixer_init() {
  digi_sample_rate = SAMPLE_RATE_44K;

  if (MIX_DIGI_DEBUG) con_printf(CON_DEBUG,"digi_init %d (SDL_Mixer)\n", MAX_SOUNDS);
  if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) Error("SDL audio initialisation failed: %s.", SDL_GetError());

  if (Mix_OpenAudio(digi_sample_rate, MIX_OUTPUT_FORMAT, MIX_OUTPUT_CHANNELS, SOUND_BUFFER_SIZE)) {
    //edited on 10/05/98 by Matt Mueller - should keep running, just with no sound.
    con_printf(CON_URGENT,"\nError: Couldn't open audio: %s\n", SDL_GetError());
    GameArg.SndNoSound = 1;
    return 1;
  }

  Mix_AllocateChannels(digi_max_channels);
  Mix_Pause(0);

  // Attempt to load jukebox
  jukebox_load();
  //jukebox_list();

  digi_initialised = 1;

  oplmus_init();

  return 0;
}
	void SimpleAudioEngine::pauseAllEffects()
	{
        for(int i = 0; i < NR_CHANNELS; i++)
        {
            Mix_Pause(i);
        }
	}
Exemple #8
0
void JukeBox::Pause(bool all) const
{
  const Config* cfg = Config::GetConstInstance();
  if (cfg->GetSoundEffects() || cfg->GetSoundMusic())
    Mix_Pause(-1);
  if (all)
    Mix_PauseMusic();
}
void ChannelInternalState::PauseAll() {
  Mix_Pause(kAllChannels);
#ifdef PINDROP_MULTISTREAM
  Mix_PauseMusicCh(kAllChannels);
#else
  Mix_PauseMusic();
#endif  // PINDROP_MULTISTREAM
}
Exemple #10
0
static mrb_value
mrb_sdl2_mixer_pause_channel(mrb_state *mrb, mrb_value self)
{
  mrb_int which;
  mrb_get_args(mrb, "i", &which);
  Mix_Pause(which);
  return mrb_nil_value();
}
Exemple #11
0
	void pause()
	{
		// Pause all sound
		Mix_Pause(-1);

		// Pause music
		Mix_PauseMusic();
	}
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;
}
Exemple #13
0
	static int lua_Mix_Pause(State & state){
		Stack * stack = state.stack;
		int channel = -1;
		if (stack->is<LUA_TNUMBER>(1)){
			channel = stack->to<int>(1);
		}
		Mix_Pause(channel);
		return 0;
	}
void ONScripter::stopAllDWAVE()
{
    for (int ch=0; ch<ONS_MIX_CHANNELS ; ch++)
        if ( wave_sample[ch] ){
            Mix_Pause( ch );
            Mix_FreeChunk( wave_sample[ch] );
            wave_sample[ch] = NULL;
        }
}
Exemple #15
0
void SoundEngine::PauseLoopedSound(int id)
{
    if (nosound)
    {
        return;
    }

    Mix_Pause(id);
}
Exemple #16
0
void SDLDrv_PCM_StopPlayback(void)
{
	if (!Initialised || !Playing) {
		return;
	}

    Mix_Pause(-1);
	
	Playing = 0;
}
bool	Sounds::pause_audio_player(void)
{
	if (Mix_PausedMusic() != 1)
	{
		Mix_PauseMusic();
		Mix_Pause(1);
		return (true);
	}
	return (false);
}
Exemple #18
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);
     }
}
void ONScripter::stopBGM( bool continue_flag )
{
    removeBGMFadeEvent();
    if (timer_bgmfade_id) SDL_RemoveTimer( timer_bgmfade_id );
    timer_bgmfade_id = NULL;
    mp3fadeout_duration_internal = 0;

#ifdef USE_CDROM
    if ( cdaudio_flag && cdrom_info ){
        extern SDL_TimerID timer_cdaudio_id;

        if ( timer_cdaudio_id ){
            SDL_RemoveTimer( timer_cdaudio_id );
            timer_cdaudio_id = NULL;
        }
        if (SDL_CDStatus( cdrom_info ) >= CD_PLAYING )
            SDL_CDStop( cdrom_info );
    }
#endif

    if ( wave_sample[MIX_BGM_CHANNEL] ){
        Mix_Pause( MIX_BGM_CHANNEL );
        Mix_FreeChunk( wave_sample[MIX_BGM_CHANNEL] );
        wave_sample[MIX_BGM_CHANNEL] = NULL;
    }

    if ( music_info ){
        ext_music_play_once_flag = true;
        Mix_HaltMusic();
        Mix_FreeMusic( music_info );
        music_info = NULL;
    }

    if ( midi_info ){
        ext_music_play_once_flag = true;
        Mix_HaltMusic();
        Mix_FreeMusic( midi_info );
        midi_info = NULL;
    }

    if ( !continue_flag ){
        setStr( &music_file_name, NULL );
        music_play_loop_flag = false;
        if (music_buffer){
            delete[] music_buffer;
            music_buffer = NULL;
        }

        setStr( &midi_file_name, NULL );
        midi_play_loop_flag = false;

        current_cd_track = -1;
    }
}
void ChannelInternalState::RealChannelPause() {
  assert(is_real());
  if (IsStream()) {
#ifdef PINDROP_MULTISTREAM
    Mix_PauseMusicCh(channel_id_);
#else
    Mix_PauseMusic();
#endif  // PINDROP_MULTISTREAM
  } else {
    Mix_Pause(channel_id_);
  }
}
Exemple #21
0
void PauseWave ( int no )
{
	switch ( s_iYGSSoundType[no] )
	{
	case YGS_SOUNDTYPE_WAV:
		Mix_Pause(no);
		break;

	case YGS_SOUNDTYPE_MUS:
		Mix_PauseMusic();
		break;
	}
}
Exemple #22
0
void snd_pause(int on)
{
	if (!sound_on) 
		return;
	if (on) {
		Mix_Pause(-1);
		Mix_PauseMusic();
	} else {
		Mix_Resume(-1);
		Mix_ResumeMusic();
	}
	return;
}
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;
  };
}
Exemple #24
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;
    }
}
Exemple #25
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();
		}
	}


}
Exemple #26
0
// ---
void SDLSound::pause ()
{
	switch (_type)
	{
		case SOUND_MUSIC:
			break;
		
		case SOUND_SFX:
			Mix_Pause (_realChannel);
			break;

		default:
			break;
	};
}
Exemple #27
0
/*
 *  call-seq:
 *    pause  ->  self
 *
 *  Pause the Sound. Unlike #stop, it can be unpaused later to resume
 *  from where it was paused. See also #unpause and #paused?.
 *
 *  Returns::     The receiver (self).
 *
 *  **NOTE**: Does nothing if the sound is not currently playing.
 *
 */
static VALUE rg_sound_pause( 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_Pause( channel );
	}

	return self;
}
Exemple #28
0
static int play_audio_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context)
{
	if (mve_audio_canplay  &&  !mve_audio_playing  &&  mve_audio_bufhead != mve_audio_buftail)
	{
#ifdef USE_SDLMIXER
		if (GameArg.SndDisableSdlMixer)
#endif
			SDL_PauseAudio(0);
#ifdef USE_SDLMIXER
		else
			Mix_Pause(0);
#endif
		mve_audio_playing = 1;
	}
	return 1;
}
Exemple #29
0
/**
 * @brief Pauses all the sounds in a group.
 */
void sound_mix_pauseGroup( 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_Playing(j))
               Mix_Pause(j);
         }
         return;
      }
   }

   WARN("Group '%d' not found.", group);
}
int ONScripter::playWave(Mix_Chunk *chunk, int format, bool loop_flag, int channel)
{
    if (!chunk) return -1;

    Mix_Pause( channel );
    if ( wave_sample[channel] ) Mix_FreeChunk( wave_sample[channel] );
    wave_sample[channel] = chunk;

    if      (channel == 0)               Mix_Volume( channel, voice_volume * MIX_MAX_VOLUME / 100 );
    else if (channel == MIX_BGM_CHANNEL) Mix_Volume( channel, music_volume * MIX_MAX_VOLUME / 100 );
    else                                 Mix_Volume( channel, se_volume * MIX_MAX_VOLUME / 100 );

    if ( !(format & SOUND_PRELOAD) )
        Mix_PlayChannel( channel, wave_sample[channel], loop_flag?-1:0 );

    return 0;
}