This was a thought I had today in relation to how slow it is to move highlighted objects with cursor keys. The thought I had was that like logarythmic volume adjustment when turning a knob you could apply the same concept to how long a cursor key is pressed so that at some rate the more you hold the key trigger or the more key triggers in series the faster the rate of movement would be so that when say moving something in playlist or piano roll or channel rack with cursor keys the rate of movement of the object would have exponential or incremental speed of movement until the key is set go.
So a movement speed counter would accumulate at some reasonable rate between a minimum and maximum value of movement obviously something at or under the visual refresh rate would probably be reasonable.
Obviously this code is probably pretty off in how it would be implemented in fl studio but hopefully it explains the idea a little. Hopefully the idea is atleast explained with it. It would be finetuned to a haptic rate humans would be comfortable controlling.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Forms, StdCtrls, ExtCtrls, Math;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
procedure ProcessKey(Key: Integer; Pressed: Boolean);
function GetSpeed(HoldTime: Integer): Integer;
end;
var
Form1: TForm1;
KeyStates: array[VK_LEFT..VK_DOWN] of Boolean;
HoldTimes: array[VK_LEFT..VK_DOWN] of Integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Interval := 10; // Runs every 10ms
Timer1.Enabled := True;
FillChar(KeyStates, SizeOf(KeyStates), False);
FillChar(HoldTimes, SizeOf(HoldTimes), 0);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Timer1.Enabled := False;
end;
// Logarithmic Speed Calculation
function TForm1.GetSpeed(HoldTime: Integer): Integer;
const
BaseSpeed = 1; // Minimum movement
MaxSpeed = 10; // Maximum movement
begin
if HoldTime = 0 then
Result := BaseSpeed
else
Result := Round(BaseSpeed + (Log10(HoldTime + 1) * (MaxSpeed - BaseSpeed) / Log10(100)));
if Result > MaxSpeed then
Result := MaxSpeed;
end;
// Processes Key Input
procedure TForm1.ProcessKey(Key: Integer; Pressed: Boolean);
var
Speed: Integer;
begin
if Pressed then
begin
Inc(HoldTimes[Key]);
Speed := GetSpeed(HoldTimes[Key]);
end
else
begin
HoldTimes[Key] := 0;
Speed := 0;
end;
// Simulate Arrow Key Presses in FL Studio
if Speed > 0 then
begin
keybd_event(Byte(Key), 0, 0, 0);
Sleep(Speed);
keybd_event(Byte(Key), 0, KEYEVENTF_KEYUP, 0);
end;
end;
// Timer Event: Check Keys and Apply Movement
procedure TForm1.Timer1Timer(Sender: TObject);
var
Key: Integer;
begin
for Key := VK_LEFT to VK_DOWN do
begin
if GetAsyncKeyState(Key) <> 0 then
begin
if not KeyStates[Key] then
begin
KeyStates[Key] := True;
HoldTimes[Key] := 0;
end;
ProcessKey(Key, True);
end
else
begin
if KeyStates[Key] then
begin
KeyStates[Key] := False;
ProcessKey(Key, False);
end;
end;
end;
end;
end.
Logarythmic cursor key actions
[You can only see part of this thread as you are not logged in to the forums]