Skip to content

Save Scale/Key Highlighting, and Many More Editor Options. - #7854

Merged
regulus79 merged 8 commits into
LMMS:masterfrom
regulus79:save-editor-options
Apr 30, 2026
Merged

regulus79 merged 8 commits into
LMMS:masterfrom
regulus79:save-editor-options

Conversation

@regulus79

@regulus79 regulus79 commented Apr 19, 2025 •

Copy link
Copy Markdown
Member

This PR makes it so that the scale/key/chord in the Piano Roll is saved with the project.

Also, while I was at it, I made it so that the zoom, vertical zoom, snap settings, quantization, and note lengths are saved too.

Aaand I also decided to save the zoom and snap size in the Song Editor because why not :D

However, the zoom/snap/etc are saved in the lmmsrc file, since it doesn't really make sense to save them per-project.

Note

It seems odd that the song editor is saved as a <trackcontainer> in the xml, since it's the Editor which does the saving, not the editor window. This means that I cannot save the state of the proportional zoom option, since that is not accessible from the editor object, only the window. However, the piano roll does it via the editor window. It feels like we should be doing it that way via the gui, since saving isn't something which should be in the core(?) (or should it? idk)

@AW1534

AW1534 commented Apr 20, 2025

Copy link
Copy Markdown
Member

Tested, works well.

@regulus79

Copy link
Copy Markdown
Member Author

Also, currently I am saving the values as attributes of the editor's xml element. However, this means that any automation connections will not be saved. Are we okay with this? Or should I try to save each model using their own saveSettings/loadSettings functions? If so, I may need to edit them to add a way to specify a default value, since currently that's not possible (and we probably want that so that old projects get loaded with reasonable values.

@Jernemies

Jernemies commented Apr 29, 2025 •

Copy link
Copy Markdown

Scale highlights are a good idea. For all the other stuff like zoom, scroll mode and stuff it seems like a more sensible solution would be saving currently used settings in something like lmmsrc.xml instead. Saving them per project doesn't make much sense because old projects will have to be adjusted one by one. These defaults are entirely user preference anyways, and in case of something like a collaboration, it will present an additional step user has to do every time the project is passed back and forth

@regulus79

Copy link
Copy Markdown
Member Author

Scale highlights are a good idea. For all the other stuff like zoom, scroll mode and stuff it seems like a more sensible solution would be saving currently used settings in something like lmmsrc.xml instead.

After thinking about this, you're right. It doesn't make sense to save those kind of ui things per-project. I've changed it in the latest commit to save it in the lmmsrc file, so now whatever zoom/snap/quantization/notelength you have last will be restored when you open lmms again.

sakertooth
sakertooth previously approved these changes May 3, 2025
@sakertooth
sakertooth dismissed their stale review May 3, 2025 01:27

Wait, maybe these kind of settings should be project specific.

@regulus79

Copy link
Copy Markdown
Member Author

Wait, maybe these kind of settings should be project specific.

Currently just the scale, key, and chord are project specific. Are you saying you also want the zoom/snap/note length/quantization settings to be saved in the project?

@Jernemies

Copy link
Copy Markdown

Wait, maybe these kind of settings should be project specific.

Imo user preferences should not be project specific for reasons I outlined above. In an ideal world we would just have defaults in settings, but saving these in config does achieve this in the meantime

@bratpeki bratpeki self-assigned this Jun 18, 2025
@regulus79 regulus79 added the gui label Jun 29, 2025
@bratpeki

Copy link
Copy Markdown
Member

This PR makes it so that the scale/key/chord in the Piano Roll is saved with the project.

Tested, works!

The zoom, vertical zoom, snap settings, quantization, and note lengths are saved too.

So, that's all the items left of the scale/key/chord and that one item to the right, correct? Tested. These properties seem to be saved globally, which is odd to me. Like, I run the PR, and the same properties are loaded.

I also decided to save the zoom and snap size in the Song Editor

Tested. This also seems to be saved globally.


However, the zoom/snap/etc are saved in the lmmsrc file, since it doesn't really make sense to save them per-project.

There we go, okay!

I'd think you want to set a different snap level for different projects; "1/4 bar" for electronic music and "1 bar" for slower, orchestral pieces, for example.

Or maybe someone wants 1/192 for music in odd time signatures and 1/8 for simple electronic music, etc.

So I'd vote for making everything per-project, and if you want it as default for your projects, just add it to your default template!

@regulus79

Copy link
Copy Markdown
Member Author

I'd think you want to set a different snap level for different projects; "1/4 bar" for electronic music and "1 bar" for slower, orchestral pieces, for example.

Or maybe someone wants 1/192 for music in odd time signatures and 1/8 for simple electronic music, etc.

That also sounds reasonable, I could see how it would be useful to keep snap sizes per-project. I know Jernemies is in favor saving most of the things per-user rather than per-project, which is why I have it implemented the way it is currently. I suppose we could also add an option in the settings window for whether to use per-project or per-use snap sizes etc.

Unfortunately, I don't really have time at the moment to make any major code changes 😅, so it would either have to wait a little while for me to find time to do it, or we could merge this now and deal with it in another PR.

@extern-stat

Copy link
Copy Markdown
Contributor

Tested this PR and it works, but I found a couple of issues:

  1. It seems that semitones marked or unmarked by the user (with "Mark/unmark current semitone") get overridden by the scale when loading a project. Changing PianoRollWindow::loadSettings to load marked semitones after the key and scale are loaded should fix this.
image 2. This issue isn't fully caused by this PR, but it does affect it, so I thought I'd note it here. Since selecting a scale with "Mark current scale" doesn't update the key set in the dropdown, reloading a project can give you the wrong key of the scale. For example, if you set the scale and key dropdowns to C Major, then click "Mark current scale" on an A# note, the piano roll will highlight A# Major while the dropdowns still show C Major. Reloading the project then will load C Major, even though the project was saved with A# Major highlighted on the piano roll.
scale_key.mp4

@bratpeki

Copy link
Copy Markdown
Member

Nicely noticed! Maybe outside the scope of the PR as of now and could be followed up. @regulus79 be the judge!

@regulus79

Copy link
Copy Markdown
Member Author

It seems that semitones marked or unmarked by the user (with "Mark/unmark current semitone") get overridden by the scale when loading a project.

I don't believe this PR saves individually marked semitones, if you are referring to the the ones marked via rightclicking -> "Mark/unmark current semitone". That would require saving a list of which ones have been manually marked/unmarked, which is totally doable, but this PR is more about just saving the current index of a few drop-down menus.

Since selecting a scale with "Mark current scale" doesn't update the key set in the dropdown, reloading a project can give you the wrong key of the scale.

That's also an interesting bug. Given that this PR doesn't save which key in particular the user rightclicked and used to mark the scale, perhaps that should be left for a future PR.

@bratpeki

Copy link
Copy Markdown
Member

Yeah, leave the PR as-is, and I'll try following it up with 2 PRs; one for the marked notes and one for the right click setting affecting the Piano Roll option.

@extern-stat

Copy link
Copy Markdown
Contributor

To clarify, the current behaviour on the latest nightly is to save/load marked semitones, but not the scale/key dropdowns (saving/loading marked semitones was added in #5146):

Video of the behaviour on the latest nightly:

nightly.mp4

With this PR, the scale/key dropdowns are saved, but the marked semitones are now overridden by the selected scale. This means you can't modify a built-in scale and save those modifications like you can on master. Moving the call to loadMarkedSemiTones after the key and scale are loaded fixes this issue:

void PianoRollWindow::loadSettings( const QDomElement & de )
{
  m_editor->loadGhostNotes( de.firstChildElement("ghostnotes") );
- m_editor->loadMarkedSemiTones(de.firstChildElement("markedSemiTones"));
  
  MainWindow::restoreWidgetState( this, de );
  
  Engine::getSong()->getTimeline(Song::PlayMode::MidiClip).setStopBehaviour(
		  static_cast<Timeline::StopBehaviour>(de.attribute("stopbehaviour").toInt()));
  
  m_editor->m_keyModel.setValue(de.attribute("key").toInt());
  m_editor->m_chordModel.setValue(de.attribute("chord").toInt());
  m_editor->m_scaleModel.setValue(de.attribute("scale").toInt());
+ m_editor->loadMarkedSemiTones(de.firstChildElement("markedSemiTones"));

@regulus79

Copy link
Copy Markdown
Member Author

To clarify, the current behaviour on the latest nightly is to save/load marked semitones, but not the scale/key dropdowns

OH I completely neglected to test it, you're right, it does save the marked keys.

I've moved the loading order in the most recent commit, as you have suggested.

@regulus79
regulus79 merged commit 38236a8 into LMMS:master Apr 30, 2026
11 checks passed
extern-stat added a commit to extern-stat/lmms that referenced this pull request May 9, 2026
jlintgod1 pushed a commit to jlintgod1/lmms that referenced this pull request May 9, 2026
This PR makes it so that the scale/key/chord in the Piano Roll is saved with the project.
Also, while I was at it, I made it so that the zoom, vertical zoom, snap settings, quantization, and note lengths are saved too.
Aaand I also decided to save the zoom and snap size in the Song Editor because why not :D
However, the zoom/snap/etc are saved in the lmmsrc file, since it doesn't really make sense to save them per-project.
regulus79 added a commit that referenced this pull request Jul 24, 2026
When #7854 was merged, the line for setting the default zoom of the piano roll was copy-pasted to also set the default vertical zoom and quantization. That way if no previous default had been saved, it would default to 100% horizontal zoom, 100% vertical zoom, and 1/16 quantization (which was the default behavior before the PR).

Unfortunately, the variable in expression it used to find the correct index of "100%" or "1/16" in the list was not correctly updated after copy-pasting, which caused the wrong defaults to be set. For example, in the vertical zoom dropdown, "100%" is index 2, but in the horizontal zoom, it's index 3. This caused the default vertical zoom to be 150%, not 100%. Likewise, since the horizontal zoom list doesn't contain "1/16", the quantization defaulted to index 0, which was "Note Lock".

This PR fixes those issues by correcting the variables names in those two lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

⌂