Mercurial > hg > svapp
changeset 320:7105604e9803 tonioni
note release is now a ramp
author | matthiasm |
---|---|
date | Tue, 14 Jan 2014 17:51:53 +0000 |
parents | ccd3c927638b |
children | 1bc4b56885bd |
files | audioio/ClipMixer.cpp audioio/ClipMixer.h |
diffstat | 2 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/audioio/ClipMixer.cpp Thu Jan 09 21:31:54 2014 +0000 +++ b/audioio/ClipMixer.cpp Tue Jan 14 17:51:53 2014 +0000 @@ -167,7 +167,8 @@ note.frequency, start < 0 ? -start : 0, start > 0 ? start : 0, - durationHere); + durationHere, + ending); } } @@ -189,13 +190,19 @@ float frequency, int sourceOffset, int targetOffset, - int sampleCount) + int sampleCount, + bool isEnd) { if (!m_clipData) return; float ratio = getResampleRatioFor(frequency); - //!!! todo: release time + float releaseTime = 0.01; + int releaseSampleCount = round(releaseTime * m_sampleRate); + if (releaseSampleCount > sampleCount) { + releaseSampleCount = sampleCount; + } + float releaseFraction = 1.f/releaseSampleCount; for (int i = 0; i < sampleCount; ++i) { @@ -214,7 +221,11 @@ if (osi + 1 < m_clipLength) { value += (m_clipData[osi + 1] - m_clipData[osi]) * (os - osi); } - + + if (isEnd && i + releaseSampleCount > sampleCount) { + value *= releaseFraction * (sampleCount - i); // linear ramp for release + } + for (int c = 0; c < m_channels; ++c) { toBuffers[c][targetOffset + i] += levels[c] * value; }