Пример #1
0
        /// <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);
        }
Пример #3
0
        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.");
        }
Пример #4
0
 /// <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);
 }
Пример #5
0
 /// <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);
 }
Пример #6
0
        /// <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);
        }
Пример #7
0
 public static void Mix_ChannelFinished(SdlMixer.ChannelFinishedDelegate channel_finished);
Пример #8
0
        /// <summary>
        /// Sets up the SDL audio system for use by the application.
        /// </summary>
        public static void Startup()
        {
            // Don't reopen it
            if (isStarted)
                return;

            // Set up the SDL sound
            SdlMixer.Mix_OpenAudio(
                SdlMixer.MIX_DEFAULT_FREQUENCY,
                (short) SdlMixer.MIX_DEFAULT_FORMAT,
                2,
                1024);

            // Allocate channels
            SdlMixer.Mix_AllocateChannels(Constants.MaximumSoundChunks);

            // Default volumnes
            int vol = 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);

            // Set up our basic sound
            isStarted = true;
        }