/// <summary>
        /// SEを再生します。
        /// </summary>
        public ISoundObjectBackend Play(string filename, double volume)
        {
            if (this.soundOut == null)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(filename))
            {
                return(null);
            }

            var source = GetSoundSource(filename);

            if (source == null)
            {
                throw new InvalidDataException(
                          "音声ファイルの読み込みに失敗しました。");
            }

            // 音量を設定します。
            var backend = new SoundObjectBackend_CSCore(source)
            {
                Volume = volume
            };

            // 再生
            this.mixer.AddSource(backend);
            if (this.soundOut.PlaybackState != PlaybackState.Playing)
            {
                this.soundOut.Play();
            }

            return(backend);
        }
Exemplo n.º 2
0
        /// <summary>
        /// <paramref name="backend"/>を再生リストに追加します。
        /// </summary>
        public void AddSource(SoundObjectBackend_CSCore backend)
        {
            if (backend == null)
            {
                throw new ArgumentNullException("backend");
            }

            /*if (source.WaveFormat.Channels != WaveFormat.Channels ||
             *  source.WaveFormat.SampleRate != WaveFormat.SampleRate)
             * {
             *  throw new ArgumentException("Invalid format.", "source");
             * }*/

            if (!Contains(backend))
            {
                var source = backend.State as IWaveSource;

                this.sourceList.Add(
                    backend,
                    source
                    .ChangeSampleRate(WaveFormat.SampleRate)
                    .ToStereo()
                    .ToSampleSource());
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// <paramref name="backend"/>を再生リストから削除します。
 /// </summary>
 public void RemoveSource(SoundObjectBackend_CSCore backend)
 {
     if (Contains(backend))
     {
         this.sourceList.Remove(backend);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// <paramref name="backend"/>が再生リストに含まれているか調べます。
        /// </summary>
        public bool Contains(SoundObjectBackend_CSCore backend)
        {
            if (backend == null)
            {
                return(false);
            }

            return(this.sourceList.ContainsKey(backend));
        }