本文整理汇总了C#中NAudio.Wave.WaveInEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# WaveInEventArgs类的具体用法?C# WaveInEventArgs怎么用?C# WaveInEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WaveInEventArgs类属于NAudio.Wave命名空间,在下文中一共展示了WaveInEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WaveIn_DataAvailable
private void WaveIn_DataAvailable(object sender, WaveInEventArgs e)
{
if (RecordCallback != null)
{
RecordCallback(e.Buffer);
}
}
示例2: waveSource_DataAvailable
void waveSource_DataAvailable(object sender, WaveInEventArgs e)
{
if (File != null)
{
File.Write(e.Buffer, 0, e.BytesRecorded);
File.Flush();
}
}
示例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);
}
示例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
//}
}
示例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();
}
示例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();
}
}
示例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;
}
示例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");
}
}
示例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);
}
示例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
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}