Mercurial > hg > svapp
comparison audioio/ClipMixer.cpp @ 320:7105604e9803 tonioni
note release is now a ramp
author | matthiasm |
---|---|
date | Tue, 14 Jan 2014 17:51:53 +0000 |
parents | abfde177731f |
children | 1bc4b56885bd |
comparison
equal
deleted
inserted
replaced
319:ccd3c927638b | 320:7105604e9803 |
---|---|
165 mixNote(toBuffers, | 165 mixNote(toBuffers, |
166 levels, | 166 levels, |
167 note.frequency, | 167 note.frequency, |
168 start < 0 ? -start : 0, | 168 start < 0 ? -start : 0, |
169 start > 0 ? start : 0, | 169 start > 0 ? start : 0, |
170 durationHere); | 170 durationHere, |
171 ending); | |
171 } | 172 } |
172 } | 173 } |
173 | 174 |
174 if (!ending) { | 175 if (!ending) { |
175 NoteStart adjusted = note; | 176 NoteStart adjusted = note; |
187 ClipMixer::mixNote(float **toBuffers, | 188 ClipMixer::mixNote(float **toBuffers, |
188 float *levels, | 189 float *levels, |
189 float frequency, | 190 float frequency, |
190 int sourceOffset, | 191 int sourceOffset, |
191 int targetOffset, | 192 int targetOffset, |
192 int sampleCount) | 193 int sampleCount, |
194 bool isEnd) | |
193 { | 195 { |
194 if (!m_clipData) return; | 196 if (!m_clipData) return; |
195 | 197 |
196 float ratio = getResampleRatioFor(frequency); | 198 float ratio = getResampleRatioFor(frequency); |
197 | 199 |
198 //!!! todo: release time | 200 float releaseTime = 0.01; |
201 int releaseSampleCount = round(releaseTime * m_sampleRate); | |
202 if (releaseSampleCount > sampleCount) { | |
203 releaseSampleCount = sampleCount; | |
204 } | |
205 float releaseFraction = 1.f/releaseSampleCount; | |
199 | 206 |
200 for (int i = 0; i < sampleCount; ++i) { | 207 for (int i = 0; i < sampleCount; ++i) { |
201 | 208 |
202 int s = sourceOffset + i; | 209 int s = sourceOffset + i; |
203 | 210 |
212 value += m_clipData[osi]; | 219 value += m_clipData[osi]; |
213 } | 220 } |
214 if (osi + 1 < m_clipLength) { | 221 if (osi + 1 < m_clipLength) { |
215 value += (m_clipData[osi + 1] - m_clipData[osi]) * (os - osi); | 222 value += (m_clipData[osi + 1] - m_clipData[osi]) * (os - osi); |
216 } | 223 } |
217 | 224 |
225 if (isEnd && i + releaseSampleCount > sampleCount) { | |
226 value *= releaseFraction * (sampleCount - i); // linear ramp for release | |
227 } | |
228 | |
218 for (int c = 0; c < m_channels; ++c) { | 229 for (int c = 0; c < m_channels; ++c) { |
219 toBuffers[c][targetOffset + i] += levels[c] * value; | 230 toBuffers[c][targetOffset + i] += levels[c] * value; |
220 } | 231 } |
221 } | 232 } |
222 } | 233 } |