Skip to content

Commit 66e7e3a

Browse files
tucktuckg00seclaude
andcommitted
Remove dead code, fix out-of-bounds bug in SET BPM handlers
- Remove unused SliceManager::createDefaultSlice() - Remove unused WaveformCache::getVisibleStart/getVisibleLen, localize members - Remove unused muteHead/muteTail variables in VoicePool bungee processing - Fix potential out-of-bounds array access in SET BPM popup callbacks - Make bars[] arrays const, getPreviewVoiceIndex() static Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3e9e2eb commit 66e7e3a

8 files changed

Lines changed: 7 additions & 33 deletions

File tree

project/src/audio/LazyChopEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class LazyChopEngine
1111
void stop (VoicePool& voicePool, SliceManager& sliceMgr);
1212
void onNote (int note, VoicePool& voicePool, SliceManager& sliceMgr);
1313

14-
int getPreviewVoiceIndex() const { return VoicePool::kMaxVoices - 1; }
14+
static int getPreviewVoiceIndex() { return VoicePool::kMaxVoices - 1; }
1515

1616
private:
1717
void startPreview (VoicePool& voicePool, int fromPos);

project/src/audio/SliceManager.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,6 @@ void SliceManager::clearAll()
101101
rebuildMidiMap();
102102
}
103103

104-
void SliceManager::createDefaultSlice (int sampleLen)
105-
{
106-
if (sampleLen <= 0)
107-
return;
108-
109-
// Reset all slices
110-
numSlices = 0;
111-
for (auto& s : slices)
112-
s.active = false;
113-
114-
createSlice (0, sampleLen);
115-
selectedSlice = 0;
116-
}
117-
118104
void SliceManager::rebuildMidiMap()
119105
{
120106
midiMap.fill (-1);

project/src/audio/SliceManager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class SliceManager
1212
int createSlice (int start, int end);
1313
void deleteSlice (int idx);
1414
void clearAll();
15-
void createDefaultSlice (int sampleLen);
1615
void rebuildMidiMap();
1716
int midiNoteToSlice (int note) const;
1817

project/src/audio/VoicePool.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,6 @@ static void fillBungeeBlock (Voice& v, const SampleData& sample)
331331
for (int i = 0; i < numFrames; ++i)
332332
{
333333
double pos = inputChunk.begin + i;
334-
int muteHead = 0, muteTail = 0;
335-
336-
if (pos < v.startSample)
337-
muteHead = std::max (muteHead, (int)(v.startSample - inputChunk.begin));
338-
if (pos >= v.endSample)
339-
muteTail = std::max (muteTail, (int)(inputChunk.end - v.endSample));
340334

341335
float sL = 0.0f, sR = 0.0f;
342336
if (pos >= v.startSample && pos < v.endSample)

project/src/ui/HeaderBar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ void HeaderBar::showSetBpmPopup (bool forSampleDefault)
475475

476476
menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this),
477477
[this, forSampleDefault] (int result) {
478-
if (result <= 0) return;
479-
float bars[] = { 0.0f, 16.0f, 8.0f, 4.0f, 2.0f, 1.0f, 0.5f, 0.25f, 0.125f, 0.0625f };
478+
if (result <= 0 || result > 9) return;
479+
const float bars[] = { 0.0f, 16.0f, 8.0f, 4.0f, 2.0f, 1.0f, 0.5f, 0.25f, 0.125f, 0.0625f };
480480

481481
// Determine start/end from selected slice or full sample
482482
int startS = 0;

project/src/ui/SliceControlBar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,8 @@ void SliceControlBar::showSetBpmPopup()
700700

701701
menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this),
702702
[this] (int result) {
703-
if (result <= 0) return;
704-
float bars[] = { 0.0f, 16.0f, 8.0f, 4.0f, 2.0f, 1.0f, 0.5f, 0.25f, 0.125f, 0.0625f };
703+
if (result <= 0 || result > 9) return;
704+
const float bars[] = { 0.0f, 16.0f, 8.0f, 4.0f, 2.0f, 1.0f, 0.5f, 0.25f, 0.125f, 0.0625f };
705705

706706
IntersectProcessor::Command cmd;
707707
cmd.type = IntersectProcessor::CmdStretch;

project/src/ui/WaveformCache.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ void WaveformCache::rebuild (const juce::AudioBuffer<float>& buffer, int numFram
1111
return;
1212
}
1313

14-
visibleLen = (int) (numFrames / zoom);
15-
visibleStart = (int) (scroll * (numFrames - visibleLen));
14+
int visibleLen = (int) (numFrames / zoom);
15+
int visibleStart = (int) (scroll * (numFrames - visibleLen));
1616
visibleStart = std::max (0, std::min (visibleStart, numFrames - visibleLen));
1717

1818
peaks.resize ((size_t) widthPixels);

project/src/ui/WaveformCache.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ class WaveformCache
1313
const std::vector<Peak>& getPeaks() const { return peaks; }
1414
int getNumPeaks() const { return (int) peaks.size(); }
1515

16-
int getVisibleStart() const { return visibleStart; }
17-
int getVisibleLen() const { return visibleLen; }
18-
1916
private:
2017
std::vector<Peak> peaks;
21-
int visibleStart = 0;
22-
int visibleLen = 0;
2318
};

0 commit comments

Comments
 (0)