3 Dot::Dot(const SurfacePoint& point, double frequency) :
7 m_noise.noteOn(frequency, 1.0);
8 // m_noise.setFrequency(frequency);
11 void Dot::advance(double deltaT)
13 // std::lock_guard<std::mutex> lock{m_mutex};
17 auto posBefore = m_pos;
19 m_vel += -std::pow(m_frequency / 440.0, 2.0) * 1.0 * ( m_pos - m_point.getHeight() ) * deltaT;
20 m_vel -= m_vel * 0.01 * deltaT;
21 m_pos += m_vel * deltaT;
23 const auto absVel = std::fabs(m_vel);
24 m_maxAbsVel = std::max(absVel, m_maxAbsVel);
26 //std::cout << m_pos << std::endl;
28 if (posBefore * m_pos < 0.0) {
29 // // std::cout << m_vel / m_maxVel << std::endl;
30 m_noise.noteOn(m_pos >= 0 ? m_frequency : m_frequency*0.5, absVel / m_maxAbsVel);
31 // //m_noise.pluck(absVel / m_maxAbsVel);
32 // m_noise.controlChange(4, 1.0 * absVel / m_maxAbsVel);
35 // m_noise.controlChange(128, 128.0 * absVel / m_maxAbsVel);
38 stk::StkFloat Dot::tick()
40 // std::lock_guard<std::mutex> lock{m_mutex};
42 return m_noise.tick();