本文整理汇总了C#中NAudio.Wave.WaveOut类的典型用法代码示例。如果您正苦于以下问题:C# WaveOut类的具体用法?C# WaveOut怎么用?C# WaveOut使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WaveOut类属于NAudio.Wave命名空间,在下文中一共展示了WaveOut类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:yodiwo,项目名称:plegma,代码行数:13,代码来源:Speaker.cs
示例2: AudioPlayer
public AudioPlayer(DiscordVoiceConfig __config)
{
config = __config;
callbackInfo = WaveCallbackInfo.FunctionCallback();
outputDevice = new WaveOut(callbackInfo);
bufferedWaveProvider = new BufferedWaveProvider(new WaveFormat(48000, 16, config.Channels));
}
开发者ID:thedanieldude1,项目名称:DanielCode,代码行数:7,代码来源:Program.cs
示例3: Stop
public void Stop()
{
if (WaveOut != null)
{
WaveOut.Stop();
WaveOut.Dispose();
WaveOut = null;
}
if (WaveChannel != null)
{
WaveChannel.Dispose();
WaveChannel = null;
}
if (WaveFileReader != null)
{
WaveFileReader.Dispose();
WaveFileReader = null;
}
if (Mp3FileReader != null)
{
Mp3FileReader.Dispose();
Mp3FileReader = null;
}
}
开发者ID:michaelbehner96,项目名称:Xyzzxyz,代码行数:27,代码来源:PureSoundButton.cs
示例4: 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();
}
开发者ID:guozanhua,项目名称:KinectGestures,代码行数:25,代码来源:MainWindow.xaml.cs
示例5: PlayAudioFromConnection
private void PlayAudioFromConnection(TcpClient client)
{
var inputStream = new BufferedStream(client.GetStream());
var bufferedWaveProvider = new BufferedWaveProvider(waveFormat);
var savingWaveProvider = new SavingWaveProvider(bufferedWaveProvider, "temp.wav");
var player = new WaveOut();
player.Init(savingWaveProvider);
player.Play();
while (client.Connected)
{
if (terminate)
{
client.Close();
break;
}
var available = client.Available;
if (available > 0)
{
var buffer = new byte[available];
var bytes = inputStream.Read(buffer, 0, buffer.Length);
bufferedWaveProvider.AddSamples(buffer, 0, bytes);
Console.WriteLine("{0} \t {1} bytes", client.Client.RemoteEndPoint, bytes);
}
}
player.Stop();
savingWaveProvider.Dispose();
}
开发者ID:duszekmestre,项目名称:MoN.Messenger,代码行数:32,代码来源:AudioRecorder.cs
示例6: Form1
public Form1()
{
_serialPort.PortName = "COM6";
_serialPort.BaudRate = 9600;
_serialPort.Parity = Parity.None;
_serialPort.DataBits = 8;
_serialPort.StopBits = StopBits.Two;
_serialPort.Handshake = Handshake.None;
_serialPort.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
_serialPort.Open();
//Set up audio outputs
jaws[0] = new WaveOut();
jaws[1] = new WaveOut();
jaws[2] = new WaveOut();
var jawsAudio1 = new WaveChannel32(new WaveFileReader("Sounds/Jaws3.wav"));
jaws[0].Init(jawsAudio1);
var jawsAudio2 = new LoopStream(new WaveFileReader("Sounds/Jaws2.wav"));
jaws[1].Init(jawsAudio2);
var jawsAudio3 = new LoopStream(new WaveFileReader("Sounds/Jaws1.wav"));
jaws[2].Init(jawsAudio3);
//Set the shark to a random position
resetShark();
InitializeComponent();
}
开发者ID:jackgllghr,项目名称:CS422Assignment3,代码行数:29,代码来源:Form1.cs
示例7: 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();
}
开发者ID:kstaruch,项目名称:Toxy,代码行数:30,代码来源:ToxCall.cs
示例8: 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();
}
}
}
开发者ID:onliner10,项目名称:FiszkiPlayer,代码行数:27,代码来源:Program.cs
示例9: TriggerPanel
public TriggerPanel()
{
InitializeComponent();
mWaveOut = new WaveOut();
mWaveOut.PlaybackStopped += new EventHandler(mWaveOut_PlaybackStopped);
AppController.Instance().AddPanel(this);
}
开发者ID:hellslinger,项目名称:SimpleSampler,代码行数:7,代码来源:TriggerPanel.xaml.cs
示例10: WaveFormat
private WaveFormat _waveFormat = new WaveFormat(8000, 16, 1); // The format that both the input and output audio streams will use, i.e. PCMU.
#endregion Fields
#region Constructors
public AudioChannel()
{
// Set up the device that will play the audio from the RTP received from the remote end of the call.
m_waveOut = new WaveOut();
m_waveProvider = new BufferedWaveProvider(_waveFormat);
m_waveOut.Init(m_waveProvider);
m_waveOut.Play();
// Set up the input device that will provide audio samples that can be encoded, packaged into RTP and sent to
// the remote end of the call.
m_waveInEvent = new WaveInEvent();
m_waveInEvent.BufferMilliseconds = 20;
m_waveInEvent.NumberOfBuffers = 1;
m_waveInEvent.DeviceNumber = 0;
m_waveInEvent.DataAvailable += RTPChannelSampleAvailable;
m_waveInEvent.WaveFormat = _waveFormat;
// Create a UDP socket to use for sending and receiving RTP packets.
int port = FreePort.FindNextAvailableUDPPort(DEFAULT_START_RTP_PORT);
_rtpEndPoint = new IPEndPoint(_defaultLocalAddress, port);
m_rtpChannel = new RTPChannel(_rtpEndPoint);
m_rtpChannel.OnFrameReady += RTPChannelSampleReceived;
_audioLogger.Debug("RTP channel endpoint " + _rtpEndPoint.ToString());
}
开发者ID:sipsorcery,项目名称:sipsorcery,代码行数:31,代码来源:AudioChannel.cs
示例11: 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();
}
开发者ID:gareththegeek,项目名称:ndaw,代码行数:30,代码来源:WaveOutputMapper.cs
示例12: APU
public APU()
{
this.audioBuffer = new AudioBuffer();
NESWaveProvider nesWaveProvider = new NESWaveProvider(audioBuffer);
waveOut = new WaveOut();
waveOut.Init(nesWaveProvider);
}
开发者ID:brandonpelfrey,项目名称:dotnes,代码行数:7,代码来源:APU.cs
示例13: 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();
}
开发者ID:odinhaus,项目名称:Saltable,代码行数:27,代码来源:Form1.cs
示例14: CreateDevice
public IWavePlayer CreateDevice(int latency)
{
IWavePlayer device;
WaveCallbackStrategy strategy = _waveOutSettingsPanel.CallbackStrategy;
if (strategy == WaveCallbackStrategy.Event)
{
WaveOutEvent waveOut = new WaveOutEvent
{
DeviceNumber = _waveOutSettingsPanel.SelectedDeviceNumber,
DesiredLatency = latency
};
device = waveOut;
}
else
{
WaveCallbackInfo callbackInfo = strategy == WaveCallbackStrategy.NewWindow ? WaveCallbackInfo.NewWindow() : WaveCallbackInfo.FunctionCallback();
WaveOut outputDevice = new WaveOut(callbackInfo)
{
DeviceNumber = _waveOutSettingsPanel.SelectedDeviceNumber,
DesiredLatency = latency
};
device = outputDevice;
}
// TODO: configurable number of buffers
return device;
}
开发者ID:akimoto-akira,项目名称:Pulse,代码行数:27,代码来源:WaveOutFactory.cs
示例15: 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();
}
开发者ID:rmichela,项目名称:Acoustico,代码行数:33,代码来源:Program.cs
示例16: 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);
}
}
}
}
});
}
开发者ID:amacal,项目名称:ine,代码行数:26,代码来源:AudioExtensions.cs
示例17: MainForm
public MainForm()
{
var start = DateTime.Now.Millisecond;
InitializeComponent();
this.DoubleBuffered = true;
_isPlay = false;
listViewMusicCollection.View = View.Details;
listViewMusicCollection.AllowColumnReorder = true;
listViewMusicCollection.GridLines = false;
//listViewMusicCollection.Columns.Add("№");
listViewMusicCollection.Columns.Add("File Name");
listViewMusicCollection.Columns.Add("Extension");
listViewMusicCollection.Columns.Add("asd");
listViewMusicCollection.Columns.Add("12423");
listViewMusicCollection.AllowDrop = true;
listViewMusicCollection.DragDrop += listViewMusicCollection_DragDrop;
listViewMusicCollection.DragEnter += listViewMusicCollection_DragEnter;
_listViewLoadr = new ListViewLoader(listViewMusicCollection);
_listViewLoadr.DirectoryPath = @"example\";
_listViewLoadr.GetItemToWrite = new ListViewLoader.GetItemDelegat( (fileInfo) => {
return new object[]{fileInfo.Name, fileInfo.Extension}; });
_listViewLoadr.Load();
_mainMenuLoader = new MainMenuLoader(this.MainMenu);
_mainMenuLoader.Load();
_waveOut = new WaveOut();
var tt = DateTime.Now.Millisecond - start;
System.Diagnostics.Debug.WriteLine(tt);
}
开发者ID:rusden220,项目名称:Mp3Player,代码行数:33,代码来源:MainForm.cs
示例18: 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();
}
开发者ID:VirusFree,项目名称:Opus.NET,代码行数:33,代码来源:Form1.cs
示例19: 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;
}
}
}
开发者ID:ryo-okabayashi,项目名称:sound,代码行数:27,代码来源:Program.cs
示例20: 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);
}
开发者ID:Sirozha84,项目名称:Retro-Tracker,代码行数:11,代码来源:Audio.cs
注:本文中的NAudio.Wave.WaveOut类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论