Beispiel #1
0
		/// <summary>
		/// Creates a duplicate of a sound buffer.
		/// </summary>
		/// <param name="buffer">The buffer to be cloned.</param>
		/// <returns>A duplicate instance of supplied sound buffer.</returns>
		public SecondaryBuffer CloneBuffer(SecondaryBuffer buffer)
		{
			if (buffer == null) throw new ArgumentNullException("buffer");

			SecondaryBuffer newbuffer = buffer.Clone(m_sounddevice);
			newbuffer.Volume = 0;

			return newbuffer;
		}
Beispiel #2
0
        public SecondaryBuffer GetBuffer(Sounds parent)
        {
            if (this.m_Empty)
            {
                return(null);
            }
            SecondaryBuffer buffer = null;

            for (int i = 0; i < this.m_Count; i++)
            {
                SecondaryBuffer buffer2 = (SecondaryBuffer)this.m_Buffers[i];
                BufferStatus    status  = buffer2.get_Status();
                if (!status.get_Playing() && !status.get_BufferLost())
                {
                    return(buffer2);
                }
                if (status.get_BufferLost())
                {
                    this.m_Buffers.RemoveAt(i);
                    i--;
                    this.m_Count--;
                }
                else
                {
                    buffer = buffer2;
                }
            }
            if (buffer != null)
            {
                try
                {
                    SecondaryBuffer buffer3 = buffer.Clone(parent.Device);
                    if (buffer3 != null)
                    {
                        this.m_Buffers.Add(buffer3);
                        this.m_Count++;
                        return(buffer3);
                    }
                }
                catch (Exception exception)
                {
                    Debug.Error(exception);
                }
            }
            SecondaryBuffer buffer4 = parent.ReadFromDisk(this.m_SoundID);

            if (buffer4 != null)
            {
                this.m_Buffers.Add(buffer4);
                this.m_Count++;
            }
            else
            {
                this.m_Empty = true;
            }
            return(buffer4);
        }
Beispiel #3
0
 public void Play(SecondaryBuffer buffer, Thing thing)
 {
     // �V�����X�P�Anull���ǂ����`�F�b�N���Ȃ���Ȃ��Ƃ͉�����
     if (device == null) return;
     if (numChannels == MAX_NUM_CHANNELS) return;
     channels[numChannels] = new GameSoundChannel(buffer.Clone(device), thing);
     channels[numChannels].Buffer.Pan = CalcPan(thing);
     channels[numChannels].Buffer.Volume = CalcVolume(thing);
     channels[numChannels].Buffer.Play(0, BufferPlayFlags.Default);
     numChannels++;
 }
Beispiel #4
0
        /// <summary>
        /// Creates a duplicate of a sound buffer.
        /// </summary>
        /// <param name="buffer">The buffer to be cloned.</param>
        /// <returns>A duplicate instance of supplied sound buffer.</returns>
        public SecondaryBuffer CloneBuffer(SecondaryBuffer buffer)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            SecondaryBuffer newbuffer = buffer.Clone(m_sounddevice);

            newbuffer.Volume = 0;

            return(newbuffer);
        }
Beispiel #5
0
 public void Play(SecondaryBuffer buffer, Thing thing)
 {
     // シュンスケ、nullかどうかチェックしなきゃならんとは何事だ
     if (device == null)
     {
         return;
     }
     if (numChannels == MAX_NUM_CHANNELS)
     {
         return;
     }
     channels[numChannels]               = new GameSoundChannel(buffer.Clone(device), thing);
     channels[numChannels].Buffer.Pan    = CalcPan(thing);
     channels[numChannels].Buffer.Volume = CalcVolume(thing);
     channels[numChannels].Buffer.Play(0, BufferPlayFlags.Default);
     numChannels++;
 }
 public int AddSound(int isound, bool soundloop)
 {
     if (isound > -1 && isound < this.availsoundlist.Count)
     {
         SecondaryBuffer secondaryBuffer = (SecondaryBuffer)this.availsoundlist[isound];
         SecondaryBuffer pbuffer         = secondaryBuffer.Clone(this.sounddevice);
         CSound          cSound          = new CSound(pbuffer, soundloop);
         if (soundloop)
         {
             cSound.buffer.Play(0, BufferPlayFlags.Looping);
         }
         else
         {
             cSound.buffer.Play(0, BufferPlayFlags.Default);
         }
         this.soundlist.Add(cSound);
         this.actionsoundlist.Add(cSound);
         return(this.actionsoundlist.Count - 1);
     }
     return(-1);
 }