commit
ee6a9aab8a
4 changed files with 13 additions and 11 deletions
|
|
@ -18,7 +18,7 @@ thiserror = "1.0.2"
|
|||
anyhow = "1.0.12"
|
||||
hound = "3.4"
|
||||
ringbuf = "0.2"
|
||||
clap = { version = "2.33.3", default-features = false }
|
||||
clap = { version = "3", default-features = false, features = ["std"] }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = { version = "0.3", features = ["audiosessiontypes", "audioclient", "coml2api", "combaseapi", "debug", "devpkey", "handleapi", "ksmedia", "mmdeviceapi", "objbase", "profileapi", "std", "synchapi", "winbase", "winuser"] }
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ extern crate anyhow;
|
|||
extern crate clap;
|
||||
extern crate cpal;
|
||||
|
||||
use clap::arg;
|
||||
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -17,12 +18,12 @@ struct Opt {
|
|||
|
||||
impl Opt {
|
||||
fn from_args() -> Self {
|
||||
let app = clap::App::new("beep").arg_from_usage("[DEVICE] 'The audio device to use'");
|
||||
let app = clap::App::new("beep").arg(arg!([DEVICE] "The audio device to use"));
|
||||
#[cfg(all(
|
||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
||||
feature = "jack"
|
||||
))]
|
||||
let app = app.arg_from_usage("-j, --jack 'Use the JACK host");
|
||||
let app = app.arg(arg!(-j --jack "Use the JACK host"));
|
||||
let matches = app.get_matches();
|
||||
let device = matches.value_of("DEVICE").unwrap_or("default").to_string();
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ extern crate cpal;
|
|||
extern crate ringbuf;
|
||||
|
||||
use anyhow::Context;
|
||||
use clap::arg;
|
||||
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||
use ringbuf::RingBuffer;
|
||||
|
||||
|
|
@ -31,17 +32,16 @@ struct Opt {
|
|||
impl Opt {
|
||||
fn from_args() -> anyhow::Result<Self> {
|
||||
let app = clap::App::new("beep")
|
||||
.arg_from_usage(
|
||||
"-l, --latency [DELAY_MS] 'Specify the delay between input and output [default: 150]'",
|
||||
)
|
||||
.arg_from_usage("[IN] 'The input audio device to use'")
|
||||
.arg_from_usage("[OUT] 'The output audio device to use'");
|
||||
.arg(arg!(
|
||||
-l --latency [DELAY_MS] "Specify the delay between input and output [default: 150]"))
|
||||
.arg(arg!([IN] "The input audio device to use"))
|
||||
.arg(arg!([OUT] "The output audio device to use"));
|
||||
|
||||
#[cfg(all(
|
||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
||||
feature = "jack"
|
||||
))]
|
||||
let app = app.arg_from_usage("-j, --jack 'Use the JACK host");
|
||||
let app = app.arg(arg!(-j --jack "Use the JACK host"));
|
||||
let matches = app.get_matches();
|
||||
let latency: f32 = matches
|
||||
.value_of("latency")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ extern crate clap;
|
|||
extern crate cpal;
|
||||
extern crate hound;
|
||||
|
||||
use clap::arg;
|
||||
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||
use std::fs::File;
|
||||
use std::io::BufWriter;
|
||||
|
|
@ -25,12 +26,12 @@ struct Opt {
|
|||
|
||||
impl Opt {
|
||||
fn from_args() -> Self {
|
||||
let app = clap::App::new("beep").arg_from_usage("[DEVICE] 'The audio device to use'");
|
||||
let app = clap::App::new("beep").arg(arg!([DEVICE] "The audio device to use"));
|
||||
#[cfg(all(
|
||||
any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd"),
|
||||
feature = "jack"
|
||||
))]
|
||||
let app = app.arg_from_usage("-j, --jack 'Use the JACK host");
|
||||
let app = app.arg(arg!(-j --jack "Use the JACK host"));
|
||||
let matches = app.get_matches();
|
||||
let device = matches.value_of("DEVICE").unwrap_or("default").to_string();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue