Какие же ОХУЕННЫЕ крутилочки, ммммммм

This commit is contained in:
IgorTimofeev 2023-12-30 21:56:40 +03:00
parent 1dcbd2d5d0
commit 470bff63e7
11 changed files with 101 additions and 40 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -22,12 +22,14 @@ if filesystem.exists(configPath) then
-- Older versions support
config.timeMode = config.timeMode or 0
config.jogSpeed = config.jogSpeed or 0
else
config = {
tapes = {
},
timeMode = 0
timeMode = 0,
jogSpeed = 0
}
end
@ -222,18 +224,32 @@ for i = 1, 12 do
jogImages[i] = loadImage("Jog" .. i)
end
local knobImages = {}
for i = 1, 8 do
knobImages[i] = loadImage("Knob" .. i)
end
local jogIndex = 1
local jogIncrementSpeedMin = 0.05
local jogIncrementSpeedMax = 2
local jogIncrementUptime = 0
local function incrementJogIndex(value)
jogIndex = jogIndex + value
if jogIndex > #jogImages then
jogIndex = 1
elseif jogIndex < 1 then
jogIndex = #jogImages
end
end
local function invalidateJogIncrementUptime(uptime)
jogIncrementUptime = uptime + (1 - speedSlider.value) * (jogIncrementSpeedMax - jogIncrementSpeedMin)
end
local function displayDrawProgressBar(x, y, width, progress)
local progressActiveWidth = math.floor(progress * width)
@ -367,6 +383,7 @@ powerButton.eventHandler = function(workspace, powerButton, e1)
-- Stopping playback
if powerButton.pressed then
jogIndex = 1
else
for i = 1, #tapes do
component.invoke(tapes[i].address, "stop")
@ -396,7 +413,6 @@ local function newImageButton(x, y, width, height, name)
return button
end
-------------------------------- Speed slider ------------------------------------------------
local speedSliderImage = loadImage("SpeedSlider")
@ -732,39 +748,28 @@ end
-------------------------------- Jog ------------------------------------------------
-- Center 40, 32
local jog = window:addChild(GUI.object(15, 20, 52, 26))
local jogAngleOld
-- local jogText = ""
-- jog.draw = function()
-- screen.drawText(jog.x, jog.y, 0x00FF00, jogText)
-- end
jog.eventHandler = function(workspace, jog, e1, e2, e3, e4, ...)
if not tape or not powerButton.pressed then
return
end
if e1 == "touch" then
elseif e1 == "drag" then
if e1 == "drag" then
local angleNew = math.atan2(
e3 - jog.x - jog.width / 2,
e4 - jog.y - jog.height / 2
)
if jogAngleOld then
local angleDelta = jogAngleOld - angleNew
local bytesPerRadian = 1 * sampleRate
local seek = bytesPerRadian * angleDelta
local direction = jogAngleOld - angleNew >= 0 and 1 or -1
-- jogText = "delta: " .. math.deg(angleDelta) .. ", seek: " .. seek
incrementJogIndex(direction)
invalidateJogIncrementUptime(computer.uptime())
incrementJogIndex(angleDelta >= 0 and 1 or -1)
invoke("seek", seek)
-- Min seek speed is 100 msec & max is 10 sec
invoke("seek", math.floor((0.1 + (10 * (1 - config.jogSpeed))) * sampleRate * direction))
workspace:draw()
end
@ -776,6 +781,66 @@ jog.eventHandler = function(workspace, jog, e1, e2, e3, e4, ...)
end
end
-------------------------------- Knobs ------------------------------------------------
local function knobDraw(knob)
screen.drawImage(knob.x, knob.y, knobImages[1 + math.floor(knob.value * (#knobImages - 1))])
end
local function knobEventHandler(workspace, knob, e1, e2, e3, e4, e5, ...)
local function increment(upper)
local speed = 0.1
knob.value = math.max(0, math.min(1, knob.value + (upper and speed or -speed)))
if knob.onValueChanged then
knob.onValueChanged(knob)
end
workspace:draw()
end
if e1 == "touch" then
knob.touchX, knob.touchY = e3, e4
elseif e1 == "drag" and knob.touchX then
local dx, dy = e3 - knob.touchX, e4 - knob.touchY
knob.touchX, knob.touchY = e3, e4
increment((math.abs(dx) > math.abs(dy) and dx or dy) >= 0)
elseif e1 == "drop" then
knob.touchX, knob.touchY = nil, nil
elseif e1 == "scroll" then
increment(e5 >= 0)
end
end
local function newKnob(x, y, value)
local knob = GUI.object(x, y, 5, 3)
knob.value = value
knob.draw = knobDraw
knob.eventHandler = knobEventHandler
return knob
end
-- Jog speed
local jogSpeedKnob = window:addChild(newKnob(61, 21, config.jogSpeed))
jogSpeedKnob.onValueChanged = function()
config.jogSpeed = jogSpeedKnob.value
saveConfig()
end
-- Speed adjust
local speedAdjustKnob = window:addChild(newKnob(72, 12, 0))
-- Release start
local releaseStartKnob = window:addChild(newKnob(72, 16, 0))
-------------------------------- Pref/next tape button ------------------------------------------------
local tapePrevButton = window:addChild(newRoundMiniButton(2, 30, 0x2D2D2D, 0xFFB600, 0x0F0F0F, 0xCC9200, "<<"))
@ -1147,11 +1212,7 @@ tempoButton.onTouch = function()
saveConfig()
end
-------------------------------- Events ------------------------------------------------
local jogIncrementSpeedMin = 0.05
local jogIncrementSpeedMax = 1
local jogIncrementUptime = 0
-------------------------------- Cyka ------------------------------------------------
local overrideWindowEventHandler = window.eventHandler
@ -1167,12 +1228,12 @@ window.eventHandler = function(workspace, window, e1, e2, e3, ...)
local shouldDraw = false
local isPlaying = invoke("getState") == "PLAYING"
local position = invoke("getPosition")
local uptime = computer.uptime()
-- Cheching if play button state was changed
if isPlaying == playButton.blinking then
playButton.blinking = not playButton.blinking
invalidateJogIncrementUptime(uptime)
shouldDraw = true
end
@ -1184,19 +1245,14 @@ window.eventHandler = function(workspace, window, e1, e2, e3, ...)
shouldDraw = true
end
if isPlaying then
-- Rotating jog
if uptime > jogIncrementUptime then
-- Jog
if isPlaying and uptime > jogIncrementUptime then
incrementJogIndex(1)
jogIncrementUptime = uptime + (1 - speedSlider.value) * (jogIncrementSpeedMax - jogIncrementSpeedMin)
invalidateJogIncrementUptime(uptime)
shouldDraw = true
end
else
jogIncrementUptime = uptime + (1 - speedSlider.value) * (jogIncrementSpeedMax - jogIncrementSpeedMin)
end
-- Blink
-- Blink state
if uptime > blinkUptime then
blinkUptime = uptime + blinkInterval
blinkState = not blinkState
@ -1209,9 +1265,6 @@ window.eventHandler = function(workspace, window, e1, e2, e3, ...)
end
end
-------------------------------- Cyka ------------------------------------------------
updateTapes()
workspace:draw()

View File

@ -671,7 +671,15 @@
"Applications/Pioneer.app/Images/Jog9.pic",
"Applications/Pioneer.app/Images/Jog10.pic",
"Applications/Pioneer.app/Images/Jog11.pic",
"Applications/Pioneer.app/Images/Jog12.pic"
"Applications/Pioneer.app/Images/Jog12.pic",
"Applications/Pioneer.app/Images/Knob1.pic",
"Applications/Pioneer.app/Images/Knob2.pic",
"Applications/Pioneer.app/Images/Knob3.pic",
"Applications/Pioneer.app/Images/Knob4.pic",
"Applications/Pioneer.app/Images/Knob5.pic",
"Applications/Pioneer.app/Images/Knob6.pic",
"Applications/Pioneer.app/Images/Knob7.pic",
"Applications/Pioneer.app/Images/Knob8.pic"
},
wallpapers = {
"Pictures/AhsokaTano.pic",