-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Custom note labels in Pianoroll editor #5357
base: master
Are you sure you want to change the base?
Conversation
🤖 Hey, I'm @LmmsBot from github.com/lmms/bot and I made downloads for this pull request, click me to make them magically appear! 🎩
Linux
Windows
🤖{"platform_name_to_artifacts": {"Linux": [{"artifact": {"title": {"title": "(AppImage)", "platform_name": "Linux"}, "link": {"link": "https://5584-15778896-gh.circle-artifacts.com/0/lmms-1.2.1.584-linux-x86_64.AppImage"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/5584?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}], "Windows": [{"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://5582-15778896-gh.circle-artifacts.com/0/lmms-1.2.1.584-mingw-win32.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/5582?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://5583-15778896-gh.circle-artifacts.com/0/lmms-1.2.1.584-mingw-win64.exe"}}, "build_link": "https://circleci.com/gh/LMMS/lmms/5583?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link"}, {"artifact": {"title": {"title": "32-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/hea053kiwjaaiwo7/artifacts/build/lmms-1.2.1-msvc2017-win32.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/29814979"}, {"artifact": {"title": {"title": "64-bit", "platform_name": "Windows"}, "link": {"link": "https://ci.appveyor.com/api/buildjobs/8j731w9enf9kro0a/artifacts/build/lmms-1.2.1-msvc2017-win64.exe"}}, "build_link": "https://ci.appveyor.com/project/Lukas-W/lmms/builds/29814979"}]}, "commit_sha": "d651fda1e55c5ddefd3ced87518a7635b17b87a4"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea!
But I don't like that it's new settings options rather than a specific file you read or not, and you are limited to 3 files instead of the ability to add any number to a single file.
I think this would be much more extensible if it was an XML file that can be read on load (if present in working dir or not). If like this, you can create a tree structure in XML that allows an unlimited number of labels. Granted the file is a little more difficult to write out, but it would be able to be parsed by Qt's loadSettings and not have to be parsed manually. So something like this:
<noteLabels>
<map name="Drums">
<label note="65" name="HI-HAT PEDAL" />
<label note="63" name="(Hi-Hat closed)" />
...
</map>
<map name="Something something">
<label note="53" name="whatever" />
...
</map>
...
</noteLabels>
Additionally, there are numerous lines here which need to follow the Coding Conventions. Namely if and while blocks, a few spacing issues, and true/false usage over 1/0 are the main issues that I see.
src/gui/editors/PianoRoll.cpp
Outdated
QTextStream stream(&labelsFile); | ||
QString line = stream.readLine(); | ||
QRegExp num("\\d*"); | ||
while (!line.isNull()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens every paintEvent
, which will block on file I/O which can cause freezing of the UI in worse cases. These labels need to be read on LMMS load rather than here and painted from memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've noticed that. I know that is not good way, I'm thinking how to change that.
Coding conventions, removed empty If
Thanks for feedback! |
I think better this will work as another option in pianoroll bar. As this will be more user-friendly UX. |
The reason I say XML is twofold. 1) You leverage Qt's XML parser, and don't need to do all this extra manual parsing. 2) Everything in LMMS is saved as an XML file, this being a plaintext file breaks from that and doesn't fit the mold.
Read on startup from the file and save in memory. |
bool fileCorrect = true; | ||
QFile labelsFile(new_file); | ||
labelsFile.open(QIODevice::ReadOnly); | ||
if (!labelsFile.isOpen()) return ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing {}
@@ -128,7 +128,9 @@ static QString getNoteString( int key ) | |||
return s_noteStrings[key % 12] + QString::number( static_cast<int>( key / KeysPerOctave ) ); | |||
} | |||
|
|||
|
|||
bool labelsFile1Correct = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
false
instead of 0
.
@@ -366,6 +369,32 @@ PianoRoll::PianoRoll() : | |||
connect( &m_quantizeModel, SIGNAL( dataChanged() ), | |||
this, SLOT( quantizeChanged() ) ); | |||
|
|||
// Set up labels model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting for this entire section to line 397.
@@ -3114,6 +3267,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) | |||
} | |||
p.drawLine( WHITE_KEY_WIDTH, y, width(), y ); | |||
++key; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra line added on accident?
{ | ||
p.drawPixmap( mousePosition + QPoint( 8, 8 ), *cursor ); | ||
} | ||
if (drawCustomLabels) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is the last drawn thing in paintEvent
, this will draw over notes at the start of the pattern. Should it?
@@ -4421,6 +4600,50 @@ Note * PianoRoll::noteUnderMouse() | |||
return NULL; | |||
} | |||
|
|||
bool PianoRoll::labelsPathCorrect( QString labelsPath ){ | |||
bool fileCorrect = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true
instead of 1
.
@@ -4421,6 +4600,50 @@ Note * PianoRoll::noteUnderMouse() | |||
return NULL; | |||
} | |||
|
|||
bool PianoRoll::labelsPathCorrect( QString labelsPath ){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting for this function.
@@ -4515,6 +4738,15 @@ PianoRollWindow::PianoRollWindow() : | |||
m_quantizeComboBox->setFixedSize( 64, 22 ); | |||
m_quantizeComboBox->setToolTip( tr( "Quantization") ); | |||
|
|||
// setup labels-stuff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix whitespace in this area.
We can support both Reaper-compatible plaintext file and standard XML/JSON files. BTW, we need to think about #1857 first.
I can see the parsing logic is repeated a few times in many places. We can probably remove the file lists from the settings and let users load them manually(optionally with histories). |
I coded function for custom note labels for Pianoroll editor. Three labels files paths are stored in lmms config file. They can be set in settings -> paths. After setting paths lmms need restart. Then in Pianoroll editor you can select which file you want to use. Function reads labels from .txt files in pattern like attached one. File can't have any empty lines between labels/comments. Empty lines can be only after labels list. Between note number and label must be ONLY ONE space.
In attached screenshots you can see how modifications looks like in Pianoroll and settings.
TODO:
Icon for labels file combo box in Pianoroll editor (currently using Quantize icon),
Only three files support, maybe add some kind of list,
May need some code clean-up and check,
labels.txt