Mercurial > hg > svapp
comparison audioio/ClipMixer.cpp @ 311:86fb9160d122 tonioni
Fix some foolish mistakes. We have arbitrary frequency note playback now (though with rough edges)
author | Chris Cannam |
---|---|
date | Wed, 08 Jan 2014 09:58:48 +0000 |
parents | 8c59cc68eabd |
children | 58582119c92a |
comparison
equal
deleted
inserted
replaced
310:8c59cc68eabd | 311:86fb9160d122 |
---|---|
102 | 102 |
103 float | 103 float |
104 ClipMixer::getResampleRatioFor(float frequency) | 104 ClipMixer::getResampleRatioFor(float frequency) |
105 { | 105 { |
106 if (!m_clipData) return 1.0; | 106 if (!m_clipData) return 1.0; |
107 float pitchRatio = frequency / m_clipF0; | 107 float pitchRatio = m_clipF0 / frequency; |
108 float resampleRatio = m_sampleRate / m_clipRate; | 108 float resampleRatio = m_sampleRate / m_clipRate; |
109 return pitchRatio * resampleRatio; | 109 return pitchRatio * resampleRatio; |
110 } | 110 } |
111 | 111 |
112 int | 112 int |
157 } | 157 } |
158 | 158 |
159 int clipDuration = getResampledClipDuration(note.frequency); | 159 int clipDuration = getResampledClipDuration(note.frequency); |
160 if (start + clipDuration > 0) { | 160 if (start + clipDuration > 0) { |
161 if (start < 0 && start + clipDuration < durationHere) { | 161 if (start < 0 && start + clipDuration < durationHere) { |
162 durationHere = clipDuration - start; | 162 durationHere = start + clipDuration; |
163 } | 163 } |
164 if (durationHere > 0) { | 164 if (durationHere > 0) { |
165 mixNote(toBuffers, | 165 mixNote(toBuffers, |
166 levels, | 166 levels, |
167 note.frequency, | 167 note.frequency, |
212 if (osi + 1 < m_clipLength) { | 212 if (osi + 1 < m_clipLength) { |
213 value += (m_clipData[osi + 1] - m_clipData[osi]) * (os - osi); | 213 value += (m_clipData[osi + 1] - m_clipData[osi]) * (os - osi); |
214 } | 214 } |
215 | 215 |
216 for (int c = 0; c < m_channels; ++c) { | 216 for (int c = 0; c < m_channels; ++c) { |
217 toBuffers[c][targetOffset + i] = levels[c] * value; | 217 toBuffers[c][targetOffset + i] += levels[c] * value; |
218 } | 218 } |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 | 222 |