Fix and display metronome
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use clap::*;
|
||||
use clap::*;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(name = "fcb-looper")]
|
||||
@@ -6,11 +6,10 @@
|
||||
pub struct Args {
|
||||
#[command(subcommand)]
|
||||
pub command: Option<Command>,
|
||||
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum Command {
|
||||
Run,
|
||||
Collect,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,4 @@ pub async fn collect_dir_output(dir: &str, output: &str) {
|
||||
.output()
|
||||
.await
|
||||
.expect("Failed to collect audio_engine sources");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,9 @@ use clap::Parser;
|
||||
async fn main() {
|
||||
let args = args::Args::parse();
|
||||
|
||||
workspace::change_to_workspace_dir().await.expect("Failed to change to workspace directory");
|
||||
workspace::change_to_workspace_dir()
|
||||
.await
|
||||
.expect("Failed to change to workspace directory");
|
||||
|
||||
match args.command {
|
||||
Some(args::Command::Run) | None => {
|
||||
@@ -19,4 +21,4 @@ async fn main() {
|
||||
collect::collect().await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,16 @@ pub async fn run() {
|
||||
// Set up signal handling for graceful shutdown
|
||||
let cleanup_handles = vec![
|
||||
qjackctl_handle.clone(),
|
||||
audio_engine_handle.clone(),
|
||||
audio_engine_handle.clone(),
|
||||
gui_handle.clone(),
|
||||
simulator_handle.clone(),
|
||||
];
|
||||
let cleanup_token = cancel_token.clone();
|
||||
|
||||
|
||||
tokio::spawn(async move {
|
||||
tokio::signal::ctrl_c().await.expect("Failed to listen for ctrl+c");
|
||||
tokio::signal::ctrl_c()
|
||||
.await
|
||||
.expect("Failed to listen for ctrl+c");
|
||||
println!("Received Ctrl+C, shutting down...");
|
||||
cleanup_token.cancel();
|
||||
cleanup_processes(cleanup_handles).await;
|
||||
@@ -102,14 +104,18 @@ async fn cleanup_processes(handles: Vec<ProcessHandle>) {
|
||||
|
||||
async fn stop_jack_daemon() {
|
||||
println!("Stopping JACK daemon...");
|
||||
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
let (jack, args) = ("taskkill", vec!["/f", "/im", "jackd.exe"]);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
let (jack, args) = ("pkill", vec!["-f", "jackd"]);
|
||||
|
||||
Command::new(jack).args(args).output().await.expect("Failed to stop JACK daemon");
|
||||
Command::new(jack)
|
||||
.args(args)
|
||||
.output()
|
||||
.await
|
||||
.expect("Failed to stop JACK daemon");
|
||||
}
|
||||
|
||||
async fn spawn_qjackctl() -> Child {
|
||||
@@ -146,24 +152,14 @@ async fn spawn_audio_engine() -> Child {
|
||||
|
||||
async fn spawn_gui() -> Child {
|
||||
Command::new("cargo")
|
||||
.args([
|
||||
"run",
|
||||
"--release",
|
||||
"--bin",
|
||||
"gui",
|
||||
])
|
||||
.args(["run", "--release", "--bin", "gui"])
|
||||
.spawn()
|
||||
.expect("Could not start gui")
|
||||
}
|
||||
|
||||
async fn spawn_simulator() -> Child {
|
||||
Command::new("cargo")
|
||||
.args([
|
||||
"run",
|
||||
"--release",
|
||||
"--bin",
|
||||
"simulator",
|
||||
])
|
||||
.args(["run", "--release", "--bin", "simulator"])
|
||||
.spawn()
|
||||
.expect("Could not start simulator")
|
||||
}
|
||||
@@ -173,4 +169,4 @@ async fn kill_process(child: &mut Child, name: &str) {
|
||||
Ok(()) => println!("Killed {}", name),
|
||||
Err(e) => eprintln!("Failed to kill {}: {}", name, e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,20 +12,24 @@ pub async fn change_to_workspace_dir() -> Result<(), Box<dyn std::error::Error>>
|
||||
return Err(format!(
|
||||
"Failed to locate workspace: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
).into());
|
||||
)
|
||||
.into());
|
||||
}
|
||||
|
||||
let workspace_cargo_toml = String::from_utf8(output.stdout)?;
|
||||
let workspace_cargo_toml = workspace_cargo_toml.trim();
|
||||
|
||||
|
||||
// Get the directory containing Cargo.toml
|
||||
let workspace_dir = PathBuf::from(workspace_cargo_toml)
|
||||
.parent()
|
||||
.ok_or("Failed to get workspace directory")?
|
||||
.to_path_buf();
|
||||
|
||||
println!("Changing to workspace directory: {}", workspace_dir.display());
|
||||
println!(
|
||||
"Changing to workspace directory: {}",
|
||||
workspace_dir.display()
|
||||
);
|
||||
std::env::set_current_dir(&workspace_dir)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user