Music

This is a discussion on Music within the C++ Programming forums, part of the General Programming Boards category; Your post earlier generates errors. Thanks...

  1. #16
    Registered User
    Join Date
    Jul 2007
    Posts
    75
    Your post earlier generates errors. Thanks

  2. #17
    Registered User
    Join Date
    Jul 2007
    Posts
    75
    Here is the code that I used (the code stated by you in an earlier post)
    Code:
    #include <windows.h>
    #include <cstdio>
    
    int main(int argc, char **argv)
    {
    	BOOL f;
    	f = PlaySound("c:\\Fanfare.wav", 0, SND_FILENAME);
    	if (!f) 
    		printf("Error\n");
    	else
    		printf("Done!\n");
    	return 0;
    }
    Here is the compile log:
    ------ Build started: Project: soundtest3, Configuration: Debug Win32 ------
    Compiling...
    soundtest3.cpp
    c:\documents and settings\mom\my documents\visual studio 2008\projects\soundtest3\soundtest3\soundtest3.cpp (7) : error C2664: 'PlaySoundW' : cannot convert parameter 1 from 'const char [15]' to 'LPCWSTR'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    Build log was saved at "file://c:\Documents and Settings\Mom\My Documents\Visual Studio 2008\Projects\soundtest3\soundtest3\Debug\BuildLog .htm"
    soundtest3 - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    I have the Fanfare.wav file on my C drive in not specific folder. I attempted to use PlaysoundA and still received errors.

    Thanks Very Much

  3. #18
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by MaGaIn View Post
    Here is the code that I used (the code stated by you in an earlier post)
    Code:
    #include <windows.h>
    #include <cstdio>
    
    int main(int argc, char **argv)
    {
    	BOOL f;
    	f = PlaySound("c:\\Fanfare.wav", 0, SND_FILENAME);
    	if (!f) 
    		printf("Error\n");
    	else
    		printf("Done!\n");
    	return 0;
    }
    Here is the compile log:
    ------ Build started: Project: soundtest3, Configuration: Debug Win32 ------
    Compiling...
    soundtest3.cpp
    c:\documents and settings\mom\my documents\visual studio 2008\projects\soundtest3\soundtest3\soundtest3.cpp (7) : error C2664: 'PlaySoundW' : cannot convert parameter 1 from 'const char [15]' to 'LPCWSTR'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    Build log was saved at "file://c:\Documents and Settings\Mom\My Documents\Visual Studio 2008\Projects\soundtest3\soundtest3\Debug\BuildLog .htm"
    soundtest3 - 1 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    I have the Fanfare.wav file on my C drive in not specific folder. I attempted to use PlaysoundA and still received errors.

    Thanks Very Much
    Well, I've already posted a working version. However, if you compile with Unicode enabled [as it seems you do], then you need to use the appropriate "make unicode out of text-string" such as TEXT("some text") or _T("some text") [those are both doing the same thing, and I can't remember which you use for which type of application - try one, and if it doesn't work, use the other.

    The latter code I posted works on my machine without errors and warnings (using Visual Studio .Net), but it's entirely possible to set the compile flags or otherwise change settings. You also need to set the right library to be linked in, either using the pragma setting that you have in your example, or using the "additional libraries" in the linker tab on Visual Studios project properties page.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone saves us from music
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 78
    Last Post: 07-02-2008, 09:59 AM
  2. Music Programming - Serial Matrix Display (Help needed)
    By CrazyHorse in forum C Programming
    Replies: 1
    Last Post: 11-13-2007, 04:28 PM
  3. Music Programming - Serial Matrix Display
    By CrazyHorse in forum C Programming
    Replies: 1
    Last Post: 11-12-2007, 04:16 PM
  4. Is AOL music crazy?
    By joeprogrammer in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 03-24-2006, 07:24 PM
  5. crashing when switch music type
    By lambs4 in forum Game Programming
    Replies: 7
    Last Post: 05-03-2004, 01:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21