Adjusting knob values with mouse wheel (Mac OS only)

This forum is for discussing Propellerhead's music software. Questions, answers, ideas, and opinions... all apply.
s0ber
Posts: 6
Joined: 01 Sep 2019

Post 01 Sep 2019

Hello, amazing reasonists!

I've just setup ability to control knobs and mixer faders with mousewheel. It turned out to work really well. Unfortunately, it only works for Mac OS. But with macbook touchpad it works veeery smoooth.

Here is the guide.
1) You need to install http://www.hammerspoon.org according to instructions on their site. This is a great utility for automating your mac.
2) Add this script to hammerspoon config (which is located at ~/.hammerspoon/init.lua). The script is really simple and there is nothing scary here, you can understand it without any programming experience:

Code: Select all

reasonState = {isPressed = false, initialPos = nil, newPos = nil}

function releaseMouse(pos) 
	if reasonState.isPressed then
		reasonState.isPressed = false
		reasonState.initialPos = nil
		reasonState.newPos = nil
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, pos):post()
	end
end

-- interfere into scroll wheel events and emulate mouse drag
-- fn+scroll - for usual rack knobs, mouse cursor will stay fixed
-- alt+scroll - for mixer faders, mouse cursor will follow the fader
reasonScrollWheelTap = hs.eventtap.new({hs.eventtap.event.types.scrollWheel}, function (event)
	if (event:getFlags()['fn'] or event:getFlags()['alt']) and hs.application.frontmostApplication():name() == 'Reason' then
		currentPos = hs.mouse.getAbsolutePosition()
		dy = event:getProperty(hs.eventtap.event.properties.scrollWheelEventDeltaAxis1)
		reasonState.newPos = {x = currentPos.x, y = currentPos.y + dy}

		if not event:getFlags()['fn'] then
			if not reasonState.isPressed then
				reasonState.initialPos = currentPos
				reasonState.isPressed = true
				hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, currentPos):post()
			end
			hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, reasonState.newPos):post()			
		else
			mods = event:getFlags()['shift'] and {shift = true} or {}

			hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, currentPos, mods):post()
			hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, reasonState.newPos, mods):post()
			hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, reasonState.newPos, mods):post()
			hs.eventtap.event._newMouseEvent(hs.eventtap.event.types.mouseMoved, currentPos, 'left'):post()
		end

		return {false}
	end
end)
reasonScrollWheelTap:start()

-- for mixer fader - release "mouse" when alt is depressed
reasonAltKeyupTap = hs.eventtap.new({hs.eventtap.event.types.flagsChanged}, function (event)
	if reasonState.isPressed and not event:getFlags()['alt'] then
		releaseMouse(reasonState.newPos)
	end
end)
reasonAltKeyupTap:start()

-- for mixer fader - release "mouse" when going out of the Y axis
reasonMouseMovedTap = hs.eventtap.new({hs.eventtap.event.types.mouseMoved}, function (event)
	if reasonState.isPressed then
		currentPos = hs.mouse.getAbsolutePosition()
		if currentPos.x ~= reasonState.initialPos.x then
			releaseMouse(currentPos)
		end
	end
end)
reasonMouseMovedTap:start()
3) Reload the config in hammerspoon menu: File -> Reload config.

That should be it. Now in Reason you just need to hold fn for scrolling over knobs, and hold alt for scrolling over mixer faders. I hope you'll find it helpful! :roll:

eiresurfer
Posts: 53
Joined: 22 May 2015

Post 03 Sep 2019

Oh wow, this looks great. I think I'll give it a go!

s0ber
Posts: 6
Joined: 01 Sep 2019

Post 03 Sep 2019

eiresurfer wrote:
03 Sep 2019
Oh wow, this looks great. I think I'll give it a go!
YaY! Please let me know if it'll work for you.

olive6741
Posts: 172
Joined: 11 May 2016

Post 03 Sep 2019

Great! it works perfectly! Thanks!

  • Information
  • Who is online

    Users browsing this forum: Ahrefs [Bot], bxbrkrz, Revise, zoidkirb and 10 guests