Quantcast
Channel: NAudio
Viewing all 5831 articles
Browse latest View live

New Post: Audio Format IEEE 64 bits

$
0
0

thanks for this. Have you tested them?


New Post: Audio Format IEEE 64 bits

$
0
0

Yes, of course, the audio is correct.

But may need to adjust the Length and Position property based.

New Post: Dsp Truespeech Play Stream

$
0
0

yes. i just duplicated your network chat demo. But in one second the buffer is getting full. and i hear a click sound in the beginning. 

Can you tell me how the bufferwaveprovider works? Is it like, the default length of the buffer is 5 seconds and as we play data from it, it gets emptied? or does the new data overwrites the buffer and whenever we call play on it, it plays whatever data is in it?

What im doing is, i call the following when the server gets connected. this is exactly the same code from network chat demo. other than discardonbufferoverflow and the remote endpoint.

this.codec = new TrueSpeechChatCodec();

 

waveOut = new WaveOut();
                                            waveProvider = new BufferedWaveProvider(codec.RecordFormat);
                                            waveProvider.DiscardOnBufferOverflow = true;
                                            waveOut.Init(waveProvider);
                                            waveOut.Play();
                                            connected = true;
					    ListenerThreadState state = new ListenerThreadState() { Codec = this.codec };
	 				    ThreadPool.QueueUserWorkItem(this.ListenerThread, state);

 

The above code gets called only once, i.e when the server gets connected. Then, whenever the server sends the truespeech data, i pass the data as string to a public variable. The variable is "PlayString" Then i assume the following code does add the data to the buffer from the public variable

 

class ListenerThreadState
        {
            public INetworkChatCodec Codec { get; set; }
        }

        private void ListenerThread(object state)
        {
            ListenerThreadState listenerThreadState = (ListenerThreadState)state;

            try
            {
                while (connected)
                {
                    byte[] b = Encoding.Default.GetBytes(this.PlayString);
                    byte[] decoded = listenerThreadState.Codec.Decode(b, 0, b.Length);

                    waveProvider.AddSamples(decoded, 0, decoded.Length);
                    
                }
            }
            catch (SocketException)
            {
                // usually not a problem - just means we have disconnected
            }
        }

This is the code i'm using. do you have any suggestion? this.codec = new TrueSpeechChatCodec();<-- is this particular line of code correct? I added the classes TrueSpeechChatCodec, INetworkChatCodec and AcmChatCodec to my project.

Forgot to mention, the data is 96 bytes. On debugging, the byte[] decoded, is of length 1440 bytes.

New Post: Dsp Truespeech Play Stream

$
0
0

BufferedWaveProvider uses a circular buffer, with a read position and a write position, so everything written to it gets read out unless the buffer overflows. Where is your incoming stream coming from? If it is a file, then it is quite possible it is downloading so fast that the buffer fills up and overflows. If it is a realtime stream, then you ought not to get too many problems with overflow. BufferedWaveProvider can be set up to have a longer buffer time if needed (e.g. 30 seconds or more).

What WaveFormat are you passing into the BufferedWaveProvider? The WaveFormat should be the decoded (i.e. PCM) WaveFormat. I have no idea whether those numbers are correct for the formats you are working with. You could compare them with the byte[] sizes in the NAudioDemo

New Post: Dsp Truespeech Play Stream

$
0
0

as i mentioned earlier, im passing in dsp truespeech waveformat. I tried setting a longer buffer time too. no use still. im getting the truespeech data with a length of 96 bytes from a server in realtime with a delay of 100 ms. In the following code 

while (connected)
                {
                    byte[] b = Encoding.Default.GetBytes(this.PlayString);
                    byte[] decoded = listenerThreadState.Codec.Decode(b, 0, b.Length);

                    waveProvider.AddSamples(decoded, 0, decoded.Length);
                    
                }

PlayString.Length = 96 bytes

Length of "b" is 96 bytes

Length of "decoded" is 1440 bytes.

New Post: Dsp Truespeech Play Stream

$
0
0

the WaveFormat of the BufferedWaveProvider must not be Truespeech. It must be PCM. It has to be the exact decoded WaveFormat from the Codec.

New Post: Dsp Truespeech Play Stream

$
0
0

ok so how do i decode truespeech to pcm and pass it on to the bufferedwaveprovider? im a total newbie in codes and stuffs like that. sry.

i know you already mentioned to use rawwavesource stream. but i really dunno how to.

Source code checked in, #4d10e8a8ccdd

$
0
0
added Pcm32BitToSampleProvider and WaveToSampleProvider64 provided by ManuN on the forums

New Post: Audio Format IEEE 64 bits

New Post: Format audio PCM 32 Bits

New Post: Dsp Truespeech Play Stream

$
0
0

To debug audio codecs I recommend doing things offline first. So save some incoming audio to a raw .dat file. Then use the RawStreamSource and WaveFileConversionStream to try to convert it to PCM, writing it out with a WaveFileWriter. Listen to the resulting WAV file and see if it sounds right. Only once you are sure you are decoding audio properly are you ready to try and play it back on the fly

New Post: Newbie Asio Playback Question

$
0
0

If you use the NAudioDemo application, can you play and stop ASIO without it stuttering?

New Post: Dsp Truespeech Play Stream

$
0
0

using the following code the sound is playing.

 

using (MemoryStream ms = new MemoryStream(Encoding.Default.GetBytes(dataToPlay)))
            {
                RawSourceWaveStream rws = new RawSourceWaveStream(ms, tspf);

                WaveFormatConversionStream pcmStream = (WaveFormatConversionStream)WaveFormatConversionStream.CreatePcmStream(rws);

                waveOut.Init(pcmStream);
            }

can you tell me how to decode dsp truespeech to pcm in realtime?

 

New Post: Dsp Truespeech Play Stream

$
0
0

The way to do it is the way that the NAudio chat demo does it. If you are feeding audio into the buffered wave provider in the correct format then it will play

New Post: Audio Format IEEE 64 bits

$
0
0

Ok, :-)

I tested the length and position properties in your demo part.

The properties work correctly.


New Post: Overlapping .wav files in NAudio

$
0
0

Ok i tried it with that but now it says that the streams must be in IEEE format. Ive seen the discussion on it but I have no idea where to edit this source. Is there an alternative to allow me to do this?

New Post: Newbie Asio Playback Question

$
0
0

Hi Mark.

Yes, when I load the demo "AsioDirectDemo" and stop, there is no stutter. I used the code from that demo in a new test. and converted that into vb.net, but it stutters.

Sorry again for be such a noob at this. Maybe it's something I'm not converting right?

Here's the converted code from that panel. I put the panel controls on a form, and used the converted code:

 

Imports NAudio.Wave

Public Class Form1
    Private reader As WaveFileReader
    Private asioOut As AsioOut
    Public Sub New()
        InitializeComponent()
        AddHandler Disposed, AddressOf AsioDirectPanel_Disposed
        For Each device In AsioOut.GetDriverNames()
            Me.comboBoxAsioDevice.Items.Add(device)
        Next device
        If Me.comboBoxAsioDevice.Items.Count > 0 Then
            Me.comboBoxAsioDevice.SelectedIndex = 0
        End If
    End Sub

    Private Sub AsioDirectPanel_Disposed(ByVal sender As Object, ByVal e As EventArgs)
        Cleanup()
    End Sub

    Private Sub Cleanup()
        If Me.asioOut IsNot Nothing Then
            Me.asioOut.Dispose()
            Me.asioOut = Nothing
        End If
        If Me.reader IsNot Nothing Then
            Me.reader.Dispose()
            Me.reader = Nothing
        End If
    End Sub

    Private Sub buttonSelectFile_Click_1(sender As System.Object, e As System.EventArgs) Handles buttonSelectFile.Click
        Cleanup()
        Dim ofd As New OpenFileDialog()
        ofd.Filter = "WAV files|*.wav"
        If ofd.ShowDialog() = DialogResult.OK Then
            Me.reader = New WaveFileReader(ofd.FileName)
        End If
    End Sub

    Private Sub buttonPlay_Click(ByVal sender As Object, ByVal args As EventArgs) Handles buttonPlay.Click
        Try
            Play()
        Catch e As Exception
            MessageBox.Show(e.Message)
        End Try
    End Sub

    Private Function GetUserSpecifiedChannelOffset() As Integer
        Dim channelOffset As Integer = 0
        Integer.TryParse(textBoxChannelOffset.Text, channelOffset)
        Return channelOffset
    End Function

    Private Sub Play()
        ' allow change device
        If Me.asioOut IsNot Nothing AndAlso (Me.asioOut.DriverName <> comboBoxAsioDevice.Text OrElse Me.asioOut.ChannelOffset <> GetUserSpecifiedChannelOffset()) Then
            Me.asioOut.Dispose()
            Me.asioOut = Nothing
        End If

        ' create device if necessary
        If Me.asioOut Is Nothing Then
            Me.asioOut = New AsioOut(comboBoxAsioDevice.Text)
            Me.asioOut.ChannelOffset = GetUserSpecifiedChannelOffset()
            Me.asioOut.Init(Me.reader)
        End If

        Me.reader.Position = 0
        Me.asioOut.Play()
        Me.Timer1.Enabled = True
        SetButtonStates()
    End Sub

    Private Sub SetButtonStates()
        buttonPlay.Enabled = asioOut IsNot Nothing AndAlso asioOut.PlaybackState <> PlaybackState.Playing
        buttonStop.Enabled = asioOut IsNot Nothing AndAlso asioOut.PlaybackState = PlaybackState.Playing
    End Sub

    Private Sub buttonStop_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonStop.Click
        Me.Stop()
    End Sub

    Private Sub [Stop]()
        Me.asioOut.Stop()
        Me.Timer1.Enabled = False
        SetButtonStates()
    End Sub

    Private Sub timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
        If asioOut IsNot Nothing AndAlso asioOut.PlaybackState = PlaybackState.Playing AndAlso reader.Position >= reader.Length Then
            Me.Stop()
        End If
    End Sub
End Class

Created Issue: ASIO number of channels [16365]

$
0
0
Hello,
I do not understand why the properties NumberOfInputChannel NumberofOutputChannel ASIO drivers and was always zero while the function getChannels is correct.
So I added a few lines in the class ASIOOut, according to InifromName properties that are functional.

private void initFromName(String driverName)
{
// Get the basic driver
ASIODriver basicDriver = ASIODriver.GetASIODriverByName(driverName);

// Add Channels Number
int nbchannelin;
int nbchannelout;
basicDriver.getChannels(out nbchannelin, out nbchannelout);

NumberOfInputChannels = nbchannelin;
NumberOfOutputChannels = nbchannelout;

// Instantiate the extended driver
driver = new ASIODriverExt(basicDriver);
this.ChannelOffset = 0;
}

there is little to be another way for these parameters!

Commented Issue: ASIO number of channels [16365]

$
0
0
Hello,
I do not understand why the properties NumberOfInputChannel NumberofOutputChannel ASIO drivers and was always zero while the function getChannels is correct.
So I added a few lines in the class ASIOOut, according to InifromName properties that are functional.

private void initFromName(String driverName)
{
// Get the basic driver
ASIODriver basicDriver = ASIODriver.GetASIODriverByName(driverName);

// Add Channels Number
int nbchannelin;
int nbchannelout;
basicDriver.getChannels(out nbchannelin, out nbchannelout);

NumberOfInputChannels = nbchannelin;
NumberOfOutputChannels = nbchannelout;

// Instantiate the extended driver
driver = new ASIODriverExt(basicDriver);
this.ChannelOffset = 0;
}

there is little to be another way for these parameters!
Comments: I did the test with a SoundCard maudio Profire610 is the modification works

Edited Issue: ASIO number of channels [16365]

$
0
0
Hello,
I do not understand why the properties NumberOfInputChannel NumberofOutputChannel ASIO drivers and was always zero while the function getChannels is correct.
So I added a few lines in the class ASIOOut, function InifromName, properties that are functional.

private void initFromName(String driverName)
{
// Get the basic driver
ASIODriver basicDriver = ASIODriver.GetASIODriverByName(driverName);

// Add Channels Number
int nbchannelin;
int nbchannelout;
basicDriver.getChannels(out nbchannelin, out nbchannelout);

NumberOfInputChannels = nbchannelin;
NumberOfOutputChannels = nbchannelout;

// Instantiate the extended driver
driver = new ASIODriverExt(basicDriver);
this.ChannelOffset = 0;
}

there is little to be another way for these parameters!
Viewing all 5831 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>