本文整理汇总了C#中IWavePlayer类的典型用法代码示例。如果您正苦于以下问题:C# IWavePlayer类的具体用法?C# IWavePlayer怎么用?C# IWavePlayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWavePlayer类属于命名空间,在下文中一共展示了IWavePlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainForm
public MainForm()
{
waveOutDevice = null;
mainOutputStream = null;
volumeStream = null;
InitializeComponent();
}
示例2: PianoSynth
public PianoSynth()
{
mixer = new WaveMixerStream32();
mixer.AutoStop = false;
int i = 0;
foreach (var note in noteFiles)
{
reader[i] = new WaveFileReader(note);
offsetStream[i] = new WaveOffsetStream(reader[i]);
channelSteam[i] = new WaveChannel32(offsetStream[i]);
channelSteam[i].Position = channelSteam[i].Length;
mixer.AddInputStream(channelSteam[i]);
i++;
}
if (waveOutDevice == null)
{
waveOutDevice = new WaveOut {DeviceNumber = 0};
waveOutDevice.Init(mixer);
waveOutDevice.Volume = 0;
waveOutDevice.Play();
waveOutDevice.Volume = 100;
}
}
示例3: Load
public bool Load(string path, Guid device)
{
var cext = path.GetExt();
_myWaveOut = new DirectSoundOut(device);
try
{
_myWaveStream = _codecs.First(v => v.Extensions.Contains(cext)).CreateWaveStream(path);
}
catch
{
return false;
}
if (_myWaveStream == null) return false;
if (_myWaveStream.WaveFormat.Channels == 2)
{
_myBalanceSampleProvider = new BalanceSampleProvider(_myWaveStream.ToSampleProvider());
_myVolumeSampleProvider = new VolumeSampleProvider(_myBalanceSampleProvider);
_myBalanceSampleProvider.Pan = (float)Balance;
}
else _myVolumeSampleProvider = new VolumeSampleProvider(_myWaveStream.ToSampleProvider());
_myEqualizer = new Equalizer(_myVolumeSampleProvider, _equalizerBands) { Enabled = _enableEqualizer };
_myWaveOut.Init(_myEqualizer);
_myWaveOut.PlaybackStopped += MyWaveOutOnPlaybackStopped;
_myVolumeSampleProvider.Volume = (float)Volume;
return true;
}
示例4: Play
private async void Play()
{
if (reader == null)
{
return;
}
if (player == null)
{
// Exclusive mode - fails with a weird buffer alignment error
//player = new MediaElementOut(MediaElement);
player = new WasapiOutRT(AudioClientShareMode.Shared, 200);
player.PlaybackStopped += PlayerOnPlaybackStopped;
}
if (player.PlaybackState != PlaybackState.Playing)
{
reader.Seek(0, SeekOrigin.Begin);
await player.Init(reader);
player.Play();
StopCommand.IsEnabled = true;
PauseCommand.IsEnabled = true;
}
}
示例5: playWave
/// <summary>
/// Lejátszik egy .mp3 fájlt
/// </summary>
/// <param name="audioFile">.mp3 fájl</param>
public static void playWave(string audioFile)
{
thread = new WaveOut();
stream = CreateInputStream(audioFile);
thread.Init(stream);
thread.Play();
}
示例6: play_Click
private void play_Click(object sender, EventArgs e)
{
if (playlist.SelectedItems.Count>0)
{
id = fn.IndexOf(playlist.SelectedItem.ToString());
if (waveOutDevice.PlaybackState.ToString() != "Paused")
{
t.Stop();
stp();
audioFileReader = new AudioFileReader(fp[id]);
waveOutDevice = new WaveOut();
waveOutDevice.Init(audioFileReader);
trackbar.Maximum = (int)audioFileReader.TotalTime.TotalSeconds + 1;
//deb.Items.Add(audioFileReader.TotalTime.Seconds.ToString());
audioFileReader.Volume = (float)vol.Value / 100;
waveOutDevice.Play();
t.Start();
}
else
{
waveOutDevice.Play();
t.Start();
}
}
}
示例7: CreateWaveOut
private void CreateWaveOut()
{
CloseWaveOut();
int latency = 300;
_waveOut = SelectedOutputAudioDeviceFactory.CreateDevice(latency);
_waveOut.PlaybackStopped += OnPlaybackStopped;
}
示例8: Connect
private void Connect(IPEndPoint endPoint, int inputDeviceNumber, INetworkChatCodec codec)
{
waveIn = new WaveIn();
waveIn.BufferMilliseconds = 50;
waveIn.DeviceNumber = inputDeviceNumber;
waveIn.WaveFormat = codec.RecordFormat;
waveIn.DataAvailable += waveIn_DataAvailable;
waveIn.StartRecording();
udpSender = new UdpClient();
udpListener = new UdpClient();
// To allow us to talk to ourselves for test purposes:
// http://stackoverflow.com/questions/687868/sending-and-receiving-udp-packets-between-two-programs-on-the-same-computer
udpListener.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
udpListener.Client.Bind(endPoint);
udpSender.Connect(endPoint);
waveOut = new WaveOut();
waveProvider = new BufferedWaveProvider(codec.RecordFormat);
waveOut.Init(waveProvider);
waveOut.Play();
connected = true;
var state = new ListenerThreadState { Codec = codec, EndPoint = endPoint };
ThreadPool.QueueUserWorkItem(ListenerThread, state);
}
示例9: AudioPlaybackEngine
public AudioPlaybackEngine(int sampleRate = 44100, int channelCount = 2)
{
outputDevice = new WaveOutEvent();
mixer = new MixingSampleProvider(WaveFormat.CreateIeeeFloatWaveFormat(sampleRate, channelCount));
mixer.ReadFully = true;
outputDevice.Init(mixer);
outputDevice.Play();
}
示例10: PlayFile
public int PlayFile(string filename)
{
waveOutDevice = new WaveOut();
mainOutputStream = CreateInputStream(filename);
waveOutDevice.Init(mainOutputStream);
waveOutDevice.Play();
return 0;
}
示例11: Audio
public Audio(string filename)
{
this.fileName = filename;
waveOutDevice = new DirectSoundOut(50);
mainOutputStream = CreateInputStream(filename);
waveOutDevice.Init(mainOutputStream);
isPlaying = false;
}
示例12: frmMain_FormClosing
private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (this._player.PlaybackState == PlaybackState.Playing)
this._player.Stop();
this._player.Dispose();
this._player = null;
}
示例13: Dispose
public void Dispose()
{
Stop();
if (playbackDevice != null)
{
playbackDevice.Dispose();
playbackDevice = null;
}
}
示例14: Stop
private void Stop()
{
if (waveOut != null)
{
this.patternSequencer = null;
waveOut.Dispose();
waveOut = null;
}
}
示例15: AudioPlaya
public AudioPlaya(string filename) {
waveOutDevice = new WaveOut();
waveOutDevice.Init(stream = loadFromFile(filename));
waveOutDevice.PlaybackStopped += (object sender, StoppedEventArgs e) =>
{
if (Finished != null)
Finished(this);
};
}