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

Method Process

Source/SampleVoice.cpp:46–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46bool SampleVoice::Process(double time, ChannelBuffer* out, int oversampling)
47{
48 PROFILER(SampleVoice);
49
50 if (IsDone(time) ||
51 mVoiceParams->mSampleData == nullptr ||
52 mVoiceParams->mSampleLength == 0)
53 return false;
54
55 float volSq = mVoiceParams->mVol * mVoiceParams->mVol;
56
57 for (int pos = 0; pos < out->BufferSize(); ++pos)
58 {
59 if (mOwner)
60 mOwner->ComputeSliders(pos);
61
62 if (mPos <= mVoiceParams->mSampleLength || mVoiceParams->mLoop)
63 {
64 float freq = TheScale->PitchToFreq(GetPitch(pos));
65 float speed;
66 if (mVoiceParams->mDetectedFreq != -1)
67 speed = freq / mVoiceParams->mDetectedFreq;
68 else
69 speed = freq / TheScale->PitchToFreq(TheScale->ScaleRoot() + 48);
70
71 float sample = GetInterpolatedSample(mPos, mVoiceParams->mSampleData, mVoiceParams->mSampleLength) * mAdsr.Value(time) * volSq;
72
73 if (out->NumActiveChannels() == 1)
74 {
75 out->GetChannel(0)[pos] += sample;
76 }
77 else
78 {
79 out->GetChannel(0)[pos] += sample * GetLeftPanGain(GetPan());
80 out->GetChannel(1)[pos] += sample * GetRightPanGain(GetPan());
81 }
82
83 mPos += speed;
84 }
85
86 time += gInvSampleRateMs;
87 }
88
89 return true;
90}
91
92void SampleVoice::Start(double time, float target)
93{

Callers

nothing calls this directly

Calls 10

GetInterpolatedSampleFunction · 0.85
GetLeftPanGainFunction · 0.85
GetRightPanGainFunction · 0.85
BufferSizeMethod · 0.80
ComputeSlidersMethod · 0.80
PitchToFreqMethod · 0.80
NumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
ScaleRootMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected