sound interface plugin (beta)

  • A new Sound Plugin - soundinterface.swf

    • this plugin adds functions to play and controls sounds direct from the xml.
    • only this one plugin must be loaded for all sound.
    • note - the functions are not available until the plugin was loaded use the plugin onloaded event or the preload="true" plugin setting to verify that!


    Download latest plugin version:

    Included in the latest krpano viewer download package


    Examples:
    Directional Sound


    Usage:

    Code
    <plugin name="soundinterface"
            url="soundinterface.swf"
            onloaded="action(preloadsounds);"
            rootpath="."
            />

    Attributes:

    • onloaded
      • this action is called when the plugin was loaded and is ready for use.
      • can be used for preloading sound.
    • rootpath
      • root path of the sound files
      • relative from the xml file, default=""
      • with krpano 1.0.8 or higher it's possible to use placeholders like %SWFPATH% here
    • volume
      • set the global volume for all sounds
      • 0.0 - 1.0, default=1.0
      • can be changed dynamically via actions (set/tween/...)
    • mute
      • set the global mute for all sounds
      • true or false, default=false
      • can be changed dynamically via actions (set/switch/...)

    Functions:

    • preloadsound(mp3file);
      • preloads a sound file
      • this can be used to reduce the latency when starting play
      • mp3file = the filename/path of a sound file
    • playsound(id, mp3file, loops*, oncomplete*);
      • plays a sound file
      • id = id/name of the sound (use "auto" for a automatic new id for every play)
      • mp3file = the filename/path of a sound file
      • loops = number of loops, 0=endless, default=1 (*optional)
      • oncomplete = action/event that will called on complete (*optional)


    • playsound2D(id, mp3file, volume*, pan*, loops*, oncomplete*);
      • plays a sound file with adjustable volume and panning
      • id = id/name of the sound (use "auto" for a automatic new id for every play)
      • mp3file = the filename/path of a sound file
      • volume = sound volume (0.0 - 1.0, default=1.0) (*optional)
      • pan = left/right panning (-1.0(=left) - +1.0(=right), default=0.0) (*optional)
      • loops = number of loops, 0=endless, default=1 (*optional)
      • oncomplete = action/event that will called on complete (*optional)


    • playsound3D(id, mp3file, ath, atv, range*, volume*, loops*, oncomplete*);
      • plays a directional 3D sound
      • id = id/name of the sound (use "auto" for a automatic new id for every play)
      • mp3file = the filename/path of a sound file
      • ath = horizontal sound source position (-180 .. 180°)
      • atv = vertical sound source position (-90 .. +90°)
      • range = range of sound (in degrees, default=90) (*optional)
      • volume = sound volume (0.0 - 1.0, default=1.0) (*optional)
      • loops = number of loops, 0=endless, default=1 (*optional)
      • oncomplete = action/event that will called on complete (*optional)


    • playsound3DHS(id, mp3file, hotspotname, range*, volume*, loops*, oncomplete*);
      • plays a directional 3D sound at a hotspot position
      • it follows the hotspot if the hotspot is moving
      • id = id/name of the sound (use "auto" for a automatic new id for every play)
      • mp3file = the filename/path of a sound file
      • hotspotname = name of the hotspot
      • range = range of sound (in degrees, default=90) (*optional)
      • volume = sound volume (0.0 - 1.0, default=1.0) (*optional)
      • loops = number of loops, 0=endless, default=1 (*optional)
      • oncomplete = action/event that will called on complete (*optional)
    • pausesound(id);- pauses a sound
      • id = id/name of the sound
    • resumesound(id);- resumes a paused sound
      • id = id/name of the sound
    • pausesoundtoggle(id);- pauses OR resumes a sound
      • id = id/name of the sound
    • stopsound(id);- stops playing a sound
      • id = id/name of the sound
    • stopallsounds();
      • stop all current playing sounds

    XML usage example:

  • This is amazing. Excellent!

    Impressive. *thumbsup*
    The plugin reproduces the sound beautifully.

    The left channel is the right channel on our computers. We do not know, if so this has to be... and as to change this.
    But...

    We are delighted.

    Thanks Klaus.

    How to change the channels of the sound from left to right?

    Pablo & Pietero
    http://www.spacerywirtualne.pl team

  • I'm noticing the same thing on the sample you setup...

    on buttons 1 and 3, as I move around the sound changes opposite of what I would expect.
    - I click on 1 while looking directly at it - sound seems even between the two speakers
    - I look to the right (which places b1 on the left of my screen) and the sound is louder from the right speaker
    - look to the left (button on the right side of the screen) and the sound is louder from the left

    I get the same effect with button 3 as well.

    With button two... as I move to the right (b2 goes to the left) the sound gets louder on the left... which seems to be what should happen as I "turn my head".

    The sound tracks button 4 just fine as well.

  • I think this could be because of the used sound samples,
    this are stereo sounds with varying left/right informations, maybe this is the problem,
    ideal would be mono sound samples, but I haven't found better sound samples in the
    short time when making this example

    swapping the left/right panning would be no problem,
    I just need to be sure

  • Klaus or anyone else that has directional audio in effect, would you be so kind as to share the .xml you used in your directional sound example. If I try to load the .xml of the example off the internet it gives me an error. I am have having a little issue with the syntax and would love to see the code in action.

  • Klaus or anyone else that has directional audio in effect, would you be so kind as to share the .xml you used in your directional sound example. If I try to load the .xml of the example off the internet it gives me an error. I am have having a little issue with the syntax and would love to see the code in action.

    Hi, here is the direct link to the xml:

    https://krpano.com/plugins/soundinterface/example.xml

    and here is it inline: *wink*

  • can someone tell me what is wrong with my syntax here ... the onclick stopallsound works, the action(audiooff) works but i cannot get the helicopter.mp3 or the planeidle.mp3 to play ... ? the action audiooff just disables the standard mp3 audio track that plays in the background.


    <!-- directional audio -->


    <hotspot name="plane"
    url="hotspot_ani.swf"
    ath="-187" atv="1"
    visible="true" enabled="true" handcursor="true"
    zorder="0"

    onover=""
    onhover="showtext(Click here to Start the Airplane then move left and right,largetext)"
    onout=""
    ondown=""
    onup=""
    onclick="stopallsounds(); action(audiooff); playsound3DHS(s2,planeidle.mp3,plane);"
    >


    </hotspot>

    <hotspot name="copter"
    url="hotspot_ani.swf"
    ath="-27" atv="-16"
    visible="true" enabled="true" handcursor="true"
    zorder="0"

    onover=""
    onhover="showtext(Click here to Start the Helicopter then move left and right,largetext)"
    onout=""
    ondown=""
    onup=""
    onclick="stopallsounds(); action(audiooff); playsound3DHS(s3,helicopter.mp3,copter);"
    >
    </hotspot>

  • the only thing I noticed is that it looks like you have an extra > towards the end of the hotspot node...

    Code
    onclick="stopallsounds(); action(audiooff); playsound3DHS(s3,helicopter.mp3,copter);"
     >                         	<--- this doesn't seem to belong
     </hotspot>

    Can't say if that would cause you a problem... but I've chased down some of my own errors that were caused by items like this.

  • "Graydon if I take that out I get an XML parser error. "

    I can get the audio to play if I use just 'playsound' but soon as I add '2d, 3d or 3dhs' i get nothing no audio at all. I have tried both krpano version 1.0.7 and 1.0.8 beta 5 neither of them let me use 2d, 3d or 3dhs. This is the last piece i have to work out for my demo spin for the optional add-ins. Here is all my audio code I am hoping someone can help me with this.

    <!--Audio-->
    <plugin name="soundinterface" url="../plugins/soundinterface.swf"/>

    <plugin name="audio2"
    url="../../images/speakeryes.png"
    visible="false" enabled="true" handcursor="true"
    zorder="4"
    alpha="1.00" blendmode="normal"
    smoothing="true"
    origin="centerbottom" edge=""
    x="270" y="2"
    width="30" height="30"
    scale="1"
    onloaded=""
    onover="tween(plugin[audio2].width,40,distance(318,0.5),easeoutquad);tween(plugin[audio2].height,40,distance(120,0.5),easeoutquad);"
    onout="tween(plugin[audio2].width,30,distance(318,0.5),easeoutquad);tween(plugin[audio2].height,30,distance(120,0.5),easeoutquad);"
    onhover="showtext(Enable Audio in the Tour)"
    ondown=""
    onup=""
    onclick="playsound(s1,music.mp3);action(audioon);tween(plugin[eq].width,100,distance(318,0.5),easeoutquad);"

    />

    <plugin name="audio"
    url="../../images/speakerno.png"
    visible="false" enabled="true" handcursor="true"
    zorder="4"
    alpha="1.00" blendmode="normal"
    smoothing="true"
    origin="centerbottom" edge=""
    x="270" y="2"
    width="30" height="30"
    scale="1"
    onloaded=""
    onover="tween(plugin[audio].width,40,distance(318,0.5),easeoutquad);tween(plugin[audio].height,40,distance(120,0.5),easeoutquad);"
    onout="tween(plugin[audio].width,30,distance(318,0.5),easeoutquad);tween(plugin[audio].height,30,distance(120,0.5),easeoutquad);"
    onhover="showtext(Disable Audio in the Tour)"
    ondown=""
    onup=""
    onclick="stopsound(s1);action(audiooff);tween(plugin[eq].width,0,distance(318,0.5),easeoutquad);"
    />


    <action name="audioon">

    set(plugin[audio2].enable,false);
    set(plugin[audio2].visible,false);
    set(plugin[audio].enable,true);
    set(plugin[audio].visible,true);
    set(plugin[eq].enable,true);
    set(plugin[eq].visible,true);

    </action>

    <action name="audiooff">
    set(plugin[audio].enable,false);
    set(plugin[audio].visible,false);
    set(plugin[audio2].enable,true);
    set(plugin[audio2].visible,true);
    set(plugin[eq].enable,false);
    set(plugin[eq].visible,false);

    </action>

    <plugin name="eq"
    url="../../images/eq.swf"
    keep="true"
    visible="false" enabled="false" handcursor="true"
    zorder="0"
    alpha="1.00" blendmode="normal"
    smoothing="true"
    origin="rightbottom" edge=""
    x="20" y="60"
    width="0" height="40"
    scale="1"
    onloaded=""

    onhover=""
    ondown=""
    onup=""
    onclick=""
    />

    <!-- directional audio -->


    <hotspot name="plane"
    url="hotspot_ani.swf"
    ath="-187" atv="1"
    visible="true" enabled="true" handcursor="true"
    zorder="0"

    onover=""
    onhover="showtext(Click here to Start the Airplane then move left and right,largetext)"
    onout=""
    ondown=""
    onup=""
    onclick="stopallsounds(); action(audiooff); playsound3DHS(s2,planeidle.mp3,plane);"

    >

    </hotspot>

    <hotspot name="copter"
    url="hotspot_ani.swf"
    ath="-27" atv="-16"
    visible="true" enabled="true" handcursor="true"
    zorder="0"

    onover=""
    onhover="showtext(Click here to Start the Helicopter then move left and right,largetext)"
    onout=""
    ondown=""
    onup=""
    onclick="stopallsounds(); action(audiooff); playsound3DHS(s3,helicopter.mp3,copter);"
    >

    </hotspot>

  • OK - I see why you get the parser error - it doesn't effect the soundinterface plugin - at least based upon my testing... but just to clariy...

    you have this...

    Code
    <hotspot name="xxx"
    ----
    >
    </hotspot>

    but could also do it this way...

    Code
    <hotspot name="xxx"
    ---
    />

    but on to your sound problem...

    The only other suggestion that I have is to make absolute sure you've got the latest krpano beta as well as the latest soundinterface.swf...

    From what I can tell... the krpano 1.0.8 b6 build (20090302) download package does NOT have the latest soundinterface.swf which is build (05.03.2009)

    You can get the latest soundinterface from one of the posts above.

    Checking the versions is easy if you have the flash standalone player... just double click on the swf... plugins will show the version / build information. The krpano.swf will try to load an xml... but then just click on "o" to see what the version / build info is in the console.

    I'm not a betting man... but I'd almost wager that you don't have the latest version of the soundinterface... because everything else looks fine. *smile*

  • Graydon many thanks to you!!! I was banging my head against a wall all morning on this one. It was too easy to be that hard. I updated everything except the soundinterface.swf once I upgraded that things feel right into place. I have got my directional Audio to work. Thank you again.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!