Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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  
  Making "looping" work  (Read 1526 times)
0 Members and 1 Guest are viewing this topic.
Offline Rorkien
« Posted 2012-07-19 21:49:47 »

Sooo, i've been using that 3D Sound Engine from Paul's Code, but i can't get stuff to loop, check the examples:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
import paulscode.sound.SoundSystem;
import paulscode.sound.SoundSystemConfig;
import paulscode.sound.SoundSystemException;
import paulscode.sound.codecs.CodecJOgg;
import paulscode.sound.libraries.LibraryJavaSound;

public class Example_2 {
   SoundSystem mySoundSystem;
   
    public static void main(String[] args) {
        new Example_2();
    }

    public Example_2() {
        try {
            SoundSystemConfig.addLibrary(LibraryJavaSound.class);
            SoundSystemConfig.setCodec("ogg", CodecJOgg.class);
            SoundSystemConfig.setSoundFilesPackage("");
            mySoundSystem = new SoundSystem(LibraryJavaSound.class);
        }
        catch(SoundSystemException e) {
            System.err.println("WE GOT AN ERROR HERE HOUSTON" );
        }
       
        String filename = "hurr.ogg";
       
        //Plays once.
        mySoundSystem.backgroundMusic("music", getClass().getResource(filename), filename, false);
        mySoundSystem.setLooping("music", true);
        mySoundSystem.play("music");
       
        //If looping is set to false, plays the first 6 seconds, then stops. If looping is set to true, it keeps looping the same 6 seconds.  
        mySoundSystem.newSource(false, "music", getClass().getResource(filename), filename, false, 0, 0, 0, SoundSystemConfig.ATTENUATION_NONE, SoundSystemConfig.getDefaultRolloff());
        mySoundSystem.setLooping("music", true);
        mySoundSystem.play("music");

        //Same as above.
        mySoundSystem.quickPlay(false, filename, true, 0, 0, 0, SoundSystemConfig.ATTENUATION_NONE, SoundSystemConfig.getDefaultRolloff());
   
        //Does not loop.
        mySoundSystem.quickStream(false, getClass().getResource(filename), filename, true, 0, 0, 0, SoundSystemConfig.ATTENUATION_NONE, SoundSystemConfig.getDefaultRolloff());

        //Plays once. queueSound does nothing.
        mySoundSystem.newStreamingSource(false, "music", getClass().getResource(filename), filename, true, 0, 0, 0, SoundSystemConfig.ATTENUATION_NONE, SoundSystemConfig.getDefaultRolloff());
        mySoundSystem.setLooping("music", true);
        mySoundSystem.queueSound("music", getClass().getResource(filename), filename);
        mySoundSystem.play("music");
               
        while(true) {
          if (mySoundSystem.playing("music")) System.out.println(mySoundSystem.millisecondsPlayed("music"));
       }
    }
}


I actually managed to make the song loop manually, using the millisecondsPlayed() method, but the loop isn't seamless
Any ideas or reccomendations on audio libs?
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #1 - Posted 2012-07-19 22:36:59 »

1  
 myMusicSystem.backgroundMusic("sourcename", "music/mymusic.ogg", true); /* last parameter tells to loop */

Offline Rorkien
« Reply #2 - Posted 2012-07-19 22:51:21 »

1  
 myMusicSystem.backgroundMusic("sourcename", "music/mymusic.ogg", true); /* last parameter tells to loop */


I tried that as well. Same results.

The mySoundSystem.setLooping("music", true); was just to emphatize it
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #3 - Posted 2012-07-19 23:12:20 »

Well it just works here. Maybe the coded you're using is failing to notify end of stream.
Which codec you're using?

Offline Rorkien
« Reply #4 - Posted 2012-07-19 23:13:57 »

Well it just works here. Maybe the coded you're using is failing to notify end of stream.
Which codec you're using?

CodecJOgg

But you are telling me it works. It got my hopes back  Smiley

EDIT: Switched to CodecJOrbis. No difference.

Another EDIT: Turns out it was JavaSound doing a poor work. Switched to LWJGLOpenAL and now it works flawlessly.
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.

Longarmx (46 views)
2014-10-17 03:59:02

Norakomi (37 views)
2014-10-16 15:22:06

Norakomi (29 views)
2014-10-16 15:20:20

lcass (32 views)
2014-10-15 16:18:58

TehJavaDev (62 views)
2014-10-14 00:39:48

TehJavaDev (62 views)
2014-10-14 00:35:47

TehJavaDev (52 views)
2014-10-14 00:32:37

BurntPizza (70 views)
2014-10-11 23:24:42

BurntPizza (41 views)
2014-10-11 23:10:45

BurntPizza (82 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!