Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard usage for synth plugin badly broken in windows #24

Open
sagantech opened this issue Sep 10, 2022 · 0 comments
Open

Keyboard usage for synth plugin badly broken in windows #24

sagantech opened this issue Sep 10, 2022 · 0 comments

Comments

@sagantech
Copy link

There are a couple of problems with the built in keyboard usage under windows. For one keyReleaseEvent never sets bit 15 for the engine to find (at least on my machine) and two, auto repeat of the keyboard wreaks major havoc sounding like audio overruns but it is not. It is just retriggering the notes in quick succession.

I have not done github pull requests for a while and I don't know if you are accepting them but at any rate both fixes to main-window.cc can be found below:

void MainWindow::keyPressEvent(QKeyEvent *event) {
Engine *engine = _application.engine();

if (!event->isAutoRepeat()) {
for (int i = 0; i < 8; i++) {
#ifdef _WIN32
if (0 == InterlockedCompareExchange(
(LONG volatile *)&engine->keyboardNoteData[i], event->key(), 0)) {
#else
if (0 == __sync_val_compare_and_swap(&engine->keyboardNoteData[i], 0, event->key())) {
#endif
break;
}
}
}
}

void MainWindow::keyReleaseEvent(QKeyEvent *event) {
Engine *engine = _application.engine();

if (!event->isAutoRepeat()) {
  for (int i = 0; i < 8; i++) {

#ifdef _WIN32
if (0 == InterlockedCompareExchange(
(LONG volatile *)&engine->keyboardNoteData[i], event->key() | 0x8000, 0)) {
#else
if (0 ==
__sync_val_compare_and_swap(&engine->keyboardNoteData[i], 0, 0x8000 | event->key())) {
#endif
break;
}
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant