locked
Playing a MIDI file

Answers

  • Hi Nate,

     

    Please ensure you have done the following:

     

    1. The DirectX 9.0c has been installed.
    DirectX 9.0c Redistributable

    DirectX 9.0 SDK Update

     

    2. Add References to your project.

        Microsoft.DirectX.dll

        Microsoft.DirectX.AudioVideoPlayback.dll

     

    3. Imports these namespaces.

       Imports Microsoft.DirectX
       Imports Microsoft.DirectX.AudioVideoPlayback

     

    Then please try Jeff's code. It works fine on my computer too.

     

    Best regards,

    Martin

    Tuesday, October 16, 2007 7:43 AM
  • I don't know what causes such an error but maybe it is the way you have the code written or where you have placed it.

     

    I use this format and i have never had any trouble with it.

     

    Imports Microsoft.DirectX

    Imports Microsoft.DirectX.AudioVideoPlayback

     

    Public Class Form1

     

    Dim song As Audio

     

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

    song = New Audio(FileIO.SpecialDirectories.Desktop & "\test.mid", True)

    End Sub

     

    End Class

    Sunday, October 14, 2007 5:13 PM
  • The loader lock is a common problem with Managed DirectX and has been posted about several times, here is a link to one such post on The Zbuffer. (http://www.thezbuffer.com/articles/304.aspx)

     

    Sunday, October 14, 2007 10:21 PM

All replies

  • Have a look at the following link, it should have a solution that will help. (http://www.vb-helper.com/index_multimedia.html)

    Friday, October 12, 2007 2:42 AM
  • When I try to use the code from that site, I get a LoaderLock exception.

    The exception:
    DLL 'C:\WINDOWS\assembly\GAC\Microsoft.DirectX\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

    My code:
    Code Block

    Dim Player As New Microsoft.DirectX.AudioVideoPlayback.Audio(FileIO.SpecialDirectories.Desktop & "\test.mid")
    Player.Play()

    The first line caused the error.
    How do I fix this error?
    Saturday, October 13, 2007 3:55 PM
  • I don't know what causes such an error but maybe it is the way you have the code written or where you have placed it.

     

    I use this format and i have never had any trouble with it.

     

    Imports Microsoft.DirectX

    Imports Microsoft.DirectX.AudioVideoPlayback

     

    Public Class Form1

     

    Dim song As Audio

     

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

    song = New Audio(FileIO.SpecialDirectories.Desktop & "\test.mid", True)

    End Sub

     

    End Class

    Sunday, October 14, 2007 5:13 PM
  • The loader lock is a common problem with Managed DirectX and has been posted about several times, here is a link to one such post on The Zbuffer. (http://www.thezbuffer.com/articles/304.aspx)

     

    Sunday, October 14, 2007 10:21 PM
  • From the information in that link it sounds like there is not an exact reason for this error to occur.

    Sunday, October 14, 2007 10:28 PM
  • I got rid of the exception, but the file still doesn't play!
    Monday, October 15, 2007 1:03 AM
  • Hi Nate,

     

    Please ensure you have done the following:

     

    1. The DirectX 9.0c has been installed.
    DirectX 9.0c Redistributable

    DirectX 9.0 SDK Update

     

    2. Add References to your project.

        Microsoft.DirectX.dll

        Microsoft.DirectX.AudioVideoPlayback.dll

     

    3. Imports these namespaces.

       Imports Microsoft.DirectX
       Imports Microsoft.DirectX.AudioVideoPlayback

     

    Then please try Jeff's code. It works fine on my computer too.

     

    Best regards,

    Martin

    Tuesday, October 16, 2007 7:43 AM
  • I got it working.
    Tuesday, October 16, 2007 9:03 PM
  • I found out why it wasn't working.  The volume was set to around -9000!  I had to set the volume to 0.  Why does DirectX store the previous volume setting, even between runs of the application?
    Wednesday, October 17, 2007 9:00 PM
  • I believe it is changing your system volume

    Wednesday, October 17, 2007 10:11 PM
  • Yes, it is because windows media player changed the volume.  Why are the volumes negative?
    Thursday, October 18, 2007 1:03 AM
  • I don't know the exact reason for that.

    I kind of have an idea as to the logic behind it though.

    0 is a mid point in referring to a balance

    I think of the 0 as being an acceptable mid point in the volume.

    More like a starting point in the volume.  Not too high, not too low.

    Above this will be positive and below will be negative.

     

    In terms of balance (left and right)  you can't really use left and right as a value.  It is number based.

    you have to have a minimum which is a negative number on the left side, a maximum which is a positive number on the right side and an equal balance between both which is 0.

     

    Of course you could use any range of numbers to represent this but positive and negative with a mid point or balance of 0 would be easier to follow as a standard.

     

    It is possible i could be way off here but this is how i look at it.

     

    Thursday, October 18, 2007 2:48 AM
  •  Nate879 wrote:

    Why are the volumes negative?

     

    This blog article may be helpful to you.

     

    What's in an audio volume?

    http://blogs.msdn.com/larryosterman/archive/2005/06/15/429437.aspx

    "When you deal with volumes in pro audio equipment, volume is measured by two factors - attenuation and amplification.  0 means that the sound is playing at its native level, negative numbers are reductions in volume from that native level, and positive numbers indicate amplification. 

    For most computer hardware, volume is measured as attenuations - negative numbers running from 0 (max volume) to -infinity (0 volume).  In practice, the number runs from 0 to -96dB.  Typically computers don't ever amplify signals, just attenuate them."

     

    DirectX volume control

    Thursday, October 18, 2007 3:05 AM