Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (568)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Sound  (Read 5247 times)
0 Members and 1 Guest are viewing this topic.
Offline rafa_es

Junior Member





« Posted 2006-10-25 16:00:38 »

Hi guys,

I´m trying to put sound in my game basing my code on SoundTestJavaSound. This eaxample runs fine but my code that is basically the same code doesn't work.
Any ideas why?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
        soundDriver = new SoundDriverImpl();
        soundDriver.setListenerVolume(1f);
        env.getView().setSoundDriver(soundDriver);
       
        MediaContainer mcWalk = new MediaContainer("src/Sounds/walk.ogg");
//        MediaContainer mcWalk = new MediaContainer(demoFolder.getResource("sounds/birds.ogg"));
       Sound sWalk = new BackgroundSound(mcWalk, 1);
        sWalk.setEnable(true);
        sWalk.setLoop(Sound.INFINITE_LOOPS);
        scene.addChild(sWalk);


Even if i try to use the sound from the test it doesn't work.

Rafael
Offline rafa_es

Junior Member





« Reply #1 - Posted 2006-10-25 16:07:26 »

I think that for some reason it is not initializing cuz when i run the test it prints

1  
2  
3  
4  
5  
6  
7  
8  
JavaSound sound driver initialized with 61 availble sources
starting frame speed test
Init file...
convsize = 20480
buffer is size=248576, freq=8000, formatMONO16
Init file...
convsize = 10240
buffer is size=115968, freq=11025, formatSTEREO16


and when i run it in my game it only prints the first line
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #2 - Posted 2006-10-25 17:24:48 »

Hi,

Does the sample that works also work if you compile it in your environment? (I mean Xith3D version etc.)

Yuri

Yuri Vl. Gushchin
JProof Group
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline rafa_es

Junior Member





« Reply #3 - Posted 2006-10-25 19:40:13 »

Hi,

Does the sample that works also work if you compile it in your environment? (I mean Xith3D version etc.)

Yuri

Yes Yuri
Offline rafa_es

Junior Member





« Reply #4 - Posted 2006-10-25 20:45:22 »

Another thing...

When i put a non existent file on MediaContainer in the test i get a error.

1  
2  
3  
4  
5  
        MediaContainer mc2 = new MediaContainer("src/Sounds/walk.ogg"); // this file don't exist
       Sound sound2 = new BackgroundSound(mc2, 1);
        sound2.setEnable(true);
        sound2.setLoop(Sound.INFINITE_LOOPS);
        tf_2.addChild(sound2);


then i get this exception

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
java.io.FileNotFoundException: src\Sounds\walk.ogg (O sistema não pode encontrar o caminho especificado)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        at com.xith3d.sound.loaders.OggLoader.load(OggLoader.java:180)
        at com.xith3d.scenegraph.MediaContainer.getSoundContainer(MediaContainer.java:112)
        at com.xith3d.sound.SoundProcessor.process(SoundProcessor.java:171)
        at com.xith3d.sound.SoundProcessor.processAll(SoundProcessor.java:268)
        at com.xith3d.render.Renderer.renderOnce(Renderer.java:421)
        at com.xith3d.render.Renderer.renderOnce(Renderer.java:448)
        at com.xith3d.render.Renderer.renderOnce(Renderer.java:463)
        at com.xith3d.scenegraph.VirtualUniverse.renderOnce(VirtualUniverse.java:158)
        at com.xith3d.scenegraph.View.renderOnce(View.java:593)
        at org.xith3d.render.base.Xith3DEnvironment.render(Xith3DEnvironment.java:785)
        at org.xith3d.render.loop.RenderLoop.invokeRendering(RenderLoop.java:640)
        at org.xith3d.render.loop.RenderLoop.loopIteration(RenderLoop.java:656)
        at org.xith3d.test.sound.SoundTesteJavaSound.loopIteration(SoundTesteJavaSound.java:161)
        at org.xith3d.render.loop.RenderLoop.run(RenderLoop.java:775)
        at java.lang.Thread.run(Thread.java:595)


But when i do the same thing with my code it runs without exception.
Do you think thta the problem is that it's not reading the file?
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #5 - Posted 2006-10-25 21:07:04 »

I don't have too much experiences with Sound. So I'm not of very much help. I could dig into the code to find it out, but it's not cleverer than if you'd do that.

But it would definitely help some people (including me) if you'd translate the error message Wink.

Marvin
Offline rafa_es

Junior Member





« Reply #6 - Posted 2006-10-25 21:14:09 »

But it would definitely help some people (including me) if you'd translate the error message Wink.

I think you refer to this line
1  
java.io.FileNotFoundException: src\Sounds\walk.ogg (O sistema não pode encontrar o caminho especificado)


it says "The system could not find the specified path

When i try to force this exception in my code it does not appear.

Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #7 - Posted 2006-10-26 00:05:39 »

Hi,

Something is definitely wrong in scene creation or initialization (say, if Sound is under "off" switch it will not play.

Can you post complete example that does not work? (explanation: I have Sound nodes working fine in my app using up-to-date CVS version of Xith3D)

Yuri

Yuri Vl. Gushchin
JProof Group
Offline rafa_es

Junior Member





« Reply #8 - Posted 2006-10-26 02:03:51 »

Hi Yuri,

I have just refreshed my cvs and it still doesn't work

I'll send you my code so you can take a better look and test the sound yourself

http://rapidshare.com/files/697800/ChemistryGame.rar.html

The sound is started in line 405

Rafael
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #9 - Posted 2006-10-26 09:30:53 »

Hi Yuri,

I have just refreshed my cvs and it still doesn't work

I'll send you my code so you can take a better look and test the sound yourself

http://rapidshare.com/files/697800/ChemistryGame.rar.html

The sound is started in line 405

Rafael
I'm taking a look at it (having been studying a bit sound in Xith recently).

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #10 - Posted 2006-10-26 10:22:16 »

Some comments on your code :
line 386 : use Material.AMBIENT, not mat.AMBIENT
line 405 : typo, rename "urlWlak" to "urlWalk"
line 405 : path you provided is "Sounds/walk.ogg" but I see no folder sounds. I changed it to "walk.ogg"
same comments on path on line 196 and 199 (loading of Sala.ASE)
(I finally had to re-create the whole directory structure)
whole code : it's a good habit to conform to standard Java coding conventions. A slight "Esc-Ctrl-F" in Eclipse does most of the work for you.

I'm having an ASE loading problem (texture). I'm working on that.

Coming soon with more news.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #11 - Posted 2006-10-26 11:01:50 »

Textures do work now I'll commit the AseMaterial changes.

Line 602 getDistance() is deprecated, so use getMinimumDistance() instead.

TODO for static geometry loaders : makes them use display lists (as implemented in PrecomputedAnimatedModel).

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline rafa_es

Junior Member





« Reply #12 - Posted 2006-10-26 12:58:02 »

line 405 : path you provided is "Sounds/walk.ogg" but I see no folder sounds. I changed it to "walk.ogg"
same comments on path on line 196 and 199 (loading of Sala.ASE)
(I finally had to re-create the whole directory structure)
Amos those paths are there. It's working for me like this. Maybe this is because i'm using netbeans.

TODO for static geometry loaders : makes them use display lists (as implemented in PrecomputedAnimatedModel).
How do i do that?

Thanks for the help

Rafael
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #13 - Posted 2006-10-26 17:12:51 »

line 405 : path you provided is "Sounds/walk.ogg" but I see no folder sounds. I changed it to "walk.ogg"
same comments on path on line 196 and 199 (loading of Sala.ASE)
(I finally had to re-create the whole directory structure)
Amos those paths are there. It's working for me like this. Maybe this is because i'm using netbeans.
Possibly they disappeared when you made the .rar archive.. or the open-source linux rar extractor doesn't re-create the file hierarchy

TODO for static geometry loaders : makes them use display lists (as implemented in PrecomputedAnimatedModel).
How do i do that?
You just have to ask ^^ I'll do that when I have time.

Thanks for the help
You're welcome.

Another tip : if you can modify your scene, then use textures instead of meshes to display text on your cylinders. It will be 2x faster. (Text is a heck lot of polys).

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline rafa_es

Junior Member





« Reply #14 - Posted 2006-10-26 17:59:08 »

You just have to ask ^^ I'll do that when I have time.

Thank you very much  Grin

Another tip : if you can modify your scene, then use textures instead of meshes to display text on your cylinders. It will be 2x faster. (Text is a heck lot of polys).

Sure, i'll modify it for textures now.

Does the sound work for you Amos?

Rafael
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #15 - Posted 2006-10-27 09:19:49 »

Done for the ASE loader, I'll now test and commit.

Sure, i'll modify it for textures now.
It's really valuable.

Does the sound work for you Amos?
No but I haven't debugged it yet.. I considered performance and correct file loading in your game to be more important than sound.. But wait once I have included Yuri's faster texture loading in the toolkit I'll debug your sound problem.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #16 - Posted 2006-10-27 13:39:53 »

But wait once I have included Yuri's faster texture loading in the toolkit I'll debug your sound problem.

Isn't it better to include it into the existing TextureLoader?
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #17 - Posted 2006-10-27 15:09:51 »

Hi,

Quote
Isn't it better to include it into the existing TextureLoader?

I guess he is intergating it with existing texture loader.

But in the meantime I plan to play a bit with even better loading which may theoretically utilize some features of the driver.

...but for this I guess we will need something like a "lazy texture loading" which will run on Rendering thread (i.e. within the context of GLCanvas.display(...)

Yuri

Yuri Vl. Gushchin
JProof Group
Offline rafa_es

Junior Member





« Reply #18 - Posted 2006-10-27 15:46:39 »

Done for the ASE loader, I'll now test and commit.

I'll check the cvs now

It's really valuable.

Got a big boost of performance without Text2D

No but I haven't debugged it yet.. I considered performance and correct file loading in your game to be more important than sound.. But wait once I have included Yuri's faster texture loading in the toolkit I'll debug your sound problem.
Sure it is.

Rafael
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #19 - Posted 2006-10-27 18:43:28 »

I guess he is intergating it with existing texture loader.
Exactly so. Marvin, I'm surprised you thought me dumb enough not to take this opportunity  Grin Grin Grin

But in the meantime I plan to play a bit with even better loading which may theoretically utilize some features of the driver.

...but for this I guess we will need something like a "lazy texture loading" which will run on Rendering thread (i.e. within the context of GLCanvas.display(...)
Well good luck.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #20 - Posted 2006-10-27 19:08:26 »

rafa_es : I changed a bit your game so that the only difference between the java sound test and your game is that your sound node is added to a render branch (pass).

Marvin, are render passes and regular branchgroup handled differently about sound nodes ?

The sound data is only loaded, when it is first "rendered". And when it's loaded there's a message. And, we don't have this message.. so this node never gets rendered... and when it's not in a special "pass" it works perfectly... soo what's going on ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #21 - Posted 2006-10-28 10:37:51 »

line 504 (not sure if it's the right one, i changed the code abit) :
1  
cronometro.setColor(new Color3f(0.12f, 0.15f, 1f));

replace by :
1  
cronometro.setFontColor(new Color3f(0.12f, 0.15f, 1f));


(setColor() is deprecated)

same for next occurences (line 509

lines 544-545 : not a good idea to have classes like "hudWinner" and "hudLooser", rather use "HudWinner" and "HudLooser". (java standards coding conventions)

I'm investigating sound processing



"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #22 - Posted 2006-10-28 12:41:06 »

Marvin,
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
 public final int collectAtoms(Locale locale, RenderPassConfigProvider defaultRenderPassConfig, ScenegraphModificationsListener modListener, Renderer renderer, com.xith3d.render.Canvas3D canvas, SoundProcessor soundProcessor)
    {

               //....

                pass.getRenderBinProvider().clearAllBins(j == 0);
                renderer.nodeUpdaters.clear();
                renderer.billboards.clear();
                // FIXME (Amos Wenger) What's That ??
               /*if (soundProcessor != null)
                    soundProcessor.clearSoundList();*/


   }


What is this code supposed to do here ?

It works well without.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #23 - Posted 2006-10-28 12:45:20 »

@rafa_es : update from CVS, should be fixed now.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #24 - Posted 2006-10-28 13:46:25 »

Exactly so. Marvin, I'm surprised you thought me dumb enough not to take this opportunity  Grin Grin Grin

I really didn't want to call you dump. Sorry if you came to understand it this way Smiley.

Marvin, are render passes and regular branchgroup handled differently about sound nodes ?

Not at all.

The sound data is only loaded, when it is first "rendered". And when it's loaded there's a message. And, we don't have this message.. so this node never gets rendered... and when it's not in a special "pass" it works perfectly... soo what's going on ?

Marvin,
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
 public final int collectAtoms(Locale locale, RenderPassConfigProvider defaultRenderPassConfig, ScenegraphModificationsListener modListener, Renderer renderer, com.xith3d.render.Canvas3D canvas, SoundProcessor soundProcessor)
    {

               //....

                pass.getRenderBinProvider().clearAllBins(j == 0);
                renderer.nodeUpdaters.clear();
                renderer.billboards.clear();
                // FIXME (Amos Wenger) What's That ??
               /*if (soundProcessor != null)
                    soundProcessor.clearSoundList();*/


   }


What is this code supposed to do here ?

It works well without.

I need to check it. But it should only be a problem, when you're using more than one Locle, which should be very rare. Will check it this evening.

Marvin
Offline Marvin Fröhlich

Senior Member




May the 4th, be with you...


« Reply #25 - Posted 2006-10-28 14:15:50 »

line 504 (not sure if it's the right one, i changed the code abit) :
1  
cronometro.setColor(new Color3f(0.12f, 0.15f, 1f));

replace by :
1  
cronometro.setFontColor(new Color3f(0.12f, 0.15f, 1f));


(setColor() is deprecated)

same for next occurences (line 509

A word about the reason, why I deprecated these methods:
I introduced a new interface called TextWidget. I'm planning to use it for a speacial implementation of the new List Widget I'm working on.
And setColor() is not a good name for a common text-color getter/setter. So I deprecated set/getColor() in Label and added the new method implemented from TextWidget called set/getFontColor().

Marvin
Offline rafa_es

Junior Member





« Reply #26 - Posted 2006-10-28 14:47:01 »

@rafa_es : update from CVS, should be fixed now.

Thank you for all the help Amos  Cheesy
I'll update the CVS now
Offline Amos Wenger

Senior Member




Everything's possible, but not everything's fun...


« Reply #27 - Posted 2006-10-30 08:49:40 »

You're welcome  Smiley

I'll update the CVS now
I hope I didn't break something else..

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (41 views)
2014-09-24 16:13:29

Pippogeek (32 views)
2014-09-24 16:12:22

Pippogeek (22 views)
2014-09-24 16:12:06

Grunnt (47 views)
2014-09-23 14:38:19

radar3301 (30 views)
2014-09-21 23:33:17

BurntPizza (65 views)
2014-09-21 02:42:18

BurntPizza (37 views)
2014-09-21 01:30:30

moogie (44 views)
2014-09-21 00:26:15

UprightPath (53 views)
2014-09-20 20:14:06

BurntPizza (55 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!