Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to select any notes on C-1 #201

Closed
Softy107 opened this issue Jul 26, 2022 · 1 comment
Closed

Impossible to select any notes on C-1 #201

Softy107 opened this issue Jul 26, 2022 · 1 comment

Comments

@Softy107
Copy link

Describe the bug
It is impossible to select any notes on C-1 for some reason

To Reproduce
Steps to reproduce the behavior:

  1. Go to signal.vercel.app
  2. Add some notes into C-1
  3. Lower the Velocity panel
  4. Try to select the notes, then See error

Expected behavior
The notes should select normally and would be able to copy, paste, etc.

Screenshots
Screenshot (224)
(mouse not visible, but it is under the selected area I promise)

Desktop (please complete the following information):

  • OS: Windows 10 education
  • Browser : MS Edge
  • Version : Version 103.0.1264.71 (Official build) (64-bit) (browser ver)

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
it is also impossible to put selected notes into C-1 without using arrow keys -
Screenshot (225)
(same here, still not visible but it is under the selected area)

@robertnhart
Copy link
Collaborator

It looks like Signal's code uses a half-open interval to describe the range of selected notes:

  • the from note number is the note number at the top of the selection.
  • the to note number is the note number just underneath the bottom of the selection.

In order for the selection to include the minimum pitch 0 (C-1), the to note number needs to be -1. However, various parts of the code are clamping values to a minimum of zero.

In particular, in the file src/main/actions/selection.ts, in the function resizeSelection:

  • the regularizedSelection function call at the beginning does some clamping
  • the clampSelection function call at the end also does some clamping

Here is the potential fix I came up with:

  • In the defintion of regularizedSelection, remove the parts that clamp note numbers to a minumum of zero:
-    Math.max(0, Math.max(fromNoteNumber, toNoteNumber)),
+                Math.max(fromNoteNumber, toNoteNumber) ,
-    Math.max(0, Math.min(fromNoteNumber, toNoteNumber)),
+                Math.min(fromNoteNumber, toNoteNumber) ,
  • At the end of resizeSelection, increment the to note number before clamping it, then decrement it after clamping it:
-    const selection
+    let   selection
-    pianoRollStore.selection = clampSelection(selection)

+    ++selection.to.noteNumber;
+    selection = clampSelection(selection);
+    --selection.to.noteNumber;
+    pianoRollStore.selection = selection;

I will submit a pull request.

@ryohey ryohey closed this as completed in 1cf659a May 23, 2024
ryohey added a commit that referenced this issue May 23, 2024
Fix #201 - Allow selection rectangle to reach minimum note c-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants