Akkorde, Gitarrengriffe, Taktraster, Strumming-Schätzung und Song-Hilfswerkzeug
- Akkorderkennung aus der Begleitung, Akkordleiste und -karte - Gitarrengriffe (Dur/Moll) und Strumming-Anzeige - Taktraster ([grid]) mit Taktstrichen, Raster-Editor und songsynchronem Metronom - Tempo aus Akkordwechseln (genauer als aus Anschlägen) - UltraStar-Import mit automatischer Zeit- und Oktavprüfung - tools/fetch_song.py: Audio laden und in Gesang/Begleitung trennen Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -602,6 +602,9 @@ impl App {
|
||||
cards.push(self.chord_card(chart, now_ms, live));
|
||||
}
|
||||
roll::draw_pitch_cards(ui, &cards);
|
||||
if self.show_grips && !chart.chords.is_empty() {
|
||||
super::grip_view::grip_strip(ui, chart, now_ms);
|
||||
}
|
||||
}
|
||||
|
||||
/// Bedienung der Probe: Start, Pause, Spulen, Zeitschieber.
|
||||
@ -1122,9 +1125,99 @@ impl App {
|
||||
self.chart_readout(ui, &roll_chart, readout_ms, live);
|
||||
self.chart_roll(ui, &roll_chart, clock, phase);
|
||||
self.mixer_controls(ui, &chart);
|
||||
self.grid_editor(ui, readout_ms);
|
||||
self.result_table(ui, &roll_chart);
|
||||
}
|
||||
|
||||
/// Takt-Raster einstellen: Tempo, Taktanfang verschieben, „Hier ist Schlag 1“, speichern.
|
||||
fn grid_editor(&mut self, ui: &mut egui::Ui, now_ms: f64) {
|
||||
use crate::chart::Grid;
|
||||
let Some(chart) = self.chart.as_mut().map(Arc::make_mut) else {
|
||||
return;
|
||||
};
|
||||
let mut grid = chart.effective_grid();
|
||||
let mut changed = false;
|
||||
let mut save = false;
|
||||
egui::CollapsingHeader::new("Takt-Raster (Taktstriche, Metronom)")
|
||||
.default_open(grid.is_none())
|
||||
.show(ui, |ui| {
|
||||
ui.checkbox(&mut self.show_grid, "Taktstriche im Notenfeld zeigen");
|
||||
let Some(g) = grid.as_mut() else {
|
||||
ui.label("Für diesen Song ist noch kein Tempo eingetragen.");
|
||||
if ui.button("Raster anlegen (100 BPM, Takt 4/4)").clicked() {
|
||||
grid = Some(Grid { bpm: 100.0, first_bar_ms: 0.0, beats_per_bar: 4 });
|
||||
changed = true;
|
||||
}
|
||||
return;
|
||||
};
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Tempo");
|
||||
changed |= ui
|
||||
.add(egui::DragValue::new(&mut g.bpm).range(30.0..=300.0).speed(0.1).suffix(" BPM").max_decimals(2))
|
||||
.on_hover_text("Songtempo in Schlägen pro Minute (ziehen oder doppelklicken und tippen)")
|
||||
.changed();
|
||||
ui.label("Takt");
|
||||
for n in [2u32, 3, 4, 6] {
|
||||
if ui.selectable_label(g.beats_per_bar == n, format!("{n}/4")).clicked() {
|
||||
g.beats_per_bar = n;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Taktanfang (Schlag 1) verschieben");
|
||||
let beat = g.beat_ms();
|
||||
for (label, delta) in [("◀◀ Schlag", -beat), ("◀ 10 ms", -10.0), ("10 ms ▶", 10.0), ("Schlag ▶▶", beat)] {
|
||||
if ui.button(label).clicked() {
|
||||
g.first_bar_ms += delta;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.horizontal(|ui| {
|
||||
if ui
|
||||
.button("Hier ist Schlag 1")
|
||||
.on_hover_text("Pausiere an einer Stelle, an der ein Takt beginnt (z. B. wenn der Akkord wechselt), und klicke hier")
|
||||
.clicked()
|
||||
{
|
||||
g.first_bar_ms = now_ms;
|
||||
changed = true;
|
||||
}
|
||||
ui.label(format!("aktuell {:.0} ms", g.first_bar_ms));
|
||||
if self.grid_dirty && super::gear::accent_button(ui, "Raster speichern", 14.0, true).clicked() {
|
||||
save = true;
|
||||
}
|
||||
});
|
||||
ui.label(
|
||||
egui::RichText::new("Tipp: Metronom einschalten und hören, ob der betonte Klick mit dem Takt der Musik übereinstimmt.")
|
||||
.weak(),
|
||||
);
|
||||
});
|
||||
if changed {
|
||||
chart.grid = grid;
|
||||
self.grid_dirty = true;
|
||||
}
|
||||
if save && let Some(g) = chart.grid {
|
||||
let path = std::path::PathBuf::from(&self.chart_path_text);
|
||||
let res = std::fs::read_to_string(&path)
|
||||
.map_err(|e| format!("{}: {e}", path.display()))
|
||||
.and_then(|t| {
|
||||
crate::import::strum::add_to_toml(&t, &g, chart.strum.as_ref())
|
||||
.map_err(|e| format!("{e:#}"))
|
||||
})
|
||||
.and_then(|out| {
|
||||
std::fs::write(&path, out).map_err(|e| format!("{}: {e}", path.display()))
|
||||
});
|
||||
match res {
|
||||
Ok(()) => {
|
||||
self.grid_dirty = false;
|
||||
self.messages.push("Raster im Chart gespeichert.".into());
|
||||
}
|
||||
Err(e) => self.messages.push(format!("Speichern fehlgeschlagen: {e}")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn chart_roll(
|
||||
&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
@ -1164,6 +1257,16 @@ impl App {
|
||||
original: &original,
|
||||
chords: if self.show_chords { &chart.chords } else { &[] },
|
||||
chord_flats: crate::import::chords::prefer_flats(&chart.chords),
|
||||
grid: if self.show_grid {
|
||||
chart.effective_grid()
|
||||
} else {
|
||||
None
|
||||
},
|
||||
extra_below_px: if self.show_grips && !chart.chords.is_empty() {
|
||||
super::grip_view::STRIP_H + 6.0
|
||||
} else {
|
||||
0.0
|
||||
},
|
||||
},
|
||||
&self.config.ui,
|
||||
);
|
||||
@ -1198,6 +1301,8 @@ impl App {
|
||||
.on_hover_text("Den Original-Gesang zur Musik mithören");
|
||||
toggle(ui, &mut self.show_chords, "Akkorde", !chart.chords.is_empty())
|
||||
.on_hover_text("Akkorde der Begleitung über dem Notenfeld und als Karte zeigen");
|
||||
toggle(ui, &mut self.show_grips, "Gitarrengriffe", !chart.chords.is_empty())
|
||||
.on_hover_text("Griffbild des aktuellen und des nächsten Akkords zeigen");
|
||||
toggle(ui, &mut self.show_original, "Original-Kurve", true)
|
||||
.on_hover_text("Die Kurve des Original-Sängers im Notenfeld zeigen");
|
||||
self.metronome_compact(ui);
|
||||
@ -1249,6 +1354,9 @@ pub(super) struct RollData<'a> {
|
||||
/// Akkorde der Begleitung (leer = ausgeblendet) und Schreibweise mit Been.
|
||||
pub chords: &'a [crate::chart::ChordSpan],
|
||||
pub chord_flats: bool,
|
||||
pub grid: Option<crate::chart::Grid>,
|
||||
/// Zusätzliche Höhe unter dem Notenfeld, die für andere Elemente frei bleibt.
|
||||
pub extra_below_px: f32,
|
||||
}
|
||||
|
||||
pub(super) fn draw_chart_roll(ui: &mut egui::Ui, d: &RollData<'_>, ui_cfg: &UiConfig) {
|
||||
@ -1261,6 +1369,8 @@ pub(super) fn draw_chart_roll(ui: &mut egui::Ui, d: &RollData<'_>, ui_cfg: &UiCo
|
||||
original,
|
||||
chords,
|
||||
chord_flats,
|
||||
grid,
|
||||
extra_below_px,
|
||||
} = *d;
|
||||
// Oktavgefaltet auf die jeweilige Zielnote anzeigen, wenn das Scoring es ebenfalls tut.
|
||||
let mut segs = roll::segments(curve.iter());
|
||||
@ -1277,7 +1387,7 @@ pub(super) fn draw_chart_roll(ui: &mut egui::Ui, d: &RollData<'_>, ui_cfg: &UiCo
|
||||
let top_pad = if chords.is_empty() { 0.0 } else { 1.5 };
|
||||
let center = (lo + hi) as f32 / 2.0 + top_pad / 2.0;
|
||||
let win = ui.ctx().content_rect().height();
|
||||
let h = (win - CHART_BELOW_PX).max(200.0);
|
||||
let h = (win - CHART_BELOW_PX - extra_below_px).max(200.0);
|
||||
let (rect, _) =
|
||||
ui.allocate_exact_size(egui::vec2(ui.available_width(), h), egui::Sense::hover());
|
||||
let vp = roll::Viewport {
|
||||
@ -1293,6 +1403,7 @@ pub(super) fn draw_chart_roll(ui: &mut egui::Ui, d: &RollData<'_>, ui_cfg: &UiCo
|
||||
original,
|
||||
chords,
|
||||
chord_flats,
|
||||
grid,
|
||||
now_ms,
|
||||
result,
|
||||
};
|
||||
|
||||
212
src/ui/grip_view.rs
Normal file
212
src/ui/grip_view.rs
Normal file
@ -0,0 +1,212 @@
|
||||
//! Gitarrengriff-Diagramme und Strumming-Anzeige.
|
||||
|
||||
use crate::chart::{NoteChart, Strum};
|
||||
use crate::guitar::{Grip, grip};
|
||||
use crate::import::chords::{display_chord, prefer_flats};
|
||||
use eframe::egui::{self, Align2, Color32, FontId, Rect, Stroke, pos2, vec2};
|
||||
|
||||
use super::gear::AMBER;
|
||||
|
||||
pub const STRIP_H: f32 = 124.0;
|
||||
const FRETS_SHOWN: u8 = 4;
|
||||
|
||||
/// Zeichnet ein Griffbrett-Diagramm in `rect` (Name oben; ×/○ über den Saiten; Punkte; Barré-Balken).
|
||||
pub fn draw_grip(painter: &egui::Painter, rect: Rect, label: &str, g: &Grip, active: bool) {
|
||||
let col = if active {
|
||||
AMBER
|
||||
} else {
|
||||
Color32::from_gray(150)
|
||||
};
|
||||
painter.text(
|
||||
pos2(rect.center().x, rect.top() + 9.0),
|
||||
Align2::CENTER_CENTER,
|
||||
label,
|
||||
FontId::proportional(16.0),
|
||||
col,
|
||||
);
|
||||
let board = Rect::from_min_max(
|
||||
pos2(rect.left() + 18.0, rect.top() + 36.0),
|
||||
pos2(rect.right() - 18.0, rect.bottom() - 6.0),
|
||||
);
|
||||
let sx = |s: usize| board.left() + board.width() * s as f32 / 5.0;
|
||||
let fy = |f: f32| board.top() + board.height() * f / f32::from(FRETS_SHOWN);
|
||||
let line = Stroke::new(1.0, Color32::from_gray(120));
|
||||
let base = g.base_fret();
|
||||
// Sattel (dick) oder Bundnummer.
|
||||
if base == 1 {
|
||||
painter.line_segment(
|
||||
[
|
||||
pos2(board.left(), board.top()),
|
||||
pos2(board.right(), board.top()),
|
||||
],
|
||||
Stroke::new(3.0, col),
|
||||
);
|
||||
} else {
|
||||
painter.line_segment(
|
||||
[
|
||||
pos2(board.left(), board.top()),
|
||||
pos2(board.right(), board.top()),
|
||||
],
|
||||
line,
|
||||
);
|
||||
painter.text(
|
||||
pos2(board.right() + 4.0, fy(0.5)),
|
||||
Align2::LEFT_CENTER,
|
||||
format!("{base}"),
|
||||
FontId::proportional(11.0),
|
||||
Color32::from_gray(190),
|
||||
);
|
||||
}
|
||||
for f in 1..=FRETS_SHOWN {
|
||||
painter.line_segment(
|
||||
[
|
||||
pos2(board.left(), fy(f32::from(f))),
|
||||
pos2(board.right(), fy(f32::from(f))),
|
||||
],
|
||||
line,
|
||||
);
|
||||
}
|
||||
for s in 0..6 {
|
||||
painter.line_segment(
|
||||
[pos2(sx(s), board.top()), pos2(sx(s), board.bottom())],
|
||||
line,
|
||||
);
|
||||
}
|
||||
let cell_y = |fret: u8| fy(f32::from(fret - base) + 0.5);
|
||||
if let Some((fret, a, b)) = g.barre() {
|
||||
let r = Rect::from_min_max(
|
||||
pos2(sx(a) - 5.0, cell_y(fret) - 5.0),
|
||||
pos2(sx(b) + 5.0, cell_y(fret) + 5.0),
|
||||
);
|
||||
painter.rect_filled(r, 5.0, col);
|
||||
}
|
||||
for (s, f) in g.frets.iter().enumerate() {
|
||||
match *f {
|
||||
None => {
|
||||
painter.text(
|
||||
pos2(sx(s), board.top() - 9.0),
|
||||
Align2::CENTER_CENTER,
|
||||
"×",
|
||||
FontId::proportional(13.0),
|
||||
Color32::from_gray(150),
|
||||
);
|
||||
}
|
||||
Some(0) => {
|
||||
painter.circle_stroke(
|
||||
pos2(sx(s), board.top() - 9.0),
|
||||
4.0,
|
||||
Stroke::new(1.2, Color32::from_gray(190)),
|
||||
);
|
||||
}
|
||||
Some(fret) => {
|
||||
painter.circle_filled(pos2(sx(s), cell_y(fret)), 5.5, col);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Streifen „Gitarre“: aktueller und nächster Griff, rechts das Strumming-Muster (falls bekannt).
|
||||
pub fn grip_strip(ui: &mut egui::Ui, chart: &NoteChart, now_ms: f64) {
|
||||
let (rect, _) =
|
||||
ui.allocate_exact_size(vec2(ui.available_width(), STRIP_H), egui::Sense::hover());
|
||||
let painter = ui.painter_at(rect);
|
||||
painter.rect_filled(rect, 6.0, Color32::from_rgb(24, 24, 26));
|
||||
painter.rect_stroke(
|
||||
rect,
|
||||
6.0,
|
||||
Stroke::new(1.0, Color32::from_gray(60)),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
let flats = prefer_flats(&chart.chords);
|
||||
let cur = chart
|
||||
.chord_at(now_ms)
|
||||
.map(|i| chart.chords[i].name.as_str());
|
||||
let next = chart.next_chord_after(now_ms, cur).map(|c| c.name.as_str());
|
||||
let mut x = rect.left() + 8.0;
|
||||
for (name, active) in [(cur, true), (next, false)] {
|
||||
let cell = Rect::from_min_size(pos2(x, rect.top() + 2.0), vec2(104.0, STRIP_H - 4.0));
|
||||
if let Some(n) = name {
|
||||
let label = if active {
|
||||
display_chord(n, flats)
|
||||
} else {
|
||||
format!("dann {}", display_chord(n, flats))
|
||||
};
|
||||
if let Some(g) = grip(n) {
|
||||
draw_grip(&painter, cell, &label, &g, active);
|
||||
}
|
||||
}
|
||||
x += 112.0;
|
||||
}
|
||||
if let Some(st) = &chart.strum {
|
||||
draw_strum(
|
||||
&painter,
|
||||
Rect::from_min_max(
|
||||
pos2(x + 16.0, rect.top() + 6.0),
|
||||
rect.right_bottom() - vec2(8.0, 6.0),
|
||||
),
|
||||
st,
|
||||
chart.strum_slot(now_ms).map(|s| s.0),
|
||||
);
|
||||
} else {
|
||||
painter.text(
|
||||
pos2(x + 16.0, rect.center().y),
|
||||
Align2::LEFT_CENTER,
|
||||
"Strumming: kein sicheres Muster erkannt",
|
||||
FontId::proportional(13.0),
|
||||
Color32::from_gray(120),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Muster als Reihe von acht Feldern („1 & 2 & 3 & 4 &“) mit ▼ (Abschlag) und ▲ (Aufschlag).
|
||||
fn draw_strum(painter: &egui::Painter, rect: Rect, st: &Strum, slot: Option<usize>) {
|
||||
painter.text(
|
||||
rect.left_top(),
|
||||
Align2::LEFT_TOP,
|
||||
"Strumming · Muster aus dem Mix geschätzt",
|
||||
FontId::proportional(12.0),
|
||||
Color32::from_gray(150),
|
||||
);
|
||||
let w = ((rect.width()) / 8.0).min(46.0);
|
||||
let top = rect.top() + 22.0;
|
||||
for (i, ch) in st.pattern.chars().enumerate().take(8) {
|
||||
let cell = Rect::from_min_size(pos2(rect.left() + i as f32 * w, top), vec2(w - 4.0, 70.0));
|
||||
let now = slot == Some(i);
|
||||
painter.rect_filled(
|
||||
cell,
|
||||
4.0,
|
||||
if now {
|
||||
Color32::from_rgb(70, 52, 18)
|
||||
} else {
|
||||
Color32::from_rgb(34, 34, 38)
|
||||
},
|
||||
);
|
||||
if now {
|
||||
painter.rect_stroke(cell, 4.0, Stroke::new(1.5, AMBER), egui::StrokeKind::Inside);
|
||||
}
|
||||
let count = if i % 2 == 0 {
|
||||
format!("{}", i / 2 + 1)
|
||||
} else {
|
||||
"&".into()
|
||||
};
|
||||
painter.text(
|
||||
pos2(cell.center().x, cell.top() + 12.0),
|
||||
Align2::CENTER_CENTER,
|
||||
count,
|
||||
FontId::proportional(13.0),
|
||||
Color32::from_gray(160),
|
||||
);
|
||||
let (glyph, c) = match ch {
|
||||
'D' => ("▼", AMBER),
|
||||
'U' => ("▲", Color32::from_rgb(110, 190, 230)),
|
||||
_ => ("·", Color32::from_gray(80)),
|
||||
};
|
||||
painter.text(
|
||||
pos2(cell.center().x, cell.center().y + 12.0),
|
||||
Align2::CENTER_CENTER,
|
||||
glyph,
|
||||
FontId::proportional(24.0),
|
||||
c,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -54,24 +54,29 @@ pub(super) fn flash_level(elapsed_s: f32) -> f32 {
|
||||
impl App {
|
||||
/// Tempo und Synchronität des Metronoms: Im Tab „Singen“ gibt ein Chart mit Tempo (`bpm`) den Takt vor und
|
||||
/// das Metronom läuft mit der Wiedergabe (inkl. Einzähler); sonst gilt das eigene Tempo, frei laufend.
|
||||
pub(super) fn effective_metronome(&self) -> (f32, bool) {
|
||||
let chart_bpm = (self.mode == Mode::Chart)
|
||||
.then(|| self.chart.as_ref().and_then(|c| c.bpm))
|
||||
pub(super) fn effective_metronome(&self) -> (f32, bool, f32) {
|
||||
let grid = (self.mode == Mode::Chart)
|
||||
.then(|| self.chart.as_ref().and_then(|c| c.effective_grid()))
|
||||
.flatten();
|
||||
let chart_bpm = grid.map(|g| g.bpm);
|
||||
let playing = self
|
||||
.session
|
||||
.as_ref()
|
||||
.is_some_and(|s| s.phase == crate::session::Phase::Running && !s.is_paused())
|
||||
|| self.practice.as_ref().is_some_and(|p| p.playing);
|
||||
match chart_bpm {
|
||||
Some(b) => (b as f32, playing),
|
||||
None => (self.metro.bpm, false),
|
||||
Some(b) => (
|
||||
b as f32,
|
||||
playing,
|
||||
grid.map_or(0.0, |g| g.first_bar_ms as f32),
|
||||
),
|
||||
None => (self.metro.bpm, false, 0.0),
|
||||
}
|
||||
}
|
||||
|
||||
/// Jedes Bild: Parameter an die Engine, LED-Zustand aus dem Klickzähler (bzw. der Anzeige-Uhr ohne Audio).
|
||||
pub(super) fn apply_metronome(&mut self) {
|
||||
let (bpm, sync) = self.effective_metronome();
|
||||
let (bpm, sync, offset) = self.effective_metronome();
|
||||
if let Some(e) = &self.engine {
|
||||
let s = &e.shared;
|
||||
s.met_on.store(self.metro.on, Ordering::Relaxed);
|
||||
@ -79,6 +84,7 @@ impl App {
|
||||
s.met_beats.store(self.metro.beats, Ordering::Relaxed);
|
||||
store_f32(&s.met_gain, self.metro.volume);
|
||||
s.met_sync.store(sync, Ordering::Relaxed);
|
||||
store_f32(&s.met_offset, offset);
|
||||
let count = s.met_count.load(Ordering::Relaxed);
|
||||
if count != self.metro.seen {
|
||||
self.metro.seen = count;
|
||||
@ -144,10 +150,14 @@ impl App {
|
||||
/// Großes Metronom-Gerät für die Stimmanzeige.
|
||||
pub(super) fn metronome_panel(&mut self, ui: &mut egui::Ui) {
|
||||
let (bpm_now, synced_to_song) = {
|
||||
let (b, _) = self.effective_metronome();
|
||||
let (b, _, _) = self.effective_metronome();
|
||||
(
|
||||
b,
|
||||
self.mode == Mode::Chart && self.chart.as_ref().is_some_and(|c| c.bpm.is_some()),
|
||||
self.mode == Mode::Chart
|
||||
&& self
|
||||
.chart
|
||||
.as_ref()
|
||||
.is_some_and(|c| c.effective_grid().is_some()),
|
||||
)
|
||||
};
|
||||
panel(ui, "Metronom", |ui| {
|
||||
@ -235,7 +245,7 @@ impl App {
|
||||
|
||||
/// Kompakte Fassung für das Mischpult im Tab „Singen“: Schalter, Lautstärke, Tempo, Schlag-LEDs.
|
||||
pub(super) fn metronome_compact(&mut self, ui: &mut egui::Ui) {
|
||||
let (bpm_now, _) = self.effective_metronome();
|
||||
let (bpm_now, _, _) = self.effective_metronome();
|
||||
let synced = self.chart.as_ref().is_some_and(|c| c.bpm.is_some());
|
||||
ui.horizontal(|ui| {
|
||||
toggle(ui, &mut self.metro.on, "Metronom", true)
|
||||
@ -298,27 +308,27 @@ mod tests {
|
||||
a.chart = Some(chart_with_bpm(Some(100.0)));
|
||||
// Stimmanzeige: eigenes Tempo, nie synchron.
|
||||
a.mode = Mode::Tuner;
|
||||
assert_eq!(a.effective_metronome(), (90.0, false));
|
||||
assert_eq!(a.effective_metronome(), (90.0, false, 0.0));
|
||||
// Singen: Songtempo; synchron erst bei laufender Wiedergabe (Probe).
|
||||
a.mode = Mode::Chart;
|
||||
assert_eq!(a.effective_metronome(), (100.0, false));
|
||||
assert_eq!(a.effective_metronome(), (100.0, false, 0.0));
|
||||
a.practice = Some(crate::ui::chart_view::Practice {
|
||||
playing: true,
|
||||
pos_ms: 0.0,
|
||||
});
|
||||
assert_eq!(a.effective_metronome(), (100.0, true));
|
||||
assert_eq!(a.effective_metronome(), (100.0, true, 0.0));
|
||||
a.practice = Some(crate::ui::chart_view::Practice {
|
||||
playing: false,
|
||||
pos_ms: 0.0,
|
||||
});
|
||||
assert_eq!(
|
||||
a.effective_metronome(),
|
||||
(100.0, false),
|
||||
(100.0, false, 0.0),
|
||||
"in der Pause frei laufend"
|
||||
);
|
||||
// Chart ohne Tempo: eigenes Tempo.
|
||||
a.chart = Some(chart_with_bpm(None));
|
||||
assert_eq!(a.effective_metronome(), (90.0, false));
|
||||
assert_eq!(a.effective_metronome(), (90.0, false, 0.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
mod calib_view;
|
||||
mod chart_view;
|
||||
mod gear;
|
||||
mod grip_view;
|
||||
mod home_view;
|
||||
mod metro_view;
|
||||
mod review_view;
|
||||
@ -120,6 +121,12 @@ pub struct App {
|
||||
show_original: bool,
|
||||
/// Akkordleiste und Akkordkarte anzeigen.
|
||||
show_chords: bool,
|
||||
/// Gitarrengriffe und Strumming-Streifen anzeigen.
|
||||
show_grips: bool,
|
||||
/// Taktstriche im Notenfeld anzeigen.
|
||||
show_grid: bool,
|
||||
/// Raster wurde verändert und noch nicht ins Chart gespeichert.
|
||||
grid_dirty: bool,
|
||||
calib_wav: std::path::PathBuf,
|
||||
config_path: std::path::PathBuf,
|
||||
config: Config,
|
||||
@ -188,6 +195,9 @@ impl App {
|
||||
original: None,
|
||||
show_original: true,
|
||||
show_chords: true,
|
||||
show_grips: true,
|
||||
show_grid: true,
|
||||
grid_dirty: false,
|
||||
calib_wav: calib_view::default_wav_path(),
|
||||
config_path: Config::path(),
|
||||
sample_rate_text: config
|
||||
|
||||
@ -233,6 +233,12 @@ impl App {
|
||||
&[]
|
||||
},
|
||||
chord_flats: crate::import::chords::prefer_flats(&st.record.chart.chords),
|
||||
grid: if self.show_grid {
|
||||
st.record.chart.effective_grid()
|
||||
} else {
|
||||
None
|
||||
},
|
||||
extra_below_px: 0.0,
|
||||
},
|
||||
&self.config.ui,
|
||||
);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Piano-Roll-Ansicht: scrollende Tonhöhenkurve. Abbildung und Segmentierung sind rein und getestet.
|
||||
|
||||
use crate::chart::{ChordSpan, NoteChart, NoteKind};
|
||||
use crate::chart::{ChordSpan, Grid, NoteChart, NoteKind};
|
||||
use crate::config::UiConfig;
|
||||
use crate::pitch::{HistoryPoint, note_name};
|
||||
use crate::score::ChartScore;
|
||||
@ -297,6 +297,8 @@ pub struct ChartOverlay<'a> {
|
||||
/// Akkordleiste (leer = ausgeblendet) und ob mit Been geschrieben wird.
|
||||
pub chords: &'a [ChordSpan],
|
||||
pub chord_flats: bool,
|
||||
/// Taktraster für Taktstriche und Zählzeiten (None = ohne).
|
||||
pub grid: Option<Grid>,
|
||||
pub now_ms: f64,
|
||||
pub result: Option<&'a ChartScore>,
|
||||
}
|
||||
@ -384,6 +386,7 @@ pub fn draw(
|
||||
}
|
||||
|
||||
if let Some(o) = overlay {
|
||||
draw_grid_lines(&painter, vp, o);
|
||||
draw_chord_lane(&painter, vp, o);
|
||||
draw_notes(&painter, vp, o);
|
||||
for seg in o.original {
|
||||
@ -470,6 +473,39 @@ fn score_color(total: f32) -> Color32 {
|
||||
Color32::from_rgb((220.0 - 130.0 * t) as u8, (70.0 + 140.0 * t) as u8, 90)
|
||||
}
|
||||
|
||||
/// Taktstriche (kräftig, mit Taktnummer unten) und Zählzeiten (schwach) hinter den Noten.
|
||||
fn draw_grid_lines(painter: &egui::Painter, vp: &Viewport, o: &ChartOverlay<'_>) {
|
||||
let Some(g) = o.grid else { return };
|
||||
let (t_left, t_right) = (vp.t_now + vp.lead_s - vp.window_s, vp.t_now + vp.lead_s);
|
||||
for (ms, beat, bar) in g.beats_between(t_left * 1000.0, t_right * 1000.0) {
|
||||
let x = vp.x(ms / 1000.0);
|
||||
if x < vp.rect.left() || x > vp.rect.right() {
|
||||
continue;
|
||||
}
|
||||
let top = vp.rect.top();
|
||||
if beat == 0 {
|
||||
painter.line_segment(
|
||||
[pos2(x, top), pos2(x, vp.rect.bottom())],
|
||||
Stroke::new(1.6, Color32::from_white_alpha(70)),
|
||||
);
|
||||
if bar >= 1 {
|
||||
painter.text(
|
||||
pos2(x + 4.0, vp.rect.bottom() - 4.0),
|
||||
Align2::LEFT_BOTTOM,
|
||||
format!("{bar}"),
|
||||
FontId::proportional(12.0),
|
||||
Color32::from_white_alpha(130),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
painter.line_segment(
|
||||
[pos2(x, top), pos2(x, vp.rect.bottom())],
|
||||
Stroke::new(1.0, Color32::from_white_alpha(22)),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Akkordleiste am oberen Rand: ein Feld je Akkord, der gerade klingende ist hervorgehoben.
|
||||
fn draw_chord_lane(painter: &egui::Painter, vp: &Viewport, o: &ChartOverlay<'_>) {
|
||||
const H: f32 = 22.0;
|
||||
|
||||
Reference in New Issue
Block a user