Audioplayer panel (using GPScript)

Hi folks,

since there are regularly questions about how to do this and that with the audioplayer plugin, i thought i could share this rackspace with you (it lied “hidden” in another thread of another sub forum).
So why not bring it back to live at the right place…

This is how the panel looks like:

And these are the functions:

  • switch which lets you change from single to multi track play (switching to “multi” disables the “radio mode”)
  • button to enable/disable the loop mode
  • button to stop / reset the counter position (while in loop mode, it just jumps back to start and starts playing again)
  • button to play / pause
  • button to open/close the player
  • switch to activate the “radio mode” (means, the track buttons act as radio buttons. While playing is active the selected track will start playing from the beginning). This can only be active in “single track” mode!
  • 8 buttons to select the track(s) that is played

Many of these functions can only be realized by using GPScript, so there is a bunch of code lines working in the background (find the code in the rackspace-script editor).

audioplayer_V4.rackspace (252.8 KB)

Maybe this is useful for some of you… have fun with it! :slight_smile:

Cheers!
Erik

18 Likes

Could a Function be added to set start and stop markers for looping?

I will have a look, later this day… i think that should be doable.

1 Like

I just had a closer look at it and unfortunately it isn’t that easy as i first thought it was… i thought there were separate parameters for a loop-start and loop-end marker, but obviously there aren’t.
@dhj : please consider this as a feature request (if it isn’t already in the queue).
So i’ll have to find a way first to translate the time-string to a parameter value (and vice versa) and a way to test if the playhead reached a particular value of those imaginary markers… and it all has to be useable as well… we’ll see.

1 Like

Hello @schamass, thank you for this gig file. I have a question. I’ve made a gig with 4 versions of this media player, each with 8 variations for the 8 tracks. The issue I’m facing is that various times I call on one of these rackspace variations from my Setlist/Song View, it will return to the rack, but the wrong track is selected. Does the rackspace somehow get reset if you randomly select one of the rackspace variations from the Setlist/Song View?

audioplayer_V4-with-label-script.gig (1.1 MB)

Hm… does this also happen when you are not in setlist mode, say did it happen that, by selecting a variation in rackspace view, the wrong track is enabled? If this doesn’t happen, the error must be in the use of the setlist mode.
Maybe you have accidentially used the snapshot function which will override a variation setting or something like this?

Hello, @schamass, thank you for the prompt reply. During performance, I only use the setlist/song view. I do not use the Panel/Rackspace view during a performance. This bug, if I may call it that, happens after the Audio Player is set up in the Rackspace, when I switch to Setlist/Song view and move between songs in Setlist/Song view, the tracks in the Rackspace change. I hope a picture is worth a 1,000 words, here’s a 45 second screen capture showing this oddity. This is only one example as I have four (4) Audio Player rackspaces, each loaded with different mp3 tracks. I set them all up, but when I go into Setlist/Song view, there are these random track changes to the specific rack variations that were set in Rackspace view mode.

I’m not sure about accidently using the snapshot function. How can I tell if that occurred?

Hi Dennis,
i managed to track down this issue… everything happens because something under the hood of the general widget management does something unexpected, which causes the audioplayer to do something unwanted at this special moment. :nerd_face: :grimacing:
On changing a rackspace, every containing widget gets refreshed, which causes the OnWidgetValue callback to be triggered - no matter if the widget value actually has changed or not.
And if this happens to the “Mode switch” widget (when set to “single”), which is connected to the corresponding parameter of the audio player, it will cause the audio player to do again a fresh activation of its “single” mode, and this results in resetting the play markers of all the lanes and re-activating only lane 1. So, as long as you stay within one rackspace, everything behaves normally, but if you change the rackspace, the actual variation will be reset to lane 1.
I think have an idea to circumvent this situation, but i first have to get some sleep now… it’s late, or early?
Anyway: I’ll go to bed now.

Ooookay… i think/guess/hope that i have now a version which works as it should.
To circumvent the “rebellious behaviour” of the audio player (i guess there will be some bugs fixed for the next release of GP), i used a group of hidden LED widgets to somehow “buffer” the actual state of the most important widgets, so their state can be recalled correctly when having changed audioplayer files or having changed rackspaces.
A new feature is the “auto recognition” for the caption of the text label!
This will automatically be created from the actual variation name which will be cut at the beginning according to the repeating naming pattern… in this example the naming pattern for the variations is
“Audio - Track A-1” where the repeating substring to be cut away will be "Audio - " (this string can be changed in the script!), so the resulting name would be “Track A-1”… in addition to this i also placed the actual variation index before the name, means the final caption for the text label would display “1: Track A-1”
Another example:
If you would rename the third variation to (i.e.) “Audio - The Wall” then the label would be automatically set to “3: The Wall” (note: you will have to change to another variation and back to have the change take effect)

Now this rackspace is flexible enough to be just duplicated without having to make changes within the script - except you want to change header of the naming pattern .
On some places the code could be improved/shortened but on other places some additional code was needed…

This is the script code:

var
switch_mode, switch_radio, btn_loop, btn_reset, btn_play, btnPlayerOpen : Widget
lbl_pos, L1 : Widget
trk_1, trk_2, trk_3, trk_4, trk_5, trk_6, trk_7, trk_8 :Widget
buttons : Widget Array = [trk_1, trk_2, trk_3, trk_4, trk_5, trk_6, trk_7, trk_8]

//hidden buffer widgets to store and recall the state of the "real" widgets
buff_mode, buff_loop, buff_radio, buff_t1, buff_t2, buff_t3, buff_t4, buff_t5, buff_t6, buff_t7, buff_t8 : widget
buffers : widget array =[buff_mode, buff_loop, buff_radio, buff_t1, buff_t2, buff_t3, buff_t4, buff_t5, buff_t6, buff_t7, buff_t8]

//Use this string to set what is "cut" from the begin of the Variation name
//The rest of the string then will be used as the caption of the test label
LabelHeader : string = "Audio - "

Function ResetAndPlay (btn_state : double)
    if GetWidgetValue (switch_radio) == 1.0 and btn_state ==1.0 and GetWidgetValue (btn_play) == 1.0 then
        SetWidgetValue (lbl_pos, 0.0)
        SetWidgetValue (btn_play, 1.0)
    end
End

Function ResetButtons()
var i, counter : integer
counter = 0
    for i = 0; i < Size(buttons); i = i + 1 do
        if GetWidgetValue (buttons[i]) > 0.55 then
           counter = counter+1 
        end
    end
    
    if counter >1 or counter ==0 then
        for i = 0; i < Size(buttons); i = i + 1 do
            SetWidgetValue (buttons[i], 0.0)
        end
        SetWidgetValue (buttons[0], 1.0)
    end
End

function SetLabelText()
var
variName, lblText : string
    variName = GetVariationName(GetCurrentVariation())
    lblText = "" + (GetCurrentVariation() +1) + " : " + CopySubstring(variName, Length(LabelHeader), Length(variName)-Length(LabelHeader))
    SetWidgetLabel(L1, lblText)
End

//function to buffer the state of the active widgets with hidden passive widgets
function WidgetStateSafe (mode : string) //mode can be "store" or "recall"
var i:integer
    If mode == "store" then
        SetWidgetValue(buffers[0], GetWidgetValue (switch_mode))
        SetWidgetValue(buffers[1], GetWidgetValue (btn_loop))
        SetWidgetValue(buffers[2], GetWidgetValue (switch_radio))
        For i=3;i<Size(buffers);i=i+1 Do
            SetWidgetValue(buffers[i], GetWidgetValue (buttons[i-3]))
        end
    Elsif mode == "recall" then
        SetWidgetValue(switch_mode, GetWidgetValue(buffers[0]))
        SetWidgetValue(btn_loop, GetWidgetValue(buffers[1]))
        SetWidgetValue(switch_radio, GetWidgetValue(buffers[2]))
        For i=3;i<Size(buffers);i=i+1 Do
            SetWidgetValue (buttons[i-3],GetWidgetValue(buffers[i]))
        end
    end
End

Initialization
    SetWidgetValue (btn_reset, 1.0)
    SetWidgetValue (btn_play, 0.0)
    SetLabelText()
    WidgetStateSafe("store")
End

On Activate
    SetLabelText()
    WidgetStateSafe("recall")
End

on Variation (oldVariation:integer, newVariation:integer)
    SetLabelText()
End

On WidgetValueChanged (newval : double) from btn_reset
    if newval == 1.0 and GetWidgetValue (btn_loop) == 0.0 then
        SetWidgetValue (btn_play, 0.0)
        SetWidgetValue (lbl_pos, 0.0)
    elsif newval == 1.0 and GetWidgetValue (btn_loop) == 1.0 then
        SetWidgetValue (lbl_pos, 0.0)
        SetWidgetValue (btn_reset, 0.0)
    end

End

On WidgetValueChanged (newval : double) from btn_play
    if newval == 1.0 then
        SetWidgetValue (btn_reset, 0.0)
    end
End

On WidgetValueChanged (newval : double) from btnPlayerOpen
    if newval >0.55 then
        WidgetStateSafe("store")
    else
        WidgetStateSafe("recall")
    end
End

On WidgetValueChanged (newval : double) from switch_mode
    if newval == 0.0 and GetWidgetValue (switch_radio) == 1.0 then
        SetWidgetValue (switch_radio, 0.0)
    Elsif newval == 1.0 then
        ResetButtons()
    end
    WidgetStateSafe("store")
End

On WidgetValueChanged (newval : double) from switch_radio
    if newval == 1.0 and GetWidgetValue (switch_mode) == 0.0 then
        SetWidgetValue (switch_radio, 0.0)
    end
    WidgetStateSafe("store")
End

On WidgetValueChanged (newval : double) from trk_1, trk_2, trk_3, trk_4, trk_5, trk_6, trk_7, trk_8
    ResetAndPlay(newval)
    WidgetStateSafe("store")
End

And this is the new gig file (i hope it works as expected):
audioplayer_V4_autolabel.gig (1.7 MB)

May it be helpful! :nerd_face: :vulcan_salute:
Cheers!
Erik

3 Likes

@schamass, this is brilliant! I can’t wait to give it a try.

Update: @schamass it works like a charm. Thank you so much for sharing your programming genius. Can I buy you a beer, mate? Really, thank you very much!

1 Like

Cool! Glad it worked for you… :slight_smile: :beers:

You are one smart cookie Eric.

1 Like