audiowaveform 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/COPYING +674 -0
- data/Cargo.lock +1108 -0
- data/Cargo.toml +28 -0
- data/README.md +255 -0
- data/bindings/ruby/CHANGELOG.md +29 -0
- data/bindings/ruby/Cargo.lock +621 -0
- data/bindings/ruby/Cargo.toml +8 -0
- data/bindings/ruby/README.md +193 -0
- data/bindings/ruby/ext/audiowaveform/Cargo.toml +20 -0
- data/bindings/ruby/ext/audiowaveform/build.rs +4 -0
- data/bindings/ruby/ext/audiowaveform/extconf.rb +6 -0
- data/bindings/ruby/ext/audiowaveform/src/lib.rs +239 -0
- data/bindings/ruby/lib/audiowaveform/version.rb +5 -0
- data/bindings/ruby/lib/audiowaveform.rb +131 -0
- data/crates/audiowaveform/Cargo.toml +73 -0
- data/crates/audiowaveform/examples/generate_from_pcm.rs +25 -0
- data/crates/audiowaveform/examples/generate_waveform.rs +18 -0
- data/crates/audiowaveform/examples/render_waveform.rs +18 -0
- data/crates/audiowaveform/examples/resample_waveform.rs +19 -0
- data/crates/audiowaveform/src/audio.rs +938 -0
- data/crates/audiowaveform/src/color.rs +201 -0
- data/crates/audiowaveform/src/error.rs +89 -0
- data/crates/audiowaveform/src/format.rs +215 -0
- data/crates/audiowaveform/src/lib.rs +79 -0
- data/crates/audiowaveform/src/render.rs +802 -0
- data/crates/audiowaveform/src/wav.rs +95 -0
- data/crates/audiowaveform/src/waveform.rs +790 -0
- data/crates/audiowaveform/tests/formats.rs +223 -0
- data/crates/audiowaveform/tests/generate.rs +233 -0
- data/crates/audiowaveform/tests/render.rs +263 -0
- data/crates/audiowaveform/tests/support/mod.rs +125 -0
- data/crates/audiowaveform/tests/wav.rs +54 -0
- data/crates/audiowaveform/tests/waveform_io.rs +255 -0
- data/crates/audiowaveform-cli/Cargo.toml +43 -0
- data/crates/audiowaveform-cli/src/main.rs +803 -0
- data/crates/audiowaveform-cli/tests/cli.rs +483 -0
- data/crates/audiowaveform-cli/tests/support/mod.rs +111 -0
- data/sig/audiowaveform.rbs +33 -0
- metadata +100 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
use std::env;
|
|
2
|
+
use std::f32::consts::PI;
|
|
3
|
+
|
|
4
|
+
use audiowaveform::{GenerateOptions, PcmAudio, WaveformFormat, generate_waveform_from_pcm};
|
|
5
|
+
|
|
6
|
+
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
7
|
+
let output = env::args()
|
|
8
|
+
.nth(1)
|
|
9
|
+
.unwrap_or_else(|| "pcm-output.json".to_string());
|
|
10
|
+
|
|
11
|
+
let sample_rate = 48_000_u32;
|
|
12
|
+
let frequency = 220.0_f32;
|
|
13
|
+
let frames = sample_rate as usize;
|
|
14
|
+
let mut samples = Vec::with_capacity(frames);
|
|
15
|
+
for frame in 0..frames {
|
|
16
|
+
let angle = (frame as f32 / sample_rate as f32) * frequency * PI * 2.0;
|
|
17
|
+
samples.push((angle.sin() * i16::MAX as f32 * 0.5) as i16);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let pcm = PcmAudio::new(sample_rate, 1, samples)?;
|
|
21
|
+
let waveform = generate_waveform_from_pcm(&pcm, &GenerateOptions::default())?;
|
|
22
|
+
waveform.save_to_path(output, Some(WaveformFormat::Json))?;
|
|
23
|
+
|
|
24
|
+
Ok(())
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
use std::env;
|
|
2
|
+
use std::fs::File;
|
|
3
|
+
|
|
4
|
+
use audiowaveform::{GenerateOptions, WaveformFormat, generate_waveform_from_path};
|
|
5
|
+
|
|
6
|
+
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
7
|
+
let mut args = env::args().skip(1);
|
|
8
|
+
let input = args
|
|
9
|
+
.next()
|
|
10
|
+
.unwrap_or_else(|| "fixtures/test_file_stereo.wav".to_string());
|
|
11
|
+
let output = args.next().unwrap_or_else(|| "output.dat".to_string());
|
|
12
|
+
|
|
13
|
+
let waveform = generate_waveform_from_path(&input, &GenerateOptions::default())?;
|
|
14
|
+
let output_file = File::create(output)?;
|
|
15
|
+
waveform.write_to_writer(output_file, WaveformFormat::Dat, None)?;
|
|
16
|
+
|
|
17
|
+
Ok(())
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
use std::env;
|
|
2
|
+
use std::fs::File;
|
|
3
|
+
|
|
4
|
+
use audiowaveform::{RenderOptions, Waveform, write_waveform_png};
|
|
5
|
+
|
|
6
|
+
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
7
|
+
let mut args = env::args().skip(1);
|
|
8
|
+
let input = args
|
|
9
|
+
.next()
|
|
10
|
+
.unwrap_or_else(|| "fixtures/test_file_stereo_8bit_64spp_wav.dat".to_string());
|
|
11
|
+
let output = args.next().unwrap_or_else(|| "output.png".to_string());
|
|
12
|
+
|
|
13
|
+
let waveform = Waveform::load_from_path(&input, None)?;
|
|
14
|
+
let output_file = File::create(output)?;
|
|
15
|
+
write_waveform_png(&waveform, &RenderOptions::default(), output_file)?;
|
|
16
|
+
|
|
17
|
+
Ok(())
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
use std::env;
|
|
2
|
+
use std::fs::File;
|
|
3
|
+
|
|
4
|
+
use audiowaveform::{ScaleSpec, Waveform, WaveformFormat};
|
|
5
|
+
|
|
6
|
+
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
7
|
+
let mut args = env::args().skip(1);
|
|
8
|
+
let input = args
|
|
9
|
+
.next()
|
|
10
|
+
.unwrap_or_else(|| "fixtures/test_file_stereo_8bit_64spp_wav.dat".to_string());
|
|
11
|
+
let output = args.next().unwrap_or_else(|| "resampled.dat".to_string());
|
|
12
|
+
|
|
13
|
+
let waveform = Waveform::load_from_path(&input, None)?;
|
|
14
|
+
let resampled = waveform.resample(ScaleSpec::SamplesPerPixel(128))?;
|
|
15
|
+
let output_file = File::create(output)?;
|
|
16
|
+
resampled.write_to_writer(output_file, WaveformFormat::Dat, None)?;
|
|
17
|
+
|
|
18
|
+
Ok(())
|
|
19
|
+
}
|