mirror of
https://github.com/iluvcapra/bwavfile.git
synced 2025-12-31 08:50:44 +00:00
Goofing around with examples
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
//! TODO: Implement command-line interface
|
||||
|
||||
use std::f64;
|
||||
use std::io;
|
||||
use bwavfile::{WaveWriter, WaveFmt};
|
||||
|
||||
fn sine_wave(t: u64, amplitude : i32, wavelength : u32) -> i32 {
|
||||
@@ -88,7 +89,10 @@ impl ToneBurstSignal for Vec<ToneBurst> {
|
||||
}
|
||||
|
||||
|
||||
fn main() -> () {
|
||||
fn main() -> io::Result<()> {
|
||||
|
||||
let sample_rate = 48000;
|
||||
let bits_per_sample = 24;
|
||||
|
||||
// BLITS Tone signal format
|
||||
// From EBU Tech 3304 §4 - https://tech.ebu.ch/docs/tech/tech3304.pdf
|
||||
@@ -190,17 +194,11 @@ fn main() -> () {
|
||||
ToneBurst::Silence(200)
|
||||
];
|
||||
|
||||
|
||||
let sample_rate = 48000;
|
||||
let bits_per_sample = 24;
|
||||
|
||||
let length = [&left_channel_sequence, &right_channel_sequence,
|
||||
¢er_channel_sequence, &lfe_channel_sequence,
|
||||
&ls_channel_sequence, &rs_channel_sequence].iter()
|
||||
.map(|i| i.duration(sample_rate)).max().unwrap_or(0);
|
||||
|
||||
println!("Will generate tone of length {} frames", &length);
|
||||
|
||||
let frames = (0..=length).map(|frame| {
|
||||
(left_channel_sequence.signal(frame, sample_rate, bits_per_sample),
|
||||
right_channel_sequence.signal(frame, sample_rate, bits_per_sample),
|
||||
@@ -220,4 +218,5 @@ fn main() -> () {
|
||||
}
|
||||
fw.end().expect("Failed to close frame writer");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
//! wave-inter.rs
|
||||
//! (c) 2021 Jamie Hardt. All rights reserved.
|
||||
//!
|
||||
//! This program demonstrats combining several wave files into a single
|
||||
//! polyphonic wave file.
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//! wave-inter.rs
|
||||
//! (c) 2021 Jamie Hardt. All rights reserved.
|
||||
//!
|
||||
//! This program demonstrates combining several wave files into a single
|
||||
//! polyphonic wave file.
|
||||
|
||||
extern crate clap;
|
||||
|
||||
use std::io;
|
||||
use clap::{Arg, App};
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
let matches = App::new("wave-inter")
|
||||
.version("0.1")
|
||||
.author("Jamie Hardt")
|
||||
.about("Combine several wave files into a single polyphonic wave file.")
|
||||
.arg(Arg::with_name("OUTPUT")
|
||||
.long("output")
|
||||
.short("o")
|
||||
.help("Output file name. If absent, will be basename, minus any channel extension, of first INPUT.")
|
||||
)
|
||||
.arg(Arg::with_name("INPUT")
|
||||
.help("Input wave file")
|
||||
.required(true)
|
||||
.multiple(true)
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
println!("Command line opts: {:?}", matches);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user