本文整理汇总了C#中Microsoft.Xna.Framework.Audio.Microphone类的典型用法代码示例。如果您正苦于以下问题:C# Microphone类的具体用法?C# Microphone怎么用?C# Microphone使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Microphone类属于Microsoft.Xna.Framework.Audio命名空间,在下文中一共展示了Microphone类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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
示例6: 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
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例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
示例16: StopCapture
public void StopCapture()
{
try
{
if (_microphone != null)
{
_baBuffer = new byte[0];
_microphone.BufferReady -= MicrophoneBufferReady;
_microphone.Stop();
_microphone = null;
}
}
catch (Exception)
{
}
}
开发者ID:Bootz,项目名称:VoIP_Project_Archives_Testing,代码行数:16,代码来源:AudioDeviceResource.cs
示例17: RecordAudio
public bool RecordAudio()
{
try
{
StopRequested = false;
if (microphone == null)
{
microphone = Microphone.Default;
}
sampleRate = microphone.SampleRate;
microphone.BufferDuration = TimeSpan.FromMilliseconds(100);
buffer = new byte[microphone.GetSampleSizeInBytes(microphone.BufferDuration)];
microphone.BufferReady += new EventHandler<EventArgs>(Microphone_BufferReady);
stream = new MemoryStream(1048576);
stream.SetLength(0);
WriteWavHeader(microphone.SampleRate);
dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(33);
dispatcherTimer.Tick += delegate
{
try
{
Microsoft.Xna.Framework.FrameworkDispatcher.Update();
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine("FrameworkDispatcher :" + ex.Message);
}
};
dispatcherTimer.Start();
Microsoft.Xna.Framework.FrameworkDispatcher.Update();
microphone.Start();
System.Diagnostics.Debug.WriteLine("Started Recording");
return true;
}
catch (System.Exception ex)
{
System.Diagnostics.Debug.WriteLine("RecordAudio :" + ex.Message);
return false;
}
}
开发者ID:praveenmohanmm,项目名称:PurposeColor_Bkp_Code,代码行数:45,代码来源:AudioRecorder.cs
示例18: StartCapture
public void StartCapture()
{
try
{
if (_microphone == null)
{
_microphone = Microphone.Default;
_microphone.BufferDuration = TimeSpan.FromMilliseconds(100);
var sampleSize = _microphone.GetSampleSizeInBytes(_microphone.BufferDuration);
_baBuffer = new byte[sampleSize];
_microphone.BufferReady += MicrophoneBufferReady;
_microphone.Start();
}
}
catch (Exception)
{
}
}
开发者ID:Bootz,项目名称:VoIP_Project_Archives_Testing,代码行数:18,代码来源:AudioDeviceResource.cs
示例19: MicRecorder
public MicRecorder()
{
worker.WorkerReportsProgress = true;
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
_microphone = Microphone.Default;
/*
* The duration of the capture buffer must be between 100ms and 1000ms. Additionally, the capture buffer must be 10ms aligned (BufferDuration % 10 == 0).
* Silverlight applications must ensure that FrameworkDispatcher.Update is called regularly in order for "fire and forget" sounds to work correctly.
* BufferDuration throws an InvalidOperationException if FrameworkDispatcher.Update has not been called at least once before making this call.
* For more information, see Enable XNA Framework Events in Windows Phone Applications.
*/
_microphone.BufferDuration = TimeSpan.FromMilliseconds(100);
_duration = _microphone.BufferDuration;
_bufferSize = _microphone.GetSampleSizeInBytes(_microphone.BufferDuration);
_microphone.BufferReady += new EventHandler<EventArgs>(MicrophoneBufferReady);
}
开发者ID:vetoketju,项目名称:WP-Noteradar,代码行数:19,代码来源:MicRecorder.cs
示例20: MicrophoneButton
private MicrophoneButton(Microphone microphone)
{
FrameworkDispatcher.Update();
var minSupportedBufferDurationMs = 100;
var duration = TimeSpan.FromMilliseconds(minSupportedBufferDurationMs);
Microphone = microphone;
Microphone.BufferDuration = duration;
Buffer = new byte[Microphone.GetSampleSizeInBytes(duration)];
Buffer2D = new Color[TexWidth * byte.MaxValue];
Texture2D = Texture2D ?? Program.Renderer.LeaseFor<Gray, byte>(TexWidth, byte.MaxValue);
Texture2D.SetData(Buffer2D);
Microphone.BufferReady += OnBufferReady;
Microphone.Start();
}
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:20,代码来源:MicrophoneButton.cs
注:本文中的Microsoft.Xna.Framework.Audio.Microphone类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论