Mercurial > hg > svapp
changeset 324:ce2b123fc2de tonioni
Merge
author | Rachel Bittner <rmb456@nyu.edu> |
---|---|
date | Thu, 16 Jan 2014 15:49:26 -0500 |
parents | 5c69d40a0e30 (current diff) 4fdf70be6671 (diff) |
children | 7bdfbaa8d93f |
files | |
diffstat | 2 files changed, 21 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/audioio/ClipMixer.cpp Sun Jan 12 05:12:08 2014 -0500 +++ b/audioio/ClipMixer.cpp Thu Jan 16 15:49:26 2014 -0500 @@ -122,7 +122,10 @@ std::vector<NoteEnd> endingNotes) { foreach (NoteStart note, newNotes) { - m_playing.push_back(note); + if (note.frequency > 20 && + note.frequency < 5000) { + m_playing.push_back(note); + } } std::vector<NoteStart> remaining; @@ -167,7 +170,8 @@ note.frequency, start < 0 ? -start : 0, start > 0 ? start : 0, - durationHere); + durationHere, + ending); } } @@ -189,13 +193,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 +224,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; }