text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
set awk_filter_retina to " | awk '{print $1, $2, $3, $4}'" # grab every pixel
|
launchpad-for-maschine.applescript
|
if options is {} then
|
launchpad-for-maschine.applescript
|
set includex to sizex
|
launchpad-for-maschine.applescript
|
set gapx to 0
|
launchpad-for-maschine.applescript
|
set includey to sizey
|
launchpad-for-maschine.applescript
|
set gapy to 0
|
launchpad-for-maschine.applescript
|
set includex to item 1 of options
|
launchpad-for-maschine.applescript
|
set gapx to item 2 of options
|
launchpad-for-maschine.applescript
|
set includey to item 3 of options
|
launchpad-for-maschine.applescript
|
set gapy to item 4 of options
|
launchpad-for-maschine.applescript
|
set bytes_per_pixel to pixel_size * 4
|
launchpad-for-maschine.applescript
|
set bytes_per_row to bmp_width * bytes_per_pixel
|
launchpad-for-maschine.applescript
|
set bmp_offset to bmp_offset + (y - 1) * bytes_per_row
|
launchpad-for-maschine.applescript
|
repeat with gridy from 1 to sizey by (includey + gapy)
|
launchpad-for-maschine.applescript
|
repeat with iy from gridy to (gridy + includey - 1)
|
launchpad-for-maschine.applescript
|
set array_offset to (iy - 1) * bytes_per_row + (x - 1) * bytes_per_pixel
|
launchpad-for-maschine.applescript
|
set commands to commands & "( od -t xI -j " & (bmp_offset + array_offset) & " -N " & sizex * bytes_per_pixel & " -v $TMPDIR/maschineLP.bmp | grep '.*' --line-buffered ) & "
|
launchpad-for-maschine.applescript
|
set awk_filter_x to ""
|
launchpad-for-maschine.applescript
|
set awk_filter_x to " | awk '(FNR-1) % " & (includex + gapx) & " < " & includex & "'"
|
launchpad-for-maschine.applescript
|
set pixels to do shell script "{ " & commands & " } | sort -k1" & awk_filter_retina & " | awk -v OFS='\\n' '{$1=$1}1' | awk 'NF'" & awk_filter_x
|
launchpad-for-maschine.applescript
|
return pixels
|
launchpad-for-maschine.applescript
|
end pixelStream
|
launchpad-for-maschine.applescript
|
on rgbToHue(r, g, b)
|
launchpad-for-maschine.applescript
|
set hue to 0
|
launchpad-for-maschine.applescript
|
if (r = g) and (g = b) then return 0
|
launchpad-for-maschine.applescript
|
set r to r / 255
|
launchpad-for-maschine.applescript
|
set g to g / 255
|
launchpad-for-maschine.applescript
|
set b to b / 255
|
launchpad-for-maschine.applescript
|
if (r ≥ g and r ≥ b) then
|
launchpad-for-maschine.applescript
|
if (g > b) then
|
launchpad-for-maschine.applescript
|
set min to b
|
launchpad-for-maschine.applescript
|
set min to g
|
launchpad-for-maschine.applescript
|
set hue to (g - b) / (r - min)
|
launchpad-for-maschine.applescript
|
if (g > r and g ≥ b) then
|
launchpad-for-maschine.applescript
|
if (r > b) then
|
launchpad-for-maschine.applescript
|
set min to r
|
launchpad-for-maschine.applescript
|
set hue to 2 + (b - r) / (g - min)
|
launchpad-for-maschine.applescript
|
if (b > g and b > r) then
|
launchpad-for-maschine.applescript
|
if (r > g) then
|
launchpad-for-maschine.applescript
|
set hue to 4 + (r - g) / (b - min)
|
launchpad-for-maschine.applescript
|
set hue to (hue * 60 + 22) mod 360
|
launchpad-for-maschine.applescript
|
return hue
|
launchpad-for-maschine.applescript
|
end rgbToHue
|
launchpad-for-maschine.applescript
|
on rgbToIntensity(r, g, b)
|
launchpad-for-maschine.applescript
|
if (r = g) and (g = b) then
|
launchpad-for-maschine.applescript
|
else if (r + g + b > 300) then
|
launchpad-for-maschine.applescript
|
return active # 3
|
launchpad-for-maschine.applescript
|
return inactive # 1
|
launchpad-for-maschine.applescript
|
end rgbToIntensity
|
launchpad-for-maschine.applescript
|
on rgbToLPcolor(r, g, b)
|
launchpad-for-maschine.applescript
|
set hue to rgbToHue(r, g, b) / 25.714 - 0.5
|
launchpad-for-maschine.applescript
|
set hue to round hue
|
launchpad-for-maschine.applescript
|
set intensity to rgbToIntensity(r, g, b)
|
launchpad-for-maschine.applescript
|
if intensity = 0 then
|
launchpad-for-maschine.applescript
|
return hue * 4 + 8 - intensity
|
launchpad-for-maschine.applescript
|
end rgbToLPcolor
|
launchpad-for-maschine.applescript
|
on getLPintensity(LPcolor)
|
launchpad-for-maschine.applescript
|
if LPcolor > 3 then
|
launchpad-for-maschine.applescript
|
set intensity to 4 - (LPcolor mod 4)
|
launchpad-for-maschine.applescript
|
return intensity
|
launchpad-for-maschine.applescript
|
return 0 # default if not a color
|
launchpad-for-maschine.applescript
|
end getLPintensity
|
launchpad-for-maschine.applescript
|
on setLPintensity(oldLPcolor, intensity)
|
launchpad-for-maschine.applescript
|
if oldLPcolor > 3 then
|
launchpad-for-maschine.applescript
|
set baseLPcolor to (oldLPcolor div 4) * 4
|
launchpad-for-maschine.applescript
|
set newLPcolor to baseLPcolor + (4 - intensity)
|
launchpad-for-maschine.applescript
|
return newLPcolor
|
launchpad-for-maschine.applescript
|
end setLPintensity
|
launchpad-for-maschine.applescript
|
on setLPcolor(padx, pady, LPcolor)
|
launchpad-for-maschine.applescript
|
set padNumber to item padx of item pady of padNumbers
|
launchpad-for-maschine.applescript
|
set item padx of item pady of mas_pattern_colors to LPcolor
|
launchpad-for-maschine.applescript
|
set intensity to getLPintensity(LPcolor)
|
launchpad-for-maschine.applescript
|
if intensity = active then
|
launchpad-for-maschine.applescript
|
return {146, padNumber, 3}
|
launchpad-for-maschine.applescript
|
if grayscale and intensity is inactive then set LPcolor to gray_inactive # for grayscale mode
|
launchpad-for-maschine.applescript
|
return {144, padNumber, LPcolor}
|
launchpad-for-maschine.applescript
|
end setLPcolor
|
launchpad-for-maschine.applescript
|
on getLPpadXY(midi_note)
|
launchpad-for-maschine.applescript
|
repeat with iy from 1 to 8
|
launchpad-for-maschine.applescript
|
repeat with ix from 1 to 8
|
launchpad-for-maschine.applescript
|
if item ix of item iy of padNumbers = midi_note then return {ix, iy}
|
launchpad-for-maschine.applescript
|
end getLPpadXY
|
launchpad-for-maschine.applescript
|
on showControlButtons()
|
launchpad-for-maschine.applescript
|
set LPcolor_inactive to 11 # dim orange
|
launchpad-for-maschine.applescript
|
set LPcolor_active to 3 # white
|
launchpad-for-maschine.applescript
|
if grayscale then set LPcolor_inactive to gray_inactive
|
launchpad-for-maschine.applescript
|
if session_pad is true then
|
launchpad-for-maschine.applescript
|
set msg to {176, item 5 of ctrlButtons, 3}
|
launchpad-for-maschine.applescript
|
set msg to {176, item 5 of ctrlButtons, 1}
|
launchpad-for-maschine.applescript
|
if drums_pad is true then
|
launchpad-for-maschine.applescript
|
set msg to msg & {176, item 6 of ctrlButtons, 5} # lights up red
|
launchpad-for-maschine.applescript
|
set msg to msg & {176, item 6 of ctrlButtons, LPcolor_inactive}
|
launchpad-for-maschine.applescript
|
if keys_pad is true then
|
launchpad-for-maschine.applescript
|
set msg to msg & {178, item 7 of ctrlButtons, LPcolor_active}
|
launchpad-for-maschine.applescript
|
set msg to msg & {176, item 7 of ctrlButtons, LPcolor_inactive}
|
launchpad-for-maschine.applescript
|
if user_pad is true then
|
launchpad-for-maschine.applescript
|
set msg to msg & {176, item 8 of ctrlButtons, LPcolor_active}
|
launchpad-for-maschine.applescript
|
set msg to msg & {176, item 8 of ctrlButtons, LPcolor_inactive}
|
launchpad-for-maschine.applescript
|
end showControlButtons
|
launchpad-for-maschine.applescript
|
on fromHex(str)
|
launchpad-for-maschine.applescript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.