LMMS / LMMS/lmms

Refactor PianoRoll::getSelectedNotes()

Open
#7,818 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.4k
Forks
1.3k
Avg merge
2d 13h
Merged PRs (30d)
7

Description

Currently, PianoRoll::getSelectedNotes loops over all notes to find the ones where isSelected is true, adds them to a NoteVector, and returns that. This is done every time the function is called, which is not efficient. @szeli1 brought this to my attention in #7759.

This is mostly a TODO issue to remind me to do this, but if anyone else wants to try to tackle it, feel free!

Implementation Ideas

  • The selected notes should probably be cached in some kind of vector.
  • Since the piano roll is afaik the only class which actually interacts with the isSelected state of the notes, perhaps for all the occurances of a note being selected/deslected, we could add a line of code which adds/removes that note from the vector. We would have to be very careful to address all the occurances, and also repopulate the vector whenever a new clip is opened in the piano roll (Since selections of notes persist within each MidiClip; selecting some notes in one clip, opening another clip, and opening the old clip will retain the selection).
  • Or, we could implement that logic within Note::setSelected. However, this would probably require either giving Note access to the piano roll or having some kind of static vector, which may not be desirable.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with PianoRoll::getSelectedNotes and trace every place where notes are selected or deselected, including switching between MidiClips. Review Note::setSelected and the existing PianoRoll selection flow before choosing an approach. Done means selected-note results stay correct across selection changes and clip changes without scanning all notes on every call.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.