Jump to content
  • Advertisement
Sign in to follow this  

OpenAl Tao Framework Not Making A Sound

This topic is 3971 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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
        ''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)
    End Sub

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

Can anybody see what is wrong Thanks Steve

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!