JOAL SoundTest, doesn't seem to pan sound

After modifying the SoundTest.java in com.xith3d.test to use an 8-bit wav file instead of an ogg file (see here), I was finally able to get the demo to load and play the song. However, as the camera moved around, the PointSound didn’t seem to be panning or changing in volume in any way. Does this work for anyone?

move to fmod and roll your own. openal is a bit if’e. even
the one on creatives site is not to hot.

[quote]move to fmod and roll your own. openal is a bit if’e. even
the one on creatives site is not to hot.
[/quote]
Wow, this is a really nice library… I’ve never even heard of it till now. It’s too bad that guy’s java port doesn’t support mac after a certain version… So, does anyone have any examples of how to use fmod with Xith3D to make 3D sound?

i have made a macosx and windows version java fmod.
will be coming real soon. just updating it to be inline
with the new fmod. also a licence la de dar to sort out.

there should be some sound demos in lwjgl-fmod. but all in all fmod looks after everyting for you :).

just get fmod to play a sound file. the 3d bit is way simple. initing fmod and all that jazz is abit of messing
around. but when u have that down your sorted :slight_smile:

[quote]i have made a macosx and windows version java fmod.
will be coming real soon. just updating it to be inline
with the new fmod. also a licence la de dar to sort out.

there should be some sound demos in lwjgl-fmod. but all in all fmod looks after everyting for you :).

just get fmod to play a sound file. the 3d bit is way simple. initing fmod and all that jazz is abit of messing
around. but when u have that down your sorted :slight_smile:
[/quote]
Great! I can’t wait to see it when it’s done. Could you post a link on this forum when it’s finished?

Hi,

I’m trying do do a test of FSound_Stream_Create . Anyone got an example of the FSoundStreamCallback needed?

I keep getting, though I have a basic implementation of the interface:
Exception in thread “main” org.lwjgl.fmod3.FMODException: missing implementation
at org.lwjgl.fmod3.FSound.nFSOUND_Stream_Create(Native Method)
at org.lwjgl.fmod3.FSound.FSOUND_Stream_Create(Unknown Source)
at

Many Thanks,
pc

The create using custom stream callbacks is unimplemented. I have stalled fmod updates, since I am waiting for what aNt will present…

thnx for the update. Suspected that might be the case (from the error message).
Please keep us posted on the progress.

ps: it works ok in the nativeFmod implementation done with swig.

make sure u have the latest build from the cvs. Manson did
get the callbacks working for dsp. goes gets dsp shenanigins

sod it :slight_smile: here we go my first tutorial on using fmod :wink:

ok first off im hoping you have got a demo working of the java fmod? so u have the dll and jar setup the way you like them? Cool.

Now lets import all the needed jazz to play an audio stream using the fmod lwjgl build (there is another build by jerome out there on the web).


import java.io.*;

import org.lwjgl.fmod3.FMOD;
import org.lwjgl.fmod3.FMODException;
import org.lwjgl.fmod3.FSound;
import org.lwjgl.fmod3.FSoundDSPUnit;
import org.lwjgl.fmod3.FSoundStream;

I’m importing the DSP fmod jazz so you can play with the callbacks. So that’s that little area covered. Next we need to init fmod and set some little card related things up.


public void innit() {
    try {
      // start up fmod java.
      FMOD.create();
      // lets set fmods output to use DirectSound.
      FSound.FSOUND_SetOutput(FSound.FSOUND_OUTPUT_DSOUND);
      // lets use the first audio Driver. other drivers would be other
      // speaker systems on the system. headphones, internal speakers etc.
      FSound.FSOUND_SetDriver(0);
      // we will let fmod handle the mixer in our case.
      FSound.FSOUND_SetMixer(FSound.FSOUND_MIXER_AUTODETECT);
      // now we need to init fmod.
      FSound.FSOUND_Init(32000, AUDIO_COUNT, 0);
      // 3d sound managment- not yet implimented when I was messing 
      // around with lwjgl should be there by now mind.
      // FSound.FSOUND_3D_SetDistanceFactor(50f);
      // FSound.FSOUND_3D_SetRolloffFactor(1f);
    } catch (FMODException ex) {
      System.out.println("Cant connect to Native FMOD.create: ");
      ex.printStackTrace();
    }
  }

Now when I made this demo the 3d jazz wasn’t all there. And I haven’t looked at the lwjgl fmod in a while because we made our own in the end here at tomato. But I would expect lwjgl dudes added the 3d in no time at all.

Ok now we need to load and play sound file (wav, mp3, ogg etc).


  public void loadFilePlay(String filePath) {
    try {
      // just get the full file path.
      String file = (new File(filePath)).getAbsolutePath();
      // load the audio file into a FSoundStream- you could force it to mono here..
      stream[CHAN_COUNT] = FSound.FSOUND_Stream_Open(file, FSound.FSOUND_NORMAL, 0, 0);
      // set the sound file to loop.
      FSound.FSOUND_Stream_SetMode(stream[CHAN_COUNT], FSound.FSOUND_LOOP_NORMAL);
      // get the Hz of the file in X channel to play.
      int hzs = 11024; //FSound.FSOUND_GetFrequency(CHAN_COUNT);
      System.out.println("fmod HZ: " + hzs);

      ///////////////// lowpass filter start DSP (just a lowpass filter class)
      IIRLowpassFilterDesign lpf = new IIRLowpassFilterDesign(5000, hzs, 1.0);
      lpf.doFilterDesign(); lpf.printCoefficients();
      ///////////////// lowpass filter end

      // make a dsp callback.
      unit = FSound.FSOUND_Stream_CreateDSP(stream[CHAN_COUNT], new DSPCallingUBack("1", lpf), 1);
      // wack the dsp unit on- need this to get it ticking away.
      FSound.FSOUND_DSP_SetActive(unit, true);
      // lets play the file.
      play(CHAN_COUNT);
      // move up into the next channel.
      // CHAN_COUNT++; // not needed.
    } catch (Exception ex) {
      System.out.println("cant find the file most likely:");
      ex.printStackTrace();
    }
  }

Now the above call does everything. I made a DSP filter (never worked, because I have no idea how to make dsp filters. Not fmod or anything else- just me). This filter gets attached to the callback and your sorted. Here what the callback class looks like:


import java.nio.*;

import org.lwjgl.fmod3.FSound;
import org.lwjgl.fmod3.callbacks.FSoundDSPCallback;

import ant.audio.filters.*;

public class DSPCallingUBack implements FSoundDSPCallback {
  private String name;
  private IIRLowpassFilterDesign lpfd = null;
  private IIRLowpassFilter lpf = null;

  public DSPCallingUBack(String name, IIRLowpassFilterDesign lpfd) {
    this.name = name;
    this.lpfd = lpfd;
    this.lpf = new IIRLowpassFilter(lpfd);
  }

  private int random(int num) {
    return ( (int) (Math.random() * num));
  }

  /**
   * originalbuffer: This is the pointer to the original buffer passed into the
   * first DSP unit. This is useful if you want the clean, original data, and you
   * have been returning new modified buffers for the DSP chain to use.
   *
   * newbuffer: This is a pointer to the previous DSP buffer that *it* returned.
   * This buffer that this DSP returns will be passed into the newbuffer parameter
   * of the NEXT unit in the DSP chain.
   *
   * length: The length of the buffer provided in SAMPLES, not bytes.
   **/

  public ByteBuffer FSOUND_DSPCALLBACK(ByteBuffer originalbuffer, ByteBuffer newbuffer, int length) {

      // Filter the data
      lpf.doFilter(originalbuffer, newbuffer, length);

      newbuffer.rewind();
      return newbuffer;
  }
}

Pretty much ripped off from Manson’s test on callbacks. The filter itself is a mess and I think I got it all wrong. But the class for fmod does work with callbacks.

Now 3d is just as simple. all u do is call the 3d functions on the channel your sound is attached and then do an fmod.update();

Well hope that helps. If u would like more info on 3d sound just yell. :slight_smile:

Hey thanks for the info, I’ll have a look at your suggestions.

I’m testing some ideas for real-time 3d procedural audio, but I don’t think it will work in 3d. I have tried to extend the userstream example to a 3d one. Currently using the nativeFmod Sig wrapper userstream example, but have run into a showstopper.

Fmod docs:
FSOUND_Sample_Load(int index, const char *name_or_data, unsigned int inputmode, int offset, int length); Bitwise OR in the FSOUND_HW3D flag into the mode parameter of the loading function.

It says name_or_data, but I’m not sure if you can get the bytebuffer from a stream callback into the Sample_load, or if FSOUND_HW3D works for streams? Gave me some errors when I tried.

UPDATE: 3d streams ok
stream = NativeFmod.FSOUND_Stream_Create(streamcallback, 6*2048, FSOUND_HW3D |FSOUND_FORCEMONO | FSOUND_NORMAL | FSOUND_16BITS , 44100, null);

thanks,
pc

I want 3d sound :slight_smile:

3d sound works fine for me on lwjgl/jme openal/fmod/nativeFmod…now give me 3d sound with real-time audio ::slight_smile:

Found some more info
http://www.fmod.org/forum/viewtopic.php?t=2427&highlight=3d
that looks positive :smiley:

as in u want to stream the sound? well u can do that
with fmod- just load the sound as a stream. u can even
make your own sounds on the fly using DSP callbacks.
netaudio works also.

main thing is some sounds types cant use the HW because
of the way the hardware loads audio. but then have u
seen the cpu hit of fmod? its like sod all.

[quote]The create using custom stream callbacks is unimplemented. I have stalled fmod updates, since I am waiting for what aNt will present…
[/quote]
Pity :frowning:

After checking the FMOD forums, I successfully tested this with the nativeFmod implementation, so 3d with a user created audio stream now works fine. FSOUND_HW3D |FSOUND_FORCEMONO | on the stream create does the trick.

Now I get a problem doing custom DSP on this. Not sure if this is a nativeFMod error or what…still working on it.

Latest CVS LWJGL notes:
Missing implementations:
FSOUND_File_SetCallbacks
FSOUND_Stream_Create

Do you think this will be implemented soon?

I’d like to use the fmod implementation over nativFmod as it looks a little cleaner.

Also it looks like the eax FSOUND_REVERB_PRESETS are not implemented in the lwjgl fmod binding?

Thanks,
pc

UPDATE: http://www.mojomonkeycoding.com/jmeforum/viewtopic.php?t=732

You are correct. I haven’t worked on lwjgl-fmod for some time, since I needed some tests to test the functionality and largely because aNt is comming out with an fmod binding too, which afaik should be more complete and OO. Depending on how that stuff looks, I think that, that will become the de facto binding. If not, I’ll resume work on lwjgl-fmod.

And yeah - swig generated bindings look like crap, and shouldn’t be let loose at all. This was the main reason behind lwjgl-fmod (that, and the stupid license for NativeFMOD).

oki doki…thnx for the update.

Any idea of your fmod binding status, aNt?

pc

its all working and finished- should be on a site near you
in a few weeks. need to check a few things before
eveyone here rips the piss out of it :slight_smile:

I’d be happy to alpha/beta/theta test it beforehand if you wish. No ripping, just focused feedback ::slight_smile: