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;
18 auto velBefore = m_vel;
20 m_vel += -std::pow(m_frequency/440.0, 2.0) * 10.0 * ( m_pos - m_point.getHeight() ) * deltaT;
21 m_vel -= m_vel * 0.01 * deltaT;
22 m_pos += m_vel * deltaT;
24 const auto absVel = std::fabs(m_vel);
25 m_maxAbsIntVel = std::max(m_maxAbsIntVel, absVel);
26 m_maxAbsVel = std::max(absVel, m_maxAbsVel);
28 //std::cout << m_pos << std::endl;
30 // if (posBefore * m_pos < 0.0) {
31 // // // std::cout << m_vel / m_maxVel << std::endl;
32 // m_noise.noteOn(m_pos >= 0 ? m_frequency : m_frequency, absVel / m_maxAbsVel);
33 // // m_noise.pluck(absVel / m_maxAbsVel);
34 // // m_noise.controlChange(4, 1.0 * absVel / m_maxAbsVel);
37 if (m_vel * velBefore < 0.0) {
38 m_noise.noteOn(m_frequency, m_maxAbsIntVel/m_maxAbsVel);
42 // m_noise.controlChange(128, 128.0 * absVel / m_maxAbsVel);
45 stk::StkFloat Dot::tick()
47 // std::lock_guard<std::mutex> lock{m_mutex};
49 return m_noise.tick();