Hi folks!
This time i made a rackspace for a sample/audio player with 8 tracks/slots.
I used the internal Streaming Audio File Player (SAFP) as the source…
In the rackspace you can load up to 8 audio files into the SAFP which are then available to be played via separate buttons (you can map those buttons to your midi controller at will).
The tracks will only work in a “radio button” manner (the SAFP can only play one track at a time)!
You can activate “loop play” mode, or leave it OFF which then causes the tracks to be played as single shot.
I used quite a bit of scripting to make the UI as informative as possible, which means:
- you only will see widgets for the number of actual available tracks
(empty track’s elements are hidden) - the name of the available tracks
- the tracks area is updated with each change of the track list in the SAFP
Just press a “Track button” to make it play.
As long as loop mode is active, the player will continue playing, while you can switch between the diffrent tracks.
Pressing “STOP” will stop the player and reset the playhead position.
Pressing PLAY/PAUSE while audio is played will pause the playhead, from where you can continue playing by pressing PLAY again.
Important to know:
If you change the playlist in the SAFP (deleting one file or adding one), the respecting assignment of the track buttons will change accordingly! The SAFP only supports a continuous playlist - no empty spaces allowed/possible!
Even if you can load up to 1000 tracks into SAFP, the rackspace is layed out to handle just 8!
This is how it looks like:
empty state
5 files loaded
fully loaded (8 tracks)
in action:
This is the script content (for the curious ones):
var
lblTrkSelect, btnLoop, btnPlay, btnStop : widget
btnTrk1,btnTrk2,btnTrk3,btnTrk4,btnTrk5,btnTrk6,btnTrk7,btnTrk8 :widget
lblTrk1,lblTrk2,lblTrk3,lblTrk4,lblTrk5,lblTrk6,lblTrk7,lblTrk8 :widget
trackSelection : widget array = [btnTrk1,btnTrk2,btnTrk3,btnTrk4,btnTrk5,btnTrk6,btnTrk7,btnTrk8]
lblTrkNames : widget array = [lblTrk1,lblTrk2,lblTrk3,lblTrk4,lblTrk5,lblTrk6,lblTrk7,lblTrk8]
trkNrTot : integer
plgSAFP : PluginBlock
function SetTracks() //user function to set the trackselection area on start or if the tracklist has changed
var
index: integer
trkNrTot = Round(GetParameter(plgSAFP, 15)*1000) //get number of loaded tracks
if trkNrTot == 0 Then
SetWidgetLabel(lblTrkSelect, "NO TRACKS LOADED!")
else
SetWidgetLabel(lblTrkSelect, "TRACK SELECTION")
end
For index=0; index<Size(trackSelection); index = index +1 Do
if index +1 > trkNrTot Then
SetWidgetHideOnPresentation(trackSelection[index], true)
SetWidgetHideOnPresentation(lblTrkNames[index], true)
else
SetWidgetHideOnPresentation(trackSelection[index], false)
SetWidgetHideOnPresentation(lblTrkNames[index], false)
end
SetWidgetValue(trackSelection[index],0) // turn off all trackselect widgets
end
For index=0; index<Size(lblTrkNames); index = index +1 Do
SetParameter(plgSAFP, 13, IntToFloat(index)/1000)
SetWidgetLabel(lblTrkNames[index],GetParameterText(plgSAFP, 14))
end
End
function zeroTrackSelection() // user function to zero every track select button
var
index : integer
for index=0; index<Size(trackSelection); index = index +1 Do
SetWidgetValue(trackSelection[index],0)
end
End
// Called automatically after script is loaded
Initialization
SetTracks() // call user function to set the trackselection area
zeroTrackSelection() // call user function to zero the trackselect widgets
End
// Called when a plugin block parameter value has changed
On ParameterValueChanged(parameterNumber : integer, parameterValue : double) from plgSAFP
if parameterNumber == 15 Then // if the number of tracks has changed
SetWidgetValue(btnStop,1.0)
SetTracks() // call user function to set the trackselection area
SetWidgetValue(btnStop,0)
end
End
// set track selection
On WidgetValueChanged(w : Widget, index: integer, newValue : double) from btnTrk1,btnTrk2,btnTrk3,btnTrk4,btnTrk5,btnTrk6,btnTrk7,btnTrk8
if newValue > 0.6 Then
SetParameter(plgSAFP, 13, IntToFloat(index)/1000)
SetWidgetValue(btnPlay,1.0)
end
End
On WidgetValueChanged(bVal:double) from btnPlay
if bVal <0.4 and GetWidgetValue(btnLoop) < 0.4 Then
zeroTrackSelection() // call user function to zero the trackselect widgets
end
End
On WidgetValueChanged(bVal:double) from btnLoop
if bVal <0.4 Then
zeroTrackSelection() // call user function to zero the trackselect widgets
end
End
On WidgetValueChanged(bVal:double) from btnStop
if bVal <0.4 Then
zeroTrackSelection() // call user function to zero the trackselect widgets
end
End
And finally the gig file to download
(make sure you download the file for your actual version of Gig Performer!!!):
Only for GP V4
8xLoopPlayer.gig (459.2 KB)
Only for GP V5
8xLoopPlayer_workaround(V5).gig (459.5 KB)
(see postings below to know the reason for having to use a temporary “workaround”)
Have fun with it!