Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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  
  Line pooling  (Read 2508 times)
0 Members and 1 Guest are viewing this topic.
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Posted 2003-04-30 21:27:45 »

Is there any downsides to converting the wavs to the same format upon loading? That's the only problem I see with pooling SourceDataLine's so far.

The goal is to be able to load a wav, and play it x times concurrently, along with all the other sounds. Fastest thing I can think of is to just create as many lines as I want max sounds playing, and just reuse them for whatever is currently playing. So you could play the same axe hit sound 2-3 times at once.
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #1 - Posted 2003-04-30 22:14:43 »

You could potentially be using more memory by upconverting streams. Other than that, it's actually more of an advantage than disadvantage.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #2 - Posted 2003-05-02 15:26:00 »

Apparently no acual conversion stuff is implemented at the moment.

Neat?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #3 - Posted 2003-05-02 18:44:30 »

Quote
Apparently no acual conversion stuff is implemented at the moment.


Errmm... Not sure what you mean here. You can use various formats for SourceDataLines that will all be mixed correctly before being output to the sound card. Is that what you mean?

Java Game Console Project
Last Journal Entry: 12/17/04
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #4 - Posted 2003-05-02 20:12:40 »

No what I mean is, if I load a 10000hz 8 bit mono wav file, I can't use the API's to convert it to say, 12025hz 8bit stereo before opening a line for it.

The methods are in there to DO it but it's not acually in on the implementation level, i.e. the methods don't seem to acually do anything at the moment. I read this in 2 places as well just to confirm it.

The problem I'm having is I don't want to be creating/opening/etc lines to play sounds. I want 8-16 lines for the max number of sounds that can play at once, and just use those for everything, but you have to specify formats at creation or open() (and the apis say you cant close/open on some machines) so I was going to just convert all the wavs to a like format and just make the lines use that.

But now I either have to get another plan of attack, or force someone to convert them to the same format outside the APIs. Which would be kinda annoying.

Edited: to clarify one thing
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #5 - Posted 2003-05-03 03:40:09 »

Well, I'm no expert on sound data management, but I do believe it should be pretty easy to upsample the data. In it's simplest form, all you need to do is "stretch" the data much in the same way you'd stretch an image. It's easy with standard multiples (i.e. 11hz, 22hz, 44h) since the sound is always even after conversion (i.e. 11hz to 44hz would just require that you quadruple each byte). With non-standard sample rates, it's better to use a float to count out the streaching. For example:


double multiple = 2.5;
double count = 0;

byte[] olddata = getSoundData();
byte[] newdata = olddata * multiple;

for(int i=0, j=0; i<newdata.length; i++)
{
   newdata = olddata[j];

   count++;
   
   if(count > multiple)
   {
       j++;
       count -= multiple;
   }
}


Downsampling is just as easy. You just grab every so many bytes and throw away the rest. Of course, for more professional sounds (Whatcho' talkin' about? This is a game! I pitty the foo that get fancy! Wink) you'd probably want to "smooth" the sounds by performing averages on the resized data. For upsampling, this would mean that you would take the difference between the last byte and this one and add "in between" values. With downsampling, you'd average the X number of bytes to create the one byte for each sample. (i.e. 44hz to 11hz would require averaging 4 bytes of the original to produce one byte of the result.)

Does anyone else have any comments on this?

Java Game Console Project
Last Journal Entry: 12/17/04
Offline bedelf

Junior Member




Are you suggesting coconuts migrate?


« Reply #6 - Posted 2003-05-03 04:15:19 »

I'm still amazed it's not in there, the java sound stuff just seems very... unfinished?

Common Sun, get to it bitches. Tongue
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #7 - Posted 2003-05-12 07:22:19 »

Quote
you'd probably want to "smooth" the sounds by performing averages on the resized data.

A better sounding way to do that is not to average the data, but to use a steep low-pass filter with the cut-off frequency at the original wav's sample frequency.

Erik

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #8 - Posted 2003-05-12 07:23:47 »

Oops forget that.
This only applies for upsampling.

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #9 - Posted 2003-05-12 07:27:29 »

For downsampling you should also filter *before* you down-sample. This to avoid aliasing which causes distortion.

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.

pw (12 views)
2014-07-24 01:59:36

Riven (10 views)
2014-07-23 21:16:32

Riven (11 views)
2014-07-23 21:07:15

Riven (12 views)
2014-07-23 20:56:16

ctomni231 (43 views)
2014-07-18 06:55:21

Zero Volt (38 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (34 views)
2014-07-16 23:30:00

Cero (50 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!