Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] Simple Sound

January 09 (3 years ago)

Edited February 09 (2 years ago)
Finds
API Scripter

Simple Sound

This is a very short script I made for my own campaigns a while ago that does just one job it plays sounds via command line and macros. I figured someone else might have a use for it.

Quick Update: Script has been added to the Roll20/roll20-api-scripts repository and is now available as a One-Click Install from the Library dropdown, thanks to everyone for the encouragement!

Commands

!splay <track name> - Plays the sound effect.

!sstop <track name> - Stops a track playing (in case you want to halt a very long track).

!sstop - Stops all tracks currently playing when no track is specified.

!swhisper - Toggle whispers to GM on play/stop off and on.


Code  (latest version 0.2.1)

Roll20-API-Scripts\SimpleSound 

January 09 (3 years ago)
Andreas J.
Forum Champion
Sheet Author
Translator

I like it.
Simpler than Roll20AM, where you need to do the import command every time you upload/change thing in the jukebox.

Sweet. Thanks for this!

January 10 (3 years ago)
Gold
Forum Champion

Good Finds

January 10 (3 years ago)
Finds
API Scripter

Some things I've done with it in the past are name a series of audio tracks with the same name and a number like hit1, hit2, hit3 and then call a macro that rolls a random 1-3 appended to the name to play a random sound. Also I have a dice rolling sound I'm fond of adding to many of my macros.

January 10 (3 years ago)

Can my players use this?

January 10 (3 years ago)
Finds
API Scripter

Yes they would just need to know the track name or have access to a macro so you can build macros for your players that will play sounds.

January 11 (3 years ago)
Andreas J.
Forum Champion
Sheet Author
Translator

Finds said:

Some things I've done with it in the past are name a series of audio tracks with the same name and a number like hit1, hit2, hit3 and then call a macro that rolls a random 1-3 appended to the name to play a random sound. Also I have a dice rolling sound I'm fond of adding to many of my macros.

This is a pretty nice thing. I renamed a couple of my sounds and the following command worked for me:

!splay combat[[1d6]]


If someone would help to implement this as a toggle for the API, I think this would be a great one to submit to the One-click install menu, there are so few APIs that handle audio, and this is a simpler & quicker alternative to Roll20AM to start using.

If you like to be notified of the track being played or stopped via GM whisper you can modify this line to true

    var whispers = false; // Whisper confirmation of stop/play to GM
January 11 (3 years ago)

Edited January 11 (3 years ago)
Finds
API Scripter

If someone would help to implement this as a toggle for the API, I think this would be a great one to submit to the One-click install menu, there are so few APIs that handle audio, and this is a simpler & quicker alternative to Roll20AM to start using.

Try the above version now (0.2.0), I've added !swhisper to toggle whispers on and off.

January 28 (3 years ago)
Nick O.
Forum Champion

This is a great script, thanks, Finds! If I may make a request, could we get a global Stop option, that would stop any track that was currently playing?

February 02 (3 years ago)
Finds
API Scripter

Try the above I updated it to version 0.2.1, using !sstop without a track name will now stop all playing tracks

February 05 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Finally got around to switching over from Roll20AM, which does way more than I need. Great script. Easy to use. I did change line 53 to:

            sendChat('Simple Sound Script', '/w gm No Track Found Named '+ trackname);
So that when it reports a missing track, you know which track it is looking for. Saved me from hunting down a misspelling.
February 14 (2 years ago)
Mike
Pro

Oh my god thank you! So simple and yet so amazing.

February 17 (2 years ago)

The !splay <track name> command works fine in chat but when I add it to a macro, it just outputs the command on the screen.  Am I missing a step?  I pulled the ReadMe off GitHub but it didn't provide additional data.  Would appreciate some direction.

February 17 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Hi Thom,

In situations like this, it's easier to get a useful answer if you post the whole macro. For instance, API commands don't usually work within a roll template.

February 17 (2 years ago)

Edited February 17 (2 years ago)
Andreas J.
Forum Champion
Sheet Author
Translator

maybe the ' in the title is a problem, can you play the track with the command by itself?


Or try place the API call on the first line

February 17 (2 years ago)

@keithcurtis Thank you for the tip.  I'll include the whole macro going forward.  When I enter the command on the character sheet under Abilities, it looks like this:

!splay Eye_Beam_Sound

Oculor fires a random ray at [[1t[Random-Player] ]].  It's a [[1t[Tyrant] ]]

However, i discovered if I open the corresponding Ability name on the Attributes & Abilities tab, and add !splay Eye_Beam_Sound there, it DOES play BUUUT it also displays "!splay Eye_Beam_Sound" in the chat.  Is there a way to suppress the command text? 


February 17 (2 years ago)
Finds
API Scripter

The ' shouldn't be a problem as long as the track name is exactly the same. Keith is correct in that it should be on it's own line, it basically cuts off the !splay and takes everything else as the track name (spaces and all), if it's actually having problems finding the track it will spit out a warning in chat that no track was found even if whispers are turned off.

In any macro I created nothing that begins with a ! gets output to chat so if you're actually seeing the full line printed it may be how it's formatted in the macro, if you paste it here I'll take a look.

February 17 (2 years ago)

Edited February 17 (2 years ago)
Finds
API Scripter


Dungeon Master said:

@keithcurtis Thank you for the tip.  I'll include the whole macro going forward.  When I enter the command on the character sheet under Abilities, it looks like this:

!splay Eye_Beam_Sound

Oculor fires a random ray at [[1t[Random-Player] ]].  It's a [[1t[Tyrant] ]]

However, i discovered if I open the corresponding Ability name on the Attributes & Abilities tab, and add !splay Eye_Beam_Sound there, it DOES play BUUUT it also displays "!splay Eye_Beam_Sound" in the chat.  Is there a way to suppress the command text? 


Hrmm that's really odd I've built up a macro on a test token and I'm not seeing any extra output in chat, with this macro I get the following results with two generic tables of Player1-4 and Beam1-4. If you want me to hop into your game and take a look PM me, I'd be curious to see how thats happening.

!splay Eye_Beam_Sound

&{template:default} {{name=Eye Attack}} {{player=[[1t[Random-Player] ]]}} {{ beam=[[1t[Tyrant] ]] }}


Afterthought; if you take your entire macro and paste it directly into chat as if it we're a command do you still see this behavior?

February 17 (2 years ago)

Thank you so much for your support!  You guys are awesome!


@Finds – I  did a few different experiments and here are my results:

- My original macro code added to the character sheet as an ability – Generates a formatted box with “!splay Eye_Beam_Sound” included in chat as text along with the proper output.  No sound.

- Your macro code added to the character sheet as an ability – Generates a formatted box like the one above (not default) with the text of the macro on screen.  No sound.  Tried with !play line both as first line and last line.  Same result.

- My macro code cut/pasted into chat – The text appears including the proper data, but no box/formatting.  Just appears as text.  The sound plays successfully.  All of the cutting & pasting is probably too cumbersome for game play though.

- Your macro code cut/pasted into chat – Works!  Default format box, properly populated but doesn’t match the format of my other macros.  The sound plays successfully but same drawback as previous.

- My macro code cut/pasted in the Attributes & Abilities tab as an Ability – The text appears including the random table data, but no box/formatting.  Just appears as text.  The sound plays successfully.  Workable but not pretty.

- Your macro code cut/pasted in the Attributes & Abilities tab as an Ability – Works!  Default format box, properly populated but doesn’t match the format of my other macros.  The sound plays successfully.  I can live with this.


So I think I’m good with the bottom solution.  Thanks again for your help!

April 13 (2 years ago)

Edited April 13 (2 years ago)

Hello.  I love simple sound api. Awesome work Finds. Here's a little addon so the player can whisper to self when using a menu.  The ideas is from the 'get info' interactive map send info to chat in a whisper.


/w ?{Who Are You?|players display name here}&{template:traits} {{name=Effects Ranged Weapons}} {{description=

[Arrow Barrage vs Chain](!splay Arrow Barrage vs Chain)

[Arrow Barrage vs Plate](!splay Arrow Barrage vs Plate)

[Arrow Barrage vs Steel Shield](!splay Arrow Barrage vs Steel Shield)

[Arrow Barrage vs Wooden Shield](!splay Arrow Barrage vs Wooden Shield)

[Arrow vs Chain](!splay Arrow vs Chain)

[Arrow vs Plate](!splay Arrow vs Plate)

[Arrow vs Shield](!splay Arrow vs Shield)

[bow twang_01](!splay bow_twang_01)

}}