/// <summary> /// Sets up the sound system and loads in the music controls. This /// does use the full library for Tao, but only the mixer functions /// are used. /// </summary> public void Initialize() { // Set up the SDL sound SdlMixer.Mix_OpenAudio( SdlMixer.MIX_DEFAULT_FREQUENCY, (short)SdlMixer.MIX_DEFAULT_FORMAT, 2, 1024); // Allocate channels SdlMixer.Mix_AllocateChannels(MaximumSoundsChunks); // Default volumnes int vol = Game.Config.GetInt(Constants.ConfigMusicVolume, 75); SdlMixer.Mix_VolumeMusic(vol); // Hook up the events musicStopped = new SdlMixer.MusicFinishedDelegate(OnMusicEnded); SdlMixer.Mix_HookMusicFinished(musicStopped); channelStopped = new SdlMixer.ChannelFinishedDelegate(OnChannelEnded); SdlMixer.Mix_ChannelFinished(channelStopped); }
/** * Constructor initializes SDL Audio * allocates DEFAULTNUMCHANNELS channels * and sets the SDL ChannelFinished delegate * * @param theEngine The Engine. */ public AudioComponent(MirrorEngine engine) : base(engine) { if (Sdl.SDL_InitSubSystem(Sdl.SDL_INIT_AUDIO) != 0) { throw new Exception("Could not init SDL Audio: " + Sdl.SDL_GetError()); } if (SdlMixer.Mix_OpenAudio(44100, (short)Sdl.AUDIO_S16SYS, 2, 2048) == -1) { throw new Exception("Could not init SDL_Mixer: " + SdlMixer.Mix_GetError()); } //Channel Setup openChannels = new LinkedList <int>(); addChannels(DEFAULTNUMCHANNELS); cfinished = freeChannel; SdlMixer.Mix_ChannelFinished(cfinished); }
public override void Initialize() { if (Sdl.SDL_InitSubSystem(Sdl.SDL_INIT_AUDIO) != 0) { throw new AgateLib.AgateException("Failed to initialize SDL for audio playback."); } if (SdlMixer.Mix_OpenAudio( SdlMixer.MIX_DEFAULT_FREQUENCY, Sdl.AUDIO_S16, 2, 512) != 0) { throw new AgateLib.AgateException("Failed to initialize SDL_mixer."); } SdlMixer.Mix_AllocateChannels(64); mChannelFinishedDelegate = ChannelFinished; SdlMixer.Mix_ChannelFinished(mChannelFinishedDelegate); Report("SDL driver instantiated for audio."); }
/// <summary> /// Enables the callback for this channel /// </summary> /// <remarks> /// When the sound stops playing, the delegate will be called. /// </remarks> public void EnableChannelFinishedCallback() { channelFinishedDelegate = new SdlMixer.ChannelFinishedDelegate(ChannelFinished); SdlMixer.Mix_ChannelFinished(channelFinishedDelegate); Events.ChannelFinished += new EventHandler <ChannelFinishedEventArgs>(Events_ChannelFinished); }