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

Report inserting media, including items with adjusted playrate #1104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/reaper_osara.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3389,7 +3389,10 @@ void cmdSplitItems(Command* command) {
void cmdPaste(Command* command) {
MediaItem* item = GetSelectedMediaItem(0, 0);
int oldTakes = CountTakes(item);
int oldItems = CountMediaItems(0);
set<MediaItem*> oldItems;
for (int i = 0; i < CountMediaItems(0); i++) {
oldItems.insert(GetMediaItem(0, i));
Copy link
Owner

Choose a reason for hiding this comment

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

I worry that this (and the loop below) could cause performance problems in really large projects. This isn't just walking selected media items or items on the current track; it's walking through every item in the entire project. While I understand why that is the case, walking through potentially thousands of items twice every time one pastes seems like it might become problematic. It's not necessarily a show stopper, but I'd like some assurance that this has been verified to be snappy in a massive project before we consider merging.

}
int oldTracks = CountTracks(0);
TrackEnvelope* envelope = GetSelectedEnvelope(0);
int oldPoints = 0;
Expand All @@ -3409,7 +3412,7 @@ void cmdPaste(Command* command) {
// {} will be replaced with the number of tracks; e.g. "2 tracks".
s << format(translate_plural("{} track", "{} tracks", added), added);
}
if ((added = CountMediaItems(0) - oldItems) > 0) {
if ((added = CountMediaItems(0) - oldItems.size()) > 0) {
if (s.tellp() > 0) {
s << " ";
}
Expand All @@ -3422,6 +3425,15 @@ void cmdPaste(Command* command) {
// Translators: Reported after the number of tracks and/or items added.
s << " " << translate("added");
maybeAddRippleMessage(s, command->gaccel.accel.cmd);
int rateAdjusted = 0;
for (int i = 0; i < CountMediaItems(0); i++) {
MediaItem* item = GetMediaItem(0, i);
if (!oldItems.contains(item) &&
*(double*)GetSetMediaItemTakeInfo(GetActiveTake(item), "D_PLAYRATE", nullptr) != 1.0)
rateAdjusted++;
}
if (rateAdjusted > 0)
s << ", " << format(translate_plural("{} item rate adjusted", "{} items rate adjusted", rateAdjusted), rateAdjusted);
Copy link
Owner

Choose a reason for hiding this comment

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

Translators comment please.

outputMessage(s);
return;
}
Expand Down Expand Up @@ -4901,6 +4913,7 @@ Command COMMANDS[] = {
{MAIN_SECTION, {{0, 0, 42398}, nullptr}, nullptr, cmdPaste}, // Item: Paste items/tracks
{MAIN_SECTION, {{0, 0, 40603}, nullptr}, nullptr, cmdPaste}, // Take: Paste as takes in items
{MAIN_SECTION, {{0, 0, 40062}, nullptr}, nullptr, cmdPaste}, // Track: Duplicate tracks
{MAIN_SECTION, {{0, 0, 40018}, nullptr}, nullptr, cmdPaste}, // Insert media files...
{MAIN_SECTION, {{0, 0, 40005}, nullptr}, nullptr, cmdRemoveTracks}, // Track: Remove tracks
{MAIN_SECTION, {{0, 0, 40337}, nullptr}, nullptr, cmdRemoveTracks}, // Track: Cut tracks
{MAIN_SECTION, {{0, 0, 40006}, nullptr}, nullptr, cmdRemoveItems}, // Item: Remove items
Expand Down