Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3900095
feat(a11y): screen reader (NVDA) and keyboard support
fdrv161 Oct 14, 2026
9d3f302
fix(a11y): keyboard note volume uses the volume envelope transaction
fdrv161 Oct 14, 2026
d6d32fb
feat(a11y): note values change with Ctrl+Up/Down, as in Melodyne
fdrv161 Oct 14, 2026
a83ddcc
fix(a11y): the note audition plays with the note volume
fdrv161 Oct 14, 2026
dd8d6ed
fix(a11y): paste at REAPER's edit cursor while the transport is stopped
fdrv161 Oct 14, 2026
d2bf93b
feat(a11y): arrows start at REAPER's edit cursor, Shift+X splits at it
fdrv161 Oct 14, 2026
e216d08
fix(a11y): after a stop in the plugin, cursor actions use the stop po…
fdrv161 Oct 14, 2026
8c748a1
fix(a11y): arrows go to the note at the new song position after a pause
fdrv161 Oct 14, 2026
7efb7d4
fix(a11y): say when a keyboard note edit could not be applied
fdrv161 Oct 14, 2026
9587684
fix(a11y): the song position comes from REAPER's transport, Shift+I s…
fdrv161 Oct 17, 2026
a7296a9
fix(a11y): stopped, the song position is REAPER's edit cursor
fdrv161 Oct 17, 2026
5820448
fix(a11y): arrows follow the cursor right after opening, skip the not…
fdrv161 Oct 17, 2026
eb21ddd
Merge upstream standalone into a11y-pr
fdrv161 Oct 18, 2026
c57f09c
Merge upstream standalone into a11y-pr
fdrv161 Oct 20, 2026
808dd02
fix(a11y): hide the new piano roll zoom buttons from screen readers
fdrv161 Oct 20, 2026
356c9e2
Merge upstream standalone into a11y-pr
fdrv161 Oct 23, 2026
6d6fa29
Merge upstream standalone into a11y-pr
fdrv161 Oct 29, 2026
8584ad0
a11y: make the About dialog readable with a screen reader
fdrv161 Oct 29, 2026
5002178
a11y: drop the unnamed viewport Tab stop in the About dialog
fdrv161 Oct 29, 2026
ecf8d9d
Merge upstream standalone into a11y-pr
fdrv161 Oct 31, 2026
5a83290
Merge upstream standalone into a11y-pr
fdrv161 Nov 1, 2026
3a7c01a
fix(plugin): apply saved preferences when the editor opens
fdrv161 Nov 1, 2026
cb208be
Merge upstream standalone into a11y-pr
fdrv161 Nov 4, 2026
482a4d8
a11y: check boxes without "read only", state spoken on toggle
fdrv161 Nov 4, 2026
cbc5806
a11y: mix keyboard note audition in the editor renderer
fdrv161 Nov 4, 2026
c33db77
a11y: one preference for note audition after a pitch change
fdrv161 Nov 4, 2026
fc63031
Merge upstream standalone into a11y-pr
fdrv161 Nov 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,16 @@ set(OPENTUNE_COMMON_SOURCES
Source/Utils/NoteGeneratorTypes.h
Source/Utils/PianoKeyAudition.cpp
Source/Utils/PianoKeyAudition.h
Source/Utils/NoteAudition.cpp
Source/Utils/NoteAudition.h
Source/Utils/NoteSpeech.h
Source/Utils/ScreenReaderAnnouncer.cpp
Source/Utils/ScreenReaderAnnouncer.h
Source/Utils/AccessibleComboBox.h
Source/Utils/AccessibleKnob.h
Source/Utils/AccessibleToggleButton.h
Source/Utils/ContextMenuKey.cpp
Source/Utils/ContextMenuKey.h
Source/Utils/AppLogger.cpp
Source/Utils/AppLogger.h
Source/Utils/ExternalEditSession.cpp
Expand Down Expand Up @@ -940,6 +950,8 @@ set(OPENTUNE_STANDALONE_SOURCES
set(OPENTUNE_NON_STANDALONE_SOURCES
Source/Plugin/Vst3ProcessorStateCodec.cpp
Source/Plugin/Vst3ProcessorStateCodec.h
Source/Plugin/ReaperHostBridge.cpp
Source/Plugin/ReaperHostBridge.h
Source/Content/CaptureSegmentContent.h
Source/Content/CaptureSegmentContent.cpp
)
Expand Down Expand Up @@ -1937,6 +1949,17 @@ if(OPENTUNE_BUILD_TESTS)
endif()
add_test(NAME PitchLaneVisualPolicyTests COMMAND OpenTunePitchLaneVisualPolicyTests)

# Spoken note pitch text for screen readers - standard library only
add_executable(OpenTuneNoteSpeechTests
Tests/NoteSpeechTests.cpp
)
target_include_directories(OpenTuneNoteSpeechTests
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Source)
if(MSVC)
target_compile_options(OpenTuneNoteSpeechTests PRIVATE /utf-8 /EHsc)
endif()
add_test(NAME NoteSpeechTests COMMAND OpenTuneNoteSpeechTests)

add_executable(OpenTuneHostTransportTests
Tests/HostTransportTests.cpp
)
Expand Down
37 changes: 37 additions & 0 deletions Source/ARA/OpenTuneDocumentController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "OpenTunePlaybackRenderer.h"

#include "../Audio/NotePitchAudition.h"
#include "../Utils/NoteAudition.h"

#include "../Inference/F0InferenceService.h"
#include "../Runtime/ProcessF0Runtime.h"
Expand Down Expand Up @@ -1053,6 +1054,42 @@ void OpenTuneDocumentController::stopNotePitchAudition() noexcept
notePitchAudition_->stop();
}

void OpenTuneDocumentController::setKeyboardAuditionSource(NoteAudition* source) noexcept
{
while (keyboardAuditionLock_.test_and_set(std::memory_order_acquire)) {}
keyboardAuditionSource_ = source;
keyboardAuditionLock_.clear(std::memory_order_release);
}

void OpenTuneDocumentController::mixKeyboardAudition(
juce::ARAEditorRenderer* renderer,
juce::AudioBuffer<float>& buffer,
int numSamples,
double sampleRate) noexcept
{
if (keyboardAuditionLock_.test_and_set(std::memory_order_acquire))
return;

// One mixer per document: a second one would advance the clip twice per block.
if (keyboardAuditionMixer_ == nullptr)
keyboardAuditionMixer_ = renderer;
if (keyboardAuditionMixer_ == renderer && keyboardAuditionSource_ != nullptr)
keyboardAuditionSource_->mixIntoBuffer(buffer, numSamples, sampleRate);

keyboardAuditionLock_.clear(std::memory_order_release);
}

void OpenTuneDocumentController::releaseKeyboardAudition(
NoteAudition* source, juce::ARAEditorRenderer* renderer) noexcept
{
while (keyboardAuditionLock_.test_and_set(std::memory_order_acquire)) {}
if (keyboardAuditionSource_ == source)
keyboardAuditionSource_ = nullptr;
if (renderer != nullptr && keyboardAuditionMixer_ == renderer)
keyboardAuditionMixer_ = nullptr;
keyboardAuditionLock_.clear(std::memory_order_release);
}

bool OpenTuneDocumentController::PlaybackRegionProjection::isPlaybackRenderable() const noexcept
{
return contentKey.isValid()
Expand Down
17 changes: 17 additions & 0 deletions Source/ARA/OpenTuneDocumentController.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class OpenTunePlaybackRenderer;
class OpenTuneAudioProcessor;
class ResamplingManager;
class NotePitchAudition;
class NoteAudition;
struct RenderJob;
class OpenTuneDocumentController : public juce::ARADocumentControllerSpecialisation
{
Expand Down Expand Up @@ -241,6 +242,16 @@ class OpenTuneDocumentController : public juce::ARADocumentControllerSpecialisat
double sampleRate) noexcept;
void stopNotePitchAudition() noexcept;

// Keyboard note audition. The editor view owns it, but as an item FX in REAPER that
// instance is a playback renderer and gets no audio blocks while stopped, so the
// arrows were silent. The realtime editor renderer of the document mixes it instead.
void setKeyboardAuditionSource(NoteAudition* source) noexcept;
void mixKeyboardAudition(juce::ARAEditorRenderer* renderer,
juce::AudioBuffer<float>& buffer,
int numSamples,
double sampleRate) noexcept;
void releaseKeyboardAudition(NoteAudition* source, juce::ARAEditorRenderer* renderer) noexcept;

/** Shared PlayHeadState for all ARA roles bound to this document. The
* realtime editor renderer publishes host transport here; UI binds to this. */
const PlayHeadState& getSharedPlayHeadState() const noexcept { return sharedPlayHeadState_; }
Expand Down Expand Up @@ -296,6 +307,12 @@ class OpenTuneDocumentController : public juce::ARADocumentControllerSpecialisat
std::atomic<juce::ARAEditorRenderer*> notePitchAuditionRenderer_{nullptr};
std::atomic_flag notePitchAuditionMixLock_ = ATOMIC_FLAG_INIT;

// Guarded by keyboardAuditionLock_: the audio thread only tries it, the message thread
// waits for it, so a source is never freed while it is being mixed.
NoteAudition* keyboardAuditionSource_ = nullptr;
juce::ARAEditorRenderer* keyboardAuditionMixer_ = nullptr;
std::atomic_flag keyboardAuditionLock_ = ATOMIC_FLAG_INIT;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OpenTuneDocumentController)
};

Expand Down
71 changes: 67 additions & 4 deletions Source/Editor/AboutDialogContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class AboutDialogContent : public juce::Component,

juce::DialogWindow::LaunchOptions options;
options.content.setOwned(content);
options.dialogTitle = {};
// The title bar is hidden, but the window name is what NVDA reads on open.
options.dialogTitle = LOC(kAbout);
options.dialogBackgroundColour = UIColors::backgroundDark;
options.escapeKeyTriggersCloseButton = false;
options.useNativeTitleBar = false;
Expand All @@ -45,12 +46,18 @@ class AboutDialogContent : public juce::Component,
explicit AboutDialogContent(const juce::String& markdown)
: parentSubscription_(*this)
{
setWantsKeyboardFocus(true);
// Accessibility: the content itself is not a focus stop (NVDA read it as "unknown").
// Every text line and link is, so Tab reads the page in order; keys bubble up here.
setWantsKeyboardFocus(false);

buildItems(markdown);
viewport_.setViewedComponent(&body_, false);
viewport_.setScrollBarsShown(true, false);
viewport_.setScrollBarThickness(8);
viewport_.getVerticalScrollBar().setAccessible(false);
// JUCE Viewport is a Tab stop by default; NVDA read it as "unknown" (user test).
// Tab scrolls the focused line into view, so the viewport needs no focus.
viewport_.setWantsKeyboardFocus(false);
addAndMakeVisible(viewport_);

closeButton_.setButtonText(LOC(kClose));
Expand Down Expand Up @@ -85,6 +92,17 @@ class AboutDialogContent : public juce::Component,

bool keyPressed(const juce::KeyPress& key) override
{
// Enter and Space press the focused link or Close, as in standard Windows dialogs;
// Enter on a text line closes the dialog as before.
if (key == juce::KeyPress::returnKey || key == juce::KeyPress::spaceKey)
{
if (auto* button = dynamic_cast<juce::Button*>(juce::Component::getCurrentlyFocusedComponent());
button != nullptr && isParentOf(button))
{
button->triggerClick();
return true;
}
}
if (key == juce::KeyPress::escapeKey || key == juce::KeyPress::returnKey)
{
closeDialog();
Expand All @@ -93,6 +111,28 @@ class AboutDialogContent : public juce::Component,
return false;
}

// Tab can land on a line scrolled out of view: bring it into the viewport.
void focusOfChildComponentChanged(FocusChangeType) override
{
auto* focused = juce::Component::getCurrentlyFocusedComponent();
if (focused == nullptr || !body_.isParentOf(focused))
return;

const auto area = body_.getLocalArea(focused, focused->getLocalBounds());
const int viewTop = viewport_.getViewPositionY();
const int viewHeight = viewport_.getViewHeight();
if (area.getY() < viewTop)
viewport_.setViewPosition(0, area.getY());
else if (area.getBottom() > viewTop + viewHeight)
viewport_.setViewPosition(0, area.getBottom() - viewHeight);
}

// Plain group without a name: NVDA skips it instead of saying "unknown".
std::unique_ptr<juce::AccessibilityHandler> createAccessibilityHandler() override
{
return std::make_unique<juce::AccessibilityHandler>(*this, juce::AccessibilityRole::group);
}

void parentHierarchyChanged() override
{
if (auto* dialog = findParentComponentOfClass<juce::DialogWindow>();
Expand Down Expand Up @@ -129,6 +169,14 @@ class AboutDialogContent : public juce::Component,
TextRun(const juce::String& text, Style style) : text_(text), style_(style)
{
setInterceptsMouseClicks(false, false);
// The text is only painted: expose it as a focusable line so NVDA reads it on Tab.
setTitle(text);
setWantsKeyboardFocus(true);
}

std::unique_ptr<juce::AccessibilityHandler> createAccessibilityHandler() override
{
return std::make_unique<juce::AccessibilityHandler>(*this, juce::AccessibilityRole::staticText);
}

int preferredWidth() const
Expand Down Expand Up @@ -216,6 +264,9 @@ class AboutDialogContent : public juce::Component,
return;

auto& run = texts_.emplace_back(std::make_unique<TextRun>(trimmed, line.style));
// JUCE orders Tab by y then x, and centred text sits lower than a link on the
// same row, so keep the reading order explicitly.
run->setExplicitFocusOrder(nextFocusOrder_++);
body_.addAndMakeVisible(*run);
line.items.push_back({ run.get(), run.get(), nullptr });
}
Expand All @@ -237,6 +288,7 @@ class AboutDialogContent : public juce::Component,
}
};

button->setExplicitFocusOrder(nextFocusOrder_++);
body_.addAndMakeVisible(*button);
line.items.push_back({ button.get(), nullptr, button.get() });
}
Expand Down Expand Up @@ -368,8 +420,17 @@ class AboutDialogContent : public juce::Component,
{
juce::Component::SafePointer<AboutDialogContent> safeThis(this);
juce::MessageManager::callAsync([safeThis] {
if (safeThis != nullptr && safeThis->isShowing())
safeThis->grabKeyboardFocus();
if (safeThis == nullptr || !safeThis->isShowing() || safeThis->initialFocusDone_)
return;
// This runs more than once while the dialog opens; focus only the first time,
// or NVDA repeats the window name and the line.
safeThis->initialFocusDone_ = true;

// Focus the first line (the heading): NVDA reads the window name and the line.
juce::Component* target = &safeThis->closeButton_;
if (!safeThis->lines_.empty() && !safeThis->lines_.front().items.empty())
target = safeThis->lines_.front().items.front().component;
target->grabKeyboardFocus();
});
}

Expand All @@ -380,6 +441,8 @@ class AboutDialogContent : public juce::Component,
juce::Viewport viewport_;
juce::TextButton closeButton_;
bool closing_ = false;
bool initialFocusDone_ = false;
int nextFocusOrder_ = 1;
ComponentListenerSubscription parentSubscription_;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(AboutDialogContent)
Expand Down
52 changes: 47 additions & 5 deletions Source/Editor/ConfirmDialogContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "ComponentListenerSubscription.h"
#include "../Standalone/UI/UIColors.h"
#include "../Utils/LocalizationManager.h"
#include "../Utils/ScreenReaderAnnouncer.h"

namespace OpenTune {

Expand Down Expand Up @@ -60,7 +61,9 @@ class ConfirmDialogContent : public juce::Component,
parentSubscription_(*this),
dialogSubscription_(*this)
{
setWantsKeyboardFocus(true);
// Accessibility: the content used to take focus itself and NVDA read it as
// "unknown". Now only the buttons take focus; keys still bubble up to keyPressed.
setWantsKeyboardFocus(false);

// 创建按钮并确定默认按钮(先有按钮才能按最佳宽度决定弹窗宽度)
for (size_t i = 0; i < buttonSpecs_.size(); ++i) {
Expand Down Expand Up @@ -115,7 +118,8 @@ class ConfirmDialogContent : public juce::Component,
{
juce::DialogWindow::LaunchOptions options;
options.content.setOwned(content);
options.dialogTitle = {};
// The title bar is hidden, but the window name is what NVDA reads on open.
options.dialogTitle = content->title_;
options.dialogBackgroundColour = UIColors::backgroundDark;
options.escapeKeyTriggersCloseButton = false; // Esc 由内容处理(dismiss 路径)
options.useNativeTitleBar = false;
Expand Down Expand Up @@ -143,10 +147,15 @@ class ConfirmDialogContent : public juce::Component,
const juce::String& summary,
const juce::String& diagnosticText)
{
juce::Component::SafePointer<juce::Component> safeParent(parent);
auto* content = new ConfirmDialogContent(title, summary,
{
{ LOC(kCopy), [diagnosticText] {
{ LOC(kCopy), [diagnosticText, safeParent] {
juce::SystemClipboard::copyTextToClipboard(diagnosticText);
// The dialog closes on Copy, so confirm it from the editor.
if (safeParent != nullptr && safeParent->isShowing())
a11y::announce(*safeParent, LOC_RAW("Copied to clipboard"),
a11y::SpeechQueue::keepAll);
} },
{ LOC(kOK), nullptr, true }
});
Expand Down Expand Up @@ -236,6 +245,15 @@ class ConfirmDialogContent : public juce::Component,
dismiss();
return true;
}
// Space presses the focused button, as in standard Windows dialogs.
if (key == juce::KeyPress::spaceKey) {
for (auto* btn : buttons_) {
if (btn->hasKeyboardFocus(false)) {
btn->triggerClick();
return true;
}
}
}
if (key == juce::KeyPress::returnKey) {
// 按 Enter 触发默认按钮
if (defaultButtonIdx_ >= 0 && defaultButtonIdx_ < static_cast<int>(buttons_.size())) {
Expand Down Expand Up @@ -311,6 +329,7 @@ class ConfirmDialogContent : public juce::Component,
int defaultButtonIdx_ = 0;

bool closing_ = false;
bool messageAnnounced_ = false;
bool verticalButtons_ = false;
bool centreButtons_ = false;
int messageHeight_ = 24;
Expand Down Expand Up @@ -428,11 +447,34 @@ class ConfirmDialogContent : public juce::Component,
{
juce::Component::SafePointer<ConfirmDialogContent> safeThis(this);
juce::MessageManager::callAsync([safeThis] {
if (safeThis != nullptr && safeThis->isShowing())
safeThis->grabKeyboardFocus();
if (safeThis == nullptr || !safeThis->isShowing())
return;

// Focus the default button: NVDA reads the window name (the title) and the button.
const int idx = safeThis->defaultButtonIdx_;
juce::Component* target = safeThis.getComponent();
if (idx >= 0 && idx < safeThis->buttons_.size())
target = safeThis->buttons_[idx];
// takeKeyboardFocus runs more than once while the dialog opens; grabbing the
// already focused button again made NVDA repeat "dialog, OK button".
if (!target->hasKeyboardFocus(false))
target->grabKeyboardFocus();

// The message is only painted, so speak it once. keepAll queues it after
// the focus speech instead of cutting it off.
if (!safeThis->messageAnnounced_ && safeThis->message_.isNotEmpty()) {
safeThis->messageAnnounced_ = true;
a11y::announce(*target, safeThis->message_, a11y::SpeechQueue::keepAll);
}
});
}

// Plain group without a name: NVDA skips it instead of saying "unknown".
std::unique_ptr<juce::AccessibilityHandler> createAccessibilityHandler() override
{
return std::make_unique<juce::AccessibilityHandler>(*this, juce::AccessibilityRole::group);
}

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ConfirmDialogContent)
};

Expand Down
Loading