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] Roll20 Audio Master -- Hear the dice, Hear the action!

All right, another thing I discovered is that this only happens if you launch the music playlist from the jukebox. If you launch the playlist from the Roll20AM interface the tracks work fine and do not change when automatic sound effects are played. It's a good enough workaround at the moment, albeit not perfect.
1506865940
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, thanks for the update sirren.
Scott, I'm seeing problematic behavior, and I'm not sure if it's a script bug or if it's operator error. Specifically, when I use the --play command, the tracks never appear to stop playing on their own.  I'm primarily using Roll20AM for sound effects with spells and attacks, with multiple variations of a particular sound under an umbrella playlist, which I have configured to run in single mode. For example: Playlist fx-crossbow contains fx-crossbow-firing-01 fx-crossbow-firing-02 fx-crossbow-firing-03 fx-crossbow-firing-04 fx-crossbow-firing-05 I see the same behavior (that is, the sound's playback not actually stopping) whether I call the playlist or an individual sound, and whether I explicitly declare single  mode in my -- play  call or rely on the implicit setting from the playlist. What I observe is the track remaining listed in "Now Playing" on the Jukebox tab once it's done, and when I call another sound it plays the new one *and* the old one. And playing a third track plays all three, and so on. In case it's relevant: The --stop command *does* work, both as explicit per-track calls and as a blanket --stop,ignore| call. (I tried both appending a --stop,soft call onto a --play call as well as issuing both commands back-to-back, but neither method ever played anything.) Any insight you can share?
1509425605
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, I'll have to take a look. Thanks for the report. It'll probably be this weekend before I get to investigate
No worries, Scott. Thanks for looking into it! :-)
An additional wrinkle I just discovered: The never-actually-stopping playback only seems to be affecting me when I'm logged in as a player ;  when I'm logged in to the same game and running the same macros as GM , the tracks are removed from the "Now playing" as expected.
1509455465
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, ok, that's interesting. Thanks for the update.
Anyone have an example of a shuffle macro?  The directions are not as intuitive as I had hoped.  I have tried all the combinations of what I would think it should look like.  The name of my playlist is FCast.  Here is the macro: !roll20AM --play,mode:shuffle|FCast  I have tried !roll20AM --play,[mode:shuffle]|FCast as well as taking out the comma, and a lot of other combinations but nothing works
I cannot get any list to play using :  !roll20AM --play|listname
1515535861
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Drask, is this a playlist in the jukebox or one that you made in the script? The way that the jukebox works, the script can't directly control playlists in it. You need to make a playlist in roll20AM in order for the script to be able to play it. There is a playlist importer as well. See the directions in the OP or the script's handout in game for syntax. As a note the [] in the syntax explanation is to denote an optional argument, you don't include the [] in the actual command, so your !roll20AM --play,mode:shuffle|FCast is correct, it just needs a script play list to play.
1515537560
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
sirren said: All right, another thing I discovered is that this only happens if you launch the music playlist from the jukebox. If you launch the playlist from the Roll20AM interface the tracks work fine and do not change when automatic sound effects are played. It's a good enough workaround at the moment, albeit not perfect. Sirren, just re read your post. This is unfortunately the intended behavior. Playlists only work with Roll20AM if they are created in the script. Other than importing currently existing playlists from the jukebox to the script, it can't interact with them in any way.
What I observe is the track remaining listed in "Now Playing" on the Jukebox tab once it's done, and when I call another sound it plays the new one *and* the old one. And playing a third track plays all three, and so on. I can confirm said behaviour. I would like to add, that if the GM logs on to the game in this situation all tracks "queued" in the "Now playing" section start playing and get removed one after another. The items getting stuck only happens when there is no GM logged in (it has nothing to do whether the player himself is a GM the only important thing in my case is whether there is any one GM in the game currently. Manually issueing a --stop command (as player) removes the stuck items.
Just tried out the Fade Feature and cannot get it working. Is this supposed to work as mentioned in the 1.05 changelog, or is it still broken (as the command overview says)? Either way I'm having an issue with the following command crashing the API: !roll20AM --vcontrol,volume:0,ignore,fade,tickTime:1,volTick:2| This crashes the API with the following error: ReferenceError: who is not defined     at changeVolume (apiscript.js:4730:40)     at _.each (apiscript.js:4782:25)     at Function._.each._.forEach (/home/node/d20-api-server/node_modules/underscore/underscore.js:153:9)     at fadeTracks (apiscript.js:4774:19)     at Timeout.delayHandler [as _onTimeout] (apiscript.js:4995:33)     at ontimeout (timers.js:393:18)     at tryOnTimeout (timers.js:244:5)     at Timer.listOnTimeout (timers.js:214:5) I played around with the parameters and noticed it seems to happen when the volume parameter is not 100. If it is 100 the API doesn't crash (but the command doesn't do anything). Like in the following command: !roll20AM --vcontrol,volume:100,ignore,fade,tickTime:1,volTick:1| Maybe there is something I misread or forgot, maybe someone could help me out and point me in the right direction.
1518447773
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Thanks Florian. It should be working. I'll take a look today and see what's going on.
I looked a bit further into the issue and can give some more pointers. The problem with the script crashing the API comes from line 666 (coincidence?) in the changeVolume function. In the body of the last if statement of the function the script is accessing the `who` variable which has not been passed to the function. This crashes the API with the error I mentioned. For further testing I hardcoded the gm there. So far so good, the script doesn't crash the API anymore. But the codepath we're having a problem with is one that should be taken if something is wrong with the syntax changeVolume is expecting.  In fact everywhere changeVolume gets called, there is a latent issue with the errormessage of the script crashing the API because the signature of changeVolume does not allow to pass in a who-variable. The call in question to the changeVolume function comes from the fadeTracks function. I then added some logging for the variables that are used in the fadeTracks function to see if they're being initialized correctly and I may have found something. For whatever reason the tickTarget variable always stays undefined / empty. JavaScript isn't my strong side so I'm leaving you with that info for now and hope you can make something of it.
Found another small issue (are you hating me already?): If you have a list whose name contains a comma it cannot be deleted or targeted by the roll20AM commands because the listname will get truncated at the first comma. Traditional ways of escaping (\) or enclosing it in either quotes or doublequotes did not help. Possible Source: If you're using !roll20AM --listCreate to create the list and !roll20AM --listEdit to edit / remove the list the problem won't show since the command will truncate the list at the same position. This is only becoming an issue when using --listImport. With --listImport the name of the playlist doesn't get truncated while creating them but cannot be the target of another command anymore because that command will get truncated and the script won't find the correct list to edit. This could even lead to the script deleting the wrong playlist if you have similar listnames. If you have two lists, "foo" and "foo,bar" trying to delete "foo,bar" will most likely result in foo being deleted (untested).
Is it possible to use this alongside the 5E OGL Character Sheets? I've tried messing around and putting a known working play command in the description section of a spell but I guess due to the way its outputted into chat it can't be read? Any other pathways?
1520148526
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yes, it is. It just requires some manipulation of the code. See this post for details
AWWWW YEAH! IT WORKS PERFECTLY! Now to go through all my players spells and add sound effects before Wednesday.
1520179611
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Happy rolling
Could you find out something about the fading not working or do you need some further information? I would really love to use that feature specifically.
1520952926
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi Florian, Sorry, I've been a bit busy with work. I'll work on it this week and should hopefully have a fix for it by next merge day.
1523131367

Edited 1523131387
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
1.11523130236 Fix for fade command not working. The fade command will accept decimal seconds (e.g. 1.5) for tickTime. TickTime should never be set below 1 as the delay is shorter than the processing time required to manipulate the volume so you wind up with not a fade, but just a delayed volume change.
1523268989

Edited 1523275713
Hey Scott, thanks once again for the work you pour into this. I'm still having an issue getting the fading to work correctly. I'm trying the following command: !roll20AM --vcontrol,volume:20,fade,tickTime:2,volTick:10|CarelessWhisper Issueing above command floods the chat with the message: The volume change command you sent was invalid. Volume to change to can be a number or basic arithmetic (e.g. 5,+5,-5,*2,/2). This I believe shows, that the right function is being triggered because fading should be the one recursive function here. From what I can gather this might be (just guessing) because the fraction the scripts calculates gets incredibly small until it will be printed in scientific notation which then sets off the regular expression. Otherwise it does in fact reduce the volume but from what I can gleam it does so only on the first tick, does not change the volume on subsequent ticks and seems to lower the volume on the first tick way to low (if I understand the working correctly it should decrease the volume every 2 seconds by 10 until it reaches 20 - correct?), but I believe the first tick already reduces it to 20 and the subsequent ticks don't do anything. I noticed, independent on how the tracks are set-up it never seems to fade up, only down. Edit: after fudging around, I now cannot reproduce this anymore. I'm trying to find a way to reproduce this and otherwise thank you for your work! One thing I can reproduce kind of is when I fade a track to volume 0, Roll20AM gets stuck in a loop and repeats the message in chat after fading a bit: The volume change command you sent was invalid. Volume to change to can be a number or basic arithmetic (e.g. 5,+5,-5,*2,/2). This causes the issue: !roll20AM --vcontrol,volume:0,fade,tickTime:2,volTick:10|CarelessWhisper This does not: !roll20AM --vcontrol,volume:1,fade,tickTime:2,volTick:10|CarelessWhisper I believe this is caused by the script failing to calculate the change on the final tick.
1523282346
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
hmm, thanks Florian. I'll look into it later today.
Hi Scott, I'm trying roll20AM for the first time and i'm getting no audio output nor chat output at all. No sound, errors, nothing. I've installed oneclick version and pasted the latest version to no success. I've tried !roll20AM --play|goblin laugh 1 to play goblin laugh 1 by Bryn. (The audio works from the jukebox.) I've also tried !roll20AM --config|menu:tracks     Is there a convention for track names? ie do I use just the name, the name and author etc etc Hope you can help. Thx in advance
1523964964

Edited 1524021135
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi hawkmoon, other than the -players- tag, you must use the name of the track in it's entirety. So this should work: !roll20AM --play|goblin laugh 1 by bryn EDIT: spelling of players
Thx Scott. Pretty sure I tried that too. Just copied and pasted your example and nothing happens.
1524021184
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
hmm, ok. If you're looking at your jukebox when you send the command, nothing appears in the now playing section?
Nope. Now no api's are working.Api console was throwing an error. Disabled all one by one. Error stopped after 5e OGL character sheet was disabled. Trying to restart api's and console stuck on starting.....
corection to last its the common.js throwing the error. Spinning up new sandbox... "Starting webworker script..." SyntaxError: Invalid or unexpected token
1524025363

Edited 1524025493
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
hmm, ok, that's strange. It loads fine for me from one-click. Do you have any other scripts installed? Can you try disabling all of them except roll20AM and test that way? Missed your first of the two posts above. Is that "starting webworker script..." that it is stuck on?
Still nothing with all disabled.  Are there any setup steps I may have missed? The roll20Am handout is the only thing that seems to work
I opened up the game in another tab and the starting up issue resolved. Hasn't helped getting roll20Am to work nor the token error with common.cs
1524027554
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, yes, the sandbox doesn't start unless someone is in the vtt. So, when does the token error show up?
after I install common.js
ok somehow its now working Scott. Not sure why. I've left monster.js, common.js and torch.js disabled as I dont need them atm. Not sure if there's a conflict ther at all, but common.js def was throwing errors for some reason.
1524054798
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I'm not familiar with common and monster. One thing you can try is to put some empty lines at the end of those scripts.
1524058364
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Also, was there a semicolon at the end of common.js? The scripts are concatenated into one uber script at run time and not closing the end properly can cause the first line of the next script to write to the same line.
Sorry for delay responding. Keith here is the script. // Misc. utility functions, common to my scripts. Array.prototype.unique = function() { var a = this.concat(); for(var i=0; i<a.length; ++i) { for(var j=i+1; j<a.length; ++j) { if(a[i] === a[j]) a.splice(j--, 1); } } return a; }; function mergeArray(array1,array2) { for(item in array1) { array2[item] = array1[item]; } return array2; }; String.prototype.capitalizeFirstLetter = function() { return this.charAt(0).toUpperCase() + this.slice(1); }; String.prototype.repeat = function( num ) { return new Array( num + 1 ).join( this ); }; © 2018 GitHub, Inc. Terms Privacy Security Status Help
1524295873
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I'm assuming you didn't paste © 2018 GitHub, Inc. Terms Privacy Security Status Help into the API window?
nope was in the script
1524315327
The Aaron
Pro
API Scripter
To be clear, you're only copying this part into the api: // Misc. utility functions, common to my scripts. Array.prototype.unique = function() { var a = this.concat(); for(var i=0; i<a.length; ++i) { for(var j=i+1; j<a.length; ++j) { if(a[i] === a[j]) a.splice(j--, 1); } } return a; }; function mergeArray(array1,array2) { for(item in array1) { array2[item] = array1[item]; } return array2; }; String.prototype.capitalizeFirstLetter = function() { return this.charAt(0).toUpperCase() + this.slice(1); }; String.prototype.repeat = function( num ) { return new Array( num + 1 ).join( this ); }; and not this part: © 2018 GitHub, Inc. Terms Privacy Security Status Help
Thx Aaron and Keith. It was working, then stopped. Not sure if script was updated. Will remove the github info from script
1524322752
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
When copying from Github, it's safest to click the "raw" button and select the text from the resulting screen. There's no chance of accidentally selecting part of the Github interface or other text, then.
Is there a way to have add an Audio Attribute to a token and have Roll20AM call the name from the attribute? Trying to have different dying effects for creatures without chaning the macro for each.
1527111441

Edited 1527111625
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Sure, make an attribute on your character's attribute & abilities page, name it something like "death_knell". Then, you'd do a global macro containing the Roll20 command (and make it a token action) like this: !roll20AM --play|@{selected|death_knell} You could alternatively create it as an ability and reference it as: !roll20AM --play|%{selected|death_knell} or use one of a token's bars as: !roll20AM --play|@{selected|bar1}