Thank you for reply.
Is there any libraries for filter noise?
Is there any libraries for filter noise?
public void Play(string uri)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
}
private void GetResponseCallback(IAsyncResult asynchronousResult)
{
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
Stream responseStream = response.GetResponseStream();
StreamReader streamRead = new StreamReader(responseStream);
var waveFormat = new WaveFormat(8000, 16, 1);
var bufferedWaveProvider = new BufferedWaveProvider(waveFormat);
bufferedWaveProvider.BufferDuration = TimeSpan.FromMilliseconds(200);
var waveOut = new WasapiOutRT(AudioClientShareMode.Shared, 100);
waveOut.Init(() => bufferedWaveProvider);
waveOut.Play();
byte[] buffer = new byte[800];
while (true)
{
var sizeRead = streamRead.BaseStream.Read(buffer, 0, buffer.Length);
if (sizeRead > 0 && bufferedWaveProvider.BufferLength - bufferedWaveProvider.BufferedBytes > sizeRead)
{
bufferedWaveProvider.AddSamples(buffer, 0, sizeRead);
}
}
}
var webRequest = WebRequest.Create(uri);
using (var webResponse = (HttpWebResponse)webRequest.GetResponse())
{
using (var responseStream = new StreamReader(webResponse.GetResponseStream()))
{
var waveFormat = new WaveFormat(8000, 16, 1);
var bufferedWaveProvider = new BufferedWaveProvider(waveFormat);
bufferedWaveProvider.BufferDuration = TimeSpan.FromMilliseconds(200);
var waveOut = new WaveOutEvent();
waveOut.DesiredLatency = 100;
waveOut.Init(bufferedWaveProvider);
waveOut.Play();
byte[] buffer = new byte[800];
while (true)
{
if (bufferedWaveProvider.BufferLength - bufferedWaveProvider.BufferedBytes > buffer.Length)
{
if (responseStream.Peek() > -1 && responseStream.BaseStream.Read(buffer, 0, buffer.Length) > 0)
{
bufferedWaveProvider.AddSamples(buffer, 0, buffer.Length);
await Task.Delay(1, cancellationToken.Token);
}
}
}
}
}
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
Stream responseStream = response.GetResponseStream();
StreamReader streamRead = new StreamReader(responseStream);
var waveFormat = new WaveFormat(4000, 16, 1);
var bufferedWaveProvider = new BufferedWaveProvider(waveFormat);
bufferedWaveProvider.BufferDuration = TimeSpan.FromMilliseconds(1000);
var waveOut = new WasapiOutRT(AudioClientShareMode.Shared, 100);
waveOut.Init(() => bufferedWaveProvider);
waveOut.Play();
byte[] buffer = new byte[800];
while (true)
{
if (bufferedWaveProvider.BufferLength - bufferedWaveProvider.BufferedBytes > buffer.Length)
{
var bufferSize = streamRead.BaseStream.Read(buffer, 0, buffer.Length);
if (bufferSize > 0 && bufferedWaveProvider.BufferLength - bufferedWaveProvider.BufferedBytes > bufferSize)
bufferedWaveProvider.AddSamples(buffer, 0, bufferSize);
}
}
Please note that this provided correct audio for a 8000hz audio stream from disk and also a 8000hz network audio stream. If you have suggestions on improving this code, by all means. Thanks!Private Sub ComboASIO_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboASIO.SelectedIndexChanged
' Hold the current device index in case of failure.
Dim CurrentIndex = ComboASIO.SelectedIndex
Try
Dim Asio = New AsioOut(ComboASIO.SelectedIndex)
Dim outputs = Asio.DriverOutputChannelCount
' load the outputs from the selected device
ComboASIOOutputs.Items.Clear()
For output = 0 To outputs - 1
ComboASIOOutputs.Items.Add(Asio.AsioOutputChannelName(output))
Next
If ComboASIOOutputs.Items.Count > 0 Then ComboASIOOutputs.SelectedIndex = 0
Catch ex As Exception
MsgBox(ComboASIO.Text & " Error: " & ex.Message, vbOKOnly + vbInformation, "Set ASIO Device")
Exit Sub
End Try
End Sub
Private Sub ComboASIOOutputs_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboASIOOutputs.SelectedIndexChanged
'**** need code here to make the selected output (or output pair) the target for playback.
End Sub
wave = New NAudio.Wave.WaveFileReader(Filename)
Dim output = New AsioOut(ComboASIO.Text)
output.ChannelOffset = ComboASIOOutputs.SelectedIndex
output.Init(New NAudio.Wave.WaveChannel32(wave))
output.Play()
And the mono/stereo thing is irrelevant, hitting the left hits both anyway so it's a non issue.Hello Sir,
I have developed one player using NADUIO and its working fine, but now I have got a small problem. where the compressed Wave file cannot be played through waveoutevent player, as I am getting an error stating “NoDriver calling acmFormatSuggest”. So, Kindly let me know how to play the compressed Wave file using WAVEOUTEVENT player.
Thank’s in Advance!!!
Thank You.
Athivarathan.S
+91-9500351051