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

Add feedback for MIDI event mute/unmute #1188

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MatejGolian
Copy link
Contributor

I wanted to add feedback when muting/unmuting MIDI events. The reported message should depend on the selection (notes vs CCs vs both). The basic logic seems to work, but I can't figure out how to count muted CCs, because a method completely analogous to how it's done with notes is clearly not possible - at least that's my impression.
@jcsteh could you take a look and perhaps even fix the problem? I think it would take far less time for you to fix it than explain to me what the problem is, but of course I'm not opposed to fixing it myself - I just don't know how.
Many thanks...

@jcsteh
Copy link
Owner

jcsteh commented Jan 11, 2025

Thanks for your work. Just FYI, I'm about to go away on holiday for a couple of weeks, so I likely won't be able to look at this until the end of January at the very earliest.

@MatejGolian
Copy link
Contributor Author

I understand. Have a nice holiday then.

@MatejGolian
Copy link
Contributor Author

BTW I have a vague understanding of why it isn't working, but of course not on a level that would help me come up with a solution.
I have a variable called selectedCCs which is a vector. Now when its size is 1 my goal would be to get the 1st CC and check if its muted. The problem is that if I just use something like
auto cc = selectedCCs[0];
or
auto cc = selectedCCs.begin(); ,
checking the value of cc.muted does not work as I would have expected.
On the other hand
auto cc = findCC(take, 0);
returns an object which works, but doing it this way is probably not optimal. So the thing is that I don't get the difference between the objects returned in each scenario.
Next this is the line responsible for counting the total number of muted CCs, but it uses the begin() and end() methods and probably that's the reason for it not working.
int mutedCount = count_if(selectedCCs.begin(), selectedCCs.end(), [](auto cc) { return cc.muted; });
So hopefully it's not a big issue, but it's not something I'm able to figure out.

@RDMurray
Copy link
Collaborator

@MatejGolian the problem seems to be in getSelectCCs. It doesn't get the muted field. You could replace lines 1001-1005 to use MidiControlChange::get.

Remember that toggle commands with multiple selection in Reaper can get kind of crazy; you could end up with w notes muted, x notes unmuted, y CCs muted and z ccs unmuted.

See postToggleItemMute.

@MatejGolian
Copy link
Contributor Author

@RDMurray, thanks.
What would the relevant section than look like? Something like this? I don't know how to declare the 3rd parameter that should be passed to MidiControlChange::get correctly, so the first line below is definitely incorrect.
ReqParams params;
double position;
MidiControlChange::get(take, ccIndex, &params);
position = MIDI_GetProjTimeFromPPQPos(take, params.position);
ccs.push_back({params.channel, ccIndex, params.msg1, params.msg2, params.msg3, position});

@RDMurray
Copy link
Collaborator

The third parameter is MidiControlChange::ReqParams, which is a struct of 7 bools used to indicate which params of the event should be requested from Reaper. In this case we probably want everything, something like below (untested):

		ccs.push_back(MidiControlChange::get(take, ccIndex, {
			true,  // position
			true,  // message1
			true,  // channel
			true,  // message2
			true,  // message3,
			true,  // selected
			true  // muted
		}));

Btw what does it mean for a CC to be muted? I'm surprised it's even a thing.

@MatejGolian
Copy link
Contributor Author

Thanks, I'll have a go at it.
Actually I'm not completely sure either of what it does, but I'd assume that it behaves similar to muting notes where the muted note behaves as if it wasn't there at all = it's not being sent out.

@MatejGolian
Copy link
Contributor Author

I've got it. Turns out that the fix was much simpler than it looked like. But thanks @RDMurray, I couldn't have done it without you.
So I guess my work on this is done until Jamie checks it out.

@MatejGolian MatejGolian marked this pull request as ready for review January 15, 2025 18:38
@RDMurray
Copy link
Collaborator

This is a toggle. It should report when events are unmuted as well.

@MatejGolian
Copy link
Contributor Author

I've added reporting whenever single events become unmuted. I haven't altered the behavior in case toggling mute for multiple events though. The message being reported in the latter case is analogous to the one Osara reports when navigating to chords containing muted notes which seems reasonable IMO and I think that we don't have to be any more verbose than that.

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.

4 participants