SoundJLayer

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

SoundJLayer

jfpauly
SoundJLayer does not work in my code now. Is it a known problem ??
Thank you for help
jf Pauly (project Cliper on SourceForge)
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

gouessej
Administrator
Hello

I'm going to look into your source code but please be more accurate.

By the way, the french hosting service "PagesPerso" provided by Orange was closed this month. I advise you to host your website elsewhere (directly on Sourceforge?). I advise you to use a versioning system, either Subversion or Git, both are available on Sourceforge as far as I remember.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

gouessej
Administrator
In reply to this post by jfpauly
I'll really need some information. SoundJLayer uses JLayer.jar, is your problem in SoundJLayer itself?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

jfpauly
Thank you for your fast reply. All my stuff was on pageperso hosting and I did not know it was  closed.
Not only sound does not work but access to textures, imported objects,...
A lot of work for me now. Sometime in the past, as my project is not on Github, for instance, you said to me : <<make an effort>>. I should. Thank you again...
jf Pauly
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

gouessej
Administrator
I didn't suggest you to use Github, you can use Git on Sourceforge or elsewhere.

What do you mean by "Not only sound does not work"? Do you succeed in compiling your project? I remind you that Java3D 1.6 and Java3D >= 1.7 use two distinct package namespaces as we're not allowed to name our packages "javax". Can you indicate exactly which version of Java3D you use, your version of Java and your operating system? If you use Java >= 9, do you use the necessary "--add-exports" and "--add-opens" clauses? Have you ever read my tutorial?

I don't want to be harsh with you. If you really want to allow people to use your project, it will be better to use a versioning system to ease the understanding of its evolution. If you make it easy to build by using a popular build tool or build system, it will cause less friction and less useless surprise. Ideally, a Java programmer should be able to get your source code and build your project within a few minutes. The more time (s)he has to spend in understanding how to build it, the more chance you have (s)he will just give up.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

jfpauly
The project did not work recently because orange hosting is stopped. I did not know . Fortunatly you said it to me.
Sound was  down without any message from this code :

public void play(String Path) {
            Object file = Path;
            try {
                player = new AdvancedPlayer(new java.net.URL(Path).openStream(),
                        javazoom.jl.player.FactoryRegistry.systemRegistry().createAudioDevice());
                player.setPlayBackListener(this);
                Thread playerThread = new Thread(this, "AudioPlayerThread");
                playerThread.start();
            } catch (Exception ex) {
                System.out.println(ex);
                JOptionPane.showMessageDialog(menupane1, file, "File is bad or not found",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
Why. I do not know. Anyway the problem ,is not here. May be something around threads  ??

Here is what I am going to do.

1- move files (textures, sounds, 3d models,..) in the dist file. Repackage to get project working.
2- document project in classes comments (may be elsewhere).
3- Follow your advice and put project in Git. Here, I start from scratch.

If I understand it would allow other Java programmers to get project more easily than getting a  Netbeans project.
Ideally, someone would take the project for him with my help, and may be make it live.

Thank you for your advices.
jf Pauly

 

Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

gouessej
Administrator
The problem doesn't come from Java3D. JLayer relies on the standard audio API (JavaSound), which I stopped using many years ago because of some bugs and limitations. JLayer is terribly old and unmaintained as far as I know. I've found some posts on StackOverflow that suggest that playing MP3 files with JLayer stopped working since Java 9 in some cases. I advise you to debug to ensure that the file is found (it seems to be the case). The problem is that there are only a very few alternatives to JLayer, JavaFX/OpenJFX (javafx.scene.media) is able to play MP3 files, Paul Lamb's sound library works and there is probably a combination of plugins allowing it to play MP3 files but it's not very actively maintained, JMF is abandoned.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

basti
This post was updated on .
In reply to this post by jfpauly
Hello jfpauly,
in addition to Julien's replies i would like to suggest a Java3D approach limited to WAV and AU files.
If you're not strictly bound to MP3, of course.

BackgroundSoundTest.java

greetings,
basti

EDIT:
I realised that parenting the BackgroundSound instance directly to the root BranchGroup is not suitable for use-cases in which
the sound is not needed anymore once a certain event occurs, and therefore is just hogging memory. To be able to detach it
from the scene it needs to be in it's own BranchGroup. So just in case someone stumbles upon this, a possible solution could be this:

/**
 * Implementation of BackgroundSound able to be detached from scene graph.
 *
 * @author basti
 */
public class DetachableBackgroundSound extends BackgroundSound {
   
    /* Parent of bgSound, e.g.: the root BranchGroup */
    private final BranchGroup parent;
   
    /* Immediate parent of this class, since only instances of
       BranchGroup can be detached from scene. */
    private final BranchGroup bgSound;

    /**
     * Creates new instance of DetachableBackgroundSound.
     * @param parent the BranchGroup to act as parent of bgSound
     */
    public DetachableBackgroundSound(BranchGroup parent) {
        this.parent = parent;
        this.bgSound = new BranchGroup();
       
        checkStateOfParent();
        setCapabilities();
        addToSceneGraph();
    }
   
    /**
     * Frees sound data and detaches BranchGroup containing sound from scene
     * graph.
     */
    public void detachFromSceneGraph() {
        setSoundData(null);
        bgSound.detach();
    }

    /**
     * Checks if parent BranchGroup has needed capability set.
     *
     * @throws IllegalStateException if capability must be set but parent is
     *      live
     * @throws IllegalStateException if capability must be set but parent is
     *      compiled
     */
    private void checkStateOfParent() {
        int capability = BranchGroup.ALLOW_CHILDREN_WRITE;
       
        if (!parent.getCapability(capability)) {
            if(parent.isCompiled()) {
                throw new IllegalStateException(
                    "Unable to set capability to write children, because " +
                    "parent BranchGroup is already compiled.");
            }
            else if(parent.isLive()) {
                throw new IllegalStateException(
                    "Unable to set capability to write children, because " +
                    "parent BranchGroup is already live.");
            }
            parent.setCapability(capability);
        }
    }

    private void setCapabilities() {
        bgSound.setCapability(BranchGroup.ALLOW_DETACH);
        setCapability(BackgroundSound.ALLOW_SOUND_DATA_WRITE);
    }

    private void addToSceneGraph() {
        bgSound.addChild(this);
        parent.addChild(bgSound);
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

gouessej
Administrator
Excellent idea basti, yes it's possible to use org.jogamp.java3d.MediaContainer and org.jogamp.java3d.BackgroundSound (maybe other child classes of org.jogamp.java3d.Sound too).

As it relies on JavaSound under the hood, MIDI, SND, AIFF-C and AIFF are supported too, call AudioSystem.getAudioFileTypes() to check that.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

jfpauly
Thank you Basti and J Gouesse for replies. JavaSound works now because problem was in Host support stopped.
But in future coding I shall use your advices.
Regards.
jf Pauly
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

gouessej
Administrator
Thank you for the feedback. I'm glad to see you've just solved your problem. Yes, keep it in your todo list, you know that you rely on an unmaintained third party library, it's up to you to manage your priorities.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

Sven Gothel
Administrator
Sorry, haven't fully followed this track.

Just throwing in our AudioSink and ALAudioSink implementation using OpenAL
as a PTS accurate output _plus_ our dear GLMediaPlayer,
which also can play just audio - any format your ffmpeg installed library supports.

The latter of course on the default systems using ffmpeg, i.e. ex-android.
For that .. I might need to dabble and test a little .. but should also work
with the Android audio backend.

+++

I am meditating with Bug 1472 https://jogamp.org/bugzilla//show_bug.cgi?id=1472
resolving AV sync issues - which looks and sound good now.
Yeah, more a self therapy to distract in these times.
Reply | Threaded
Open this post in threaded view
|

Re: SoundJLayer

basti
This post was updated on .
@gouessej
Oh yes i forgot about the other child classes (e.g.: PointSound), and thanks for mentioning AudioSystem.getAudioFileTypes()
i wasn't aware.

@jfpauly
nice to see your problem resolved.

@Sven Gothel
Hello, i'm trying to get FFMPEGMediaPlayer to work, but no luck so far.

I downloaded ffmpeg-n5.1.3-16-g566aa38d98-win64-gpl-shared-5.1.zip
Then i extracted: avcodec-59.dll, avformat-59.dll and avutil-57.dll to my working-directory and renamed them to avcodec, avformat and avutil.
Which should work if i'm interpreting the source right FFMPEGDynamicLibraryBundleInfo
If i run:
System.out.println("FFMPEGMediaPlayer available: " + FFMPEGMediaPlayer.isAvailable());
GLMediaPlayer gLMediaPlayer = new FFMPEGMediaPlayer();


i get this error:
FFMPEGMediaPlayer available: false
FFMPEG Tool library incomplete: [ avutil true, avformat false, avcodec false]
LIB_AV Not Available: lavu, lavc, lavu
Exception in thread "main" java.lang.RuntimeException: FFMPEGMediaPlayer not available
        at jogamp.opengl.util.av.impl.FFMPEGMediaPlayer.<init>(FFMPEGMediaPlayer.java:320)
        at soundtest.GLMediaPlayerTest.main(GLMediaPlayerTest.java:25)


So apparently the avutil.dll was found but the other two were not.

I'm running Java3D 1.7.1 on Windows 10.

Maybe you can help me, thanks.

EDIT:
I realized that i'm still using jogAmp 2.4 so i switched to 2.5 jogamp-current
Now i'm getting:

FFMPEG Tool library incomplete: [ avcodec false, avformat false, avutil true, swres false ]
FFmpeg Not Available, missing libs: avcodec, avformat, swresample

Debug output via -Djogl.debug says:

Checking for Java2D/OpenGL support
Java2D support: default GraphicsConfiguration = sun.awt.Win32GraphicsConfig
JOGL/Java2D OGL Pipeline active false, resourceCompatible false

Is there a way to set the GraphicsConfiguration to 64bit, or would a 32bit version of ffmpeg help ?