-
Notifications
You must be signed in to change notification settings - Fork 46
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
Implement tempo and time signature reporting #1073
Conversation
Introduces a new action to report the current tempo and time signature of the project, specifically the tempo reported at the position of the play cursor. see issue jcsteh#179 for discussion.
Build succeeded! Build osara pr1073-1418,359eb84f completed (commit 359eb84f18 by @day-garwood) |
Woo, it's excellent to see you landing code here dude! Let's have a think about where we want to put it on the key map. FYI doing that requires access to Windows and Mac, we've got @jennykbrennan handling the Mac side at the moment.
That's it. Commit, push, switch back to your prior reaper-kb.ini to restore customizations if needed. |
To be fair, I couldn't actually find anywhere I would put it - of course the logical choice would be something linked to T but everything I tried was taken, so I think I'll leave that to the experienced keymappers for now. |
Adding tempo time sig markers is on Shift+C. The C part isn't strong but it's been there forever and T is already jam packed so I guess that'll be staying where it is. |
Updated "OSARA: Report current tempo and time signature" to "OSARA: Manage current tempo and time signature" to accommodate dual functionality. A single press announces the current tempo and time signature for enhanced accessibility, while a double press triggers the insertion of a tempo/time signature change marker. Also updated the Windows keymap to reflect this change: "Shift+C" now activates this new function, replacing "Tempo envelope: Insert tempo/time signature change marker at edit cursor...".
I've just pushed a new commit so you can see what that would look like. |
Build succeeded! Build osara pr1073-1419,0e53777f completed (commit 0e53777faa by @day-garwood) |
Welcome, @day-garwood. I just wanted to let you know that I've seen this and I'm keen to review it when I can. Just a bit flat out here with very little headspace at the moment, so it might take me a few more days to get to it. Thanks for your work. |
Build succeeded! Build osara pr1073-1421,ad75caad completed (commit ad75caadf5 by @ScottChesworth) |
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.
Thanks for your work on this, and thanks for putting time and effort into contributing to OSARA. Functionally, this is great, but there are a few code style and readability nits. I tend to be a bit picky about code readability and polish. I can make these changes myself if this is overwhelming, but I figured you might like to learn from the code review.
readme.md
Outdated
@@ -222,7 +222,8 @@ SWS/FNG: Time stretch selected items (fine): Control+Alt+= | |||
- Markers: Insert region from time selection: Shift+R | |||
|
|||
#### Time Signature/Tempo Markers | |||
- Move edit cursor to previous tempo or time signature change: Shift+; | |||
- OSARA: Report tempo and time signature at play cursor (press twice to add/edit tempo marker): Shift+C |
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.
@ScottChesworth Hmm. I don't love the "press twice..." in parentheses here. First, it's not really an action name any more at this point; it's providing instructions, which feels inconsistent with everything else. Second, it makes adding/editing seem like an afterthought, rather than a primary function of the action which just happens to be on a second press to save keystrokes.
"OSARA: Report/add/edit tempo and time signature at play cursor" feels like it would be more consistent. However, I do get your point regarding shortcut help. I guess using a semi-colon rather than parentheses would at least solve my second concern somewhat; i.e. "OSARA: Report tempo and time signature at play cursor; press twice to add/edit tempo marker".
src/reaper_osara.cpp
Outdated
@@ -3583,6 +3583,26 @@ void cmdUnselAllTracksItemsPoints(Command* command) { | |||
outputMessage(translate("unselected tracks/items/envelope points")); | |||
} | |||
|
|||
void reportTempoTimeSig() { | |||
ReaProject* proj=EnumProjects(-1, nullptr, 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.
While it's not necessary to get the code to compile, code blocks should be indented for good style. We use a tab character for each level of indentation. Unfortunately, we don't have automatic code formatting working yet, so this has to be done manually.
src/reaper_osara.cpp
Outdated
ReaProject* proj=EnumProjects(-1, nullptr, 0); | ||
if(proj==nullptr) return; | ||
double tempo=0; | ||
int timesig1=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.
Please rename these to be more descriptive; e.g. num and denom. This makes it clearer what each of these actually is: numerator and denominator.
src/reaper_osara.cpp
Outdated
int timesig2=0; | ||
double pos=GetPlayPosition(); | ||
TimeMap_GetTimeSigAtTime(proj, pos, ×ig1, ×ig2, &tempo); | ||
outputMessage(formatDouble(tempo, 1, false)+", "+to_string(timesig1)+"/"+to_string(timesig2)); |
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.
Rather than concatenating strings like this, it would be cleaner and easier to follow to use format(). This way, it's much easier to see what the output will look like. Something like this:
outputMessage(format("{}, {}/{}",
formatDouble(tempo, 1, false), timesig1, timesig2));
You could even name the format template arguments, though that might be overkill for only three arguments for an untranslatable message:
outputMessage(format("{tempo}, {num}/{denom}",
"tempo"_a=formatDouble(tempo, 1, false),
"num"_a=timesig1, "denom"_a=timesig2));
I could go either way.
src/reaper_osara.cpp
Outdated
|
||
void cmdManageTempoTimeSigMarkers(Command* command) { | ||
if(lastCommandRepeatCount==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.
Brace on the same line as the statement please, like this:
if (lastCommandRepeatCount == 0) {
src/reaper_osara.cpp
Outdated
reportTempoTimeSig(); | ||
return; | ||
} | ||
Main_OnCommand(40256, 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.
It'd be great if you could add a comment at the end of this line to explain what action this is:
Main_OnCommand(40256, 0); // Tempo envelope: Insert tempo/time signature change marker at edit cursor...
Thanks for the suggestions. I will make these changes now. |
Ideally, we'd have auto code formatting so we just wouldn't have to worry about it. There's been some work on that in #940, but it causes some problems and so isn't quite ready to merge yet. Sorry about that. Personally, I actually find it easier to follow code with indentation, but it did take some practice. I use NVDA and I have indentation reporting set to tones, which means I can hear the indentation simultaneously with speech. That cuts down on both time and speech clutter. I always have my punctuation set to all, not just when I'm coding. But I'm also ridiculous in that I generally have my speech rate set somewhere between 650 and 960 WPM. :) |
Formatted code to conform to overall project and based on additional suggestions by @jcsteh in PR jcsteh#1073. Removed keymap entries from config and readme due to ongoing discussion about possible reassignment (see issue jcsteh#1076).
Build succeeded! Build osara pr1073-1422,92c4c2e8 completed (commit 92c4c2e8d3 by @day-garwood) |
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.
Thank you.
@ScottChesworth, shall I land this now and we can update the Mac key map later or do you want to get the Mac key map updated here? Normally, I'd just land it and update both key maps later, but it feels different to have one key map updated and one not. |
Build succeeded! Build osara pr1073-1425,bddfef83 completed (commit bddfef8393 by @jcsteh) |
Don't land just yet, will get @jennykbrennan to do Mac mapping tomorrow. |
Ooh nice. Since this isn't my project thought I'd go for clarity over brevity, but I also prefer boolean checks. Yay. |
…ursor; press twice to add/edit tempo markers per Jamie's suggestion, added it to ReadMe.
Build succeeded! Build osara pr1073-1426,b2811d4e completed (commit b2811d4ee9 by @ScottChesworth) |
Build succeeded! Build osara pr1073-1427,f4985419 completed (commit f498541936 by @ScottChesworth) |
Introduces a new action to report the current tempo and time signature of the project, specifically the tempo reported at the position of the play cursor.
see issue #179 for discussion.
Note: This isn’t linked to the keymap yet. Still figuring that part out.
Any feedback would be appreciated since I'm new here. Thanks.