當前位置: 首頁>>代碼示例>>C#>>正文


C# Audio.Microphone類代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Audio.Microphone的典型用法代碼示例。如果您正苦於以下問題:C# Microphone類的具體用法?C# Microphone怎麽用?C# Microphone使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Microphone類屬於Microsoft.Xna.Framework.Audio命名空間,在下文中一共展示了Microphone類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Initialize

        private void Initialize()
        {

            InitializeComponent();

            recordButton = ApplicationBar.Buttons[0] as ApplicationBarIconButton;
            playButton = ApplicationBar.Buttons[1] as ApplicationBarIconButton;
            saveButton = ApplicationBar.Buttons[2] as ApplicationBarIconButton;
            

   
            stream = new MemoryStream();
            microphone = Microphone.Default;
            soundIsPlaying = false;

            DispatcherTimer dt = new DispatcherTimer();
            dt.Interval = TimeSpan.FromMilliseconds(33);
            dt.Tick += new EventHandler(dt_Tick);
            dt.Start();


            microphone.BufferReady +=
                new EventHandler<EventArgs>(microphone_BufferReady);

           blankImage = new BitmapImage(new Uri("Images/blank.png", UriKind.RelativeOrAbsolute));
           microphoneImage = new BitmapImage(new Uri("Images/microphone.png", UriKind.RelativeOrAbsolute));
           speakerImage = new BitmapImage(new Uri("Images/speaker.png", UriKind.RelativeOrAbsolute));
        }
開發者ID:shayananique,項目名稱:SoundRecorderWP8,代碼行數:28,代碼來源:MainPage.xaml.cs

示例2: WitMic

        /// <summary>
        /// Initializes new instance of WitMic
        /// </summary>
        /// <param name="witPipedStream">Stream to write audio to</param>
        /// <param name="detectSpeechStop">Voice activity detection feature</param>
        public WitMic(WitPipedStream witPipedStream, bool detectSpeechStop)
        {
            this.witPipedStream = witPipedStream;
            this.detectSpeechStop = detectSpeechStop;

            microphone = Microphone.Default;

            if (microphone == null)
            {
                WitLog.Log("Did you enabled ID_CAP_MICROPHONE in WMAppManifest.xml?");

                return;
            }

            witDetectTalking = new WitVadWrapper(8.0, 16000, 60);

            microphone.BufferDuration = TimeSpan.FromMilliseconds(100);

            speech = new byte[microphone.GetSampleSizeInBytes(microphone.BufferDuration)];

            microphone.BufferReady += microphone_BufferReady;

            updateTimer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(1)
            };
            updateTimer.Tick += (s, e) =>
            {
                FrameworkDispatcher.Update();
            };
        }
開發者ID:carriercomm,項目名稱:wit-windowsphone-sdk,代碼行數:36,代碼來源:WitMic.cs

示例3: PhoneRecorder

 /// <summary>
 ///     Initializes a new instance of the <see cref="PhoneRecorder" /> class.
 /// </summary>
 /// <param name="microphone">The microphone.</param>
 public PhoneRecorder(Microphone microphone)
 {
     _mic = microphone;
     var timer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(33)};
     timer.Tick += timer_Tick;
     timer.Start();
     _mic.BufferReady += microphone_BufferReady;
 }
開發者ID:asebak,項目名稱:rapbattleonline,代碼行數:12,代碼來源:PhoneRecorder.cs

示例4: NewButtonPage

        public NewButtonPage()
        {
            InitializeComponent();

            // Create new Microphone and set event handler
            buttonMic = Microphone.Default;
            buttonMic.BufferReady += OnMicrophoneBufferReady;
            buttonPlayback = new DynamicSoundEffectInstance(buttonMic.SampleRate, AudioChannels.Mono);
        }
開發者ID:amahood,項目名稱:MassiveAttack,代碼行數:9,代碼來源:NewButtonPage.xaml.cs

示例5: NetworkTestPageViewModel

        public NetworkTestPageViewModel()
        {
            _Sending = false;

            microphone = Microphone.Default;
            stream = new MemoryStream();

            InputBytes = new ObservableCollection<ByteHolder>();
            G711Bytes = new ObservableCollection<ByteHolder>();
            StartTimer();

            microphone.BufferReady += new EventHandler<EventArgs>(microphone_BufferReady);
        }
開發者ID:T045T,項目名稱:Echo-App,代碼行數:13,代碼來源:NetworkTestPageViewModel.cs

示例6: MicHelper

        public MicHelper()
        {
            //Setup mic
            mic = Microphone.Default;

            //Setup timers
            recordingTimer = new DispatcherTimer();
            recordingTimer.Interval = TimeSpan.FromSeconds(Utils.maxRecordingDuration);
            recordingTimer.Tick += new EventHandler(recordingTimer_Tick);

            playbackTimer = new DispatcherTimer();
            playbackTimer.Tick += new EventHandler(playbackTimer_Tick);
        }
開發者ID:WindowsPhone-8-TrainingKit,項目名稱:HOL-BackgroundTransferService,代碼行數:13,代碼來源:MicHelper.cs

示例7: RecPage

 byte[] msBuffer; //讀取數據的緩衝區
 public RecPage()
 {
     InitializeComponent();
     // Microphone.Default靜態屬性獲得默認麥克風的引用
     myMicrophone = Microphone.Default;
    // myMicrophone.BufferDuration = TimeSpan.FromMilliseconds(1000);
     msBuffer = new byte[myMicrophone.GetSampleSizeInBytes(myMicrophone.BufferDuration)];
     //FrameworkDispatcher.Update();
 }
開發者ID:Jasminekiki,項目名稱:WinProg,代碼行數:10,代碼來源:RecPage.xaml.cs

示例8: MainPage

        // コンストラクター
        public MainPage()
        {
            InitializeComponent();

            microphone = Microphone.Default;
            microphone.BufferReady += OnMicrophoneBufferReady;

            playback = new DynamicSoundEffectInstance(microphone.SampleRate, AudioChannels.Mono);
            playback.BufferNeeded += OnPlaybackBufferNeeded;
        }
開發者ID:roshi,項目名稱:wpat2013,代碼行數:11,代碼來源:MainPage.xaml.cs

示例9: XnaMicrophone

        public XnaMicrophone()
        {
            this.microphone = Microphone.Default;

            this.timer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(50)
            };

            this.timer.Tick += (s, e) => FrameworkDispatcher.Update();
        }
開發者ID:rid00z,項目名稱:Xamarin-Forms-Labs,代碼行數:11,代碼來源:XnaMicrophone.cs

示例10: UDPAudioSink

        public UDPAudioSink(bool ALaw)
        {
            _Sending = false;
            ALAW = ALaw;

            dt = new DispatcherTimer();
            microphone = Microphone.Default;
            stream = new MemoryStream();
            FrameworkDispatcher.Update();

            microphone.BufferReady += new EventHandler<EventArgs>(microphone_BufferReady);
        }
開發者ID:T045T,項目名稱:Echo-App,代碼行數:12,代碼來源:UDPAudioSink.cs

示例11: XnaMicrophone

        public XnaMicrophone()
        {
            this.microphone = Microphone.Default;
            this.microphone.BufferReady += microphone_BufferReady;

            this.Start = new RelayCommand<int>(
                (rate) => this.microphone.Start(),
                (rate) => this.SupportedSampleRates.Contains(rate) && this.microphone != null && this.microphone.State == MicrophoneState.Stopped);

            this.Stop = new Command(
                () => this.microphone.Stop(),
                () => this.microphone != null && this.microphone.State == MicrophoneState.Started);
        }
開發者ID:Gunner92,項目名稱:Xamarin-Forms-Labs,代碼行數:13,代碼來源:XnaMicrophone.cs

示例12: AudioRecorder

        /// <summary>
        /// Creates new instance of the AudioRecorder class.
        /// </summary>
        public AudioRecorder()
        {
            this.microphone = Microphone.Default;
            this.microphone.BufferDuration = TimeSpan.FromMilliseconds(500);

            this.buffer = new byte[microphone.GetSampleSizeInBytes(this.microphone.BufferDuration)];

            this.microphone.BufferReady += new EventHandler<EventArgs>(MicrophoneBufferReady);

            this.InitializeXnaGameLoop();

            // microphone requires special XNA initialization to work
            InitializeComponent();
        }
開發者ID:sgrebnov,項目名稱:phonegap-wp7,代碼行數:17,代碼來源:AudioRecorder.xaml.cs

示例13: Initialize

        public override void Initialize(AudioCaptureInitializeArgs captureArgs)
        {
            Microphone = Microphone.Default;
            Microphone.BufferDuration = TimeSpan.FromMilliseconds(100); // 100 minimum
            Microphone.BufferReady += Microphone_BufferReady;

            Resampler = new Resampler(DesiredClockRate / 16000);

            RunOnUIThread(() =>
            {
                XnaTimer = new DispatcherTimer();
                XnaTimer.Interval = TimeSpan.FromMilliseconds(50);
                XnaTimer.Tick += delegate { try { FrameworkDispatcher.Update(); } catch { } };
                XnaTimer.Start();
            });
        }
開發者ID:QuickBlox,項目名稱:quickblox-dotnet-sdk,代碼行數:16,代碼來源:AudioCaptureProvider.cs

示例14: Recorder

        public Recorder()
        {
            //Microphone config
            _microphone = Microphone.Default;
            _microphone.BufferDuration = TimeSpan.FromMilliseconds(100);
            _duration = _microphone.BufferDuration;
            numBytes = _microphone.GetSampleSizeInBytes(_microphone.BufferDuration);
            TimeSpan sample = TimeSpan.FromSeconds(1.0 / _microphone.SampleRate);
            int numBytesPerSample = _microphone.GetSampleSizeInBytes(sample);
            _buffer = new byte[numBytes];
            _microphone.BufferReady += new EventHandler<EventArgs>(MicrophoneBufferReady);

            stream = new MemoryStream();

            totalNumBytes = 0;
        }
開發者ID:jasonkuster,項目名稱:MetroLooper,代碼行數:16,代碼來源:Recorder.cs

示例15: Game1

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            // Extend battery life under lock.
            InactiveSleepTime = TimeSpan.FromSeconds(1);

            mic = Microphone.Default;
            mic.BufferDuration = TimeSpan.FromSeconds(1);
            audioBuffer = new byte[mic.GetSampleSizeInBytes(mic.BufferDuration)];
            mic.BufferReady += BufferIsReady;
        }
開發者ID:Vintharas,項目名稱:WP7projects,代碼行數:16,代碼來源:Game1.cs


注:本文中的Microsoft.Xna.Framework.Audio.Microphone類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。