timning debug
This commit is contained in:
@@ -45,7 +45,8 @@ void KeyboardController::handleKeyPress(QKeyEvent* e) {
|
|||||||
queue_.push({
|
queue_.push({
|
||||||
NoteEventType::NoteOn,
|
NoteEventType::NoteOn,
|
||||||
it->second,
|
it->second,
|
||||||
0.8f
|
0.8f,
|
||||||
|
std::chrono::high_resolution_clock::now()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ void KeyboardController::handleKeyRelease(QKeyEvent* e) {
|
|||||||
queue_.push({
|
queue_.push({
|
||||||
NoteEventType::NoteOff,
|
NoteEventType::NoteOff,
|
||||||
it->second,
|
it->second,
|
||||||
0.8f
|
0.8f,
|
||||||
|
std::chrono::high_resolution_clock::now()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,8 @@ void MidiController::handleMessage(const std::vector<unsigned char>& msg) {
|
|||||||
noteQueue_.push({
|
noteQueue_.push({
|
||||||
NoteEventType::NoteOn,
|
NoteEventType::NoteOn,
|
||||||
static_cast<uint8_t>(note),
|
static_cast<uint8_t>(note),
|
||||||
vel / 127.0f
|
vel / 127.0f,
|
||||||
|
std::chrono::high_resolution_clock::now()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Note Off (or Note On with velocity 0)
|
// Note Off (or Note On with velocity 0)
|
||||||
@@ -76,7 +77,10 @@ void MidiController::handleMessage(const std::vector<unsigned char>& msg) {
|
|||||||
noteQueue_.push({
|
noteQueue_.push({
|
||||||
NoteEventType::NoteOff,
|
NoteEventType::NoteOff,
|
||||||
static_cast<uint8_t>(note),
|
static_cast<uint8_t>(note),
|
||||||
0.0f
|
0.0f,
|
||||||
|
std::chrono::high_resolution_clock::now()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "MidiHandleMessage start (0)" << std::endl;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
#include "NoteQueue.h"
|
#include "NoteQueue.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
bool NoteQueue::push(const NoteEvent& event) {
|
bool NoteQueue::push(const NoteEvent& event) {
|
||||||
size_t head = head_.load(std::memory_order_relaxed);
|
size_t head = head_.load(std::memory_order_relaxed);
|
||||||
@@ -9,6 +10,9 @@ bool NoteQueue::push(const NoteEvent& event) {
|
|||||||
|
|
||||||
buffer_[head] = event;
|
buffer_[head] = event;
|
||||||
head_.store(next, std::memory_order_relaxed);
|
head_.store(next, std::memory_order_relaxed);
|
||||||
|
|
||||||
|
std::cout << "Notequeue::push: " << std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - event.timestamp) << std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,5 +23,8 @@ bool NoteQueue::pop(NoteEvent& event) {
|
|||||||
|
|
||||||
event = buffer_[tail];
|
event = buffer_[tail];
|
||||||
tail_.store((tail + 1) % SIZE, std::memory_order_release);
|
tail_.store((tail + 1) % SIZE, std::memory_order_release);
|
||||||
|
|
||||||
|
std::cout << "Notequeue::pop: " << std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - event.timestamp) << std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
enum class NoteEventType {
|
enum class NoteEventType {
|
||||||
NoteOn,
|
NoteOn,
|
||||||
@@ -14,6 +15,7 @@ struct NoteEvent {
|
|||||||
NoteEventType type; // noteOn or noteOff
|
NoteEventType type; // noteOn or noteOff
|
||||||
uint8_t note; // 0-128, a keyboard goes 0-87
|
uint8_t note; // 0-128, a keyboard goes 0-87
|
||||||
float velocity; // 0-1, from a midi instrument its 0-127 though
|
float velocity; // 0-1, from a midi instrument its 0-127 though
|
||||||
|
std::chrono::time_point<std::chrono::high_resolution_clock> timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
// the queue is to keep track of note events from the UI/input thread to the audio engine thread
|
// the queue is to keep track of note events from the UI/input thread to the audio engine thread
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ inline float Synth::getParam(ParamId id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Synth::handleNoteEvent(const NoteEvent& event) {
|
void Synth::handleNoteEvent(const NoteEvent& event) {
|
||||||
|
|
||||||
|
std::cout << "Synth::handleNoteEvent: " << std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - event.timestamp) << std::endl;
|
||||||
|
lastTime = event.timestamp;
|
||||||
|
|
||||||
if(event.type == NoteEventType::NoteOn) {
|
if(event.type == NoteEventType::NoteOn) {
|
||||||
|
|
||||||
// TODO: find quietest voice and assign a note to it instead of just the first inactive one
|
// TODO: find quietest voice and assign a note to it instead of just the first inactive one
|
||||||
@@ -106,4 +110,6 @@ void Synth::process(float* out, uint32_t nFrames, uint32_t sampleRate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//std::cout << "Notequeue::push: " << std::chrono::high_resolution_clock::now() - lastTime << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -52,4 +52,6 @@ private:
|
|||||||
// for the scope
|
// for the scope
|
||||||
ScopeBuffer* scope_ = nullptr;
|
ScopeBuffer* scope_ = nullptr;
|
||||||
|
|
||||||
|
std::chrono::time_point<std::chrono::high_resolution_clock> lastTime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user