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

1641701668

Edited 1644379395
Finds
Pro
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 
1641741290
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!
1641777651
Gold
Forum Champion
Good Finds
1641778639
Finds
Pro
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.
1641846111
Can my players use this?
1641851125
Finds
Pro
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.
1641892551
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
1641940815

Edited 1641942918
Finds
Pro
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.
1643403021
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?
1643832063
Finds
Pro
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
1644084139
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.
1644878571
Mike
Pro
Oh my god thank you! So simple and yet so amazing.
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.
1645111739
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.
1645116764

Edited 1645116800
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
@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? 
1645124747
Finds
Pro
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.
1645125962

Edited 1645126279
Finds
Pro
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?
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!
1649830218

Edited 1649830326
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) }}