MCI Command strings

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Anteater

MCI Command strings

Post by Anteater »

Hi. I'm using Irrlicht for graphics, and MCI strings for sound (they support midi), And I have run into a problem. The only time I can get music/sound to play is at the very start of the console. Any ideas?

Code:
//////////INCLUDE//////////////////////////////////////////////////////////////
#include <stdio.h>
#include <irrlicht.h>
#include <windows.h>
#include <math.h>
#include <mmsystem.h>

///////NAMESPACES//////////////////////////////////////////////////////////////
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

///////////////////DEFINE INT VALUES///////////////////////////////////////////
int resxset = 640;
int resyset = 480;
int globalswitch = 0;
int lvlstrt = 0;


///////////////////DEFINE FUNCTIONS////////////////////////////////////////////

/////////SET SOME POINTERS FOR WINDOW POSITION AND DEVICE//////////////////////
IrrlichtDevice *deviceIrr = 0;
s32 cnt = 0;


/////////////////EVENTS////////////////////////////////////////////////////////
class MenuEventR : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* guienv = deviceIrr->getGUIEnvironment();
switch (event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if (id == 0000000004)
{
if (globalswitch == 0)
{

}
}
if (id == 0000000003)
{
if (globalswitch == 0)
{
IGUIWindow *window1 = guienv->addWindow(rect<s32>(cnt+200,cnt+250,cnt+400,cnt+400),false,L"HELP");
guienv->addStaticText(L"Eric the Anteater and the Elixer of Life\n\nThis software is based in part on the work of the Independent JPEG Group.\n\nProgrammer........Josh Stevens\nSpecial Thanks....Guest",rect<s32>(20,25,180,130),1,1,window1);
}
}
if (id == 0000000002)
{
if (globalswitch == 0)
{
globalswitch = 1;
}
}
if (id == 0000000001)
{
if (globalswitch == 0)
{
deviceIrr->closeDevice();
return true;
}
}
break;
}
}
return false;
}
};




///MAIN////////////////////////////////////////////////////////////////////////
main()
{

///////////////////////////////CONSOLE/////////////////////////////////////////
mciSendString("play mid1.mid",NULL,0,NULL);
printf ("Title\n");
system ("pause");

////////////////START ENGINE///////////////////////////////////////////////////
deviceIrr =
createDevice(video::EDT_OPENGL, core::dimension2d<s32>(resxset, resyset), 32, true, true, true,0);

//////SET WINDOW CAPTION AND SET POINTERS//////////////////////////////////////
deviceIrr->setWindowCaption(L"Eric the Anteater and the Elixer of Life");
IVideoDriver* driver = deviceIrr->getVideoDriver();
ISceneManager* smgr = deviceIrr->getSceneManager();
IGUIEnvironment* guienv = deviceIrr->getGUIEnvironment();

///////////EVENT RECEIVER//////////////////////////////////////////////////////
MenuEventR receiver1;
deviceIrr->setEventReceiver(&receiver1);

///////////////LOAD PK3 FILEs//////////////////////////////////////////////////
deviceIrr->getFileSystem()->addZipFileArchive("pak1.pk3");

////LOAD LEVELS////////////////////////////////////////////////////////////////

////////////////////////SET NO MIPMAPS AND LOAD TEXTURES///////////////////////
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
video:: ITexture* ericlogo1 = driver->getTexture("eric3.bmp");

///////////////////ADD GUI BUTTONS/////////////////////////////////////////////
guienv->addStaticText (L"DEVELOPED BY DECAPITATION GAMES", rect<int>(0,2,195,12), false);
guienv->addButton (rect<s32>(160,420,240,445),0,0000000004,L"LOAD");
guienv->addButton (rect<s32>(400,390,480,415),0,0000000001,L"QUIT");
guienv->addButton (rect<s32>(160,390,240,415),0,0000000002,L"START");
guienv->addButton (rect<s32>(400,420,480,445),0,0000000003,L"ABOUT");
//////////////SOUND////////////////////////////////////////////////////////////


///GAMEPLAY////////////////////////////////////////////////////////////////////


////////////DO EVERYTHING//////////////////////////////////////////////////////
while(deviceIrr->run())
{
driver->beginScene(true, true, SColor(0,255,255,255));

if (globalswitch == 0)
{
driver->draw2DImage(ericlogo1, core::position2d<s32>(0,0),
core::rect<s32>(0, 0, 640, 480), 0,
video::SColor(1, 255, 255, 255), true);
}
if (globalswitch == 1)
{
if (lvlstrt == 0)
{
smgr->addCameraSceneNodeFPS();
lvlstrt = 1;
}
}
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
deviceIrr->drop();
return 0;
}

///////////////////END/////////////////////////////////////////////////////////
Guest

Post by Guest »

Maybe DirextX gets in the way? MCI seems to be built on top of DirectX, maybe it conflicts somehow?
If you move your mci play command to the line just after the createdevice call, does it work?

Maybe the mci play command does not stop until you explicitly send a stop command?

system("pause") just waits for a keypress, but I assume you know that.

It's difficult to see what's wrong with your sound code if you don't post any (other than that initial mci command), by the way.
Guest

Post by Guest »

Although I don't have an answer to your problem. I thought I might suggest that you take a look at FMOD http://www.fmod.org/ which has the ability to play MIDI files.
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

It looks like you are loading the sound before the device. That will cause you problems. I, like the answer above, would suggest you load your app before you load your sound. I load my sound files last.
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
Post Reply