Esempio n. 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);
        }
Esempio n. 2
0
        public void AllocateChannels()
        {
            InitAudio();
            int results = SdlMixer.Mix_AllocateChannels(16);

            Assert.AreEqual(results, 16);
            QuitAudio();
        }
        /*
         * Deallocates extra channels from SDL
         */
        private void deallocateChannels()
        {
            for (int i = numChannels; i < numChannels * 2; i++)
            {
                if (SdlMixer.Mix_Playing(i) == 1)
                {
                    return;
                }
            }

            SdlMixer.Mix_AllocateChannels(numChannels);
            readyToDeallocate = false;
        }
        /*
         * Used to add any channels not already allocated up to x
         *
         * @param x the highest number of channels to allow
         */
        private void addChannels(int x)
        {
            if (x > MAXCHANNELS)
            {
                x = MAXCHANNELS;
            }

            SdlMixer.Mix_AllocateChannels(x);

            for (int i = numChannels; i < x; i++)
            {
                openChannels.AddLast(i);
                SdlMixer.Mix_Volume(i, _masterVolume);
            }

            numChannels       = x;
            readyToDeallocate = false;
        }
Esempio n. 5
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.");
        }
Esempio n. 6
0
 /// <summary>
 /// Create a new audio manager.
 /// </summary>
 public AudioPlayer()
 {
     Sdl.SDL_Init(Sdl.SDL_INIT_AUDIO);
     SdlMixer.Mix_OpenAudio(SdlMixer.MIX_DEFAULT_FREQUENCY, (short)SdlMixer.MIX_DEFAULT_FORMAT, SdlMixer.MIX_DEFAULT_CHANNELS, 1024);
     SdlMixer.Mix_AllocateChannels(16);
 }