This project has moved. For the latest updates, please go here.

Complete Newbie haveing some problems

Mar 2, 2010 at 3:10 PM

Hi

I have just stumbled across your libary and am having some problems getting it to play G711 RTP Packets

I have created a class that inherites the bits i think it needs and reports the waveformat as Return WaveFormat.CreateALawFormat(8000, 1)

I have a event that fires when a new RTp packet arrives and i then run this code

Dim b As WaveStream

        b = WaveFormatConversionStream.CreatePcmStream(New G711_Wave_Stream(packet.DataPointer))
        Dim c As New WaveChannel32(b, 1000, 0)

        waveOutDevice.Init(c)

        waveOutDevice.Play()

I think i have something wrong as my app crashes after a few packets and you dont hear anything out of the speakers

Thanks for any help in advance

 

Colin

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font><font size="2" color="#0000ff">

 

</font>

 

Coordinator
Mar 3, 2010 at 11:07 AM

when you say "crashes", do you get an exception?

Mar 3, 2010 at 11:30 AM

Hi

Thanks for the responce

I have solved the problem it was my missunderstanding of the way to use the libary

Another question i have is does the libary support any other Codec's? eg G.723

Thanks

Colin

Coordinator
Mar 3, 2010 at 11:31 AM

NAudio uses ACM (audio compression manager) for WaveFormatConversionStream, so it depends if you have an ACM encoder/decoder installed for G.723. I have certainly used it for G.723 and G.728 so it is possible.

Mark

Mar 3, 2010 at 11:55 AM

Hi

Thats brilliant news :) thanks for your help

I may be bothering you in the future

 

Colin

Mar 4, 2010 at 11:41 AM

Hi

Im not as working as i thought i was

Currently i have my RTP data coming into my app in packets of 80 Bytes using G711A

My code is currently for whan a packet arrives is

Dim c As New WaveFormatConversionStream(WaveFormat.CreateCustomFormat(WaveFormatEncoding.Pcm, 8000, 1, 16000, 2, 16), New G711_Wave_Stream(packet.DataPointer))

        'b = WaveFormatConversionStream.CreatePcmStream()

        playData = New WaveChannel32(c, 2.0, 1.0)

        waveOutDevice.Init(playData)

        waveOutDevice.Play()
I have also created a class call G711_Wave_Stream and the code is as follows
Public Class G711_Wave_Stream
    Inherits WaveStream

    Private Data() As Byte
    Private Pos As Long

    Public Sub New(ByVal Input() As Byte)
        Data = Input
    End Sub

    Public Overrides ReadOnly Property Length() As Long
        Get
            Return Data.Length
        End Get
    End Property

    Public Overrides Property Position() As Long
        Get
            Return Pos
        End Get
        Set(ByVal value As Long)
            Pos = value
        End Set
    End Property

    Public Overrides Function Read(ByVal buffer() As Byte, ByVal offset As Integer, ByVal count As Integer) As Integer
        Array.Copy(Data, 0, buffer, offset, Data.Length - 1)
        Return Data.Length
    End Function

    Public Overrides ReadOnly Property WaveFormat() As NAudio.Wave.WaveFormat
        Get
            Dim a As WaveFormat
            a = WaveFormat.CreateALawFormat(8000, 1)
            Return a
        End Get
    End Property
End Class
When audio arrives it comes out the speakers by all grabled and not ledgeable I think i have a problem when the audio is being uncompressed and a lack of knodlege of your libary
Any help will be much apeciated
Colin
Mar 8, 2010 at 11:10 AM

Hi

 

I have been playing with this a bit more and think i have found the problem but i dont know how to impiment it

My input form my RTP source is G711A @ 64000K with 16bit samples but im not sure how to tell the ACM decoder these options to decode the input correctly

 

Please can anyone help?

 

Colin

Coordinator
Mar 11, 2010 at 3:09 PM

that is always the challenge with compression formats - finding the correct WaveFormat structure. If you can get hold of a valid WAV file containing G711A data, you can look at its contents in a hex editor to work out what the WaveFormat structure should  look like. With any luck it won't require any "extra bytes"

Mark