Waxe and NME Sound: "Please init Stage before creating sound" problem

122 views
Skip to first unread message

Cambiata

unread,
Nov 20, 2012, 9:33:01 AM11/20/12
to haxe...@googlegroups.com
Hi Hugh and others!

I want to implement sound playback in my Waxe/NME application. However, when trying to load a sound, I get an exception callded from from neash/media/Sound.hx line 66: "Could not load:mix.mp3 > Please init Stage before creating sound."

Below a Main.hx example causing this error, based on Nick Holder's (http://nickholder.wordpress.com/2012/06/13/waxe-nmestage/).

I've tried wrapping the sound object into a sprite, adding it to the nmeStage befor initializing, but that doesn't seem to make a difference. Any idea how to get around this?

/ Jonas


class Main
{
   
private var frame:Frame;
   
   
function new()
   
{
       
// Make an app window
        frame
= Frame.create(null, "WaxeApp" , null , { width:400 , height:400 } );
       
// Make a panel
       
var waxePanel:Panel = Panel.create( frame );
       
var button:Button = Button.create( waxePanel, null, 'A Button');
       
// Make an NME stage
       
var nmeStage:NMEStage = NMEStage.create( waxePanel );
        nmeStage
.stage.align = StageAlign.TOP_LEFT;
        nmeStage
.stage.scaleMode = StageScaleMode.NO_SCALE;
       
// Draw something on the NMEStage
        nmeStage
.stage.graphics.beginFill( 0x000000 );
        nmeStage
.stage.graphics.drawCircle( 50 , 50 , 50 );
        nmeStage
.stage.graphics.endFill();
       
// Auto position the panel and NMEStage with a sizer
       
var sizer:Sizer = BoxSizer.create(true);
        waxePanel
.setSizer(sizer);
        sizer
.add( button , 1 , Sizer.EXPAND | Sizer.BORDER_ALL , 5 );
        sizer
.add( nmeStage , 3 , Sizer.EXPAND | Sizer.BORDER_ALL , 5);
       
// Show your window
       
App.setTopWindow( frame );
        frame
.shown = true;
       
       
//----------------------------------------------------------
       
// The following causes an exception with "Please init Stage before creating sound."
       
var sound = new Sound();
        sound
.load(new URLRequest('mix.mp3'));
   
}
   
   
// Entry
   
public static function main()
   
{
       
App.boot( function(){ new Main(); } );
   
}
}




Cambiata

unread,
Nov 20, 2012, 10:05:11 AM11/20/12
to haxe...@googlegroups.com
Investigating further, it seems that just adding the waxe dependency to a nme app changes the ApplicationMain bootstrapping. I guess something is missing here in the waxe conditional code to satisfy the sound object...

By the way, in the ApplicationMain.hx template, lines 30-32, a stage is created as local variable, wich seems a bit odd as it's never used. The public nmeStage variable is never assigned...

Andreas Mokros

unread,
Nov 20, 2012, 11:13:03 AM11/20/12
to haxe...@googlegroups.com
Hi.

Still playing with waxe, are you? :-)

On Tue, 20 Nov 2012 07:05:11 -0800 (PST)
Cambiata <jona...@gmail.com> wrote:
> I guess something is
> missing here in the waxe conditional code to satisfy the sound
> object...

Well, as far as I see, wx.NMEStage, create creates a ManagedStage,
while nme.Lib.create creates a SDLStage. The ManagedStage seems to work
without SDL, i.e. also apparently without sound support. But don't ask
me why :-)

What about wxMediaCtrl?
http://docs.wxwidgets.org/trunk/classwx_media_ctrl.html

--
Mockey

Cambiata

unread,
Nov 20, 2012, 12:27:58 PM11/20/12
to haxe...@googlegroups.com
@Mockey:


Still playing with waxe, are you? :-)

No playing here! With Pah's listbox additions, I can do really serious stuff! :-)

Well, as far as I see, wx.NMEStage, create creates a ManagedStage,
while nme.Lib.create creates a SDLStage. The ManagedStage seems to work
without SDL, i.e. also apparently without sound support.

Thank you for pointing out - as clearifying as always!
I guess that it should be possible to somewhow instantiate a SDLStage "off stage". Will look into that.

What about wxMediaCtrl?

I guess that it's perfectly possible (apart from the fact that the wx implementation has to be created...), but I need nme graphics anyway, and I would prefer to stick to the nme solutions and workflow when possible.

Jonas

Andreas Mokros

unread,
Nov 20, 2012, 3:56:36 PM11/20/12
to haxe...@googlegroups.com
Hi.

On Tue, 20 Nov 2012 09:27:58 -0800 (PST)
Cambiata <jona...@gmail.com> wrote:
> I guess that it should be possible to somewhow instantiate a SDLStage
> "off stage". Will look into that.

Don't know. I think the SDLStage needs the main loop from SDL via a
"real" NME app to work. The ManagedStage uses the OS main loop via
wxWidgets (and avoids SDL).

--
Mockey

Marcelo de Moraes Serpa

unread,
Nov 20, 2012, 4:02:29 PM11/20/12
to haxe...@googlegroups.com
Hey guys, what's the state of Waxe? Can it be used for cross-platform C++ apps as of now?

- Marcelo


Hugh

unread,
Nov 20, 2012, 11:55:12 PM11/20/12
to haxe...@googlegroups.com
Yes, SDL is used for audio on the desktop, and this is not started unless sdl is also used for video.
It should be possible to use SDL audio only with perhaps only a few changes.
It may also be possible to use another solution like wx audio? or expose the openal solution from iPhone/Sound.mm

Hugh

Cambiata

unread,
Nov 21, 2012, 2:33:53 AM11/21/12
to haxe...@googlegroups.com
@Marcelo:

No linux waxe.ndll in the 1.0.1 release, don't know about the mac status.
On windows, after adding some missing handlers in the cpp code and recompiling the waxe.ndll, the basics are there.
I use it in my current project and it really makes creating data admin solutions so much easier!
If I only had a little more than close-to-none cpp knowledge, I would love to get into creating a Linux target... :-)

@Hugh:

The possibility to wrap NME content in a Waxe context is exciting - wx.audio is another way to go. Interesting as such,
but lower on my wish list.

It should be possible to use SDL audio only with perhaps only a few changes.

Some code lines in this direction would be much appreciated..!

/ J
waxe-win.png

Andreas Mokros

unread,
Nov 21, 2012, 3:33:20 AM11/21/12
to haxe...@googlegroups.com
Hi.

On Tue, 20 Nov 2012 23:33:53 -0800 (PST)
Cambiata <jona...@gmail.com> wrote:
> [waxe-win.png image/png (158737 bytes)]

Pretty impressive screenshot! What exactly is it? Database of song
notations?
Did you work out the scrollbar stuff or do the listboxes get scrollbars
automatically?
Do you simply need to play MP3s or do you need to do more with audio?

--
Mockey

Cambiata

unread,
Nov 21, 2012, 4:00:59 AM11/21/12
to haxe...@googlegroups.com
I'm working with a FP based multichannel mixable music player called ScorxPlayer, right now with content targeted at swedish choir singers. Here's an example:
http://sensus.scorxplayer.com/player/play/SKA-00044/default
The player is still not haxified (created in as3/flex), but most of the rest of the chain is.

I use sqlite for storage of file data (mp3s, graphics, pointerdata, metadata) - each song is an sqlite database file - and the Waxe example shows the administration tool for this.
The tool for creating graphic pointer sync data is an AIR app right now (attached png).

Of course I'm seeking ways to create player solutions - preferrably NME-based of course - that would let me integrate everything and choose targets freely...

With FP on decline multichannel sound playback is the really tricky part. Html5 audio apis are still very rudimentary - and unfortunately it seems that I will be forced to abandon the fully interactive multichannel mixer and use a setup of prefab mixes instead, at least until the audio apis are matured.

Regarding the Waxe scrollbars, the listbox handle them automatically.
I haven't had much time to look further into this area. I'm compiling with neko target right now, and the 31 bit restrictions mentioned in another post has held me back there... But I will be back in this case!
scorx-grapic-pointer-editor-air.png

Andreas Mokros

unread,
Nov 21, 2012, 5:52:42 PM11/21/12
to haxe...@googlegroups.com
Hi.

On Wed, 21 Nov 2012 01:00:59 -0800 (PST)
Cambiata <jona...@gmail.com> wrote:
> With FP on decline multichannel sound playback is the really tricky
> part. Html5 audio apis are still very rudimentary - and unfortunately
> it seems that I will be forced to abandon the fully interactive
> multichannel mixer and use a setup of prefab mixes instead, at least
> until the audio apis are matured.

I see. That's a bit more than simple MP3 playback.
Did you try the NME Sound stuff (in a NME app)? Can you do multichannel
mixing with that?

> Regarding the Waxe scrollbars, the listbox handle them automatically.

Yes, I see. I just fixed my Test App here, so that it compiles again.
Added some ListBox stuff as well.

> I haven't had much time to look further into this area. I'm compiling
> with neko target right now, and the 31 bit restrictions mentioned in
> another post has held me back there...

The easiest way to fix that is to use neko 2 from SVN.

--
Mockey
Reply all
Reply to author
Forward
0 new messages