C Board  

Go Back   C Board > General Programming Boards > Game Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 02-15-2006, 04:20 AM   #1
Supermassive black hole
 
ahluka's Avatar
 
Join Date: Jul 2005
Location: South Wales, UK
Posts: 1,709
FMOD Decides it doesn't want to...

I've decided to use FMOD after deciding I don't like OpenAL (don't ask) and twas all going fine, but sometimes it just decides not to load the sound files.

This snippet works, but only sometimes:

Code:
result = fmod_system->createStream ("\\Condensed.mp3", FMOD_DEFAULT, 0, &sound);
if (result != FMOD_OK) {
    cout << "\tFAILED\n";
    exit (1);
}
It works fine (Condensed.mp3 is in the same directory) but sometimes it just fails. If I change the file I want to load - even when it's in the same place - it sometimes doesn't work. The funny thing is it always works if I place the file in the root directory (C:\\ for example).

Anyone have a similar problem?
__________________
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

- Mike McShaffry
ahluka is offline   Reply With Quote
Old 02-15-2006, 04:26 AM   #2
Registered User
 
Join Date: May 2004
Posts: 1,362
does removing the '\\' make a difference?
sand_man is offline   Reply With Quote
Old 02-15-2006, 04:27 AM   #3
Supermassive black hole
 
ahluka's Avatar
 
Join Date: Jul 2005
Location: South Wales, UK
Posts: 1,709
Nope I get the same problem.
EDIT: When it doesn't load it from the same dir, if I move it to C:\\Condensed.mp3 then it loads it, and I re-compile it using "\\Condensed.mp3", it suddenly can see it.
__________________
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

- Mike McShaffry
ahluka is offline   Reply With Quote
Old 02-15-2006, 04:46 AM   #4
Registered User
 
Join Date: Jun 2004
Posts: 134
Then you could get the path to your exe and then strcat \\Condensed.mp3. I had to do that once for something can't quite remember what though.
__________________
New to the BBS? Go Here:
http://postingandyou.info/

I'll bet I get flamed for this.
~Kyo~ is offline   Reply With Quote
Old 02-15-2006, 04:47 AM   #5
Supermassive black hole
 
ahluka's Avatar
 
Join Date: Jul 2005
Location: South Wales, UK
Posts: 1,709
Ok I'll try that.
EDIT: I assume there's a winAPI call to get that - to save me hard coding it?
__________________
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

- Mike McShaffry

Last edited by ahluka; 02-15-2006 at 04:49 AM.
ahluka is offline   Reply With Quote
Old 02-15-2006, 05:29 AM   #6
Super Moderator
 
Bubba's Avatar
 
Join Date: Aug 2001
Posts: 7,819
This will play MP3's through DirectShow. Most of the source originates from Special Effects Game Programing with DirectX 8. All it needs is a window handle.

Code:
#ifndef CDXSHOWWND
#define CDXSHOWWND

#include <dshow.h>

class CDXShowWnd
{
  protected:
    IGraphBuilder *m_pGraph;
    IVideoWindow  *m_pVidWnd;
    IMediaControl *m_pMedia;
    IMediaEvent   *m_pEvent;


    HWND          m_Hwnd;
  public:
    CDXShowWnd(void):m_pGraph(NULL),m_pVidWnd(NULL),m_Hwnd(0) {}
    virtual ~CDXShowWnd(void)
    {
      ShutDown();
    }

    void Create(HWND hwnd)
    {
      //Create filter graph
      CoCreateInstance(CLSID_FilterGraph,NULL,CLSCTX_INPROC,IID_IGraphBuilder,
                       (void **)&m_pGraph);
      
      m_pGraph->QueryInterface(IID_IVideoWindow,(void **)&m_pVidWnd);
      m_pGraph->QueryInterface(IID_IMediaControl,(void **)&m_pMedia);
      m_pGraph->QueryInterface(IID_IMediaEvent,(void **)&m_pEvent);

      //Set window
      m_pVidWnd->put_Owner((OAHWND)hwnd);
      m_pVidWnd->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
      RECT grc;
      ::GetClientRect(hwnd,&grc);
      m_pVidWnd->SetWindowPosition(0,0,grc.right,grc.bottom);
    }

    void Play(const unsigned short *File)
    {
      m_pGraph->RenderFile(File,NULL);
      m_pMedia->Run();

      long lDone=0;
      m_pEvent->WaitForCompletion(0,&lDone);

    
    }

    void ShutDown(void)
    {
      m_pMedia->Release();
      m_pEvent->Release();
      m_pVidWnd->Release();
      m_pGraph->Release();
      CoUninitialize();
    }

};

#endif
You will need to link with quartz.lib and strmiids.lib and of course have access to dshow.h.

To respond to messages consult the DirectShow SDK on how to use IMediaEvent and callbacks.
__________________
If you aim at everything you will hit something but you won't know what it is.
Bubba is offline   Reply With Quote
Old 02-15-2006, 12:45 PM   #7
Supermassive black hole
 
ahluka's Avatar
 
Join Date: Jul 2005
Location: South Wales, UK
Posts: 1,709
Cheers Bubba; I was going to ask about using DirectX for sound if all else failed.
__________________
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

- Mike McShaffry
ahluka is offline   Reply With Quote
Old 02-15-2006, 02:05 PM   #8
Super Moderator
 
Bubba's Avatar
 
Join Date: Aug 2001
Posts: 7,819
DirectSound won't natively load MP3's nor will DirectMusic. To get the spec for MP3's you must pay for them. But DirectShow does support them and you can use DirectShow as your sound system for simple apps.
__________________
If you aim at everything you will hit something but you won't know what it is.
Bubba is offline   Reply With Quote
Old 02-15-2006, 03:16 PM   #9
Registered User
 
Join Date: Jun 2004
Posts: 134
Or in theory... you are typing \\Condensed.mp3 you could use just Condensed.mp3 to get from the same directory or for say another dir you could sound\\Condensed.mp3. \\Condensed.mp3 may have some strange effects. I don't know why I didn't think of it sooner... but it hit me when I was working on some code...
Code:
player->SetImage("art/man.bmp",APAL);
I know this works although I use / instead of \\
Maybe this will help you some.
__________________
New to the BBS? Go Here:
http://postingandyou.info/

I'll bet I get flamed for this.
~Kyo~ is offline   Reply With Quote
Old 02-16-2006, 02:20 AM   #10
Registered User
 
Join Date: Jan 2006
Posts: 7
Try to use:
".\\Condensed.mp3" or "./Condensed.mp3"
The dot at start tells that Condensed is in the same folder where the executable is running (or debugging). Almost the same way the double dot, tells the file is at the "one folder above" folder. It reminds a little bit of "DOS", Unix, e.t.c.

I hope this to work..

Ps. For other folder (examples) you can use: ".\\x\\y\\z.mp3" (or "./x/y/z.mp3"). Or "..\\..\\x\\y\\z.mp3" ("../../x/y/z.mp3") e.t.c. At least I never had such problems using the dots. (I have never try it without the dots).
terablade is offline   Reply With Quote
Old 02-16-2006, 06:39 AM   #11
Supermassive black hole
 
ahluka's Avatar
 
Join Date: Jul 2005
Location: South Wales, UK
Posts: 1,709
Cheers to everyone for your help
__________________
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

- Mike McShaffry
ahluka is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Incorrect results from fmod()? karlthetruth C Programming 4 04-11-2008 09:12 AM
FMOD implimentation, how'd you do it? Jeremy G Game Programming 10 06-12-2004 12:04 AM
error with fmod() function minesweeper C++ Programming 3 08-30-2003 05:24 AM
Fmod and windows programming AtomRiot Windows Programming 1 01-06-2003 03:13 PM
fmod problem yusiye C Programming 3 08-01-2002 07:28 PM


All times are GMT -6. The time now is 09:24 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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