MCPcopy Create free account
hub / github.com/LabSound/LabSound / valueForContextTime

Method valueForContextTime

src/core/AudioParamTimeline.cpp:136–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136float AudioParamTimeline::valueForContextTime(
137 ContextRenderLock & r,
138 float defaultValue, bool & hasValue)
139{
140 auto context = r.context();
141 if (!context)
142 return defaultValue;
143
144 std::unique_lock<std::mutex> lock(m_eventsMutex, std::try_to_lock);
145 if (!lock.owns_lock() || !m_events.size() || context->currentTime() < m_events[0].time())
146 {
147 hasValue = false;
148 return defaultValue;
149 }
150
151 // Ask for just a single value.
152 double sampleRate = context->sampleRate();
153 double startTime = context->currentTime();
154 double endTime = startTime + 1.1 / sampleRate; // time just beyond one sample-frame
155 double controlRate = sampleRate / AudioNode::ProcessingSizeInFrames; // one parameter change per render quantum
156 float value = valuesForTimeRange(startTime, endTime, defaultValue, &value, 1, sampleRate, controlRate);
157
158 hasValue = true;
159 return value;
160}
161
162float AudioParamTimeline::valuesForTimeRange(
163 double startTime,

Callers 2

smoothMethod · 0.80
calculateFinalValuesMethod · 0.80

Calls 5

sizeMethod · 0.80
timeMethod · 0.80
contextMethod · 0.45
currentTimeMethod · 0.45
sampleRateMethod · 0.45

Tested by

no test coverage detected