Skip to content

Commit f3272b2

Browse files
committed
Rolled back temp changes
1 parent 5c26732 commit f3272b2

File tree

1 file changed

+10
-91
lines changed

1 file changed

+10
-91
lines changed

modules/tracktion_engine/midi/tracktion_ActiveNoteList.h

+10-91
Original file line numberDiff line numberDiff line change
@@ -13,128 +13,47 @@ namespace tracktion { inline namespace engine
1313

1414
struct ActiveNoteList
1515
{
16-
struct NoteState
17-
{
18-
juce::uint16 activeNotes = 0;
19-
juce::uint16 pendingOns = 0;
20-
juce::uint16 pendingOffs = 0;
21-
};
22-
23-
NoteState noteStates[128] = {};
16+
juce::uint16 activeChannels[128] = {};
2417

2518
void reset() noexcept
2619
{
27-
std::memset (noteStates, 0, sizeof (noteStates));
28-
}
29-
30-
void clearPendingEvents() noexcept
31-
{
32-
for (auto& state : noteStates)
33-
{
34-
state.pendingOns = 0;
35-
state.pendingOffs = 0;
36-
}
20+
std::memset (activeChannels, 0, sizeof (activeChannels));
3721
}
3822

3923
bool isNoteActive (int channel, int note) const noexcept
4024
{
4125
return isValidIndex (channel, note)
42-
&& (noteStates[note].activeNotes & (1u << (channel - 1))) != 0;
43-
}
44-
45-
bool hasPendingNoteOn (int channel, int note) const noexcept
46-
{
47-
return isValidIndex (channel, note)
48-
&& (noteStates[note].pendingOns & (1u << (channel - 1))) != 0;
49-
}
50-
51-
bool hasPendingNoteOff (int channel, int note) const noexcept
52-
{
53-
return isValidIndex (channel, note)
54-
&& (noteStates[note].pendingOffs & (1u << (channel - 1))) != 0;
26+
&& (activeChannels[note] & (1u << (channel - 1))) != 0;
5527
}
5628

5729
void startNote (int channel, int note) noexcept
5830
{
5931
if (isValidIndex (channel, note))
60-
noteStates[note].activeNotes |= (1u << (channel - 1));
32+
activeChannels[note] |= (1u << (channel - 1));
6133
}
6234

6335
void clearNote (int channel, int note) noexcept
6436
{
6537
if (isValidIndex (channel, note))
66-
noteStates[note].activeNotes &= ~(1u << (channel - 1));
67-
}
68-
69-
void addPendingNoteOn (int channel, int note) noexcept
70-
{
71-
if (isValidIndex (channel, note))
72-
noteStates[note].pendingOns |= (1u << (channel - 1));
73-
}
74-
75-
void addPendingNoteOff (int channel, int note) noexcept
76-
{
77-
if (isValidIndex (channel, note))
78-
noteStates[note].pendingOffs |= (1u << (channel - 1));
79-
}
80-
81-
void applyPendingEvents() noexcept
82-
{
83-
for (auto& state : noteStates)
84-
{
85-
// Apply pending note-offs first
86-
state.activeNotes &= ~state.pendingOffs;
87-
88-
// Then apply pending note-ons
89-
state.activeNotes |= state.pendingOns;
90-
91-
state.pendingOns = 0;
92-
state.pendingOffs = 0;
93-
}
38+
activeChannels[note] &= ~(1u << (channel - 1));
9439
}
9540

9641
bool areAnyNotesActive() const noexcept
9742
{
98-
for (const auto& state : noteStates)
99-
if (state.activeNotes > 0)
100-
return true;
101-
102-
return false;
103-
}
43+
juce::uint16 result = 0;
10444

105-
bool areAnyEventsPending() const noexcept
106-
{
107-
for (const auto& state : noteStates)
108-
if (state.pendingOns > 0 || state.pendingOffs > 0)
109-
return true;
45+
for (auto a : activeChannels)
46+
result |= a;
11047

111-
return false;
48+
return result > 0;
11249
}
11350

11451
template <typename Visitor>
11552
void iterate (Visitor&& v) const noexcept
11653
{
11754
for (int note = 0; note < 128; ++note)
11855
for (int chan = 0; chan < 16; ++chan)
119-
if ((noteStates[note].activeNotes & (1u << chan)) != 0)
120-
v (chan + 1, note);
121-
}
122-
123-
template <typename Visitor>
124-
void iteratePendingOns (Visitor&& v) const noexcept
125-
{
126-
for (int note = 0; note < 128; ++note)
127-
for (int chan = 0; chan < 16; ++chan)
128-
if ((noteStates[note].pendingOns & (1u << chan)) != 0)
129-
v (chan + 1, note);
130-
}
131-
132-
template <typename Visitor>
133-
void iteratePendingOffs (Visitor&& v) const noexcept
134-
{
135-
for (int note = 0; note < 128; ++note)
136-
for (int chan = 0; chan < 16; ++chan)
137-
if ((noteStates[note].pendingOffs & (1u << chan)) != 0)
56+
if ((activeChannels[note] & (1u << chan)) != 0)
13857
v (chan + 1, note);
13958
}
14059

0 commit comments

Comments
 (0)