Jump to content
  • Advertisement
Sign in to follow this  
DarkRayne

Game Programming and MIDI sound

This topic is 3318 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 all, I very new to the programming and gameprogramming field. I am currently at the American sentinel online school. I have a basic game programming class that uses the Michael Morrison Beginning Game Programming book. I have an assignment in it that uses MIDI windows code that the book doesnt go through in much detail. I am trying to add music to my code that was given by the school. Whenever i compile i get the error : cannot convert from 'const char [10]' to 'LPCWSTR' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast its at mciOpenParms.lpstrDeviceType = "sequencer"; in my code. Is anyone familiar with this error? Should I post more code? Any help is much appeciated.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by DarkRayne
: cannot convert from 'const char [10]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


its at

mciOpenParms.lpstrDeviceType = "sequencer";


Long
Pointer
Constant
Wide
STRing

so it's the wide part that is causing you trouble that means you're working with unicode. in this case the string you pass is a char[] but it expect a wchar_t[] instead.

try with:

mciOpenParms.lpstrDeviceType = TEXT("sequencer");

instead of TEXT() you could use _T()
if you have problem compiling that try including <tchar.h>

basically those are macros that returns the string as a wide (unicode) one if you are working with unicode or as normal (ansi) string if you are not. That means if _UNICODE is defined or not.

To force it to be a unicode string you need to write it like this: L"Hello Word"

Functions from one type won't work on the other.

you should try using tchar.h functions wich calls the according function depending on _UNICODE, that way you won't have problems working with strings.


EDIT: here is a webpage explaining how to use TCHAR
http://www.flipcode.com/archives/Advanced_String_Techniques_in_C-Part_I_Unicode.shtml

[Edited by - ZaHgO on April 22, 2009 3:07:03 AM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!