Streaming Sound?

Okay, for some reason I'm not getting any sound playing now with SoundSystem.createStream(url):



In my init:

        snode = SoundSystem.createSoundNode();
        URL url = SoccerGame.class.getResource("/data/music/beat_plus.ogg");
        background = SoundSystem.createStream(url);
        SoundSystem.setSampleMaxAudibleDistance(background, 1000);
        SoundSystem.setCamera(pg.getCamera());
        SoundSystem.addSampleToNode(background, snode);
        SoundSystem.setSampleVolume(background, 1.0f);
        SoundSystem.setStreamLooping(background, true);



In my update:

SoundSystem.update(0.0f);



In my render:

SoundSystem.draw(snode);



Now if I swap the code back to SoundSystem.create3DSample(url) it works just fine, but when I switch it back it stops working.  Is there something extra I need to do here?

darkfrog

update and draw doesnt really apply to a stream…neither does maxaudibledistance, setcamera, addsample etc, they apply only to sample3d's which are created by the createSample method…



this is all you need to do to kickstart a stream:



      URL rootUrl = getClass().getClassLoader().getResource("("/data/music/beat_plus.ogg");
      log.debug("Trying to load streaming background ...");
      background = SoundSystem.createStream(rootUrl);
      if(SoundSystem.isStreamOpened(background)) {
         int lgth = (int) SoundSystem.getStreamLength(background);
         log.debug("Stream background loaded! Music length:" + lgth);
         SoundSystem.playStream(background);
      }
      else {
         log.debug("Failed to open stream!");
      }

Awesome, that worked. :slight_smile:



Okay, so how do I fade-out a streamed sound or even change the volume?



darkfrog

doesnt seem like that's implemented yet…arman?

maybe you can fake it with an Equlizer  :smiley:

Okay, thanks for the info.



darkfrog

Hm, last time i looked the method calling 'gain' in openal missed for streams but should be easy to add.

(i suggested it a few threads back)

i'll try to hack that in and see how it works…

Stream Volume control done

great work!

Arman,



Great job!  I'm sure you're getting sick of me by now, but when the stream was finished and I would think should have looped (I tried to enable looping) I got this exception:


Exception in thread "Thread-9" java.lang.NullPointerException
   at java.io.FileInputStream.<init>(FileInputStream.java:103)
   at java.io.FileInputStream.<init>(FileInputStream.java:66)
   at com.jmex.sound.openAL.objects.util.StreamPlayer.reopenOgg(StreamPlayer.java:122)
   at com.jmex.sound.openAL.objects.util.StreamPlayer.open(StreamPlayer.java:103)
   at com.jmex.sound.openAL.objects.util.StreamPlayer.access$0(StreamPlayer.java:98)
   at com.jmex.sound.openAL.objects.util.StreamPlayer$Player.run(StreamPlayer.java:407)
   at com.jmex.sound.openAL.objects.util.StreamPlayer$Player.run(StreamPlayer.java:425)
   at java.lang.Thread.run(Thread.java:595)



Thanks,

darkfrog

you are damn hard to please  :smiley:

Can you tell me the revision of your StreamPlayer please?

just looked through the code and i can see that you changed


tmp = new OggInputStream(file.openStream());



to


tmp = open(file.getFile(), true);



in StreamPlayer.java...

this just reverts the usage of the URL version to being the same as using createStream(/*string*/ url.getFile()), which brakes the reason i made the URL version all together...

url.openStream() is not the same as FileInputStream(url.getFile())...

I know but for the moment the files should be loaded locally… until I add the remote streaming capability…

The code you added does not load Wav files and it does not calculate the length of the stream…

For me it was a quick fix (more than I do quick fixes!!!) thats why I changed the code.

One question : Can someone tell me if you have seen any game loding sounds from a remote location?

As I always see the files are loaded locally in any game…This may be because of network lag… And not everybody has a dsl connection in networked games…

well, at least the code i added works when loading streams from a jar-file(and locally), which was why i added the code…

Yeah, that's why I need URL loading as well.  The way Arman did it is fine when I'm developing, but when I release I plan on keeping the music in JAR files.



darkfrog

CVS commit ok : TOTAL URL support on openAL side :smiley:

Hurray for Arman! :slight_smile:



darkfrog

spanx!