Crystal Space
Welcome, Guest. Please login or register.
April 24, 2014, 09:19:58 pm

Login with username, password and session length
Search:     Advanced search
8990 Posts in 2037 Topics by 7628 Members
Latest Member: Majstersztyk1989
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  General Crystal Space Discussion
| | |-+  Help me! Problem with sound
« previous next »
Pages: [1] Print
Author Topic: Help me! Problem with sound  (Read 4441 times)
Shamaz.mazum
Newbie
*
Posts: 10


View Profile Email
« on: May 29, 2008, 02:51:54 pm »

I can`t play sounds in Crystal Space using CEL. First I attach all needed plugins.
Second I load my sound wrapper.

CsRef<iLoader> loader;
CsRef<iSndSysRenderer> sndrdr;
CsRef<iSndSysManager> sndmgr;
CsRef<iCelPlLayer> pl;
CsRef <MyBehaviourLayer> bl;
....
loader->LoadSoundWrapper ("background", "/mydata/music/tarck02.ogg");

Third, I create music playing entity:

pl->CreateEntity ("music_player", bl, "item", "pcsound.source", CEL_PROPCLASS_END);
csRef<iPcSoundSource> bgsound_source = CEL_QUERY_PROPCLASS_ENT (pl->FindEntity ("music_player"), iPcSoundSource);

Fourth, play sound

bgsound_source->SetSoundName ("background");
bgsound_source->GetSoundSource()->SetVolume (1.0f);
bgsound_source->GetSoundSource()->GetStream()->SetLoopState (
                CS_SNDSYS_STREAM_LOOP);
bgsound_source->GetSoundSource()->GetStream()->Unpause();

On string "bgsound_source->GetSoundSource()->SetVolume (1.0f);" my game crashes.

I can play sounds with iSysSndRenderer and iSysSndManager:
csRef<iSndSysStream> stream = sndrdr->CreateStream (
      sndmgr->FindSoundByName ("background")->GetData(), CS_SND3D_DISABLE);
csRef<iSndSysSource> source = sndrdr->CreateSource (stream);
source->SetVolume(1.0f);
stream->Unpause();
All works perfect, but I want play sounds using CEL. What I am doing wrong? Please help me to learn how to create playable sound source using sound wrappers and CEL.
Logged
Vincent
Full Member
***
Posts: 191


View Profile WWW
« Reply #1 on: May 29, 2008, 11:27:11 pm »

Hello,

  it would be nice if you could provide a buildable/runnable example for the problem,
it could speed up the testing. I'm willing to investigate, but I don't have much time at the
moment and will be away next week (using CS/scripts/jamtemplate/createproject.sh to create
a test case easy to build/run on any platform is a good idea).
Someone else might do it before I do, tho...
Logged
Shamaz.mazum
Newbie
*
Posts: 10


View Profile Email
« Reply #2 on: May 30, 2008, 05:54:49 am »

Unfortunately, I can`t provide buildable variant because it have size of 180MB and because of strange promblem with forum: I can`t upload anything. I think all I can to do, it is give you some pieces of code if you need.

NB:Last post I forgot say you that I set up sound listener properly: it always follows the player mesh.
Logged
Zuck
Newbie
*
Posts: 4


View Profile Email
« Reply #3 on: May 31, 2008, 01:27:23 pm »

I'm not sure, but i think the "iPcSoundSource" property is not yet implemented in current CEL version because the "SetSoundName" method implementation is:

Code:
void celPcSoundSource::SetSoundName (const char* name)
{
  soundname = name;
  soundwrap = 0;
  source = 0;
  source3d = 0;
  stream = 0;
}

I imagine it shoulds be something like this:

Code:
void celPcSoundSource::SetSoundName (const char* name)
{
  soundname = name;
  soundwrap = 0;
  source = 0;
  source3d = 0;
  stream = 0;

  GetSoundWrap();

  if (!GetSource())
  {
    // @@@ Report error?
    printf ("Can't set sound '%s'!\n", (const char*)name);
    fflush (stdout);
  }
}
Logged
Shamaz.mazum
Newbie
*
Posts: 10


View Profile Email
« Reply #4 on: June 01, 2008, 09:36:17 am »

Thanks, Zuck.
Logged
Zuck
Newbie
*
Posts: 4


View Profile Email
« Reply #5 on: June 01, 2008, 04:45:48 pm »

Please, give me a feedback if it works... Wink
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 5.127 seconds with 15 queries.