Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 3 [4] 5 6 ... 8
  ignore  |  Print  
  3D Sound Engine  (Read 81287 times)
0 Members and 1 Guest are viewing this topic.
Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #90 - Posted 2010-08-26 21:02:37 »

Maybe I can try to force the second one to see if there is any difference.
Let me know if it works any better than the other one.  If so, I'll try and set up some test machines with Linux and webcams to see if there is any way to predict which one works.  If neither work, then it really won't be solvable until I finish writing my software mixer.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #91 - Posted 2010-09-04 15:40:41 »

the mixer that is selected only succeeds in playing 2 sounds and does not work anymore after that (it is unable to play the same sounds once more).

Give this version a try and let me know if it works any better:

JavaSound library pluggin

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #92 - Posted 2010-09-06 11:36:43 »

Give this version a try and let me know if it works any better:

JavaSound library pluggin

Ok I'm going to give it a try when I'm back home in some hours. However, it seems to be something really wrong with my webcam; when it is plugged, some other USB devices do not work anymore...

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #93 - Posted 2010-09-06 18:13:56 »

I get this now:
Quote
Error in class 'ChannelJava Sound'
    Unable to attach buffer to clip in method 'attachBuffer'
    ERROR MESSAGE:
        line with format PCM_SIGNED 22050.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian not supported.
    STACK TRACE:
        com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(DirectAudioDevice.java:494)
        com.sun.media.sound.DirectAudioDevice$DirectClip.implOpen(DirectAudioDevice.java:1280)
        com.sun.media.sound.AbstractDataLine.open(AbstractDataLine.java:107)
        com.sun.media.sound.DirectAudioDevice$DirectClip.open(DirectAudioDevice.java:1061)
        com.sun.media.sound.DirectAudioDevice$DirectClip.open(DirectAudioDevice.java:1028)
        paulscode.sound.libraries.ChannelJavaSound.attachBuffer(ChannelJavaSound.java:278)
        paulscode.sound.libraries.SourceJavaSound.play(SourceJavaSound.java:311)
        paulscode.sound.Library.play(Library.java:706)
        paulscode.sound.Library.play(Library.java:675)
        paulscode.sound.SoundSystem.CommandPlay(SoundSystem.java:2076)
        paulscode.sound.SoundSystem.CommandQueue(SoundSystem.java:2599)
        paulscode.sound.CommandThread.run(CommandThread.java:121)

On my view, don't waste any time in fixing this bug as I have not checked whether it is reproducible on any other Linux machines.

Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #94 - Posted 2010-09-06 18:50:54 »

That's odd, I wouldn't have expected it to get into ChannelJavaSound.attachBuffer without printing some of the debug messages from the Mixer selection process first. 

Anyway, what is the brand/model of your webcam, and the Linux version?  I'm going to set up some Linux test environments and want to see if I can reproduce the problem here.  I'm not placing a high priority on this bug, but it is something I'll continue to look at among other things.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #95 - Posted 2010-09-06 21:36:09 »

That's odd, I wouldn't have expected it to get into ChannelJavaSound.attachBuffer without printing some of the debug messages from the Mixer selection process first. 

Anyway, what is the brand/model of your webcam, and the Linux version?  I'm going to set up some Linux test environments and want to see if I can reproduce the problem here.  I'm not placing a high priority on this bug, but it is something I'll continue to look at among other things.
Mandriva Linux 2010 (one of the most famous Linux distro just behind Ubuntu).
Logitech, Inc. QuickCam Messenger

Offline markus.borbely

Junior Duke





« Reply #96 - Posted 2010-09-11 10:47:04 »

Hi!

I am using you library for my latest game Gunslinger 2:

http://www.java-gaming.org/topics/gunslinger-2-sci-fi-action-top-down-shooter/22854/view.html

It works very good! However, even if my game is not 3D I still want the player to know if the sound comes from the left or right.

Since it is java2D my coordinate system have 0,0 at the top left corner of the map. I use this to set the initial values:

1  
2  
[code]            soundSystem.setListenerAngle(0);
            soundSystem.setListenerOrientation(0, -1, 0, 0, 0, 1);
[/code]

If I understand it correctly it should make the player stand at the bottom of the screen and look up (to the top of the screen). His head points out of the screen. This way, his right ear is to the right and his left ear is to the left. Correct? I have tried to experiment, but am not sure that it sounds right.

Of course, each frame I update the player position. I never need to update these other vectors, right?

I use mostly quickPlay since that allows a sound to overlap itself (I don't want to keep track of multiple sources from the same object). Will 30 calls per second to quickPlay be a problem?

A design note, I would have preferred if a source wasn't tightly bound to a sample. Instead, I would like to have a source: "enemy_1" or "door_2" and then those sources could play different samples. As it is now, I have to have lots of sources that always are at the same position. A door can open and close, so it must have two sources. A creature can walk, attack, take damage and die, that means at least 4 sources. In the end, I just use quickPlay for almost everything.
Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #97 - Posted 2010-09-11 20:43:58 »

The call to setListenerAngle is not necessary (zero is already the default value, and it would be overwritten by setListenerOrientation anyway).  The best way to visualize the orientation you wrote, you are laying face-down flat on your stomach (looking in the -y direction) with your feet pointing into the screen (up is in the +z direction, toward the player).  Thus, if you were to position the listener in the center of the screen, then things on the left side of the screen will sound like they are to the right and things in the right side of the screen will sound like they are to the left (and if you have an OpenAL version designed for surround-sound system, things that are at the top of the screen would sound like they are behind you and things that are at the bottom of the screen would sound like they are in front of you).  A better orientation might be (0, 1, 0, 0, 0, -1).

Notice, however, that you must also change the listener's position, not just his angle.  Without changing position, the listener will be at the top-left (0, 0), and everything will sound like it is to one side.

Next, you must consider the fact that if (0, 0) is the top-left, this means that +y is down in your coordinate system, but it is up in SoundSystem's coordinate system.  So to keep things correct, you would want to reverse the sign of any y-coordinates you pass to SoundSystem.

Assuming you have the listener position and coordinate signs correct, but you are still not hearing what you expect, there are a couple of problems that can be easily adjusted (both can be done if needed):

Problem #1: Panning between left and right speaker either pans too rapidly or too slowly compared to the 2D positions
Solution:
    Ignore y and z (use only x coordinates) and adjust the diameter of the circle used to calculate the pan.  You would use the default listener orientation for this (where +y is up, -z is into the screen), and when setting the position of the listener and all sources only pass them the x-coordinates.  So say you want to have the listener at (5, 7) and to play an explosion at (2, 4):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
float diameterFactor = 0.0f;  // increase gradually to achieve the desired panning behavior
soundSystem.setListenerPosition( 5, -diameterFactor, 0 );  // ignore the y-coordinate which was 7.. use the diameter factor instead

...

boolean priority = false;
String filename = "explosion.wav";
boolean loop = false;
float x = 2;
float y = 0;  // ignore the y-coordinate, which was 4
float z = 0;
int aModel = SoundSystemConfig.ATTENUATION_ROLLOFF;
float rFactor = SoundSystemConfig.getDefaultRolloff();
soundSystem.quickPlay( priority, filename, loop, x, y, z, aModel, rFactor );

The good thing about this method is you don't have to worry about the sign difference in y coordinates, because you are only using the x coordinates.

Problem #2: Far away sounds are either too loud or too quiet based on their distance from the listener
Solution:
    Adjust the rolloff factor if using Logarithmic/Rolloff Attenuation (or fade distance if using Linear Attenuation)

For your question about the listener's orientation, correct you should only need to set it one time.  Also, you really only need to update the listener's position if it changes.  It doesn't hurt to update it every frame but it may not be necessary (for LibraryJavaSound, each update of the listener position requires a loop through all the sources to calculate a new pan/gain, so only calling setListenerPosition when it changes could potentially be a useful optimization if there are a ton of sources to loop through).

For your question about 30 calls per second to quickPlay, in stress tests that is not a problem as far as stability goes, however you should note that there are generally only 28 normal channels available, so sources will be getting cut off if you are playing that many simultaneously.  Depending on the speed of the user's system, there could be a noticeable performance hit as the channels are rapidly being started, stopped, reset, and started again.  Also, if a lot of copies of the same sample are playing at close to the same time, you will experience phase-resonance interference (this is true for any sound library, not just SoundSystem).  What this sounds like is randomly amongst the numerous playing sources, you will hear a distorted version of the sample played either extremely loud or extremely quiet (this behavior is very noticeable).  It is caused by the amplitude values of more than one sample aligning to either amplify or cancel each other out.  It happens most noticeably with sound effects that are made up of repeating sample data (such as bells, engine hums, laser pulses, etc).  Interestingly, this phenomenon actually happens in the real world as well (for example, some migratory birds have specially-designed in-flight calls that reduce the effect of echo off of mountains by inversely aligning the wave amplitudes as returning sound waves passes back over the oncoming waves, making it easier for them to locate other flocks and coordinate their movements).

As for your design note, true it would be better optimized to allow more than one sample to play from a single source, but it would also create more of a headache for the developer, who would now have to keep track of which sample is currently assigned to each source.  Since sources are relatively cheap, I think the potential optimization benefit compared to the "easy to use" benefit falls in favor of easy to use.  Additionally, in both of your examples, it is more realistic to play the samples from more than one source, because they may overlap (a door could be slammed shut then rapidly opened again, or a creature could be walking and attacking at the same time or taking damage and dying at the same time, etc.).  Just quickPlay the sample where it needs to play, and let SoundSystem worry about creating and getting rid of the sources for you.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline markus.borbely

Junior Duke





« Reply #98 - Posted 2010-09-12 11:00:12 »

Thanks for your elaborate answer (and thanks for writing this engine)!
Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #99 - Posted 2010-10-24 03:41:12 »

Bug-Fixes Update

Sound System jPCT
Sound System

JavaSound library pluggin

WAV codec pluggin


What's New:
- Updated CodecWav link to current version
- Improved LibraryJavaSound performance slightly in non-Sun Java versions
- Handled rare pan-control exception
- Fixed fadeOutIn bug which caused fade-in effect to be silent

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #100 - Posted 2010-11-23 22:25:59 »

CodecJorbis, Bug-Fix

Jorbis codec pluggin

- Fixed a bug where certain types of .ogg files created in versions of Audacity were cut off just before the end of the sample.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #101 - Posted 2010-12-05 20:16:08 »

Hi!

The sounds that I use are played correctly the first time I play them but after that, I hear nothing Sad I'm going to update the library and check if I reproduce this problem when my webcam is not plugged.

When I stop playing a sound (especially the introduction sample), it fails, it goes on playing it until the end.

Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #102 - Posted 2010-12-06 00:14:35 »

That's a new one.  What is your OS, 32/64 bit, Java version, etc?  I'm sure you've told me before, but the thread has gotten so long that I can't seem to find it.  Let me know if it is related to the webcam.  I'll try and reproduce it here if I can.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #103 - Posted 2010-12-06 09:08:17 »

What is your OS, 32/64 bit, Java version, etc?
Mandriva Linux 2010, 32 bits, Oracle Java 1.6 update 22. I have not tested with OpenJDK. I'm going to test it with the latest version of your library in some hours.

Offline gouessej
« Reply #104 - Posted 2010-12-06 23:06:36 »

Ok I confirm that the bug is reproducible only when the webcam is used because it uses another mixer. It is not important, don't worry. I'm impatient to use your low-latency software mixer  Wink Thank you for your good work  Smiley

Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #105 - Posted 2010-12-07 01:14:50 »

I'm impatient to use your low-latency software mixer  Wink
I've written a native software mixer for the Android (or rather I've hijacked one from someone else's code and ported it to the NDK Grin ).  That has helped me quite a bit with understanding what all is involved.  I'm still in the process of taking that knowledge and translating it into something usable in Java, though.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #106 - Posted 2010-12-07 15:32:30 »

I've written a native software mixer for the Android (or rather I've hijacked one from someone else's code and ported it to the NDK Grin ).  That has helped me quite a bit with understanding what all is involved.  I'm still in the process of taking that knowledge and translating it into something usable in Java, though.
Do you use OpenSL ES or OpenMAX on Android to do this? Is the use of native code mandatory to write such a software mixer?

I have to write this report about my problem of webcam. It would be fine if it was fixed in Java 1.7.

Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #107 - Posted 2010-12-07 21:11:08 »

Do you use OpenSL ES or OpenMAX on Android to do this? Is the use of native code mandatory to write such a software mixer?
The mixing is done purely by c code.  The code is taken from the open-source SDL software mixer.  The output data is passed in buffers through an interface method into Java where it is played through an AudioTrack instance.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #108 - Posted 2010-12-07 22:12:40 »

The mixing is done purely by c code.  The code is taken from the open-source SDL software mixer.  The output data is passed in buffers through an interface method into Java where it is played through an AudioTrack instance.
Ok I see what you mean. When you port this code to the desktop, will you keep all this C code? Is it a pure utopia to imagine a pure Java software mixer? SFML has a nice software mixer, maybe you could look at it too.

Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #109 - Posted 2010-12-08 00:10:30 »

Well, I'm attempting to port it to pure Java (somewhat difficult to deal with the whole pointers vs Objects issue).  If this fails or turns out to simply be too slow, I may have to go with native code in the end (I hope not).  If that happens, I will modify LWJGL's AppletLoader so that it deploys the necessary natives (which will make using the library in Applets easier, but will of course still require the end user to accept the digital signature).

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #110 - Posted 2010-12-08 15:17:30 »

Well, I'm attempting to port it to pure Java (somewhat difficult to deal with the whole pointers vs Objects issue).  If this fails or turns out to simply be too slow, I may have to go with native code in the end (I hope not).
What are the bottlenecks? What could be noticeably slower in Java?

Offline paulscode

Senior Duke


Medals: 12


Staff Sergeant


« Reply #111 - Posted 2010-12-11 19:38:37 »

What are the bottlenecks? What could be noticeably slower in Java?
Well, I was just talking in general terms, since I have not actually finished the port yet.  I meant that Java, as an interpreted runtime environment, trades some amount of speed for its portability.  For the most part, this isn't a problem (the fact that there are pure-java 3D engines is proof of that).  Audio data manipulation and mixing is rather math-intensive, so it remains to be seen if a straight port from native code will run fast enough, or if it will require additional optimizations.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #112 - Posted 2010-12-11 21:58:38 »

Well, I was just talking in general terms, since I have not actually finished the port yet.  I meant that Java, as an interpreted runtime environment, trades some amount of speed for its portability.  For the most part, this isn't a problem (the fact that there are pure-java 3D engines is proof of that).  Audio data manipulation and mixing is rather math-intensive, so it remains to be seen if a straight port from native code will run fast enough, or if it will require additional optimizations.
Ok. Maybe you could use JOCL even to perform computations on the CPU to benefit of features that are not exposed in Java, it would avoid to write native code.

I have looked a bit at the sound system of SFML. Actually, even the software renderer relies on OpenAL.

Offline gouessej
« Reply #113 - Posted 2010-12-12 16:36:34 »

I have submitted a bug report there, it will be visible in some days:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7006285

Lol even the official demo of JavaSound crashes when I plug my webcam in  Shocked

Offline CWolf

Junior Newbie





« Reply #114 - Posted 2011-01-06 15:41:17 »

Firstly I'd like to say I think this sound system is great Smiley.

Secondary I've encountered an issue with playing .ogg files that are of a small size (for instance 13kb).  I can play it in another media player (Winamp for example) but not using the sound system.  When I change the file to a larger sized .ogg (a track of size 500kb) it works fine.  Is there a lower size limit for use of .ogg?

I encounter this issue using LibraryLWJGLOpenAL.class and LibraryJavaSound.class whilst I have also tried CodecJOrbis.class and CodecJOgg.  Any ideas?

EDIT:  It also works with .ogg of file size 184kb.  So I guess there may be a lower size limit?
Offline gouessej
« Reply #115 - Posted 2011-01-06 19:37:37 »

Firstly I'd like to say I think this sound system is great Smiley.

Secondary I've encountered an issue with playing .ogg files that are of a small size (for instance 13kb).  I can play it in another media player (Winamp for example) but not using the sound system.  When I change the file to a larger sized .ogg (a track of size 500kb) it works fine.  Is there a lower size limit for use of .ogg?

I encounter this issue using LibraryLWJGLOpenAL.class and LibraryJavaSound.class whilst I have also tried CodecJOrbis.class and CodecJOgg.  Any ideas?

EDIT:  It also works with .ogg of file size 184kb.  So I guess there may be a lower size limit?
Do you use the latest version? I use tiny ogg files with JavaSound and it works fine. Do you use the streaming?

Offline CWolf

Junior Newbie





« Reply #116 - Posted 2011-01-06 23:00:17 »

Thanks for a reply.  I am using the versions from the first post.  I'm using the assumption that these are the newest (as a lot of people tend to re-edit their first post with the links).  I've tried it with both newSource(...) and newStreamingSource(...) methods.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
      
boolean priority = false;
String sourcename = "Source 1";
String filename = "/sound/badge.ogg";    // this is stored in a package Sounds.sound and other files work fine like this.
boolean loop = false;
float x = 0;
float y = 0;
float z = 0;
int aModel = SoundSystemConfig.ATTENUATION_ROLLOFF;
float rFactor = SoundSystemConfig.getDefaultRolloff();

soundSystem.newStreamingSource( priority, sourcename, filename, loop, x, y, z, aModel, rFactor );
soundSystem.play( "Source 1" );


EDIT: I ultimately want to use fades and I noticed you can only use fades with SteamingSources so says the console info
Offline gouessej
« Reply #117 - Posted 2011-01-07 13:49:43 »

I don't use streaming and I succeed in playing very short ogg files but that is not what you want to do :s

Offline CWolf

Junior Newbie





« Reply #118 - Posted 2011-01-07 15:09:42 »

Thanks for the info.  It doesn't work for me even when I don't use streaming.  What file size is the smallest ogg file you use?
Offline gouessej
« Reply #119 - Posted 2011-01-07 21:46:15 »

Thanks for the info.  It doesn't work for me even when I don't use streaming.  What file size is the smallest ogg file you use?
This one:
http://tuer.svn.sourceforge.net/viewvc/tuer/pre_beta/sounds/teleporter_use.ogg?view=log

Look at my repository to be sure we use the same version of his sound engine.

Pages: 1 2 3 [4] 5 6 ... 8
  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.

Longarmx (49 views)
2014-10-17 03:59:02

Norakomi (38 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (34 views)
2014-10-15 16:18:58

TehJavaDev (65 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (54 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!