MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / OnTransportAdvanced

Method OnTransportAdvanced

Source/NoteSinger.cpp:61–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void NoteSinger::OnTransportAdvanced(float amount)
62{
63 PROFILER(NoteSinger);
64
65 if (!mEnabled)
66 return;
67
68 ComputeSliders(0);
69 SyncInputBuffer();
70
71 int pitch = -1;
72
73 int bestBucket = -1;
74 float bestPeak = -1;
75 for (int i = 0; i < mNumBuckets; ++i)
76 {
77 BufferCopy(mWorkBuffer, GetBuffer()->GetChannel(0), GetBuffer()->BufferSize());
78 mBands[i].Filter(mWorkBuffer, GetBuffer()->BufferSize());
79 mPeaks[i].Process(mWorkBuffer, GetBuffer()->BufferSize());
80
81 float peak = mPeaks[i].GetPeak();
82 if (peak > bestPeak)
83 {
84 int numPitchesInScale = TheScale->NumTonesInScale();
85 if (bestBucket != -1 &&
86 peak < 2 * bestPeak &&
87 i % numPitchesInScale == bestBucket % numPitchesInScale)
88 continue; //don't let a harmonic beat a fundamental
89
90 bestBucket = i;
91 bestPeak = peak;
92 }
93 }
94 assert(bestBucket != -1);
95
96 pitch = GetPitchForBucket(bestBucket) + mOctave * 12;
97
98 if (pitch != mPitch && bestPeak > .01f)
99 {
100 PlayNoteOutput(gTime, pitch, 80, -1);
101 PlayNoteOutput(gTime, mPitch, 0, -1);
102 mPitch = pitch;
103 }
104
105 GetBuffer()->Reset();
106}
107
108void NoteSinger::DrawModule()
109{

Callers

nothing calls this directly

Calls 8

BufferCopyFunction · 0.85
GetChannelMethod · 0.80
BufferSizeMethod · 0.80
GetPeakMethod · 0.80
FilterMethod · 0.60
ProcessMethod · 0.45
NumTonesInScaleMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected