Redeclaring Audio Assets

lmao I know its not that part of the declaration its the new new AudioNode(asset, s, false); My apologies that is what I meant before lol.



I attempt declaring a new AudioNode as stated above and it still hangs at that section. I also attempted simply creating and playing a new AudioNode and saving only the file location at the previous point declaring and playing a new AudioNode every time the play button is pressed however the result is the same. I did find out through a user case using Simple application that i have no problem switching between two AudioNodes however So I have no idea why my module is giving an issue.



If it helps this is for a platform module that Iā€™m helping with.

This:

currentClip = new AudioNode(asset, s, false);

May be causing your app to hang.



But this part:

currentClip =



Is definitely not. I stake my life on it.



If youā€™ve narrowed it down to that line then even:

AudioNode foo = new AudioNode(asset, s, false);



Would hang. Or there is something wrong with your debugging methodology.

Dude, your testcase worked for me, and in a high fps 1608 xD. Btw your code just load the audio once, I had to slightly modify it, just the simpleInitApp():



[java]

@Override

public void simpleInitApp() {

AudioNode foo = null;

foo = new AudioNode(this.assetManager, ā€œMusic/Zero - Project - Silence.oggā€, false);

foo.play();

foo.stop();

foo = new AudioNode(this.assetManager, ā€œMusic/Zero - Project - Silence.oggā€, false);

foo.play();

check = false;

}

[/java]



It works like a charm dude. Do an update in your jme. Also, I didnā€™t know an audio node can be played without it has been added to the scene graph xD.

AudioNodes are weird. They donā€™t have to be attached to anything, really. And there is no benefit to doing so as their sound position is not automatically set unless they have a control to do it. (at least as I recall)

@glaucomardano

yeah I realized it was a slight mistake, I fixed it and it did work perfectly thats why I deleted the other post and edited my prior one. My apologies I didnā€™t realize anyone saw that post within the period I saw my error thats why I deleted it lol.



I actually Have no idea what the issue might be now because creating a completly new AudioNode shouldnā€™t be causing any issues lol

Whatā€™s your problem now dude?

@glaucomardano

The original issue was never resolved. The test case was inconclusive because I have already confirmed the issue to be when I create more than one AudioNode in a module.

Just donā€™t try to reuse the AudioNodes.

You can replay an audio node that is not streamed but you cannot change itā€™s data (and they may have fixed it for the streamed case). So the node is forever locked to the sound it has.

@Normen

I tried that as previously stated; I tried only saving the file path in a property change listener and in an actionlistener for the play button I attempted to create and play a completely new AudioNode it however once again it only works once. When the file is changed and the audionode played for a second time it hangs. I have tried debugging and placed JOptionPanes around certain areas and it seems as though the only place I donā€™t get a return is after an audionode is created for a second time as shown above.





the playbuttonā€™s actionlistener only called play() and I tried to enqueue it however the result is the same

[java]private void play() {

if (path != null) {

stop();



JOptionPane.showMessageDialog(null, ā€œCheck 1ā€);

AudioNode currentClip = new AudioNode(SceneApplication.getApplication().getAssetManager(), path, false);

JOptionPane.showMessageDialog(null, ā€œCheck 2ā€);

currentClip.playInstance();





}

}[/java]



The only difference with this is that it hangs after i click play instead of while I am switching files

The play command has to be run on the update loop thread.

@normen said:
The play command has to be run on the update loop thread.


And if it isn't then it's supposed to give you an error.

I donā€™t receive an error and can I ask what do you mean by the update loop thread? I Believed anything that had to do with manipulating Sceneapplication I would just enqueue which I stated I tried and gives no change in results.

Iā€™m not sure what to say. I play multiple sounds all the time. Iā€™m not sure what the specific issue is in this case and thereā€™s been too much ā€œcode under the bridgeā€ at this point for me to get a handle on the non-working code anymore.

You have two issues a) you try to use swing components that block the current code, they have to be managed on the AWT thread, then b) you have code that needs to be run on the update loop thread. So the quickest solution is probably using the AWT queue and OpenGL queue in a nested callable:

[java]

java.awt.EventQueue.invokeLater(new Runnable() {



public void run() {

//DO AWT STUFF HERE

app.enqueue(new Callable(){

public Object call(){

//DO OPENGL STUFF HERE

}

});

}

});

[/java]

1 Like

@Normen

hmm iā€™ve tried that and it no longer seems to hang though a white screen appears the size of the filechooser on the openGL window after its closed and opened a few times. I attempted to load the audiodata and audiokey and use the proper constructor for audionode a second time except I placed a few messagePane checks at each step and found that the issue is when loading a second or successive audio file through AssetManager.loadAsset(ā€¦); what happens is the first time all of the messages appear. The second they only appear up to the loadAsset method and any successive attempts does not produce any messages at all.



I also attempted jst out of curiosity to open a model file into scenecomposer and then play a sound and then load another or the same sound and found the sceneComposer hangs indefinitely though the rest of the platform works fine

For some odd reason I found that it seems to stop at the part of DesktopAssetManager.loadAsset(AssetKey) at the section that says loader.load(info) - [AssetLoader.load(ā€¦)] - which is initialized by handler.aquireLoader(AssetKey). Somewhere it gets to OGGLoader.load(InputStream in, boolean readStream, boolean streamCache) and freezes at AudioBuffer.updateData(readToBuffer());