Passagen, Übungsmodus, Stimmfinder-Überarbeitung, Gerätedesign, Metronom und Akkorde
- Passagenwahl, Original-Kurve, Spulen/Üben und Pause - Startseite, Klartext-Oberfläche, Stimmfinder mit Stimmtyp-Vorschlag - Gerätedesign (Regler, Schalter, LED) und Metronom (frei/songsynchron, Tap) - Akkorderkennung aus der Begleitung, Akkordleiste und -karte - zweiter Song als Chart Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
45
src/main.rs
45
src/main.rs
@ -45,7 +45,7 @@ fn extract_cli(args: &[String]) -> Result<(), String> {
|
||||
cfg.import.set(k, *v)?;
|
||||
}
|
||||
let input = std::path::Path::new(input);
|
||||
let notes = match lyrics {
|
||||
let (notes, sections) = match lyrics {
|
||||
Some(path) => {
|
||||
let text = std::fs::read_to_string(&path).map_err(|e| format!("{path}: {e}"))?;
|
||||
let anchor_file = anchors
|
||||
@ -61,27 +61,51 @@ fn extract_cli(args: &[String]) -> Result<(), String> {
|
||||
)
|
||||
.map_err(|e| format!("{e:#}"))?;
|
||||
print!("{}", r.report);
|
||||
r.notes
|
||||
(r.notes, r.sections)
|
||||
}
|
||||
None => {
|
||||
let frames = import::analyze_file(input, &cfg.pitch).map_err(|e| format!("{e:#}"))?;
|
||||
import::segment_notes(&frames, &cfg.import)
|
||||
(import::segment_notes(&frames, &cfg.import), Vec::new())
|
||||
}
|
||||
};
|
||||
let chart = import::build_chart(
|
||||
let mut chart = import::build_chart(
|
||||
&title.unwrap_or_else(|| "Import".into()),
|
||||
notes,
|
||||
backing.map(Into::into),
|
||||
vocals.map(Into::into),
|
||||
);
|
||||
chart.sections = sections;
|
||||
let text = toml::to_string_pretty(&chart).map_err(|e| e.to_string())?;
|
||||
std::fs::write(&out, text).map_err(|e| format!("{out}: {e}"))?;
|
||||
println!("{out}: {}", import::summary(&chart));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `singtrainer chords <chart.toml> <begleitung.mp3>`: erkennt die Akkorde der Begleitmusik und schreibt sie in das Chart.
|
||||
fn chords_cli(args: &[String]) -> Result<(), String> {
|
||||
let [chart_path, audio] = args else {
|
||||
return Err("Aufruf: singtrainer chords <chart.toml> <begleitung>".into());
|
||||
};
|
||||
let cfg = config::Config::load();
|
||||
let (mono, rate) =
|
||||
audio::decode::load_mono(std::path::Path::new(audio)).map_err(|e| format!("{e:#}"))?;
|
||||
let spans = import::chords::detect(&mono, rate as f32, &cfg.chords);
|
||||
let text = std::fs::read_to_string(chart_path).map_err(|e| format!("{chart_path}: {e}"))?;
|
||||
let out = import::chords::add_to_toml(&text, &spans).map_err(|e| format!("{e:#}"))?;
|
||||
std::fs::write(chart_path, out).map_err(|e| format!("{chart_path}: {e}"))?;
|
||||
println!("{chart_path}: {}", import::chords::summary(&spans));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> eframe::Result {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
if args.first().map(String::as_str) == Some("chords") {
|
||||
if let Err(e) = chords_cli(&args[1..]) {
|
||||
eprintln!("Fehler: {e}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
if args.first().map(String::as_str) == Some("extract") {
|
||||
if let Err(e) = extract_cli(&args[1..]) {
|
||||
eprintln!("Fehler: {e}");
|
||||
@ -95,13 +119,22 @@ fn main() -> eframe::Result {
|
||||
let autostart = std::env::args().any(|a| a == "--autostart");
|
||||
// `--review-latest`: öffnet die neueste gespeicherte Session im Review.
|
||||
let review_latest = std::env::args().any(|a| a == "--review-latest");
|
||||
// `--chart <datei>`: lädt dieses Chart beim Start und öffnet den Chart-Tab.
|
||||
let chart_arg = std::env::args().skip_while(|a| a != "--chart").nth(1);
|
||||
// Entwicklungshilfe: `--tab <name>` und `--wizard <schritt>` öffnen gezielt eine Ansicht.
|
||||
let tab_arg = std::env::args().skip_while(|a| a != "--tab").nth(1);
|
||||
let wizard_arg = std::env::args().skip_while(|a| a != "--wizard").nth(1);
|
||||
let options = eframe::NativeOptions {
|
||||
viewport: eframe::egui::ViewportBuilder::default().with_inner_size([1000.0, 760.0]),
|
||||
viewport: eframe::egui::ViewportBuilder::default().with_inner_size([1100.0, 940.0]),
|
||||
..Default::default()
|
||||
};
|
||||
eframe::run_native(
|
||||
"Singtrainer",
|
||||
options,
|
||||
Box::new(move |_cc| Ok(Box::new(ui::App::new(sim, autostart, review_latest)))),
|
||||
Box::new(move |_cc| {
|
||||
let mut app = ui::App::new(sim, autostart, review_latest, chart_arg.clone());
|
||||
app.demo_view(tab_arg.as_deref(), wizard_arg.as_deref());
|
||||
Ok(Box::new(app))
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user