mirror of
https://github.com/odrling/Aegisub
synced 2025-04-11 22:56:02 +02:00
Audio/timing: minor style, comment
A bit more clarification of code logic. Follow predominant if/else style
This commit is contained in:
parent
85a3d1e7e1
commit
59f0fe2aeb
@ -221,14 +221,15 @@ void AudioKaraoke::RenderText() {
|
|||||||
// Draw each character in the line
|
// Draw each character in the line
|
||||||
int y = (bmp_size.GetHeight() - char_height) / 2;
|
int y = (bmp_size.GetHeight() - char_height) / 2;
|
||||||
for (size_t i = 0; i < spaced_text.size(); ++i) {
|
for (size_t i = 0; i < spaced_text.size(); ++i) {
|
||||||
if (!(marked_syl_start <= i && i < marked_syl_end)) {
|
if (!(tap_syl_start <= i && i < tap_syl_end)) {
|
||||||
|
// Only draw with normal color if _not_ the tap syllable
|
||||||
dc.DrawText(spaced_text[i], char_x[i], y);
|
dc.DrawText(spaced_text[i], char_x[i], y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw marked syllable
|
// Draw marked syllable
|
||||||
dc.SetTextForeground(*wxGREEN);
|
dc.SetTextForeground(*wxGREEN);
|
||||||
for (size_t i = marked_syl_start; i < marked_syl_end; ++i)
|
for (size_t i = tap_syl_start; i < tap_syl_end; ++i)
|
||||||
dc.DrawText(spaced_text[i], char_x[i], y);
|
dc.DrawText(spaced_text[i], char_x[i], y);
|
||||||
|
|
||||||
// Draw the lines between each syllable
|
// Draw the lines between each syllable
|
||||||
@ -343,15 +344,15 @@ void AudioKaraoke::OnScrollTimer(wxTimerEvent&) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AudioKaraoke::OnTapMarkerChanged() {
|
void AudioKaraoke::OnTapMarkerChanged() {
|
||||||
marked_syl_start = 0;
|
tap_syl_start = 0;
|
||||||
marked_syl_end = 0;
|
tap_syl_end = 0;
|
||||||
|
|
||||||
if (OPT_GET("Timing/Tap To Time")->GetBool() && kara->size() > 0) {
|
if (OPT_GET("Timing/Tap To Time")->GetBool() && kara->size() > 0) {
|
||||||
const AudioTimingController *tc = c->audioController->GetTimingController();
|
const AudioTimingController *tc = c->audioController->GetTimingController();
|
||||||
const size_t marker_idx = tc->GetTapMarkerIndex();
|
const size_t marker_idx = tc->GetTapMarkerIndex();
|
||||||
if (marker_idx > 0) {
|
if (marker_idx > 0) {
|
||||||
marked_syl_start = syl_start_points[marker_idx - 1];
|
tap_syl_start = syl_start_points[marker_idx - 1];
|
||||||
marked_syl_end =
|
tap_syl_end =
|
||||||
(marker_idx < syl_start_points.size() ?
|
(marker_idx < syl_start_points.size() ?
|
||||||
syl_start_points[marker_idx] :
|
syl_start_points[marker_idx] :
|
||||||
spaced_text.size());
|
spaced_text.size());
|
||||||
|
@ -106,8 +106,8 @@ class AudioKaraoke final : public wxWindow {
|
|||||||
|
|
||||||
wxFont split_font; ///< Font used in the split/join interface
|
wxFont split_font; ///< Font used in the split/join interface
|
||||||
|
|
||||||
size_t marked_syl_start = 0;
|
size_t tap_syl_start = 0; ///< Tap-to-time syllable start character index
|
||||||
size_t marked_syl_end = 0;
|
size_t tap_syl_end = 0; ///< Tap-to-time syllable end character index
|
||||||
|
|
||||||
bool enabled = false; ///< Is karaoke mode enabled?
|
bool enabled = false; ///< Is karaoke mode enabled?
|
||||||
|
|
||||||
|
@ -464,7 +464,8 @@ int AudioTimingControllerDialogue::GetTapMarkerPosition() const
|
|||||||
|
|
||||||
if (tap_marker_idx == 0) {
|
if (tap_marker_idx == 0) {
|
||||||
return *active_line.GetLeftMarker();
|
return *active_line.GetLeftMarker();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return *active_line.GetRightMarker();
|
return *active_line.GetRightMarker();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -612,7 +613,8 @@ void AudioTimingControllerDialogue::MoveTapMarker(int ms) {
|
|||||||
// Moving left marker (start time of the line)
|
// Moving left marker (start time of the line)
|
||||||
if (ms > *right) SetMarkers({ right }, ms, 0);
|
if (ms > *right) SetMarkers({ right }, ms, 0);
|
||||||
SetMarkers({ left }, ms, 0);
|
SetMarkers({ left }, ms, 0);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Moving right marker (end time of the line)
|
// Moving right marker (end time of the line)
|
||||||
if (ms < *left) SetMarkers({ left }, ms, 0);
|
if (ms < *left) SetMarkers({ left }, ms, 0);
|
||||||
SetMarkers({ right }, ms, 0);
|
SetMarkers({ right }, ms, 0);
|
||||||
@ -705,10 +707,12 @@ std::vector<AudioMarker*> AudioTimingControllerDialogue::OnLeftClick(int ms, boo
|
|||||||
std::vector<AudioMarker*> AudioTimingControllerDialogue::OnRightClick(int ms, bool ctrl_down, int sensitivity, int snap_range)
|
std::vector<AudioMarker*> AudioTimingControllerDialogue::OnRightClick(int ms, bool ctrl_down, int sensitivity, int snap_range)
|
||||||
{
|
{
|
||||||
if (ctrl_down) {
|
if (ctrl_down) {
|
||||||
|
// Ctrl-right-click: play audio
|
||||||
context->audioController->PlayToEnd(ms);
|
context->audioController->PlayToEnd(ms);
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
} else {
|
else {
|
||||||
|
// Normal right-click: move right marker
|
||||||
clicked_ms = INT_MIN;
|
clicked_ms = INT_MIN;
|
||||||
std::vector<AudioMarker*> ret = GetRightMarkers();
|
std::vector<AudioMarker*> ret = GetRightMarkers();
|
||||||
SetMarkers(ret, ms, snap_range);
|
SetMarkers(ret, ms, snap_range);
|
||||||
|
@ -365,11 +365,11 @@ void AudioTimingControllerKaraoke::MoveTapMarker(int ms) {
|
|||||||
// Get syllable this time falls within
|
// Get syllable this time falls within
|
||||||
const size_t syl = distance(markers.begin(), lower_bound(markers.begin(), markers.end(), ms));
|
const size_t syl = distance(markers.begin(), lower_bound(markers.begin(), markers.end(), ms));
|
||||||
|
|
||||||
// Tapping automatically all of the necessary markers for the tap marker to
|
// Tapping automatically moves all of the necessary markers for the tap
|
||||||
// land at the current audio position. Intuitively, it "pushes" or
|
// marker to land at the current audio position. Intuitively, it "pushes" or
|
||||||
// "compresses" all of the markers in front of the tap marker. The
|
// "compresses" the markers blocking the tap marker's way so they all end up
|
||||||
// expectation is that the markers will reach their proper position once the
|
// in the same position. The expectation is that the markers will reach their
|
||||||
// user finishes tapping to the line
|
// proper position once the user finishes tapping to the line
|
||||||
if (tap_marker_idx == 0) {
|
if (tap_marker_idx == 0) {
|
||||||
// Moving the start time of first syllable (i.e. start time of the line)
|
// Moving the start time of first syllable (i.e. start time of the line)
|
||||||
if (ms > end_marker) MoveEndMarker(ms);
|
if (ms > end_marker) MoveEndMarker(ms);
|
||||||
@ -381,11 +381,11 @@ void AudioTimingControllerKaraoke::MoveTapMarker(int ms) {
|
|||||||
if (ms < start_marker) MoveStartMarker(ms);
|
if (ms < start_marker) MoveStartMarker(ms);
|
||||||
else if (ms > end_marker) MoveEndMarker(ms);
|
else if (ms > end_marker) MoveEndMarker(ms);
|
||||||
if (syl < tap_marker_idx) {
|
if (syl < tap_marker_idx) {
|
||||||
// Moving marker left
|
// Moving markers left
|
||||||
CompressMarkers(syl, tap_marker_idx-1, ms);
|
CompressMarkers(syl, tap_marker_idx-1, ms);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Moving marker right
|
// Moving markers right
|
||||||
CompressMarkers(syl-1, tap_marker_idx-1, ms);
|
CompressMarkers(syl-1, tap_marker_idx-1, ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -455,9 +455,11 @@ std::vector<AudioMarker*> AudioTimingControllerKaraoke::OnLeftClick(int ms, bool
|
|||||||
|
|
||||||
std::vector<AudioMarker*> AudioTimingControllerKaraoke::OnRightClick(int ms, bool ctrl_down, int, int) {
|
std::vector<AudioMarker*> AudioTimingControllerKaraoke::OnRightClick(int ms, bool ctrl_down, int, int) {
|
||||||
if (ctrl_down) {
|
if (ctrl_down) {
|
||||||
|
// Ctrl-right-click: play audio
|
||||||
c->audioController->PlayToEnd(ms);
|
c->audioController->PlayToEnd(ms);
|
||||||
|
}
|
||||||
} else {
|
else {
|
||||||
|
// Normal right-click: select new syllable and play range
|
||||||
cur_syl = distance(markers.begin(), lower_bound(markers.begin(), markers.end(), ms));
|
cur_syl = distance(markers.begin(), lower_bound(markers.begin(), markers.end(), ms));
|
||||||
AnnounceUpdatedPrimaryRange();
|
AnnounceUpdatedPrimaryRange();
|
||||||
AnnounceUpdatedStyleRanges();
|
AnnounceUpdatedStyleRanges();
|
||||||
@ -531,7 +533,8 @@ void AudioTimingControllerKaraoke::CompressMarkers(size_t from, size_t to, int n
|
|||||||
MoveMarker(&markers[i], new_position);
|
MoveMarker(&markers[i], new_position);
|
||||||
if (i == to) {
|
if (i == to) {
|
||||||
break;
|
break;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
i += incr;
|
i += incr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user