// Script to use pad Leds to show transport and section status // Arguments: // none // // Author: LoopToGo // // Description : Will turn on different leds based on LoopToGoState // Row 1 (bottom) // Column 1 (White): Rewind All // Column 2 (Blue): Go to last start tick // Column 3 (Green): Play/Pause // Column 3 (Red): Record/Pause // Row 2 // Column 1 (purple): Next track // Row 3 // Column 1 (purple): Previous track // Row 7 and 8 // Section leds. Colour will change when a section name is different from the previous one // Current section will flash and next jump section will pulse alias aDeviceOut LaunchPadMini loadScript Looptogo\aliases.txt setScriptName "Transport Led" setScriptStopMode 1 loadScript LoopToGo\libs\Novation\novationLaunchPadMiniUtilities.ltgl while 1 callFunction updateTransportLed waitDelta .2 endWhile function updateTransportLed variable cond1 $isPlaying = $gLastIsPlaying variable cond2 $isRecording = $gLastIsRecording variable cond3 $isPaused = $gLastIsPaused variable cond4 $nbSections = $gLastNbSections variable cond5 $currentSection = $gLastCurrentSection variable cond6 $nextSection = $gLastNextSection variable cond7 $gInitTransportLed = false if $gInitTransportLed callFunction clearAllColorNames endIf // print $cond1 $cond2 $cond3 $cond4 $cond5 $cond6 $cond7 ifNot $cond1 * $cond2 * $cond3 * $cond7 // Transport buttons that can be pulsing (Stop, Play Record) // Row 1 (bottom) if $isPaused callFunction setPadPulsing aDeviceOut 3 aColorPaletteYellow // Stop pulsing else callFunction setPadColor aDeviceOut 3 aColorPaletteYellow // Stop endIf if $isPlaying callFunction setPadPulsing aDeviceOut 4 aColorPaletteGreen // Play/Pause pulsing else callFunction setPadColor aDeviceOut 4 aColorPaletteGreen // Play/Pause endIf if $isRecording callFunction setPadPulsing aDeviceOut 5 aColorPaletteRed // Record/Pause pulsing else callFunction setPadColor aDeviceOut 5 aColorPaletteRed // Record/Pause endIf endIf if $gInitTransportLed // Buttons that are never pulsing (Rewind all, rewind, etc.) // Row 1 (bottom) callFunction setPadColor aDeviceOut 1 aColorPaletteBlue // Rewind all callFunction setPadColor aDeviceOut 2 aColorPaletteWhite // Go to last start tick // Row 2 callFunction setPadColor aDeviceOut 10 aColorPaletteBlue // Beginning of song callFunction setPadColor aDeviceOut 11 aColorPalettePurple // Previous start or end of loop callFunction setPadColor aDeviceOut 12 aColorPalettePurple // Next track callFunction setPadColor aDeviceOut 13 aColorPalettePurple // Next start or end of loop callFunction setPadColor aDeviceOut 14 aColorPaletteBlue // End of song // Row 3 callFunction setPadColor aDeviceOut 21 aColorPalettePurple // Previous track // Row 3 callFunction setPadColor aDeviceOut 25 aColorPaletteBlue // Toggle structure view callFunction setPadColor aDeviceOut 26 aColorPalettePurple // Toggle mixing console view // Row 4 callFunction setPadColor aDeviceOut 34 aColorPalettePurple // Toggle zoom horizontal callFunction setPadColor aDeviceOut 35 aColorPalettePurple // Toggle zoom vertical // Row 5 callFunction setPadColor aDeviceOut 43 aColorPaletteBlue // Toggle structure view callFunction setPadColor aDeviceOut 44 aColorPalettePurple // Toggle Plugins/Chains/Songs/Playlits view endIf ifNot $cond4 * $cond5 * $cond6 * $cond7 // Sections buttons //print $gInitTransportLed $cond4 $cond5 $cond6 : $cond4 * $cond5 * $cond6 //print currentSection : $currentSection gLastCurrentSection : $gLastCurrentSection nextSection : $nextSection //print $currentSection $currentSectionName $currentSectionStart $currentSectionEnd for row 6 8 // Sections Row 8 (sections 1-8) Row 7 (sections 9-16) Row 6 (sections 17-24) variable startSection 65 - $row*8 variable endSection $startSection + 7 variable offStartSection $startSection variable offEndSection $endSection // Row 8 (63) Row 7 () variable firstPad $row*9 - $startSection - 8 if $endSection > $nbSections variable endSection $nbSections endIf if $offStartSection < $endSection + 1 variable offStartSection $endSection + 1 endIf for i $startSection $endSection variable sectionName sectionName & $i callFunction selectColor color $$sectionName if $i = $currentSection callFunction setPadFlashing aDeviceOut $firstPad + $i $color 0 // Current section is flashing! else if $i = $nextSection callFunction setPadPulsing aDeviceOut $firstPad + $i $color // Next section is pulsing! else callFunction setPadColor aDeviceOut $firstPad + $i $color // Normal section endIf endIf endFor ifNot $cond4 for i $offStartSection $offEndSection callFunction setPadColor aDeviceOut $firstPad + $i 0 // Turn off unused pad endFor endIf endFor endIf globalVariable gInitTransportLed false globalVariable gLastIsPlaying $isPlaying globalVariable gLastIsRecording $isRecording globalVariable gLastIsPaused $isPaused globalVariable gLastNbSections $nbSections globalVariable gLastCurrentSection $currentSection globalVariable gLastNextSection $nextSection endFunction function selectColor // color [out] sectionName [In] // First we try to set the color based on known section name such as Verse, Chorus, etc. regexReplace firstWord $arg2 "^(\S+).*" "$1" //print sectionName : [ $arg3 ] [ $firstWord ] if $firstWord = Intro globalVariable gSectionColor aColorPaletteGreen parentVariable $arg1 $gSectionColor exitFunction endIf if $firstWord = Verse globalVariable gSectionColor aColorPalettePurple parentVariable $arg1 $gSectionColor exitFunction endIf if $firstWord = Chorus globalVariable gSectionColor aColorPaletteOrange parentVariable $arg1 $gSectionColor exitFunction endIf if $firstWord = Bridge globalVariable gSectionColor aColorPaletteYellow parentVariable $arg1 $gSectionColor exitFunction endIf if $firstWord = Solo globalVariable gSectionColor aColorPaletteRed parentVariable $arg1 $gSectionColor exitFunction endIf if $firstWord = Outro globalVariable gSectionColor aColorPaletteDarkGreen parentVariable $arg1 $gSectionColor exitFunction endIf if $firstWord = End globalVariable gSectionColor aColorPaletteGreen parentVariable $arg1 $gSectionColor exitFunction endIf // This section is for unrecognized section name variable colorName $firstWord & SectionColor ifNot $$colorName globalVariable gColorNumberForCustomSectionName $gColorNumberForCustomSectionName + 1 if $gColorNumberForCustomSectionName = 1 globalVariable $colorName aColorPaletteWhite else if $gColorNumberForCustomSectionName = 2 globalVariable $colorName aColorPaletteLightPink else if $gColorNumberForCustomSectionName = 3 globalVariable $colorName aColorPaletteBeige else if $gColorNumberForCustomSectionName = 4 globalVariable $colorName aColorPaletteLightGreen else globalVariable $colorName aColorPaletteLightOrange globalVariable gColorNumberForCustomSectionName 0 // We will start at 1 next time! endIf endIf endIf endIf endIf //print $colorName has been defined to $$colorName globalVariable gSectionColor $$colorName parentVariable $arg1 $gSectionColor endFunction function clearAllColorNames for i 1 $nbSections variable sectionName sectionName & $i regexReplace firstWord $$sectionName "^(\S+).*" "$1" variable colorName $firstWord & SectionColor if $$colorName //print cleaning $$colorName globalVariable $colorName 0 endIf endFor globalVariable gColorNumberForCustomSectionName 0 endFunction