Sign in to follow this  
Steve5050

OpenAl Tao Framework Not Making A Sound

Recommended Posts

Hi, I'm using vb.net 2003 and the tao framework I'm trying to get the audio part going, my test project is not working:
 Private Shared buffer As Integer
    Private Shared source As Integer
    Private Shared sourcePosition() As Single = {0, 0, 0}
    Private Shared sourceVelocity() As Single = {0, 0, 0}
    Private Shared listenerPosition() As Single = {0, 0, 0}
    Private Shared listenerVelocity() As Single = {0, 0, 0}
    Private Shared listenerOrientation() As Single = {0, 0, -1, 0, 1, 0}

 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
 Alut.alutInit()
        Alut.alutGetError()
        Me.LoadALData()
        Me.SetListenerValues()
End Sub

   Private Shared Function LoadALData() As Boolean
        ' Variables to load into.
        Dim format As Integer
        Dim size As Integer
        Dim data As IntPtr = IntPtr.Zero
        Dim frequency As Single
        'int loop;

        ' Generate an OpenAL buffer.
        Al.alGenBuffers(1, buffer)
        If Al.alGetError() <> Al.AL_NO_ERROR Then
            Return False
        End If

        ' Attempt to locate the file.
        Dim fileName As String = Application.StartupPath & "\...\Data\OpenAlExamples.Lesson01.FancyPants.wav"
        ''If File.Exists(fileName) Then
        ''fileName = fileName
        ''ElseIf File.Exists("Data/" & fileName) Then
        ''fileName = "Data/" & fileName
        ''ElseIf File.Exists("../../Data/" & fileName) Then
        ''fileName = "../../Data/" & fileName
        ''Else
        ''Return False
        ''End If

        ' Load wav.
        data = Alut.alutLoadMemoryFromFile(fileName, format, size, frequency)
        If data.Equals(IntPtr.Zero) Then
            Return False
        End If

        ' Load wav data into the generated buffer.
        Al.alBufferData(buffer, format, data, size, CInt(Fix(frequency)))
        ' Alut.alutUnloadWAV(format, out data, size, frequency);

        ' Generate an OpenAL source.
        Al.alGenSources(1, source)
        If Al.alGetError() <> Al.AL_NO_ERROR Then
            Return False
        End If

        ' Bind the buffer with the source.
        Al.alSourcei(source, Al.AL_BUFFER, buffer)
        Al.alSourcef(source, Al.AL_PITCH, 1.0F)
        Al.alSourcef(source, Al.AL_GAIN, 1.0F)
        Al.alSourcefv(source, Al.AL_POSITION, sourcePosition)
        Al.alSourcefv(source, Al.AL_VELOCITY, sourceVelocity)
        Al.alSourcei(source, Al.AL_LOOPING, 0)

        ' Do a final error check and then return.
        If Al.alGetError() = Al.AL_NO_ERROR Then
            Return True
        End If

        Return False
    End Function
    Private Shared Sub SetListenerValues()
        Al.alListenerfv(Al.AL_POSITION, listenerPosition)
        Al.alListenerfv(Al.AL_VELOCITY, listenerVelocity)
        Al.alListenerfv(Al.AL_ORIENTATION, listenerOrientation)
    End Sub
    Private Shared Sub KillALData()
        Al.alDeleteBuffers(1, buffer)
        Al.alDeleteSources(1, source)
        Alut.alutExit()
    End Sub

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Al.alSourcePlay(source)
    End Sub


Can anybody see what is wrong Thanks Steve

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this