You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, March 4th 2009, 10:10pm

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:

Source code

1
2
3
4
5
<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:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<plugin name=soundinterface" 
        url="plugins/soundinterface.swf" 
        rootpath="sounds/" 
        />

<hotspot name="s1" url="spot.png"
         onclick="playsound(auto,tada.mp3);"
         onover="playsound(auto,over.mp3);"
         onout="playsound(auto,out.mp3);"
         />
<hotspot name="s2" url="spot.png"
         onclick="stopallsounds();
                  loadpano(next.xml,null,MERGE,BLEND(1));
                  playsound(auto,newsound.mp3);"
         />

spacerywitualne

Professional

Posts: 1,112

Location: Poland, Europe

Occupation: krpano developer : virtual tours : the cms4vr owner

  • Send private message

2

Thursday, March 5th 2009, 12:01pm

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
www.spacerywirtualne.pl team
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

3

Thursday, March 5th 2009, 2:13pm

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...
really? are you sure?
is the left/right channel swapped or is the orientation wrong?

Graydon

Professional

Posts: 614

Location: Texas

Occupation: Industrial gas turbine services.

  • Send private message

4

Thursday, March 5th 2009, 5:45pm

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.

spacerywitualne

Professional

Posts: 1,112

Location: Poland, Europe

Occupation: krpano developer : virtual tours : the cms4vr owner

  • Send private message

5

Thursday, March 5th 2009, 5:55pm

Exactly. It is so as Graydon writes.

Can one maybe put this in xml?

We test on the new project and the sound is heard inversely.

regards *thumbsup*

Pablo & Pietero
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

6

Thursday, March 5th 2009, 6:45pm

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

7

Thursday, March 5th 2009, 7:11pm

Hi, me again
I have now made tests with mono samples and found the problem (a axis was swapped)

now it should work, I have uploaded a updated version.
(please clear browser cache before testing again)

best regards,
Klaus

Graydon

Professional

Posts: 614

Location: Texas

Occupation: Industrial gas turbine services.

  • Send private message

8

Thursday, March 5th 2009, 7:47pm

works beautifully now. shouldn't you go and get some sleep now?

spacerywitualne

Professional

Posts: 1,112

Location: Poland, Europe

Occupation: krpano developer : virtual tours : the cms4vr owner

  • Send private message

9

Thursday, March 5th 2009, 7:54pm

You are great Klaus. *thumbsup*

This is it.

Pietero & Pablo
www.spacerywirtualne.pl team
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

This post has been edited 1 times, last edit by "spacerywitualne" (Mar 6th 2009, 11:17am)


Virtual Northland

Professional

Posts: 1,336

Location: Duluth MN

  • Send private message

10

Friday, March 6th 2009, 4:24am

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.

martyhr

Intermediate

Posts: 384

Location: CZ

  • Send private message

11

Friday, March 6th 2009, 11:33am

Hi, should be working this way?
http://virtualpanorama.cz/valentine/
marty

12

Friday, March 6th 2009, 1:36pm

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:

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

and here is it inline: ;-)

Source code

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
<krpano>
    <display flash10="off" />
    <view fov="90" fovmin="60" fovmax="120" />

    <plugin name="soundinterface" url="soundinterface.swf" onloaded="" />

    <!-- play sound at 0/0 -->
    <hotspot name="b1" url="button1.png" ath="0"   atv="0" 
             onclick="playsound3D(s1,music1.mp3, 0,0);" />

    <!-- play sound at 90/0 - range 120 -->
    <hotspot name="b2" url="button2.png" ath="90"  atv="0" 
             onclick="playsound3D(s2,music2.mp3, 90,0, 120); " />

    <!-- play sound at hotspot positon -->
    <hotspot name="b3" url="button3.png" ath="180" atv="0" 
             onclick="playsound3DHS(s3,music3.mp3, b3);" />

    <!-- stop all other sounds, play sound at moving hotspot positon -->
    <hotspot name="b4" url="button4.png" ath="270" atv="0" 
             onclick="stopallsounds(); playsound3DHS(s4, music4.mp3, b4); tween(ath,630,20);" />

    <image>
        <sphere url="pano.jpg" />
    </image>
</krpano>

Virtual Northland

Professional

Posts: 1,336

Location: Duluth MN

  • Send private message

13

Saturday, March 7th 2009, 9:33pm

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>

Graydon

Professional

Posts: 614

Location: Texas

Occupation: Industrial gas turbine services.

  • Send private message

14

Saturday, March 7th 2009, 10:25pm

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

Source code

1
2
3
 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.

Virtual Northland

Professional

Posts: 1,336

Location: Duluth MN

  • Send private message

15

Saturday, March 7th 2009, 11:25pm

"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>

Graydon

Professional

Posts: 614

Location: Texas

Occupation: Industrial gas turbine services.

  • Send private message

16

Sunday, March 8th 2009, 12:19am

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...

Source code

1
2
3
4
<hotspot name="xxx"
----
>
</hotspot>


but could also do it this way...

Source code

1
2
3
<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*

Virtual Northland

Professional

Posts: 1,336

Location: Duluth MN

  • Send private message

17

Sunday, March 8th 2009, 2:32am

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.

Posts: 55

Location: FRance

Occupation: rock clinbing, scuba diving, motorbike....

  • Send private message

18

Monday, April 13th 2009, 10:12pm

loops # doesn't seen to work !
i've set it to 1 but it keep playing in a loop !

onclick="playsound2D(s1,zap.mp3,0.5,0,1);"

my fault ?
Pro website : www.bziegler.com
Blog : blog.bziegler.com

Posts: 55

Location: FRance

Occupation: rock clinbing, scuba diving, motorbike....

  • Send private message

19

Monday, April 13th 2009, 10:32pm

loops # doesn't seen to work !
i've set it to 1 but it keep playing in a loop !

onclick="playsound2D(s1,zap.mp3,0.5,0,1);"

my fault ?
Yes my fault ;)

sorry
Pro website : www.bziegler.com
Blog : blog.bziegler.com

20

Wednesday, April 15th 2009, 8:28pm

Hello,

the soundinterface plugin was updated today (2009-04-15),
there was a bug with the 3D sound directions,
download from the link in the first post
(the bugfixed plugin will be also included in the next release)

best regards,
Klaus