• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IAudioStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IAudioStream的典型用法代码示例。如果您正苦于以下问题:C# IAudioStream类的具体用法?C# IAudioStream怎么用?C# IAudioStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IAudioStream类属于命名空间,在下文中一共展示了IAudioStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: StartRecorder

		/// <summary>
		/// Starts the recorder.
		/// </summary>
		/// <param name="stream">The stream.</param>
		/// <param name="fileStream">The file stream.</param>
		/// <param name="sampleRate">The sample rate.</param>
		/// <returns>Task&lt;System.Boolean&gt;.</returns>
		public async Task<bool> StartRecorder(IAudioStream stream, Stream fileStream, int sampleRate)
		{
			if (_stream != null || stream == null)
			{
				return false;
			}

			_stream = stream;

			try
			{
				_writer = new BinaryWriter(fileStream, Encoding.UTF8);
			}
			catch (Exception)
			{
				return false;
			}

			_byteCount = 0;
			_stream.OnBroadcast += OnStreamBroadcast;

			var result = await _stream.Start(sampleRate);
			if (result)
			{
				_sampleRate = sampleRate;
				_bitsPerSample = stream.BitsPerSample;
				_channelCount = stream.ChannelCount;
			}
			return result;
		}
开发者ID:Jaskomal,项目名称:Xamarin-Forms-Labs,代码行数:37,代码来源:WaveRecorder.cs


示例2: ColorGenerator

        public ColorGenerator(IAudioStream audioStream, int numberOfColors = 3)
            : base(audioStream, numberOfColors)
        {
            if (numberOfColors < 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            var lowFreqMaxBucket = this.GetFrequencyBinIndex(LowFrequencyMax);
            var lowFreqBucket = new ColorGeneratorBucket(this.GetFrequencyBinIndex(LowFrequencyMin), lowFreqMaxBucket, this.IterationsPerSecond, hueShift: 0);
            this.generatorBuckets.Add(lowFreqBucket);

            var freqsPerBucket = (this.MaxFrequencyBinIndex - lowFreqMaxBucket) / (numberOfColors - 1);
            if (freqsPerBucket < 1)
            {
                throw new ArgumentOutOfRangeException("Not enough frequency bins for the remaining colors");
            }

            for (int freqIndex = lowFreqMaxBucket + 1; freqIndex <= this.MaxFrequencyBinIndex - 1; freqIndex += freqsPerBucket)
            {
                ushort hueShift = (ushort)(ushort.MaxValue / numberOfColors * this.generatorBuckets.Count);
                this.generatorBuckets.Add(
                    new ColorGeneratorBucket(freqIndex, Math.Min(freqIndex + freqsPerBucket - 1, this.MaxFrequencyBinIndex), this.IterationsPerSecond, hueShift: hueShift));
            }
        }
开发者ID:rdodgen,项目名称:Ezri,代码行数:25,代码来源:ColorGenerator.cs


示例3: StartRecorder

        public bool StartRecorder(IAudioStream stream, string fileName)
        {
            if (this.stream != null || stream == null)
            {
                return false;
            }

            this.stream = stream;

            try
            {
                this.streamWriter = new StreamWriter(fileName, false);
                this.writer = new BinaryWriter(this.streamWriter.BaseStream, Encoding.UTF8);
            }
            catch (Exception)
            {
                return false;
            }
            this.byteCount = 0;
            this.stream.OnBroadcast += OnStreamBroadcast;
            this.stream.OnActiveChanged += StreamActiveChanged;
            if (!this.stream.Active)
            {
                this.stream.Start();
            }

            return true;
        }
开发者ID:paul33868,项目名称:SimplyMobile,代码行数:28,代码来源:WaveRecorder.cs


示例4: StartRecorder

        public bool StartRecorder(IAudioStream stream, string fileName)
        {
            if (this.stream != null || stream == null)
            {
                return false;
            }

            this.stream = stream;

            try
            {
                //this.streamWriter = new StreamWriter(fileName, false);
                this.writer = new BinaryWriter(this.streamWriter.BaseStream, Encoding.UTF8);
            }
            catch (Exception)
            {
                return false;
            }
            this.byteCount = 0;
            this.stream.OnBroadcast += OnStreamBroadcast;

            if (this.stream.Start.CanExecute(this))
            {
                this.stream.Start.Execute(this);
                return true;
            }

            return false;
        }
开发者ID:Gunner92,项目名称:Xamarin-Forms-Labs,代码行数:29,代码来源:WaveRecorder.cs


示例5: Start

 public bool Start(IAudioStream stream)
 {
     this.stream = stream;
     this.stream.OnBroadcast += HandleOnBroadcast;
     this.description = new AudioStreamBasicDescription (AudioFormatType.LinearPCM) 
     {
         BitsPerChannel = stream.BitsPerSample / stream.ChannelCount,
     };
 }
开发者ID:paul33868,项目名称:SimplyMobile,代码行数:9,代码来源:AudioPacketConverter.cs


示例6: Flow

        public int Flow(IAudioStream input, short[] obuf, int count, int volLeft, int volRight)
        {
            var obufPos = 0;
            var inPos = 0;
            var oend = count;

            while (obufPos < oend)
            {
                // read enough input samples so that opos < 0
                while (FRAC_ONE_LOW <= opos)
                {
                    // Check if we have to refill the buffer
                    if (inLen == 0)
                    {
                        inPos = 0;
                        inLen = input.ReadBuffer(inBuf, RateHelper.IntermediateBufferSize);
                        if (inLen <= 0)
                            return obufPos / 2;
                    }
                    inLen -= (stereo ? 2 : 1);
                    ilast0 = icur0;
                    icur0 = inBuf[inPos++];
                    if (stereo)
                    {
                        ilast1 = icur1;
                        icur1 = inBuf[inPos++];
                    }
                    opos -= FRAC_ONE_LOW;
                }

                // Loop as long as the outpos trails behind, and as long as there is
                // still space in the output buffer.
                while (opos < FRAC_ONE_LOW && obufPos < oend)
                {
                    // interpolate
                    int out0, out1;
                    out0 = (short)(ilast0 + (((icur0 - ilast0) * opos + FRAC_HALF_LOW) >> FRAC_BITS_LOW));
                    out1 = stereo ? (short)(ilast1 + (((icur1 - ilast1) * opos + FRAC_HALF_LOW) >> FRAC_BITS_LOW)) : out0;

                    // output left channel
                    RateHelper.ClampedAdd(ref obuf[obufPos + (reverseStereo ? 1 : 0)], (out0 * volLeft) / Mixer.MaxMixerVolume);

                    // output right channel
                    RateHelper.ClampedAdd(ref obuf[obufPos + (reverseStereo ? 0 : 1)], (out1 * volRight) / Mixer.MaxMixerVolume);

                    obufPos += 2;

                    // Increment output position
                    opos += oposInc;
                }
            }
            return obufPos / 2;

        }
开发者ID:scemino,项目名称:nscumm,代码行数:54,代码来源:LinearRateConverter.cs


示例7: CreateBuffer

        public override AudioBuffer CreateBuffer(IAudioStream target)
        {
            int size = AudioBuffer.DefaultBufferSpan * target.Frequency * target.Channels * target.BitsPerSample / 8;

            WaveFormatEx fmt = new WaveFormatEx(target.Format, target.Channels, target.Frequency, target.BitsPerSample);

            DS.DSBufferCapsFlags flags = DS.DSBufferCapsFlags.CtrlVolume | DS.DSBufferCapsFlags.LocDefer | DS.DSBufferCapsFlags.GlobalFocus | DS.DSBufferCapsFlags.GetCurrentPosition2;
            DS.DSBufferDesc desc = new DS.DSBufferDesc((uint)size, flags, &fmt, Guid.Empty);

            return new wAudioBuffer(this, ref desc) { _source = target, _owner = this };
        }
开发者ID:blahblahblahblah831,项目名称:brawltools2,代码行数:11,代码来源:wAudioProvider.cs


示例8: Test1

        public bool Test1(IAudioStream audio, int state)
        {
            if (state == 0)
                Debug.WriteLine("Test #1: play, pause, stop and global stop");

            if (state == 2)
            {
                Debug.WriteLine("----> play for five seconds");
                audio.Play();
            }

            if (state == 7)
            {
                Debug.WriteLine("----> pause music for two seconds");
                audio.Pause();
            }

            if (state == 9)
            {
                Debug.WriteLine("----> play music for five seconds");
                audio.Play();
            }

            if (state == 14)
            {
                Debug.WriteLine("----> stop music for two seconds");
                audio.Stop();
            }

            if (state == 16)
            {
                Debug.WriteLine("----> play music for five seconds");
                audio.Play();
            }

            if (state == 21)
            {
                Debug.WriteLine("----> global stop for two seconds");
                Audio.Instance.Stop();
            }

            if (state == 23)
            {
                Debug.WriteLine("----> play music for five seconds");
                audio.Play();
            }

            if (state != 28)
                return false;

            audio.Stop();
            return true;
        }
开发者ID:GameProduction,项目名称:ScharfschiessenGame,代码行数:53,代码来源:Tests.cs


示例9: Test2

        public bool Test2(IAudioStream audio, int state)
        {
            if (state == 0)
                Debug.WriteLine("Test #2: lower global volume from 100 to 0");

            if (state >= 2)
            {
                Audio.Instance.SetVolume(100 - ((state - 2)*20));
                Debug.WriteLine("----> global volume set to: " + Audio.Instance.GetVolume());

                audio.Play();
            }

            return state == 7;
        }
开发者ID:GameProduction,项目名称:ScharfschiessenGame,代码行数:15,代码来源:Tests.cs


示例10: Flow

        public int Flow(IAudioStream input, short[] obuf, int count, int volLeft, int volRight)
        {
            int pos = 0;
            int oend = count * 2;

            while (pos < oend)
            {
                // read enough input samples so that opos >= 0
                do
                {
                    // Check if we have to refill the buffer
                    if (inLen == 0)
                    {
                        inPtr = 0;
                        inLen = input.ReadBuffer(inBuf, RateHelper.IntermediateBufferSize);
                        if (inLen <= 0)
                            return pos / 2;
                    }
                    inLen -= (stereo ? 2 : 1);
                    opos--;
                    if (opos >= 0)
                    {
                        inPtr += (stereo ? 2 : 1);
                    }
                } while (opos >= 0);

                short out0, out1;
                out0 = inBuf[inPtr++];
                out1 = (stereo ? inBuf[inPtr++] : out0);

                // Increment output position
                opos += oposInc;

                // output left channel
                RateHelper.ClampedAdd(ref obuf[reverseStereo ? 1 : 0], (out0 * (int)volLeft) / Mixer.MaxMixerVolume);

                // output right channel
                RateHelper.ClampedAdd(ref obuf[(reverseStereo ? 1 : 0) ^ 1], (out1 * (int)volRight) / Mixer.MaxMixerVolume);

                pos += 2;
            }
            return pos / 2;
        }
开发者ID:scemino,项目名称:nscumm,代码行数:43,代码来源:SimpleRateConverter.cs


示例11: Test3

        public bool Test3(IAudioStream audio, int state)
        {
            if (state == 0)
            {
                Audio.Instance.SetVolume(100);
                audio.Volume = 0;

                Debug.WriteLine("Test #3: raise individual volume from 0 to 100");
            }

            if (state >= 2)
            {
                audio.Volume = ((state - 2)*20);
                Debug.WriteLine("----> individual volume set to: " + audio.Volume);

                audio.Play();
            }

            return (state == 7);
        }
开发者ID:GameProduction,项目名称:ScharfschiessenGame,代码行数:20,代码来源:Tests.cs


示例12: PlayStream

        public SoundHandle PlayStream(SoundType type, IAudioStream stream, int id = -1, int volume = 255,
            int balance = 0, bool autofreeStream = true, bool permanent = false, bool reverseStereo = false)
        {
            lock (_gate)
            {
                if (stream == null)
                {
                    //                    Console.Error.WriteLine("stream is null");
                    return new SoundHandle();
                }

                Debug.Assert(IsReady);

                // Prevent duplicate sounds
                if (id != -1)
                {
                    for (var i = 0; i != NumChannels; i++)
                        if (_channels[i] != null && _channels[i].Id == id)
                        {
                            // Delete the stream if were asked to auto-dispose it.
                            // Note: This could cause trouble if the client code does not
                            // yet expect the stream to be gone. The primary example to
                            // keep in mind here is QueuingAudioStream.
                            // Thus, as a quick rule of thumb, you should never, ever,
                            // try to play QueuingAudioStreams with a sound id.
                            if (autofreeStream)
                                stream.Dispose();
                            return new SoundHandle();
                        }
                }

                // Create the channel
                var chan = new Channel(this, type, stream, autofreeStream, reverseStereo, id, permanent)
                {
                    Volume = volume,
                    Balance = balance
                };
                return InsertChannel(chan);
            }
        }
开发者ID:scemino,项目名称:nscumm,代码行数:40,代码来源:Mixer.cs


示例13: Flow

        public int Flow(IAudioStream input, short[] obuf, int count, int volLeft, int volRight)
        {
            Debug.Assert(input.IsStereo == stereo);

            var osamp = count / 2;

            if (stereo)
                osamp *= 2;

            // Reallocate temp buffer, if necessary
            if (osamp > _bufferSize)
            {
                _buffer = new short[osamp];
                _bufferSize = osamp;
            }

            // Read up to 'osamp' samples into our temporary buffer
            var len = input.ReadBuffer(_buffer, _bufferSize);

            int iPos = 0;
            var oPos = 0;
            var inc = stereo ? 2 : 1;
            // Mix the data into the output buffer
            for (; iPos < len; iPos += inc)
            {
                var out0 = _buffer[iPos];
                var out1 = stereo ? _buffer[iPos + 1] : out0;

                // output left channel
                RateHelper.ClampedAdd(ref obuf[oPos + (reverseStereo ? 1 : 0)], (out0 * volLeft) / Mixer.MaxMixerVolume);

                // output right channel
                RateHelper.ClampedAdd(ref obuf[oPos + (reverseStereo ? 0 : 1)], (out1 * volRight) / Mixer.MaxMixerVolume);

                oPos += 2;
            }
            return oPos / 2;
        }
开发者ID:scemino,项目名称:nscumm,代码行数:38,代码来源:CopyRateConverter.cs


示例14: StartRecorder

        public async Task<bool> StartRecorder(IAudioStream stream, Stream fileStream, int sampleRate)
        {
            if (this.stream != null || stream == null)
            {
                return false;
            }

            this.stream = stream;

            try
            {
                this.writer = new BinaryWriter(fileStream, Encoding.UTF8);
            }
            catch (Exception)
            {
                return false;
            }

            this.byteCount = 0;
            this.stream.OnBroadcast += OnStreamBroadcast;

            return await this.stream.Start(sampleRate);
        }
开发者ID:rid00z,项目名称:Xamarin-Forms-Labs,代码行数:23,代码来源:WaveRecorder.cs


示例15: GetDualMonoMode

    private static eAudioDualMonoMode GetDualMonoMode(IAudioStream[] streams, int currentIndex, ref int priority,
                                                      ref int idxStreamIndexmpeg, ref string mpegBasedOnLang)
    {
      eAudioDualMonoMode dualMonoMode = eAudioDualMonoMode.UNSUPPORTED;
      string leftAudioLang = streams[currentIndex].Language.Substring(0, 3);
      string rightAudioLang = streams[currentIndex].Language.Substring(3, 3);

      int indexLeft = _preferredLanguages.IndexOf(leftAudioLang);
      if (indexLeft >= 0 && indexLeft < priority)
      {
        dualMonoMode = eAudioDualMonoMode.LEFT_MONO;
        mpegBasedOnLang = leftAudioLang;
        idxStreamIndexmpeg = currentIndex;
        priority = indexLeft;
      }

      int indexRight = _preferredLanguages.IndexOf(rightAudioLang);
      if (indexRight >= 0 && indexRight < priority)
      {
        dualMonoMode = eAudioDualMonoMode.RIGHT_MONO;
        mpegBasedOnLang = rightAudioLang;
        idxStreamIndexmpeg = currentIndex;
        priority = indexRight;
      }
      return dualMonoMode;
    }
开发者ID:splatterpop,项目名称:MediaPortal-1,代码行数:26,代码来源:TVHome.cs


示例16: GetFirstMpegIndex

    private static int GetFirstMpegIndex(IAudioStream[] streams)
    {
      int idxFirstMpeg = -1;

      for (int i = 0; i < streams.Length; i++)
      {
        if (!IsStreamAC3(streams[i]))
        {
          idxFirstMpeg = i;
          break;
        }
      }
      return idxFirstMpeg;
    }
开发者ID:splatterpop,项目名称:MediaPortal-1,代码行数:14,代码来源:TVHome.cs


示例17: IsStreamAC3

 private static bool IsStreamAC3(IAudioStream stream)
 {
   return (stream.StreamType == AudioStreamType.AC3 ||
           stream.StreamType == AudioStreamType.EAC3);
 }
开发者ID:splatterpop,项目名称:MediaPortal-1,代码行数:5,代码来源:TVHome.cs


示例18: UpdateAudioStreamIndexesBasedOnLang

    private static void UpdateAudioStreamIndexesBasedOnLang(IAudioStream[] streams, int i, ref int idxStreamIndexmpeg,
                                                            ref int idxStreamIndexAc3, ref string mpegBasedOnLang,
                                                            ref int idxLangPriAc3, ref int idxLangPrimpeg,
                                                            ref string ac3BasedOnLang)
    {
      int langPriority = _preferredLanguages.IndexOf(streams[i].Language);
      string langSel = streams[i].Language;
      Log.Debug("Stream {0} lang {1}, lang priority index {2}", i, langSel, langPriority);

      // is the stream language preferred?
      if (langPriority >= 0)
      {
        // has the stream a higher priority than an old one or is this the first AC3 stream with lang pri (idxLangPriAc3 == -1) (AC3)
        bool isAC3 = IsStreamAC3(streams[i]);
        if (isAC3)
        {
          if (idxLangPriAc3 == -1 || langPriority < idxLangPriAc3)
          {
            Log.Debug("Setting AC3 pref");
            idxStreamIndexAc3 = i;
            idxLangPriAc3 = langPriority;
            ac3BasedOnLang = langSel;
          }
        }
        else //not AC3
        {
          // has the stream a higher priority than an old one or is this the first mpeg stream with lang pri (idxLangPrimpeg == -1) (mpeg)
          if (idxLangPrimpeg == -1 || langPriority < idxLangPrimpeg)
          {
            Log.Debug("Setting mpeg pref");
            idxStreamIndexmpeg = i;
            idxLangPrimpeg = langPriority;
            mpegBasedOnLang = langSel;
          }
        }
      }
    }
开发者ID:splatterpop,项目名称:MediaPortal-1,代码行数:37,代码来源:TVHome.cs


示例19: UpdateAudioStreamIndexesAndPrioritiesBasedOnLanguage

 private static void UpdateAudioStreamIndexesAndPrioritiesBasedOnLanguage(IAudioStream[] streams, int priority,
                                                                          ref int idxStreamIndexmpeg,
                                                                          ref string mpegBasedOnLang,
                                                                          ref int idxStreamIndexAc3,
                                                                          int idxLangPriAc3, int idxLangPrimpeg,
                                                                          ref string ac3BasedOnLang,
                                                                          out eAudioDualMonoMode dualMonoMode)
 {
   dualMonoMode = eAudioDualMonoMode.UNSUPPORTED;
   if (IsPreferredAudioLanguageAvailable())
   {
     for (int i = 0; i < streams.Length; i++)
     {
       //now find the ones based on LANG prefs.        
       if (ShouldApplyDualMonoMode(streams[i].Language))
       {
         dualMonoMode = GetDualMonoMode(streams, i, ref priority, ref idxStreamIndexmpeg, ref mpegBasedOnLang);
         if (dualMonoMode != eAudioDualMonoMode.UNSUPPORTED)
         {
           break;
         }
       }
       else
       {
         // lower value means higher priority
         UpdateAudioStreamIndexesBasedOnLang(streams, i, ref idxStreamIndexmpeg, ref idxStreamIndexAc3,
                                             ref mpegBasedOnLang, ref idxLangPriAc3, ref idxLangPrimpeg, ref ac3BasedOnLang);
       }
     }
   }
 }
开发者ID:splatterpop,项目名称:MediaPortal-1,代码行数:31,代码来源:TVHome.cs


示例20: AudioStreamParsedEventArgs

 /// <summary>
 /// Initializes a new instance of the <see cref="AudioStreamParsedEventArgs"/> class.
 /// </summary>
 /// <param name="audioStream">The audio stream.</param>
 public AudioStreamParsedEventArgs(IAudioStream audioStream)
 {
     AudioStream = audioStream;
 }
开发者ID:NeWbY100,项目名称:AudioVideoLib,代码行数:8,代码来源:AudioStreamParsedEventArgs.cs



注:本文中的IAudioStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IAuthClient类代码示例发布时间:2022-05-24
下一篇:
C# IAudioSource类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap