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

Method Process

Source/Producer.cpp:83–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void Producer::Process(double time)
84{
85 PROFILER(Producer);
86
87 IAudioReceiver* target = GetTarget();
88
89 if (!mEnabled || target == nullptr || mSample == nullptr || mPlay == false)
90 return;
91
92 ComputeSliders(0);
93
94 int bufferSize = target->GetBuffer()->BufferSize();
95 float* out = target->GetBuffer()->GetChannel(0);
96 assert(bufferSize == gBufferSize);
97
98 float volSq = mVolume * mVolume;
99
100 const float* data = mSample->Data()->GetChannel(0);
101 int numSamples = mSample->LengthInSamples();
102
103 for (int i = 0; i < bufferSize; ++i)
104 {
105 if (mPlayhead < numSamples)
106 {
107 out[i] += data[mPlayhead] * volSq;
108 }
109 else
110 {
111 mPlay = false;
112 out[i] = 0; //fill the rest with zero
113 }
114 mPlayhead += 1;
115
116 while (IsSkipMeasure(GetMeasureForSample(mPlayhead)))
117 {
118 mPlayhead += GetSamplesPerMeasure();
119 }
120
121 if (mLoop && mPlayhead > mClipEnd)
122 mPlayhead = mClipStart;
123 }
124
125 ChannelBuffer buff(out, bufferSize);
126 for (int i = 0; i < PRODUCER_NUM_BIQUADS; ++i)
127 mBiquad[i].ProcessAudio(gTime, &buff);
128
129 GetVizBuffer()->WriteChunk(out, bufferSize, 0);
130}
131
132void Producer::FilesDropped(std::vector<std::string> files, int x, int y)
133{

Callers

nothing calls this directly

Calls 7

BufferSizeMethod · 0.80
GetBufferMethod · 0.80
GetChannelMethod · 0.80
DataMethod · 0.80
LengthInSamplesMethod · 0.80
WriteChunkMethod · 0.80
ProcessAudioMethod · 0.45

Tested by

no test coverage detected