Esempio n. 1
0
        /// <summary>
        /// Sets the range of the sound to play.
        /// </summary>
        /// <param name="range">a PlayRange structure that describes the starting offset and ending point of the sound to play in seconds.</param>
        public void SetRange(PlayRange range)
        {
            if (engine.State == AudioEngineState.Invalidated)
            {
                return;
            }

            var state = PlayState;

            if (state == SoundPlayState.Playing)
            {
                Stop();
            }

            if (soundSource == null)
            {
                AudioLayer.SourceSetRange(Source, range.Start.TotalSeconds, range.End.TotalSeconds);
            }
            else
            {
                soundSource.SetRange(range);
            }

            if (state == SoundPlayState.Playing)
            {
                Play();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Sets the range of the sound to play.
 /// </summary>
 /// <param name="range">a PlayRange structure that describes the starting offset and ending point of the sound to play in seconds.</param>
 /// <remarks>This will not be valid if the sound is played with PlayAndForget</remarks>
 public void SetRange(PlayRange range)
 {
     foreach (var instance in InstanceToListener)
     {
         instance.Key.SetRange(range);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Sets the range of the sound to play.
        /// </summary>
        /// <param name="range">a PlayRange structure that describes the starting offset and ending point of the sound to play in seconds.</param>
        public override void SetRange(PlayRange range)
        {
            lock (rangeLock)
            {
                playRange = range;
            }

            base.SetRange(range);
        }
Esempio n. 4
0
        /// <summary>
        /// This type of DynamicSoundSource is streamed from Disk and reads compressed Celt encoded data, used internally.
        /// </summary>
        /// <param name="instance">The associated SoundInstance</param>
        /// <param name="soundStreamUrl">The compressed stream internal URL</param>
        /// <param name="numberOfPackets"></param>
        /// <param name="sampleRate">The sample rate of the compressed data</param>
        /// <param name="channels">The number of channels of the compressed data</param>
        /// <param name="maxCompressedSize">The maximum size of a compressed packet</param>
        public CompressedSoundSource(SoundInstance instance, string soundStreamUrl, int numberOfPackets, int sampleRate, int channels, int maxCompressedSize) : base(instance, NumberOfBuffers, SamplesPerBuffer * MaxChannels * sizeof(short))
        {
            looped                 = instance.IsLooping;
            this.channels          = channels;
            this.maxCompressedSize = maxCompressedSize;
            this.soundStreamUrl    = soundStreamUrl;
            this.sampleRate        = sampleRate;
            this.numberOfPackets   = numberOfPackets;
            playRange              = new PlayRange(TimeSpan.Zero, TimeSpan.Zero);

            if (readFromDiskWorker == null)
            {
                readFromDiskWorker = Task.Factory.StartNew(Worker, TaskCreationOptions.LongRunning);
            }

            NewSources.Add(this);
        }
Esempio n. 5
0
 /// <summary>
 /// Sets the region of time to play from the audio clip.
 /// </summary>
 /// <param name="range">a PlayRange structure that describes the starting offset and ending point of the sound to play in seconds.</param>
 public virtual void SetRange(PlayRange range)
 {
     Commands.Enqueue(AsyncCommand.SetRange);
 }