May I be the first to say, "AWESOME!".
Too bad I wrote your name in permanent marker or I'd take your name off my "list".
As soon as this is in I will probably be spending quite a bit of time with it as Galaxies Beyond currently has no sound (I know…silly!) and I will be making it a big priority once this is available so be assured you'll be getting lots of feedback from me.
You can't see (or at least I REALLY hope you can't) but I'm doing a happy dance
I'll be using it as soon as possible also, and I normally manage to break stuff
Many thanks! I will also spend a lot of time with it shortly.
Coool! I try it our ASAP!
Thank you!
I'm going to add sound system in my engine, so I think I'll wait for trying you're one.
Keep me updated on releases, please.
May be this sounds like I'm not sound of mind, but may I sound if there are news about the new sound? :?
Sorry, I got sidetracked finishing up a card game… I'll work on finishing up my javadoc quest and hopefully have things ready before I leave for GDC tomorrow.
renanse said:
Sorry, I got sidetracked finishing up a card game... I'll work on finishing up my javadoc quest and hopefully have things ready before I leave for GDC tomorrow.
Have fun at GDC, I look forward to some pics on the JME site of your adventures ;) We almost went but the guy I'm making games with had a new baby coming early March (possibly today). I imagine I'm not going to get any new artwork from him for a few weeks }:-@
Thanks! If anyone is going to be at GDC, give me a shout by email so we can hook up.
As for the sound stuff, I've finished a simple jmetest example and added basic comments to every class. I plan to do an overhaul again when I get back from GDC, but if you guys want to start picking it apart now, that's great. :) I will hold off on wiki tutorials until later this month at earliest. Once Mark has time to sync p4 and cvs, you'll find the new code in com.jmex.audio
Basic capabilities:
- Supports OpenAL 1.0
- Loads OGG or RIFF WAV files is 8 or 16 bit format; automatically detects format from media.
- Streaming and "in memory" playback are both supported. Choosing between the two is simply changing a single boolean argument.
- Built in music playlist similar to something you'd find in winamp or itunes, complete with repeat, shuffle, etc.
- Built in environmental sound bucket for managing headspace ambient noise.
- Fade in/out and cross fade.
- 3D Positional sound complete with rolloff, Doppler shift, etc.
- Basic automated tracking of positional sound assets.
- Support for filtering code from older audio system.
Known issues:
- Shifting between two streaming sounds will cause OpenAL exceptions, especially when paired with crossfade
- OpenAL use is hardcoded. (Of course, it's the only supported binding so far.)
- No environmental effects.
Great, so now I can harass up Mark until he gets the changes in…it will be a nice respite for you.
By "Shifting between two streaming sounds" you mean just fading from one streaming sound to another? Is there a work-around for this or is this just going to be something that needs to be fixed soon?
Thanks for all the work you've done, I can't wait to pick it apart.
darkfrog said:
By "Shifting between two streaming sounds" you mean just fading from one streaming sound to another?
It's streaming when used with track management. I'm actually not sure what the exact issue is yet, I've just seen it have issues starting up a new sound in the track list, but based on observations it seems like it's something with streaming + cross fade. Fortunately, you can still do multiple streams at once and most games will use streaming only for music and other occassional long audio clips anyhow. You can still load your streams into memory and use non-streaming playback as well. Lots of options.
That just struck a note of importance with me because I'm going to want to stream the music (in Roll-A-Rama I tried loading music directly but got lots of OutOfMemoryErrors when I didn't stream). Also, streaming helps to keep a big performance hit when changing from one song to another.
Once I have access to it I'll play around with it and I'm sure I can get it to work for what I need.
In TestJmexAudio I noticed the music was not affected by setVolume and found it should be setTargetVolume instead. That's intended, I assume?
Because of how it's played by the track list which fades things in and out, yes. Might be a better way to handle that though.
Speaking of the sound stuff, I made some good contacts with Creative while I was at GDC, so I'm hopeful that odd technical issues will be quite solvable now.
I've implemented pitch. Eclipse patch below. It's a pitch-patch, if you will
Index: src/com/jmex/audio/AudioTrack.java
===================================================================
RCS file: /cvs/jme/src/com/jmex/audio/AudioTrack.java,v
retrieving revision 1.1
diff -u -r1.1 AudioTrack.java
--- src/com/jmex/audio/AudioTrack.java 6 Mar 2007 15:29:17 -0000 1.1
+++ src/com/jmex/audio/AudioTrack.java 11 Mar 2007 21:49:01 -0000
@@ -34,10 +34,12 @@
import java.net.URL;
import java.util.ArrayList;
+import java.util.logging.Level;
import com.jme.math.FastMath;
import com.jme.math.Vector3f;
import com.jme.scene.Spatial;
+import com.jme.util.LoggingSystem;
import com.jmex.audio.event.TrackStateListener;
import com.jmex.audio.player.AudioPlayer;
@@ -79,6 +81,7 @@
private float maxAudibleDistance = 0;
private float referenceDistance = 0;
private float rolloff = 0;
+ private float pitch = 1.0f;
private float maxVolume = 1.0f;
private float minVolume = 0;
private URL resource = null;
@@ -301,6 +304,18 @@
public void setMaxAudibleDistance(float maxDistance) {
this.maxAudibleDistance = maxDistance;
player.setMaxAudibleDistance(maxDistance);
+ }
+
+ public float getPitch() {
+ return pitch;
+ }
+
+ public void setPitch(float pitch) {
+ if (getType() == TrackType.ENVIRONMENT || getType() == TrackType.HEADSPACE) {
+ this.pitch = pitch;
+ player.setPitch(pitch);
+ } else
+ LoggingSystem.getLogger().log(Level.WARNING, "Pitch can only be set on ENVIRONMENT or HEADSPACE type AudioTracks");
}
public float getMaxVolume() {
Index: src/com/jmex/audio/openal/OpenALPropertyTool.java
===================================================================
RCS file: /cvs/jme/src/com/jmex/audio/openal/OpenALPropertyTool.java,v
retrieving revision 1.1
diff -u -r1.1 OpenALPropertyTool.java
--- src/com/jmex/audio/openal/OpenALPropertyTool.java 6 Mar 2007 15:29:17 -0000 1.1
+++ src/com/jmex/audio/openal/OpenALPropertyTool.java 11 Mar 2007 21:49:01 -0000
@@ -47,6 +47,7 @@
public static void applyProperties(AudioPlayer player, OpenALSource source) {
applyChannelVolume(source, player.getVolume());
+ applyChannelPitch(source, player.getPitch());
applyChannelMaxVolume(source, player.getMaxVolume());
applyChannelMinVolume(source, player.getMinVolume());
applyChannelRolloff(source, player.getRolloff());
@@ -82,6 +83,11 @@
public static void applyChannelReferenceDistance(OpenALSource source, float refDistance) {
if (source != null)
AL10.alSourcef(source.getId(), AL10.AL_REFERENCE_DISTANCE, refDistance);
+ }
+
+ public static void applyChannelPitch(OpenALSource source, float pitch) {
+ if (source != null && pitch > 0f)
+ AL10.alSourcef(source.getId(), AL10.AL_PITCH, pitch);
}
}
Index: src/com/jmex/audio/openal/OpenALMemoryAudioPlayer.java
===================================================================
RCS file: /cvs/jme/src/com/jmex/audio/openal/OpenALMemoryAudioPlayer.java,v
retrieving revision 1.1
diff -u -r1.1 OpenALMemoryAudioPlayer.java
--- src/com/jmex/audio/openal/OpenALMemoryAudioPlayer.java 6 Mar 2007 15:29:18 -0000 1.1
+++ src/com/jmex/audio/openal/OpenALMemoryAudioPlayer.java 11 Mar 2007 21:49:01 -0000
@@ -32,9 +32,12 @@
package com.jmex.audio.openal;
+import java.util.logging.Level;
+
import org.lwjgl.openal.AL10;
import com.jme.math.Vector3f;
+import com.jme.util.LoggingSystem;
import com.jmex.audio.AudioBuffer;
import com.jmex.audio.AudioSystem;
import com.jmex.audio.AudioTrack;
@@ -159,6 +162,15 @@
public void setVolume(float volume) {
super.setVolume(volume);
OpenALPropertyTool.applyChannelVolume(source, volume);
+ }
+
+ @Override
+ public void setPitch(float pitch) {
+ if (pitch > 0f && pitch <= 2.0f) {
+ super.setPitch(pitch);
+ OpenALPropertyTool.applyChannelPitch(source, getPitch());
+ } else
+ LoggingSystem.getLogger().log(Level.WARNING, "Pitch must be > 0 and <= 2.0f");
}
@Override
Index: src/com/jmex/audio/player/AudioPlayer.java
===================================================================
RCS file: /cvs/jme/src/com/jmex/audio/player/AudioPlayer.java,v
retrieving revision 1.1
diff -u -r1.1 AudioPlayer.java
--- src/com/jmex/audio/player/AudioPlayer.java 6 Mar 2007 15:29:13 -0000 1.1
+++ src/com/jmex/audio/player/AudioPlayer.java 11 Mar 2007 21:49:01 -0000
@@ -32,7 +32,11 @@
package com.jmex.audio.player;
+import java.util.logging.Level;
+
+import com.jme.util.LoggingSystem;
import com.jmex.audio.AudioTrack;
+import com.jmex.audio.AudioTrack.TrackType;
/**
* @author Joshua Slack
@@ -47,6 +51,7 @@
private float refDistance;
private float rolloff;
private float volume;
+ private float pitch = -1f; // -1 indicates we haven't changed pitch yet, this is necessary cause changing pitch on positional sounds == crash
private long startTime;
private long pauseTime;
private boolean loop;
@@ -119,6 +124,10 @@
this.volume = volume;
}
+ public void setPitch(float pitch) {
+ this.pitch = pitch;
+ }
+
public float getMaxDistance() {
return maxDistance;
}
@@ -149,6 +158,10 @@
public float getVolume() {
return volume;
+ }
+
+ public float getPitch() {
+ return pitch;
}
public float getCurrentTime() {
Tobias said:
I've implemented pitch. Eclipse patch below. It's a pitch-patch, if you will :)
hehe, funny and beneficial. :)
Cool, thanks.
Is this sound system supposed to end up in one of the jars dist-all produces?
I'm failing to get the old SoundSystem working over webstart (it works fine locally, reads quite happily from jars) so I was going to give the new one a try.
Endolf.
I don't think it is currently made into a jar by our build script.
Cool, i'll add it for now untill the official version arrives
Endolf