本文整理汇总了C#中NAudio.Wave.WaveInEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# WaveInEventArgs类的具体用法?C# WaveInEventArgs怎么用?C# WaveInEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WaveInEventArgs类属于NAudio.Wave命名空间,在下文中一共展示了WaveInEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WaveIn_DataAvailable
private void WaveIn_DataAvailable(object sender, WaveInEventArgs e)
{
if (RecordCallback != null)
{
RecordCallback(e.Buffer);
}
}
开发者ID:BrandonClapp,项目名称:babble,代码行数:7,代码来源:NAudioSoundEngine.cs
示例2: waveSource_DataAvailable
void waveSource_DataAvailable(object sender, WaveInEventArgs e)
{
if (File != null)
{
File.Write(e.Buffer, 0, e.BytesRecorded);
File.Flush();
}
}
开发者ID:Dryabadi,项目名称:WebMCam,代码行数:8,代码来源:Audio_Capture.cs
示例3: OnDataAvailable
private void OnDataAvailable(object sender, WaveInEventArgs e)
{
byte[] buffer = e.Buffer;
byte[] resampled = PcmUtilities.Resample(buffer, _waveIn.WaveFormat.SampleRate, (short)_waveIn.WaveFormat.BitsPerSample, (short)_waveIn.WaveFormat.Channels,
16000, 16, 1);
this.WriteAudio(resampled);
}
开发者ID:alejandroparra,项目名称:dotnet45-sdk,代码行数:7,代码来源:AudioInStream.cs
示例4: VoiceDataAvailable
private void VoiceDataAvailable(object sender, WaveInEventArgs e)
{
if (!_recording)
return;
//At the moment we're sending *from* the local user, this is kinda stupid.
//What we really want is to send *to* other users, or to channels. Something like:
//
// _connection.Users.First().SendVoiceWhisper(e.Buffer);
//
// _connection.Channels.First().SendVoice(e.Buffer, shout: true);
//if (_protocol.LocalUser != null)
// _protocol.LocalUser.SendVoice(new ArraySegment<byte>(e.Buffer, 0, e.BytesRecorded));
//Send to the channel LocalUser is currently in
if (_protocol.LocalUser != null && _protocol.LocalUser.Channel != null)
{
//_protocol.Connection.SendControl<>
_protocol.LocalUser.Channel.SendVoice(new ArraySegment<byte>(e.Buffer, 0, e.BytesRecorded));
}
//if (DateTime.Now.TimeOfDay.TotalMilliseconds - lastPingSendTime > 1000 || DateTime.Now.TimeOfDay.TotalMilliseconds < lastPingSendTime)
//{
// _protocol.Connection.SendVoice
//}
}
开发者ID:martindevans,项目名称:MumbleSharp,代码行数:27,代码来源:MicrophoneRecorder.cs
示例5: wavInStream_DataAvailable
static void wavInStream_DataAvailable(object sender, WaveInEventArgs e)
{
upStream.Write(e.Buffer, 0, e.BytesRecorded);
upStream.Flush();
// shell.Write(e.Buffer, 0, e.BytesRecorded);
//shell.Flush();
}
开发者ID:hapylestat,项目名称:StreamAudio,代码行数:7,代码来源:Program.cs
示例6: OnDataAvailable
void OnDataAvailable(object sender, WaveInEventArgs e)
{
if (!IsCapturing)
{
return;
}
// first save the audio
byte[] buffer = e.Buffer;
writer.WriteData(buffer, 0, e.BytesRecorded);
// now report each sample if necessary
for (int index = 0; index < e.BytesRecorded; index += 2)
{
short sample = (short)((buffer[index + 1] << 8) | buffer[index + 0]);
/* short sample2 = BitConverter.ToInt16(buffer, index);
Debug.Assert(sample == sample2, "Oops"); */
float sample32 = sample / 32768f;
if (OnSample != null)
{
OnSample(this, new SampleEventArgs(sample32, 0));
}
}
// close the recording if necessary
if (maxCaptureBytes != 0 && recordedStream.Length >= maxCaptureBytes)
{
CloseRecording();
}
}
开发者ID:Punloeu,项目名称:karaoke,代码行数:29,代码来源:AudioCapture.cs
示例7: sourceStreamDataAvailable
private void sourceStreamDataAvailable(object sender, WaveInEventArgs e)
{
string path = outputPath + "wavsam" + nFiles + ".wav";
writer = new WaveFileWriter(path, waveFormat);
writer.Write(e.Buffer, 0, e.Buffer.Length);
writer.Flush();
writer.Close();
nFiles++;
Process process = new Process();
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = "praatcon.exe";
String male;
if (isMale) male = "yes"; else male = "no";
process.StartInfo.Arguments = "extract_measures.praat " + path + " " + male;
// process.StartInfo.RedirectStandardOutput = true;
process.Start();
process.WaitForExit();
ResultEventArgs args = new ResultEventArgs();
// args.text = output;
OnResults(args);
// args.nWords = err.Length;
}
开发者ID:emreza,项目名称:speech_agent,代码行数:27,代码来源:Recorder.cs
示例8: OnDataAvailable
private void OnDataAvailable(object sender, WaveInEventArgs e)
{
if (e.BytesRecorded != 0)
{
var buffer = new byte[e.Buffer.Length*2];
int readSize = WaveFloatTo16(e.Buffer, e.BytesRecorded, buffer);
if (outputStream != null)
lock (outputStream)
{
DataPacket.CreateBuilder()
.SetDataPacketType(DataPacket.Types.DataPacketType.Audio)
.SetAudio(
Audio.CreateBuilder()
.SetSound(ByteString.CopyFrom(GZipCompress(buffer, readSize))) //compress
.Build()
).Build()
.WriteDelimitedTo(outputStream);
//outputStream.Flush();
}
else
{
StopRecording();
}
//Console.WriteLine("recording");
}
}
开发者ID:ZhuGongpu,项目名称:CloudX,代码行数:27,代码来源:AudioCaptureUtils.cs
示例9: InputBufferToFileCallback
public void InputBufferToFileCallback(object sender, WaveInEventArgs e)
{
writer.Write(e.Buffer,0, e.BytesRecorded);
// Console.WriteLine(e.BytesRecorded);
if (OnAudioData != null)
OnAudioData(e.Buffer, e.BytesRecorded);
}
开发者ID:stefan-j,项目名称:MPC-Streamer,代码行数:8,代码来源:Recorder.cs
示例10: RecorderOnDataAvailable
private void RecorderOnDataAvailable(object sender, WaveInEventArgs waveInEventArgs)
{
byte[] buffer = new byte[10000];
if (waveInEventArgs.BytesRecorded > 0 && !isWriterDisposed)
writer.Write(waveInEventArgs.Buffer, 0, waveInEventArgs.BytesRecorded);
if (waveInEventArgs.BytesRecorded == 0)
Dispose(); // auto-dispose in case users forget
}
开发者ID:styloInt,项目名称:SoundPcStream-SPS-,代码行数:8,代码来源:SoundPcStreamFORM.cs
示例11: waveIn_DataAvailable
static void waveIn_DataAvailable(object sender, WaveInEventArgs e)
{
for (int index = 0; index < e.BytesRecorded; index += 2)
{
float sample = (short)((e.Buffer[index + 1] << 8) | e.Buffer[index + 0]);
sample = Math.Max(0, sample / 32768f);
Metrics.Histogram("mic_noise", sample);
}
}
开发者ID:peppy,项目名称:Workability,代码行数:10,代码来源:main.cs
示例12: OnDataAvailable
private void OnDataAvailable(object sender, WaveInEventArgs e)
{
// the float values come in chunks of 4 bytes
// first left channel then right channel
for (int n = 0; n < e.Buffer.Length; n += 8) {
float lb = BitConverter.ToSingle(e.Buffer, n);
float rb = BitConverter.ToSingle(e.Buffer, n + 4);
sampleAggregator.Add(lb, rb);
}
}
开发者ID:pwfff,项目名称:M800-Visualizer,代码行数:10,代码来源:MainForm.cs
示例13: recordingStream_DataAvailable
//credit: http://channel9.msdn.com/coding4fun/articles/NET-Voice-Recorder
private void recordingStream_DataAvailable(object sender, WaveInEventArgs e)
{
waveWriter.Write(e.Buffer, 0, e.BytesRecorded);
for (int index = 0; index < e.BytesRecorded; index += 2)
{
short sample = (short)((e.Buffer[index + 1] << 8) |
e.Buffer[index + 0]);
float sample32 = sample / 32768f;
recordingData.Add(sample32);
}
}
开发者ID:iamnilay3,项目名称:COMP3931-SoundEditor,代码行数:12,代码来源:Recorder.cs
示例14: OnDataAvailable
private void OnDataAvailable(object sender, WaveInEventArgs waveInEventArgs)
{
if (_writer == null)
{
throw new NullReferenceException();
}
_writer.Write(waveInEventArgs.Buffer, 0, waveInEventArgs.BytesRecorded);
//byte[] by = Float32toInt16(waveInEventArgs.Buffer, 0, waveInEventArgs.BytesRecorded);
}
开发者ID:jcouv,项目名称:remote-audio,代码行数:11,代码来源:Program.cs
示例15: _wave_DataAvailable
void _wave_DataAvailable(object sender, WaveInEventArgs e)
{
Debug.WriteLine(e.BytesRecorded + " bytes, " + _sw.ElapsedTicks / TimeSpan.TicksPerMillisecond);
_sw.Reset();
_sw.Start();
byte[] clear = e.Buffer;
byte[] nonce;
byte[] cipher = _clientA.Encrypt(e.Buffer, 0, e.BytesRecorded, out nonce);
clear = _clientB.Decrypt(cipher, nonce);
_playback.AddSamples(clear, 0, clear.Length);
}
开发者ID:odinhaus,项目名称:Saltable,代码行数:11,代码来源:Form1.cs
示例16: ListenerDataAvailable
public void ListenerDataAvailable(object sender, WaveInEventArgs e)
{
double sample32 = 0.0;
for (int index = 0; index < e.BytesRecorded; index += 2)
{
short sample = (short)((e.Buffer[index + 1] << 8) |
e.Buffer[index + 0]);
sample32 = Math.Abs(sample / 32768.0);
}
change(sample32);
}
开发者ID:Alvionise,项目名称:launcher,代码行数:11,代码来源:MicroListener.cs
示例17: sourcestream_DataAvailable
private void sourcestream_DataAvailable(object notUsed, WaveInEventArgs e)
{
try
{
byte[] buffer = (e.Buffer);
sender.Send(buffer, buffer.Length);
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
开发者ID:Ikthios,项目名称:Communication-System,代码行数:12,代码来源:SendOutVoice.cs
示例18: update
private void update(object sender, WaveInEventArgs e)
{
byte[] buffer = e.Buffer;
double sum = .0;
for (int i = 0; i < buffer.Length; i += 2)
{
double sample = BitConverter.ToInt16(buffer, i) / 32768d;
sum += sample * sample;
}
double rms = Math.Sqrt(sum / buffer.Length / 2d);
lastPressure = 92.8 + 20d * Math.Log10(rms);
}
开发者ID:geakstr,项目名称:minobrlabs,代码行数:12,代码来源:MicrophoneSensor.cs
示例19: OnDataAvailable
void OnDataAvailable(Object sender, WaveInEventArgs e)
{
if (_measuring)
{
if (_measured >= 0)
{
_measurements.Add(e.Buffer.Take(e.BytesRecorded).ToArray());
}
_measured++;
}
}
开发者ID:FlorianRappl,项目名称:YAMP,代码行数:12,代码来源:Microphone.cs
示例20: CaptureOnDataAvailable
private void CaptureOnDataAvailable(object sender, WaveInEventArgs waveInEventArgs)
{
if (writer == null)
{
writer = new WaveFileWriter(Path.Combine(RecordingsViewModel.OutputFolder,
currentFileName),
capture.WaveFormat);
}
writer.Write(waveInEventArgs.Buffer, 0, waveInEventArgs.BytesRecorded);
UpdatePeakMeter();
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:13,代码来源:WasapiCaptureViewModel.cs
注:本文中的NAudio.Wave.WaveInEventArgs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论