Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (697)
Games in Android Showcase (202)
games submitted by our members
Games in WIP (767)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 47
1  Game Development / Newbie & Debugging Questions / Re: Active Rendering, flickering on: 2016-10-22 00:57:03
At the risk of being little or no help, may I ask why you chose to go the active rendering route? Java has double buffering automatically set up with display classes such as JPanel. If the assignment was just to make a game, using that would be a lot easier. (And, using the latest Java graphics library, JavaFX, would be easier, still.)

I'm guessing you're already acquainted with and have read through the Java Tutorials guide on Active Rendering?
2  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-10-18 22:19:48
Had some fun Saturday while at work, on my break, tweaking settings using a new SF/X tool I wrote. I was working on a bird tweet sound (thinking the sounds were quiet and wouldn't carry), and the store Manager poked her head into the break room. She said she thought a bird had gotten stuck in the attic or something. Success!

It took a few more days to track down some bugs in the system pertaining to using the Java file-choosing code (used in save/load of xml and export of wav). I found out, for example, that I didn't handle the case where one "cancels" the action and it was leading to the app hanging. Finally posted in WIP thread today. Fingers crossed, am hoping it is stable now.
3  Games Center / WIP games, tools & toy projects / DinkMaker (Audio Tool) on: 2016-10-18 22:07:26
I've been working on a mini-synth for making short "utility" audio cues, such as the clicks and dinks for things like clicking on menus. It uses an FM Synth that I wrote (Phase Modulation, more accurately) that has a carrier/modulator pair, an LFO (for either pitch or volume uses) and some frequency sweep options and an ASR envelope. With this, there are actually some tricky and odd sounds that can be made besides clicks.

Running the app, you can make and export wav files for game use. Another option is to import the jar into your game program and use the synth in real time. This second option has a couple benefits:
  • wavs for the cues not needed
  • can tweak settings on the fly (based on game state)

The zip file includes the app (dinkmaker.jar) and twenty xml preset files that can be loaded and edited.

Very basic, bare-bones GUI at this point. There is some HELP available via the menu bar "Help" (first draft) but I will admit that knowing a bit about audio already will make it much easier to use.

I had some fun working as a "sound designer" instead of as a programmer, and making these patches. If you'd like to listen to a few:  // multiple bird chirps are probably best played at slightly  // different carrier pitches instead of the same pitch

Depending on the browser, there might be a bit of clipping of the files as they are so short.

This is the first time I really worked with Java Properties. I'm trying to use them to store a default directory for the saves and loads. Please let me know if it messes up or if the design can be improved.

Suggestions very much appreciated: on gui, on demo patch set, anything really!

I will look into getting api info up later in the week for use as part of a library. It would be great to have someone using libgdx or android to work with directly, if anyone would like to experiment with trying out the library. I recently wrote a wrapper for lwjgl 3, and earlier wrote an android wrapper. But in both cases it will probably take further tweaking to make it work smoothly.

If anyone wants to, feel free to post patches on this thread. They are just XML (text) files.

Was playing around with ideas on naming, e.g., DinkSynth or DinkySynth for example. DinkMaker doesn't exactly roll off the tongue (and reminds me of Mattel's "ThingMaker": my "Creepy Crawlers" kit from ages past.)
4  Discussions / Miscellaneous Topics / Re: Looking for simple but complete open-source game on: 2016-10-18 21:25:41 had a simple start for SpaceInvaders published as a tutorial. I don't know if this code has been maintained and works with Java8 or not.

I have a puzzle game I started and am wanting to revisit, called Hexara. It started, conceptually as a sort of reverse-Boggle: instead of searching for words in a given puzzle, one builds the puzzle from the list of found words. Except I made it hexagonal and the words became icon-strings. I don't know if this is suitable, in present form, for conversion to multiplayer, but am willing to brainstorm/collaborate and make the source available. I've been wanting to redo the Java2D graphics in JavaFX among other things, if that is an issue, but am open to other ideas.
5  Discussions / Business and Project Management Discussions / Re: Mentor Needed! on: 2016-10-18 21:14:15
I would offer to help, but I haven't dealt with controllers directly, and have not built a tile-map game myself. My interests are more around sound-effect programming.

I'm wondering if you considered using JavaFX instead of Java2D/Swing or the more powerful Libgdx. I'm finding JavaFX easier to use for GUI's than Swing or 2D. Also, it is now an official part of Java and being more recently built, likely more efficient. too. I would think the basic tile-map algorithms should translate from 2D to FX just fine. I have a tutorial that you can probably work through in an hour or so if you want to get a taste of JavaFX on Eclipse.
6  Game Development / Newbie & Debugging Questions / Re: Updated Android studio and libgdx now getting odd error message.. on: 2016-10-13 19:10:47
I've gotten major-minor version error messages before when trying to do something requiring Java 8 with Java 7. Often we have multiple versions on our computers: jre, jdk's jre, 32-bit, 64-bit. What is used by the IDE isn't the same, necessarily as the browser, etc. You probably just have to do some updating.

7  Game Development / Newbie & Debugging Questions / Re: Updated Android studio and libgdx now getting odd error message.. on: 2016-10-11 02:29:46
Sometimes dubious code runs okay until an update makes a background change that nonetheless conforms to the api and spec. Have you tracked down the source of your NPE?
8  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-10-08 08:05:56
Have been a bit obsessive about watching the political drama unfold these last couple weeks, but the news today is kind of mind blowing. I will be very surprised if Trump is still the nominee come the next scheduled debate. (He may claim to be. He may threaten to sue. But I doubt the Republican Party will tolerate him any further. The big guns have to know there is even more filth waiting to get aired and that Trump is no where near bottoming out.)

I was pleased to have finally figured out a way to go from hertz to midi in Java and posted it in the shared code. To my horror, @KaiHH (thank you!) points out that I had mistakenly set A-440 as 45 when it is actually MIDI 69. Two octaves off! I've spent most of the rest of the afternoon and evening going back to old projects, fixing this error. Fortunately, most simply have a constant at the top that is used as a MIDI reference point, and all that was needed was to add 24 to it, so the newly corrected getHertzFromMidi() method would correspond correctly.

Only the AllenSpaceGenerator app has some GUI elements that require recompiling and reposting. The Theremin, however, is not so cleanly structured. It is going to be a headache, and a further lesson in proper coding structures. Mistakes like these, when they happen, should neither be dangerous nor difficult to fix. When they are, it is a sure sign one did a less than adequate job of coding design.  Sad
9  Game Development / Shared Code / Midi and Hertz conversions on: 2016-10-07 21:32:45
The following calculations for finding a Hertz value from a given MIDI note value, and a MIDI note value from a given Hertz value make use of known values for the note A above middle C (aka A4), which has the frequency of 440 Hz and a MIDI# of 69.

Note that a MIDI step of 1 is the equivalent of 1/12th of an octave, where an octave represents a doubling or halving of frequencies.

I would be most grateful for improvements or to learn of faster running alternatives to these functions!

public class MIDIHertzConversionFunctions
   public static double getHertzFromMidi(double midiVal)
      return 440 * Math.pow(2, (midiVal - 69) / 12.0);

   public static double log2(double n)
      return Math.log(n) / Math.log(2);

   public static double getMidiFromHertz(double hertz)
      return ((12 * log2(hertz / 440.0)) + 69);

I ran a bunch of tests of the following nature:
   System.out.println("circular, midi 69: " + PitchFunctions.getMidiFromHertz(
   System.out.println("circular, hz 440: " + PitchFunctions.getHertzFromMidi(

As long as the Hertz value is positive (negative Hertz values produce NaN), the results match with a reasonably tiny amount of error.

It took me a long while to figure out getting MIDI from Hertz, due to a general weakness in mathematics (I was a Music Major in college) and the need to concoct a log2 function from Java's existing log functions. I've relied on workarounds up to now. The impetus to finally get this working came from wanting to store Hz values as frequency settings in XML rather than numbers that were dependent upon the specifics of associated GUI Sliders with discrete, linear granularity.

[EDIT: correction made, thank you KaiHH! Can't believe I was off by two octaves.]
10  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-10-07 06:18:46
Neat to see the progress people are making. But it does make me feel slow and cranky, in comparison. I thought it would be simple to set up a menu bar and save/load working for current project, since I did this once before and had some example code. Just some cut and past, right? But it is a bigger slog than expected.

Recommendation: if you are working on a GUI where you think you are going to implement save/load, definitely go ahead and make separate "model" and "display" instance variables for every item to be part of the save or load. I had quite a few local variables or internal calculations that needed to be part of the save or load. Having to go back and track these down, refactor them as instance variables is tedious. No time was saved by not doing so in the first place.

So, for today, the Menu Bar and the Save file are pretty much working right. Still finishing up the load. Not sure if I have the default file locations and properties file locations set up right yet.
11  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-10-03 03:48:54
Most of Sunday has been spent reconfiguring the UtilityClick maker (DinkMaker) to its third iteration, with carrier, modulator, and lfo that can either be tremolo or vibrato. Just finished the GUI and the api controller and am hoping to test and debug interface to synth very soon. (Hoping it doesn't need much debugging.)

Tedious to rewrite something that takes many hours, on the notion that the new setup will be a little better. I think this will work for both making utility clicks and things like short ray guns bursts. The export-to-wav works well. Discovered the export-to-wav on the ShepardTone thing I wrote is messed up. So will have to fix that at some point.

Tedium is relieved by finding and listening to music by Kaitlyn Aurelia Smith, an awesome Buchla Synthesist I just discovered, with a nice Terry Riley influence (Rainbow in Curved Air).

Following is a duet she plays with veteran synthesist Suzanne Ciani (also known as the voice of Xenon for pinball enthusiasts--this video from 1980 is a hoot!).

Here is the piece where I learned of KAS:
12  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-09-30 01:17:04
My tutorial on starting out with JavaFX looks like it will reach 90,000 hits within a couple days.  Smiley 
Not bad considering it was first posted back in Feb of this year, or sometime close to that! I wish it had resulted in more traffic and posts on our "JavaFX" child board. We've only had something like a half dozen JavaFX posts in the last month?

Got in some good work today on the "Dink" SFX making tool. Reconfiguration of controls for the modulating sine are working. I'm probably going to leave the API in the easiest state to work with as I can, and not stress the GUI too much. Am second-guessing whether to up to two modulators instead of just one: where one can track the pitch of the carrier, and the other optimized for LFO purposes. There are already optional sweeps for the freq and vol of the modulator, but a tight lfo pitch waver added to a brightened carrier:modulator pair can make a good ray gun. That would require two modulators.

Goal remains to get the wav export to work later tonight. While fooling around with it, got a good "penalty whistle" effect--made a screen shot for future reference.
13  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-09-29 06:32:49
WIDT: Mostly read online news and commentary, from multiple sites, about the US Presidential debate. I'm finding it hard not to obsess on this horror show circus of an election. Am glad HRC did as well as she did but sincerely wish the odds on the election outcome were a little more one-sided in her favor. Did a bit of contract work and a handful of practice questions for the Java Associate certification test. I also made a modicum of progress on a tool for making utility clicks and chirps and whistles and possibly laser zaps as well. The notion is that this 2-op FM tool will be usable in multiple ways: save/load configurations, export wavs, or as api for generation of playable Clips, or as an api to play on demand via the mini synth itself. It will only be able to make tone bursts of a max of maybe 3/4 second. 

Also spent a few extra minutes on the way home trying to get a Station Agent or Policeman to check out a fellow collapsed on stairs leading down to the BART station. How are you supposed to tell if it is "merely" a homeless person "taking a nap" or someone collapsed due to a heart attack or diabetic coma or something? (By time I got someone to check him out he was gone, so "just taking a nap" seems to be the proper euphemism here. "Sublimate!" I tell myself. Channel the anger to something useful.)

I am feeling a bit burned out. Hopefully tomorrow will be a fresh, new, and more productive day.
14  Java Game APIs & Engines / Java Sound & OpenAL / Re: Should sound be on its own thread? on: 2016-09-25 18:34:49
If a thread is playing sound, it will not do anything else until the sound is done. So yes, sound playback has to take place in its own thread.

I think it makes sense to organize control of the sound as a whole into a single class. Is that what you are doing with SoundHandler? Or is SoundHandler part of some sort of library that you are using?

Mostly, I've been making the sound handling class static. But in a couple of situations I've done some sound management in the game loop as well. (Your question makes me think maybe I should consider doing more of this.)

For example, game-loop based management makes sense in a situation where the volumes or panning are being updated by the positions of objects on the screen (more common with 3D, but can apply to 2D as well). Another case would be reading the mouse position and putting the [X,Y] values in variables that are only consulted once per game loop and used with the sound methods on that basis. This often makes more sense than triggering the sound with every mouse update.

I'm still learning, though. And a lot depends on the specifics of the game and the sound library you are using (I most use javax.sound.sampled).
15  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Starting game development, need guidance? on: 2016-09-15 21:07:32
I recommend putting the late-comer JavaFX into consideration, as well. (I'm referring to the Java 8 iteration of JavaFX, not the original mess.) I think it is easier to learn and use than Swing/Java2D and has a lot of 3D implemented as well. It is part of the base Java language now. I wrote a tutorial to help get started, if you want to get a taste of it.

I'm not clear what is going on with LWJGL-based game engines right now. A version 3.0 has been created, but the game engines (Libgdx, JMonkeyEngine, Flash) seem to be sticking with 2.9.2 or whatever the last version 2 is. The jump from 2 to 3 is significant. I don't know the extent to which the various game engines shield the user from the OpenGL implementation. Maybe it is a non-issue for the application programmer. Am looking forward to comments that might clarify this situation! Thanks Brynn.

There is also JOGL to consider. Folks that actually have experience with it will have to give you its selling points. I've not tried it myself.
16  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-09-14 17:25:49
People believe what there told to believe...esp when it's convenient and relieves them of any responsibility.

If you would like to get even more depressed, check out this book (I am currently half way through it)
The Crisis Caravan
17  Game Development / Newbie & Debugging Questions / Re: manipulating SourceDataLine on: 2016-09-14 16:42:24
For synchronization you need any non changeable(not null) object that you can access from 2 threads

I use sdl like example – because in many cases you don’t want create new SourceDataLine object in Audio thread.
But to make code clean better create separate syn object
public static final Object Syn = new Object();

Using Direct synchronized from another Thread its rude, same as static Syn object,
but for raw example its ok, and it works just fine

Its prefers for using Sync, i show why:
//Thread 2 set ais_swap
if(ais_swap != null){//Thread 1
   //Thread 2 set ais_swap = null
   //but Thread 1 already pass null check
   ais = ais_swap;//Thread 1 ais = null;
   ais_swap = null;
   swap = true;

Yes its rare, very rare but you can simulate this in debug mode
(stop threads, step line by line for 1, 2 Thread as you want)
synchronized block Prevent this.

Given that the preparation of the cue should probably be on a different thread than the audio playback thread, guaranteeing that a concurrency conflict does not occur is needed. On this I agree with Icecore.

As with most things in programming, there is more than one way.  Smiley

My biases come from when I "got religion" via nsigma about making it a high priority to never block the audio thread. Thus, I avoid using synchronization in the audio thread if I can figure out an efficient non-blocking algorithm. If nothing else, maybe provide a boolean latch and have the audio thread check the latch and "fail" if the AIS is not ready rather than block and wait. An "IllegalStateException" is often thrown in this case.

Also, as the programmer and architect of the sound design, you have the ability to set things up so that the "open" and the "play" of this special sound object (employing multiple AIS and other code) never enter into a race condition. This sort of concurrency requirement would normally be prominently documented in the class, and it would be up to the programmer to implement safely.

But I can also see that if the only audio that is being blocked is the one cue, then using synchronization and waiting is reasonable. This sort of thing is more of a concern in a scenario where all the audio is being mixed down to a single audio thread, as I do with the mixing system I wrote, or with a system like TinySound that also funnels all sound through a single output. There, a single block can delay the entire sound mixing process and contribute to dropouts. (This assumes that the native code that plays back audio will continue to process other cues while the one cue blocks. I don't know if that is how audio works on all implementations.)
18  Game Development / Newbie & Debugging Questions / Re: manipulating SourceDataLine on: 2016-09-14 16:03:10
I'm not sure about step 2 Smiley
Yes it works and almost everyone use it, but is it right?
Its same as Add 2 Red colors bytes, when you must add luminance of colors...
That is a reasonable question to ask. But in fact, from what I have learned from working through this resource, audio signal are indeed linear and can be added. The math supports this.

I doubt that simple multiply Hz of played note on 2.
At least it must be some exponential Curve for Raw adding,
But for more clear it must be something Like LAB space in Color

You are correct in that the relationship between what we hear as a progression from silent to loud and the magnitude of the waves is not linear. However, in the specific application (goal is to avoid creating a click from the discontinuity in the data), linear progression works and executes at less of a cost than using a power curve. Here I am speculating, but I bet that one could shorten the number of frames needed for the transition from silent to full volume by using a power curve, maybe by as much as half or even more. Whether the benefit of using a sweep of 32 instead of 128 frames is worth it is debatable. 128 frames = 3 milliseconds, and at that point, sensory events are next to impossible to discriminate.

But the best test is to try it out and listen to the results.

The links that you provide are for the situation where the volumes of the contributing signals overflow. Yes, compensating for that on the fly requires significant complexity in that one wants to reduce the components in a way that preserves as much of the tonal content as possible.

But my point of view is that if you are getting signals that are too hot to mix, the sanest solution is to just turn them down! Then, all mixing can proceed linearly and all of those complexities (which can be a drag on a limited budget for on-the-fly audio processing) can be avoided. In my conception of how to run things, the person responsible for implementing the audio simply has to review "loudest case" scenarios and listen, checking for the distortion that arises from overflowing. If there is distortion, adjust volumes so that this doesn't happen. If the low end of sounds get lost this way, send the cue back to the sound designer for compression or some other means of narrowing the dynamic range of the cue.

A good sound designer knows how to use a tool like Audacity to provide the desired amount of compression or whatever is needed to best make a sound with levels that "play well" with others. (I would make this a hiring point --> somewhere on the chain from musician or sf/x creator to audio implementer, the knowledge and ability to mix sounds without overflowing.)

There is also the safety mechanism of putting in a Max and Min (for example if the DSP range is -32768 to 32767) is a reasonable choice as well. A little bit of overshooting here can cause clipping, but in some contexts the sound is an interesting effect, especially if you like metal guitar playing.
19  Game Development / Newbie & Debugging Questions / Re: manipulating SourceDataLine on: 2016-09-14 00:18:59
Thanks for that. Now I have a question about the synchronized block. It synchronizes on sdl, but there is nothing inside the block that actually references sdl. Can you please explain to me how this works? Forgive my ignorance!

It's not my example, but I'm not seeing why synchronization is needed.
20  Game Development / Newbie & Debugging Questions / Re: manipulating SourceDataLine on: 2016-09-14 00:17:23
Technical you can mix audio in Byte Array befor send it
but I have no idea how mix "byte Audio data" )
(I believe simple + 2 data's is wrong)

1) Convert the byte data to PCM values (very likely to -32768 to 32767 range if 16-bit data).
2) Add the values from each input (and check to prevent going out of range).
3) Convert back to byte data and ship it out.

Icecore's basic example with multiple AudioInputStream is a good one. And, actually, it is okay if the incoming audio formats differ, as long as you make the necessary conversions before writing the data.

You get to pick when you read from either AIS. Another way to code would be to test if the read from the AIS returns -1. If it does, flip a switch and read from the other AIS without dropping a beat. That would eliminate the need for using a LineListener.

Where I was talking about counting frames, I'm thinking you can also do that by using the skip(long n) method. Let's say you want to start exactly 2 seconds in. If the frame rate is 44100 fps, that would be 88200 frames. If the format is stereo, 16-bit, then there would be 4 bytes per frame, so the number of bytes to read before starting would be 88200 * 4 or 352800 bytes.

Starting or stopping abruptly in the middle of a sound can create a click. To avoid that, do a fade in. Even as few as 32 or 64 frames can suffice. (In the 3-step chart above, the middle step would be to multiply the PCM data by a factor that ranges from 0 to 1 over 64 or however many steps.)

I think we are beyond "Newbie & Debugging..." and that this thread is a good candidate to move over to the Audio part of the Forum.
21  Game Development / Newbie & Debugging Questions / Re: manipulating SourceDataLine on: 2016-09-13 20:44:19
It is possible to run two SourceDataLines at the same time from the same file, but each requires its own AudioInputStream instance.

Theoretically, if you put a LineListener on one and have it launch the other SDL, many of the intervening tasks you mention can occur independently, on their respective threads, and not contribute to a gap. But there will likely still be some sort of gap. I've not tried this myself except in very forgiving situations.

There are some notes about LineListeners here, and the tutorials touch on what I'm calling frame counting in the very last section ("Manipulating the Audio Data Directly") of the tutorial Processing Audio with Controls. Actually, the best code example is in the tutorial Using Files and Format Converters, in the section "Reading Sound Files" -- where the example code has the comment
      // Here, do something useful with the audio data that's 
      // now in the audioBytes array..."

I'm guessing you won't want to get in that deep. Best will probably be just pre-process the sound files into the exact forms that you wish to have them play back as, in Audacity, and load them as Clips when you want to use seamless looping.
22  Game Development / Networking & Multiplayer / Re: Why Threads for the Client on the Server? on: 2016-09-13 17:49:21
Different context, but related?

I was making and using individual threads for audio event streams where certain sound effects schedule their next playbacks. Going to an ExecutivorService, with a FixedThreadPool instead improved performance. But I only need to run a pool of 10, so far.

Kevin Workman's explanation is to the point. I remember this coming up in a lecture in college about operating systems back in the 1980's (I had a work-study job video-taping lectures, I wasn't actually a CS major), where they made a point about there being drawbacks with strict first-in first-out scheduling.

23  Game Development / Newbie & Debugging Questions / Re: manipulating SourceDataLine on: 2016-09-13 17:33:50
I think using a LineListener is going to be both more accurate and more efficient than polling. But if you are trying to make two files play perfectly contiguously and seamlessly, I don't know if that is going to be possible without frame counting.

If you have the midi data I assume that approach can work. You then have to decide whether to provide you own samples or rely on those provided by sound cards. I've only just started working with Java midi myself, so I can't offer much in the way of advice on that topic.
24  Discussions / Miscellaneous Topics / Re: What I did today on: 2016-09-13 09:06:52
I got depressed a bit.

Should display that at the Smithsonian's David H. Koch Hall of Human Origins. Facts would be refreshing in a place where one learns that it is only a matter of time before we evolve more sweat glands in response to global warming.
25  Game Development / Newbie & Debugging Questions / Re: manipulating SourceDataLine on: 2016-09-13 01:37:25
When reading a file via AudioInputStream, I think one has to pretty much start at the beginning and go until the end, or until quitting, whichever comes first.

It is possible to read and throw away input data until you get to the desired starting point. You'd have to count elapsed sound frames in order to know when to switch over to actually streaming data to the SourceDataLine instead of throwing it away.

Another thing is to just take the cue itself and edit it down to exactly where you want to start it. I use Audacity for this sort of thing. If you don't intend to use the first few seconds, clipping off the data will reduce the size of the file which is also a good thing.

Since you want to repeat the cue, you could either append the repeat, again using Audacity, or programmatically put in place a LineListener to determine when the cue ends and use that notification to start another iteration.

Simplest, though, if there is enough RAM to hold the entire cue, would be to go back to making the cue a Clip. Clips allow the programmer to set the "playback head" to any starting point as well as allowing looping.
26  Java Game APIs & Engines / Java Sound & OpenAL / OpenAL and current LWJGL-based tools on: 2016-09-12 07:38:28
I made a working endless, non-repeating campfire sf/x, and it runs on the OpenAL that comes with LWJGL 3. First get it to work, then improve it, right?

If I understand correctly, there are basically four "layers" that require handling for sound:
> device
   > context
      > source
         > buffers

I was puzzling out what should be handled automatically by the class and instance, and what should be provided by the programmer. I'm figuring, since the "source" is given a 3D location, maybe it should be accessible to the programmer (sometimes audio cues need to be moved around). Also, possibly the programmer may be organizing sources into various "contexts."

I'm thinking the cue instance should require the programmer to provide these values as arguments to the constructor. The constructor would then handle setting up the streaming buffers so that the game developer wouldn't ever have to deal with that level of detail, they would just start or stop the CampfireSFX.

But it seemed to me that this could be a lot to ask of the game developer, especially if they had signed up for a library to help shield them from managing these details.

So...I thought the thing to do would be to see how the various game engines handle "device" and "context" and "source". First look was at a Slick audio example and...full stop: it is using LWJGL 2, not 3.

A quick look at our JGO "OpenGL" forum shows the first entry as LWJGL 2.9.2.
Does Libgdx also still use 2.9.2?
Does JMonkeyEngine also still use 2.9.2?
If so, are there plans to migrate to 3?

It is not clear to me from the documentation what versions of LWJGL these engines are using. I guess I just need to go ahead and download them and see what I get...
27  Games Center / WIP games, tools & toy projects / Re: PFTheremin on: 2016-09-09 19:56:09
Nice app, worked fine for me on windows 10 java 8.
The default settings make a spooky wail. Will be interesting to see how you and others tune and use it.
I have no experience in how to make or use sound but intend to learn one day.

Good to hear!

Re learning audio: no time like the present!

You comment brings up a point though which is that I haven't made a place where people can share patches. Maybe, since they are text files (xml, that is), the simplest thing is to post patches on this thread if anyone wants to share? I don't think I can support a forum on my website. Maybe it is possible but I haven't figured out how.

I've been meaning to post more myself, but I'm letting "perfect pictures" get in the way. I've been intending to do things like rent "The Day the Earth Stood Still" or "The Red Planet" and try and replicate the effects used there, or maybe try and match the theremin in "Good Vibrations" or "Dark Shadows". Too ambitious, should just post some that illustrate basic capabilities.

I did make one upgrade to the program a few weeks ago. There's a trade off with screen size, pitch range and pitch precision. The wider the range, the more difficult it is to hit specific notes. What I came up with is this: when hitting the shift key, the mouse pitch stays the same, playing or not, where ever you move. Thus either in silences or on held notes, use of the shift key and maneuvering can shift the screen pitch range to the area you wish to play in.
28  Games Center / WIP games, tools & toy projects / Re: PFTheremin on: 2016-09-09 19:43:04
Very cool.

Do you happen to have the source for this on github or a similar site?

Thank you for the compliment!

The only code that is posted has been posted here on JGO over the years. I've been working on getting better at using Java Sound (javax.sound.sampled) for several years now, and the posting reflect progress made and issues dealt with. Some of the later code is better than the earlier stuff I posted.

I am happy to answer questions on it or on how to make things using Java Sound. I have a notification attached to the jgo audio forum and always check on anything posted there.
29  Game Development / Newbie & Debugging Questions / Re: Reading mp3's from executable jar file on: 2016-09-08 01:48:09
I haven't looked closely at your solution. If it works, great! Very glad to hear it is all running more smoothly. Java's sound classes are much maligned (mostly due to difficult-to-assimilate documentation), but they are capable of performing quite well, imho.

I have some questions about how to properly implement this. Since exec is static, it would be senseless to have more than one instance of SoundThreadPool, so it would be instantiated somewhere like the main Game class, correct?

What I do is to make a class called SoundHandler or GameSound or something like that and make it the top organizational point for all game sound. The executor is called in the SoundHandler constructor:

    new SoundThreadPool(10);

That is all that is needed.

The SoundHandler has (among other things) two methods, a start() and a stop(). I put the shutdown code in the stop() method:

Is there an event listener that detects a program shutdown, like clicking to close the window?

I've only made GUIs with JavaFX since coming up with this scheme. The main JavaFX GUI element is type Stage. It has the following method for detecting closes:
    stage.setOnCloseRequest( e -> cleanShutdown() );

The method cleanShutdown() is where I put soundHandler.stop() which in turn calls SoundThreadPool.shutdown().

I haven't tried this with Swing yet. I did a search and found this which looks like just the way to go:

Working with the Runtime thread looks interesting! I haven't delved into that area yet, and know little about it's mysteries or capabilities. Just goes to show, though, that there's almost always more than one way to accomplish something.
30  Game Development / Newbie & Debugging Questions / Re: Reading mp3's from executable jar file on: 2016-09-07 21:03:32
Looks solid. I could see where it might take a few seconds to decode and load all these cues. That could happen on a background thread, perhaps. Depending upon their length, some of the "songs" might be better off as SourceDataLines. Unlike a Clip, though, you can only use one once before having to close it and open a new one.

Since each playback requires a new Thread, you might experiment with using an ExecutiveService.

public class SoundThreadPool {

   private static ExecutorService exec;
   public SoundThreadPool(int nThreads)
      exec = Executors.newFixedThreadPool(nThreads);
   public static void shutdown()
   public static void execute(Runnable command)

Initialize it to something that covers your maximum use case (how many concurrent sounds--then add a couple more for safety) Then, code something like the following in your play and loop methods:

     SoundThreadPool.execute(new Runnable() {
         public void run() {

Making and destroying Threads has more than the usual overhead for most Objects and so it often benefits from pooling. Note: the Executor will need to be shut down as part of exiting the app.

I think my pool class above is reasonably efficient. I haven't exposed it to scrutiny before. It is pretty simple and bare bones. I'm finding it has improved the performance of my soundscapes, and it has also made coding the individual cues a bit easier. Maybe this will alleviate some of the latencies (if they are related to the overhead of making new Threads).
Pages: [1] 2 3 ... 47
theagentd (10 views)
2016-10-24 17:51:53

theagentd (9 views)
2016-10-24 17:50:08

theagentd (9 views)
2016-10-24 17:43:15

CommanderKeith (35 views)
2016-10-22 15:22:05

Roquen (39 views)
2016-10-22 01:57:43

Roquen (52 views)
2016-10-17 12:09:13

Roquen (54 views)
2016-10-17 12:07:20

Icecore (68 views)
2016-10-15 19:51:22

theagentd (331 views)
2016-10-04 17:29:37

theagentd (335 views)
2016-10-04 17:27:27
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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‑
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!