You are not logged in.

gabriel

Beginner

  • "gabriel" started this thread

Posts: 28

Location: Paris, France

Occupation: photographer

  • Send private message

1

Wednesday, June 1st 2022, 11:27pm

Randomize sound of a hotspot

Hi All, I'm looking to randomise the sound of a hotspot.
I have a folder call "sounds" with 12 sounds named "1.mp3", "2.mp3" ... to "12.mp3".

I try to adapt a code found here, with some changes, but it doesn't work. here is :

<krpano>
<plugin name="hasard"/>
<action name="hasard">
mul(randomvalue, random, 10);
roundval(randomvalue,0);
set(plugin[hasard].numero,
get(randomvalue));
trace('randomvalue=', randomvalue);
trace('randomvalue by get=', get(plugin[hasard].numero));
txtadd(plugin[hasard].action); call(plugin[hasard].action);
</action>

<action name="onclickspotpoint12">
playsound(soundspotpoint12, %$videos_sounds_path%/sounds/
((txtadd(plugin[hasard].action)).numero).mp3,
true, false, -121.693252, -28.525799,90, 1, spotpoint12);
</action>
</krpano>

What I was looking to do is to randomise the name of the .mp3, but maybe it's not the best way to achieve what I want to do.
Any help is very welcome. Thank you.

Tuur

Sage

Posts: 3,839

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

2

Thursday, June 2nd 2022, 11:04am

Salut,

this should be enough.

Source code

1
2
3
4
5
6
7
    <action name="DoRandomSound">
        mul(val, random, 4); <!-- 5 sounds -->
        add(val, 1);
        roundval(val);

        playsound(auto, calc('sounds/' + val + '.mp3'));
    </action>


perhaps you want to playback sound at hotspot position?
Then look here: https://krpano.com/plugins/soundinterfac…ound_at_hotspot

Hope it helps,
Tuur *thumbsup*

gabriel

Beginner

  • "gabriel" started this thread

Posts: 28

Location: Paris, France

Occupation: photographer

  • Send private message

3

Thursday, June 2nd 2022, 11:23pm

Thanks a loooooot Tuur !!

Similar threads