I finally got round to adding sound into my game, and I wanted to use ogg. Took me a while to find what I wanted and then found EasyOgg to be my answer.I don't know much about sound but I did improve on the code quality, e.g removed useless variables, code reuse and all the tips from FindBugs. But wondering if someone could help me(and others who want to use this) where I left off and improve it more.There is no way to set the volume of the left and right channels is someone able to help create a constructor or so that able to do this?Also stopping isn't instant and playing multiple times and sound is corrupted.I have attached my changes below.

ThanksI got the source from http://www.cokeandcode.com/node/625It just makes using JOrbis a lot easier to use.But wondering if a few people help out and improve on this while still making it easy to use. I done all I can, but I have no knowledge in this kind of area. Though I did try fixing the stop problem but failed on all the ways I tried.

If you provide your changes as a diff I'll happily apply them (though FindBugs default set is full of misconceptions and over compensations). As to the updates you request, there's a new version of EasyOGG available. You should find:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

/** * Attempt to set the global gain (volume ish) for the play back. If the control is not supported * this method has no effect. * * @param gain The gain value */publicvoidsetGain(floatgain);

/** * Attempt to set the balance between the two speakers. -1.0 is full left speaker, 1.0 if full right speaker. * Anywhere in between moves between the two speakers. If the control is not supported * this method has no effect * * @param balance The balance value */publicvoidsetBalance(floatbalance);

Stopping should be pretty instant now - well as instant as Java Sound will let you have. It should also cope with replays alright. If not, try mailing the author.

The stop is good but will still glitch up badly when you stop and then soon play it again.I also found that checking if a clip is stopped and then set and play a new clip it doesn't sound to nice when changing over.

Sorry should of used different names, they are 2 different clips. I think they are overlapping slightly. But if its a driver problem then don't worry about it.But a way around it is maybe able give a list of songs which it will play through the list.

Anyway I'm finding your updates very helpful.I couldn't mute with your new change in the setgain.I fixed it by uncommenting "control.getMinimum();" then setting the default gain to 1. Not sure if that's the right way but it got mute working again.

Also you might want to have a ispaused method or change resume to play when there's nothing to resume.Also noticed you bundle the old version of Jorbis, the .17 version works well with this.

It ticks loud when it pauses/resumes and after a few steps it just keeps ticking even when standing still.

Edit:Ok I did a bit more testing. I think I solved the always ticking problem when I change the end of the walking cycle to this:

1 2 3

if(!ogg.stopped()){ogg.pause();}

But still have the pause/resume ticks, but this only happens when there's a large pause between pause and the resume.Meaning if I keep walking I get no ticks. But if I stop-walk-stop-walk I get really bad ticking.

I'll take a look tonight. Setting the default gain to -1 makes no sense to me. That means you should be getting the minimum value supported by your master gain control. Hopefully it'll make sense tonight

Having a default gain value of 1 it will distort the sound clips, making my music sound horrible. So you might want to leave the default as default Also still horrible ticking for pause/resume. If you can't fix this then it doesn't matter, I could just leave out things that require the pause atm.

Well ogg is used in a lot of things so I'm sure someone must no how to fix the clicking problem.Though fading would be good if you could add that. Though not sure if it would solve my problem unless the fade time was short or able to set the fade time.Would make my music a lot nicer when stopping since its just a instant stop.

There is something wrong with EasyOgg. It is impossible to play 2 sounds simultaneously. I tried to use 2 OggClip instances at the same time and I heard only the first one. Do you know how to solve this problem? I think that each clip uses the same SourceDataLine instance

It was originally implemented just so someone could play ogg music through JavaSound, so no mixer was required. It'd need mixer support to get multiple sound fx working I think. Assuming your oggs have the same rate/channels the same line might get picked by AudioSystem currently I guess (?), though here it works with multiple clips it seems.

My clips do have different rates, but I'm not sure thats the reason it works. It could be the JavaSound implementation also. I'm on Windows here.

Kev

Lol, my problem is reproducible under Linux and Windows XP I think that the default mixer selected by the audio system supports only a very few lines on some machines. I'm going to select the mixer by myself.

Some controls are not supported by the default mixer. Instead of using a lot of try/catch clause, I prefer using the method Mixer.isControlSupported(Type control).

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