CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97

    Playing Sounds with C#

    I am working on a small app that will be playing a variety of audio files. I found that by importing winmm.dll, I can play a few wav files OK:

    [DllImport("winmm.dll")]
    public static extern long PlaySound(String lpszName, long hModule, long dwFlags);

    However, with my limited amount of audio and/or media experience, I was wondering if there is something better. Maybe something with more functions available instead of just PlaySound()...just an overall better way to do it. I even only found this DllImport from a sample application somewhere else, so I can't even say I have something to compare with yet. ;P

    If it matters, my plan is to really just play wav and mp3 files. Any help would be great.

    Thanks

  2. #2
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    OR...

    I am willing to utilize a TTS engine if the speaking sounds "human". I downloaded and ran a sample app from the Microsoft Speech SDK 5.1, but it literally sounds like an archaic PC talking to you. Are there other voices I am able to use? Is anyone familiar with implementing this?

    Thanks

  3. #3
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    that's true,
    but COOL is to use
    DirectX capabilities.

    check out DirectX SDK on MSDN.


    Paresh
    - Software Architect

  4. #4
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    Has anyone personally tried installing the DirectX SDK 9.0? I am having the hardest time trying to find the Microsoft.DirectX.xxxxx assemblies. Nothing will compile, it says that the namespace DirectX does not exist in the class or namespace 'Microsoft'. So, I went ahead and installed the SDK again...no luck. I THEN decided to just install the SDK for C#...didn't work either. Any ideas? Am I completely missing something here?

    I'm running VS .NET 2003 Final Beta w/ the .NET Framework 1.1 if it matters.

  5. #5
    Join Date
    Jul 2002
    Location
    .NET 2.0/.NET 3.0/.NET 3.5 VS2005/VS2008
    Posts
    284
    I definitly recommend using DirectX 9, there's a managed version of the runtime aviable at MSDN.

    I used it for my mp3 player
    WM.

    What about weapons of mass construction?

  6. #6
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    That's what I've got...it isn't working though.

    It's like it didn't register the components when it was installed or something, but I've reinstalled it 5 times now without any luck.

  7. #7
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    first you should always try out some samples and debug it before even making of your own. I think directX samples do work.

    Paresh
    - Software Architect

  8. #8
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    Maybe I'm not being clear...NOTHING works. I can't even start the debuug process because it can't find any of the DirectX assemblies. They are displayed in the Assembly Cache when I go into the .NET Configuration though.

  9. #9
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    then you might be forgeting
    the reference part.
    go in your project settings.
    and on solution add project reference and add that DirectX assembly.

    Paresh
    - Software Architect

  10. #10
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    At least we're on the same wavelength here now. ;P I tried that, but the assembly is not able to be added, because I don't know where it is. I searched my entire system and couldn't find it, even though it shows up in my assembly cache. I was able to find a "Managed DirectX" directory with a lot of xml files in it, but after adding the directory (C:\WINDOWS\Microsoft.NET\Managed DirectX\v4.09.00.0900) to my references path in the project, it still failed. I'm really at a loss here because I haven't ran into this sort of problem before. Usually I just add the reference and everything works. And by the way, I'm actually just using a sample right now. I haven't even thought about using my own app yet.

  11. #11
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    you could try other examples like using
    winmm as a reference and it will give you a control. you can use that GUI control in your application




    PAresh
    - Software Architect

  12. #12
    Join Date
    Oct 2002
    Location
    Atlanta, GA
    Posts
    97
    Yeah, that's pretty much what I've decided to go with since I can't get the DirectX to work. Oh well, thanks for your time anyway, I appreciate it.

  13. #13
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    if you get it working then give party
    lol

    - Software Architect

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured