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

[WIP] Paint in different color normal beats, bar beats, and phrase beats. #1918

Conversation

JaviVilarroig
Copy link
Contributor

captura de pantalla de 2018-11-25 12-18-16
Also writes a tag with the beat number with the phrase beats.

The colors are taken from the skin.

Added placeholder values in all skins. Please improve them!!!

Also writes a tag with the beat number with the phrase beats.

The colors are taken from the skin.

Added placeholder values in all skins. Please improve them!!!
@JaviVilarroig
Copy link
Contributor Author

This is still a work in progress

@JaviVilarroig JaviVilarroig changed the title Paint in different color normal beats, bar beats, and phrase beats. [WIP] Paint in different color normal beats, bar beats, and phrase beats. Nov 25, 2018
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much. I have added some comments. Sorry for being too picky.
Did you concider to alter the minor down beat in a 7/8 measure?

src/waveform/renderers/waveformrenderbeat.cpp Outdated Show resolved Hide resolved
src/waveform/renderers/waveformrenderbeat.cpp Outdated Show resolved Hide resolved
src/waveform/renderers/waveformrenderbeat.cpp Outdated Show resolved Hide resolved
src/waveform/renderers/waveformrenderbeat.cpp Outdated Show resolved Hide resolved
src/waveform/renderers/waveformrenderbeat.cpp Outdated Show resolved Hide resolved
src/waveform/renderers/waveformrenderbeat.cpp Outdated Show resolved Hide resolved
src/waveform/renderers/waveformrenderbeat.cpp Show resolved Hide resolved
@ronso0
Copy link
Member

ronso0 commented Nov 26, 2018

while I see the benefit for others, I think (for me) this adds yet another distraction to the Mixxx interface.
Could you please make bar/phrase makers otional?

@daschuer what was that downbeat marker PR again? @JaviVilarroig I bet you can pick some snippets from that one..

(didn't test yet, but I'll help with the colors)

@daschuer
Copy link
Member

This is the other PR targeting the same problem:
#1529

@JaviVilarroig
Copy link
Contributor Author

while I see the benefit for others, I think (for me) this adds yet another distraction to the Mixxx interface.
Could you please make bar/phrase makers otional?
I understand your point. Somthing like adding an option in the preferences dialog will be OK?

I will have to investigate how to do it. Any pointer will be welcome :)

@daschuer what was that downbeat marker PR again? @JaviVilarroig I bet you can pick some snippets from that one..
I will take a look.

(didn't test yet, but I'll help with the colors)

@ronso0
Copy link
Member

ronso0 commented Nov 29, 2018

I understand your point. Somthing like adding an option in the preferences dialog will be OK?

yeah, an Preferences option would be nice.

I will have to investigate how to do it. Any pointer will be welcome :)

Maybe look at /src/preferences/dialog/dlgprefwaveform.cpp for example how waveform type is changed and how the value is passed to the waveform widget. Or the elapsed/remaining switch of the PlayPos widget, that's also changeable in the prefs.

Copy link
Contributor

@WaylonR WaylonR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the whitespace you've added.
Seems to be causing a merge conflict, or at least, its making life difficult for me, manually merging.

@JaviVilarroig
Copy link
Contributor Author

Sorry @WaylonR didn't wanted to me it difficult.
I'm new to GitHub and I don't know how to identify the conflicts.
If you can tell me which are the files/lines involved, or how to identify the conflicts by myself, I will be more than happy to fix the issue.

@xeruf
Copy link
Contributor

xeruf commented Dec 23, 2018

@JaviVilarroig you need to

git checkout master
git pull upstream master
git checkout lp1128005_Bar_and_phrase_marking
git merge master

Then you should see the merge conflicts, solve them and enter git add . && git merge --continue after resolving them. Then you can push and everything should be done ;)

@Be-ing
Copy link
Contributor

Be-ing commented Dec 31, 2018

Copy link
Contributor

@Be-ing Be-ing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for getting started on this. It is a good step in the right direction.

The preference option currently does not work. The bar and phrase markers are always drawn regardless of the option.

I think before we merge this we should implement some way for users to set the first downbeat. I suspect any automatic method of determining this will be wrong in many cases, even with 4/4 beat grids. Let's discuss that further on Zulip and keep the discussion here focused on the code.

src/waveform/renderers/waveformrenderbeat.cpp Outdated Show resolved Hide resolved

// Selects the right pen, if we are in phrase also paints the phrase tag
bool showBarAndPhrase = true;
if(beatNum % (c_beatsPerBar * c_barsPerPhrase) == 0 && beatNum > 0 && showBarAndPhrase) {
Copy link
Contributor

@Be-ing Be-ing Dec 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic for determining a beat's position in the bar and the phrase should be moved to the Beats class. For this initial implementation that can rely on the constants that are currently private members of WaveformRenderBeat (those constants should be moved to Beats too). Then it will be easier to implement support for configurable time signatures and the waveform rendering logic shouldn't need any updating. The code here should look something like if (trackBeats->barNumberInPhrase(beatPosition) == 0 && trackBeats->beatNumberInBar(beatPosition) == 0) {

QString label(QString::number(beatNum/16+1));
QRect wordRect = metrics.tightBoundingRect(label);
const int marginX = 1;
const int marginY = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should be multiplied by the scale factor.

painter->drawText(labelRect, Qt::AlignCenter, label);

painter->setPen(phrasePen);
} else if(beatNum % c_beatsPerBar == 0 && beatNum > 0 && showBarAndPhrase) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, this check should be replaced by a call to Beats, something like:
if (trackBeats->beatNumberInBar(beatPosition) == 0) {

const int marginX = 1;
const int marginY = 1;
wordRect.moveTop(marginX + 1);
wordRect.moveLeft(marginY + 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use scaleFactor() instead of 1

//even wordrect to have an even Image >> draw the line in the middle !

int labelRectWidth = wordRect.width() + 2 * marginX + 4;
int labelRectHeight = wordRect.height() + 2 * marginY + 4 ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int labelRectHeight = wordRect.height() + 2 * marginY + 4 ;
int labelRectHeight = wordRect.height() + 2 * marginY + 4 * scaleFactor();

rectColor.setAlpha(200);
painter->setPen(m_phraseColor);
painter->setBrush(QBrush(rectColor));
painter->drawRoundedRect(labelRect, 2.0, 2.0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 * scaleFactor()

src/waveform/waveformwidgetfactory.h Outdated Show resolved Hide resolved
src/waveform/waveformwidgetfactory.cpp Outdated Show resolved Hide resolved
src/waveform/waveformwidgetfactory.h Outdated Show resolved Hide resolved
@Be-ing
Copy link
Contributor

Be-ing commented Dec 31, 2018

The bottom edge of the phrase markers look cut off:
screenshot from 2018-12-30 20-14-25

@xeruf
Copy link
Contributor

xeruf commented Dec 31, 2018

The first downbeat is obviously the Cue, what is there to discuss? Why would you set the Cue differently?

@Be-ing
Copy link
Contributor

Be-ing commented Dec 31, 2018

That is not a safe assumption. There are many different ways to use the cue point with the variety of modes that Mixxx supports. With some of these modes, the cue point moves often and it would be very easy to throw off the grid if that was tied to the cue point.

@xeruf
Copy link
Contributor

xeruf commented Dec 31, 2018

Okay. But then the track should also jump to the first downbeat at load instead of the cue. Isn't there an unused "Beat" Cue? What about using that?

@xeruf
Copy link
Contributor

xeruf commented Dec 31, 2018

Btw, the green markings pop out much more than the phrase markings. It should be the other way around.

@Be-ing
Copy link
Contributor

Be-ing commented Dec 31, 2018

IMO it would be inappropriate to use a cue for marking the beatgrid. That information belongs with the Beats class.

@xeruf
Copy link
Contributor

xeruf commented Dec 31, 2018

So I guess it could just be part of the Beatgrid, and you just move the first downbeat with the Beatgrid?

@xeruf
Copy link
Contributor

xeruf commented Dec 31, 2018

Also, we need something for songs that have extra one or two measures in the middle, sometimes that is like that before the drop and it would offset all phrase markings.

@Be-ing
Copy link
Contributor

Be-ing commented Dec 31, 2018

Yes, but this is going beyond the scope of this PR to draw the marks on the waveforms. If you want to discuss that further, let's continue on Zulip.

@JaviVilarroig
Copy link
Contributor Author

@JaviVilarroig you need to

git checkout master
git pull upstream master
git checkout lp1128005_Bar_and_phrase_marking
git merge master

Then you should see the merge conflicts, solve them and enter git add . && git merge --continue after resolving them. Then you can push and everything should be done ;)

I think I manage to solve the conflicts that were affecting you. Not 100% sure dure to my lack of expertise on git. Can you please confirm?

@Be-ing
Copy link
Contributor

Be-ing commented Jan 9, 2019

It looks like you accidentally committed a lot of new files with the last commit.

@JaviVilarroig
Copy link
Contributor Author

It looks like you accidentally committed a lot of new files with the last commit.

Humm. May be I added in my branch all the changes from master? I just wanted to remove the conflict :(

Again my lack of undestanding of git. Sorry for the mess. Is there any way I can fix that? Something like undo the commit and then try again to fix the files?

@Be-ing
Copy link
Contributor

Be-ing commented Jan 9, 2019

First, list the files that should not be committed in .git/info/exclude. Then run git reset --hard HEAD~ and redo the merge. You'll need to do git push --force when you are done to overwrite the old merge commit.

@JaviVilarroig JaviVilarroig force-pushed the lp1128005_Bar_and_phrase_marking branch from 1a33720 to 92bdfdd Compare January 11, 2019 10:21
JaviVilarroig and others added 6 commits January 11, 2019 11:28
Co-Authored-By: JaviVilarroig <43292281+JaviVilarroig@users.noreply.github.com>
Co-Authored-By: JaviVilarroig <43292281+JaviVilarroig@users.noreply.github.com>
…arroig/mixxx into lp1128005_Bar_and_phrase_marking
@JaviVilarroig
Copy link
Contributor Author

Thank you for getting started on this. It is a good step in the right direction.

The preference option currently does not work. The bar and phrase markers are always drawn regardless of the option.

Yep. I know.

Despite the fact of being able to add a new configuration variable, add it to the dialog and having it properly serialized, I have been unable to read the value from the WaveformRenderBeat class. I have set up a constant to allow testing while I try to find a solution to that issue.

I tried with a Control/ControlProxy pair but failed. If you can point me to a practical example of the use of that classes to read configuration parameters I will investigate from there.

@JaviVilarroig
Copy link
Contributor Author

I'm going to put this PR in stand by wile I work in a separate one for improving the Beats class to manage additional information for bars and phrases, variable BPM and beat emphasis, as discussed in Zulip.
My question is, is better to reject that one and to start from scratch in a new PR when I'm ready to work again on that topic or we just leave it as it is by now?

@xeruf
Copy link
Contributor

xeruf commented Mar 15, 2019

Can we please integrate this as is soon and care about the details later? I do a lot of stuff that just revolves around phrases, and having this would already save me a huge amount of work.
Maybe just implement this together with a config option that is disabled by default and indicates that this feature is WIP. But I'd really like to use this soon!

@JaviVilarroig
Copy link
Contributor Author

I have been playing some sessions using this PR and the result is not really satisfactory. Without more control on what is considered a downbeat, initial one and short phrases, it's not really helpful.
The issue is that is very difficult to produce something better that I have made already without the improvements in Beats.
You can build that branch and test it yourself.

1 similar comment
@JaviVilarroig
Copy link
Contributor Author

I have been playing some sessions using this PR and the result is not really satisfactory. Without more control on what is considered a downbeat, initial one and short phrases, it's not really helpful.
The issue is that is very difficult to produce something better that I have made already without the improvements in Beats.
You can build that branch and test it yourself.

@JaviVilarroig JaviVilarroig deleted the lp1128005_Bar_and_phrase_marking branch April 22, 2019 15:41
@Be-ing
Copy link
Contributor

Be-ing commented Apr 22, 2019

@JaviVilarroig can you undelete your branch? It will still be a useful starting point for whoever works on adding bar and phrase information to the Beats class.

@sharst
Copy link
Contributor

sharst commented Jun 8, 2019

I agree that this is not in a state to be merged, but since there was some interest in the feature so far, I recreated the original branch and fixed the option to enable / disable from menu: https://github.com/sharst/mixxx/tree/beat_and_phrase_marks

@daschuer
Copy link
Member

daschuer commented Jun 8, 2019

Cool Thank you. Can you issue a PR for this and describe the current state of work, to make it visible for all.

@sharst
Copy link
Contributor

sharst commented Jun 11, 2019 via email

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

Successfully merging this pull request may close these issues.

None yet

7 participants