本文整理汇总了C#中NAudio.Wave.WaveOut.Init方法的典型用法代码示例。如果您正苦于以下问题:C# WaveOut.Init方法的具体用法?C# WaveOut.Init怎么用?C# WaveOut.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NAudio.Wave.WaveOut
的用法示例。
在下文中一共展示了WaveOut.Init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Speaker
//------------------------------------------------------------------------------------------------------------------------
#endregion
#region Constructor
//------------------------------------------------------------------------------------------------------------------------
public Speaker()
{
waveout = new WaveOut();
bufferedWaveProvider = new BufferedWaveProvider(new WaveFormat(8000, 16, 2));
waveout.PlaybackStopped += Waveout_PlaybackStopped;
volumeProvider = new VolumeWaveProvider16(bufferedWaveProvider);
waveout.Init(volumeProvider);
}
示例2: PlaySound
public void PlaySound(string name, Action done = null)
{
FileStream ms = File.OpenRead(_soundLibrary[name]);
var rdr = new Mp3FileReader(ms);
WaveStream wavStream = WaveFormatConversionStream.CreatePcmStream(rdr);
var baStream = new BlockAlignReductionStream(wavStream);
var waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback());
waveOut.Init(baStream);
waveOut.Play();
var bw = new BackgroundWorker();
bw.DoWork += (s, o) =>
{
while (waveOut.PlaybackState == PlaybackState.Playing)
{
Thread.Sleep(100);
}
waveOut.Dispose();
baStream.Dispose();
wavStream.Dispose();
rdr.Dispose();
ms.Dispose();
if (done != null) done();
};
bw.RunWorkerAsync();
}
示例3: StartEncoding
void StartEncoding()
{
_startTime = DateTime.Now;
_bytesSent = 0;
_segmentFrames = 960;
_encoder = new OpusEncoder(48000, 1, OpusNet.OpusApplication.Voip);
_encoder.Bitrate = 8192;
_decoder = new OpusDecoder(48000, 1);
_bytesPerSegment = _encoder.FrameByteCount(_segmentFrames);
_waveIn = new WaveIn(WaveCallbackInfo.FunctionCallback());
_waveIn.BufferMilliseconds = 50;
_waveIn.DeviceNumber = comboBox1.SelectedIndex;
_waveIn.DataAvailable += _waveIn_DataAvailable;
_waveIn.WaveFormat = new WaveFormat(48000, 16, 1);
_playBuffer = new BufferedWaveProvider(new WaveFormat(48000, 16, 1));
_waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback());
_waveOut.DeviceNumber = comboBox2.SelectedIndex;
_waveOut.Init(_playBuffer);
_waveOut.Play();
_waveIn.StartRecording();
if (_timer == null)
{
_timer = new Timer();
_timer.Interval = 1000;
_timer.Tick += _timer_Tick;
}
_timer.Start();
}
示例4: Main
static void Main(string[] args)
{
string mp3FilesDir = Directory.GetCurrentDirectory();
if (args.Length > 0)
{
mp3FilesDir = args.First();
}
var waveOutDevice = new WaveOut();
var idToFile = Directory.GetFiles(mp3FilesDir, "*.mp3", SearchOption.AllDirectories).ToDictionary(k => int.Parse(Regex.Match(Path.GetFileName(k), @"^\d+").Value));
while (true)
{
Console.WriteLine("Wprowadz numer nagrania");
var trackId = int.Parse(Console.ReadLine());
using (var audioFileReader = new AudioFileReader(idToFile[trackId]))
{
waveOutDevice.Init(audioFileReader);
waveOutDevice.Play();
Console.ReadLine();
}
}
}
示例5: Main
static void Main(string[] args)
{
// for recording
waveFileWriter = new WaveFileWriter(@"C:\rec\out.wav", new WaveFormat(44100, 2));
var sound = new MySound();
sound.SetWaveFormat(44100, 2);
sound.init();
waveOut = new WaveOut();
waveOut.Init(sound);
waveOut.Play();
ConsoleKeyInfo keyInfo;
bool loop = true;
while (loop)
{
keyInfo = Console.ReadKey();
if (keyInfo.Key == ConsoleKey.Q)
{
waveOut.Stop();
waveOut.Dispose();
waveFileWriter.Close();
waveFileWriter.Dispose();
loop = false;
}
}
}
示例6: Initialise
public void Initialise(WaveFormat format, WaveOut driver)
{
if (driver == null)
{
throw new ArgumentNullException("driver", "Must specify a WaveIn device instance");
}
if (format == null)
{
throw new ArgumentNullException("format", "Must specify an audio format");
}
var caps = WaveOut.GetCapabilities(driver.DeviceNumber);
device = new WaveOutDeviceData
{
Driver = driver,
Name = caps.ProductName,
Channels = caps.Channels,
Buffers = new float[caps.Channels][]
};
Format = WaveFormat.CreateIeeeFloatWaveFormat(format.SampleRate, caps.Channels);
OutputBuffer = new BufferedWaveProvider(Format);
OutputBuffer.DiscardOnBufferOverflow = true;
driver.Init(OutputBuffer);
mapOutputs();
}
示例7: APU
public APU()
{
this.audioBuffer = new AudioBuffer();
NESWaveProvider nesWaveProvider = new NESWaveProvider(audioBuffer);
waveOut = new WaveOut();
waveOut.Init(nesWaveProvider);
}
示例8: Start
public void Start()
{
if (WaveIn.DeviceCount < 1)
throw new Exception("Insufficient input device(s)!");
if (WaveOut.DeviceCount < 1)
throw new Exception("Insufficient output device(s)!");
frame_size = toxav.CodecSettings.audio_sample_rate * toxav.CodecSettings.audio_frame_duration / 1000;
toxav.PrepareTransmission(CallIndex, false);
WaveFormat format = new WaveFormat((int)toxav.CodecSettings.audio_sample_rate, (int)toxav.CodecSettings.audio_channels);
wave_provider = new BufferedWaveProvider(format);
wave_provider.DiscardOnBufferOverflow = true;
wave_out = new WaveOut();
//wave_out.DeviceNumber = config["device_output"];
wave_out.Init(wave_provider);
wave_source = new WaveIn();
//wave_source.DeviceNumber = config["device_input"];
wave_source.WaveFormat = format;
wave_source.DataAvailable += wave_source_DataAvailable;
wave_source.RecordingStopped += wave_source_RecordingStopped;
wave_source.BufferMilliseconds = (int)toxav.CodecSettings.audio_frame_duration;
wave_source.StartRecording();
wave_out.Play();
}
示例9: Main
static void Main(string[] args)
{
var adj = new AdjustableTFunc {Value = 1600};
var tFuncWaveProvider = new TFuncWaveProvider
{
// Amplitude = TFunc.Sin(new Frequency(adj.TFunc))
// Amplitude = TFunc.Sin(new Frequency(t => TFuncs.Sin(Frequency.Hertz(1))(t) + 1000))
Amplitude = TFunc.Sin(TFunc.Sin(Frequency.Hertz(2)) + 1000)
};
var waveOut = new WaveOut();
waveOut.Init(tFuncWaveProvider);
waveOut.Play();
Console.WriteLine("Press q to kill");
char k;
while ((k = Console.ReadKey().KeyChar) != 'q')
{
if (k == 'u')
{
adj.Value+=10;
}
if (k == 'd')
{
adj.Value-=10;
}
Console.Write(" ");
Console.WriteLine(adj.Value);
}
waveOut.Stop();
waveOut.Dispose();
}
示例10: Play
public static Task Play(this Captcha captcha)
{
return Task.Run(() =>
{
using (MemoryStream memory = new MemoryStream(captcha.Data, false))
{
memory.Seek(0, SeekOrigin.Begin);
using (Mp3FileReader reader = new Mp3FileReader(memory))
using (WaveStream pcm = WaveFormatConversionStream.CreatePcmStream(reader))
using (WaveStream stream = new BlockAlignReductionStream(pcm))
{
using (WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
{
waveOut.Init(stream);
waveOut.Play();
while (waveOut.PlaybackState == PlaybackState.Playing)
{
Thread.Sleep(100);
}
}
}
}
});
}
示例11: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
byte[] apk, ask, bpk, bsk;
NaClClient.CreateKeys(out apk, out ask);
NaClClient.CreateKeys(out bpk, out bsk);
var hasher = System.Security.Cryptography.SHA256.Create();
_clientA = NaClClient.Create(apk, ask, bpk);
_clientB = NaClClient.Create(bpk, bsk, apk);
_sw = new Stopwatch();
_sw.Start();
_wave = new WaveIn(this.Handle);
_wave.WaveFormat = new WaveFormat(12000, 8, 1);
_wave.BufferMilliseconds = 100;
_wave.DataAvailable += _wave_DataAvailable;
_wave.StartRecording();
_playback = new BufferedWaveProvider(_wave.WaveFormat);
_waveOut = new WaveOut();
_waveOut.DesiredLatency = 100;
_waveOut.Init(_playback);
_waveOut.Play();
}
示例12: StartPlayback
private void StartPlayback()
{
masterMix = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(44100, 2));
foreach (var source in trackSources) masterMix.AddMixerInput(source);
outDevice = new WaveOut();
outDevice.Init(masterMix);
outDevice.Play();
}
示例13: playButton_Click
private void playButton_Click(object sender, EventArgs e)
{
waveOut = new WaveOut();
waveOut.PlaybackStopped += waveOut_PlaybackStopped;
reader = new WaveFileReader("sample.wav");
waveOut.Init(reader);
waveOut.Play();
}
示例14: Init
public void Init(string path)
{
durationStopwatch = new Stopwatch();
waveIn = new WasapiLoopbackCapture();
wri = new LameMP3FileWriter(@path + ".mp3", waveIn.WaveFormat, 32);
waveOut = new WaveOut();
waveOut.Init(new SilenceGenerator());
}
示例15: InitAudio
/// <summary>
/// Первоначальная инициализация звуковой системы
/// </summary>
public static void InitAudio()
{
player = new Player();
player.SetWaveFormat(SampleRate, 1);
waveOut = new WaveOut();
waveOut.DesiredLatency = 200; // длина буфера /2=50 миллисекунд
waveOut.Init(player);
}