distance to closest node displayed, timing problems with midi notes being sent 1 to 3ms too early, or too late
This commit is contained in:
+10
-6
@@ -71,22 +71,24 @@ class SignalManager{
|
||||
}
|
||||
|
||||
void updateSignals(){
|
||||
auto last = std::chrono::steady_clock::now();
|
||||
auto last = std::chrono::high_resolution_clock::now();
|
||||
while(loop){
|
||||
std::chrono::duration<double, std::micro> diff = std::chrono::steady_clock::now() - last;
|
||||
if(diff.count() > 500){
|
||||
std::chrono::duration<double, std::micro> diff = std::chrono::high_resolution_clock::now() - last;
|
||||
if((int)diff.count() >= 250){
|
||||
mutex->lock();
|
||||
if(play){
|
||||
for(auto& s : signals){
|
||||
s.direction = (nm->nodes[s.next].position - s.position).norm();
|
||||
s.update(diff.count());
|
||||
if(s.position.dist(&nm->nodes[s.next].position) < 1.0f) {
|
||||
if(s.position.dist(&nm->nodes[s.next].position) < 0.6f) {
|
||||
int n = cm->next(s.next, s.last);
|
||||
nm->nodes[s.next].trigger();
|
||||
|
||||
if(n != s.next && n != -1) {
|
||||
for(auto &m : nm->nodes[s.next].midi_outs){
|
||||
if(m.second.enabled) midi.note(m.second.i, nm->nodes[s.next].midi_channel, nm->nodes[s.next].midi_note, nm->nodes[s.next].midi_velocity, nm->nodes[s.next].midi_gate);
|
||||
if(m.second.enabled) {
|
||||
midi.note(m.second.i, nm->nodes[s.next].midi_channel, nm->nodes[s.next].midi_note, nm->nodes[s.next].midi_velocity, nm->nodes[s.next].midi_gate);
|
||||
}
|
||||
}
|
||||
s.last = s.next;
|
||||
s.next = n;
|
||||
@@ -96,14 +98,16 @@ class SignalManager{
|
||||
}
|
||||
midi.update();
|
||||
mutex->unlock();
|
||||
last = std::chrono::steady_clock::now();
|
||||
last = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawSignals(Vec2D<float> *mouse_pos, Camera2D *camera){
|
||||
for(auto& s : signals){
|
||||
mutex->lock();
|
||||
s.draw(mouse_pos, camera);
|
||||
mutex->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user