//deltaT *= 10;
auto posBefore = m_pos;
+ auto velBefore = m_vel;
m_vel += -std::pow(m_frequency/440.0, 2.0) * 10.0 * ( m_pos - m_point.getHeight() ) * deltaT;
m_vel -= m_vel * 0.01 * deltaT;
m_pos += m_vel * deltaT;
const auto absVel = std::fabs(m_vel);
+ m_maxAbsIntVel = std::max(m_maxAbsIntVel, absVel);
m_maxAbsVel = std::max(absVel, m_maxAbsVel);
//std::cout << m_pos << std::endl;
-
- if (posBefore * m_pos < 0.0) {
-// // std::cout << m_vel / m_maxVel << std::endl;
- m_noise.noteOn(m_pos >= 0 ? m_frequency : m_frequency, absVel / m_maxAbsVel);
-// //m_noise.pluck(absVel / m_maxAbsVel);
-// m_noise.controlChange(4, 1.0 * absVel / m_maxAbsVel);
+
+// if (posBefore * m_pos < 0.0) {
+// // // std::cout << m_vel / m_maxVel << std::endl;
+// m_noise.noteOn(m_pos >= 0 ? m_frequency : m_frequency, absVel / m_maxAbsVel);
+// // m_noise.pluck(absVel / m_maxAbsVel);
+// // m_noise.controlChange(4, 1.0 * absVel / m_maxAbsVel);
+// }
+
+ if (m_vel * velBefore < 0.0) {
+ m_noise.noteOn(m_frequency, m_maxAbsIntVel/m_maxAbsVel);
+ m_maxAbsIntVel = 0.0;
}
// m_noise.controlChange(128, 128.0 * absVel / m_maxAbsVel);