Skip to content

Commit 940240f

Browse files
committed
[add] README to showcase how to use the tool.
1 parent 07bd48c commit 940240f

2 files changed

Lines changed: 117 additions & 1 deletion

File tree

tools/lambda_audio/README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# lambda-audio
2+
3+
`lambda-audio` is a small CLI tool for inspecting and playing sound files using
4+
the `lambda` audio APIs.
5+
6+
Scope
7+
- Load sound files into `lambda::audio::SoundBuffer`.
8+
- Print decoded metadata (sample rate, channels, duration).
9+
- Render a small ASCII waveform preview.
10+
- Play the decoded audio via the default output device.
11+
12+
## Usage
13+
14+
From the repository root:
15+
16+
```bash
17+
cargo run -p lambda-audio-tool -- <command> [path]
18+
```
19+
20+
Commands
21+
- `info <path>`: decode and print metadata.
22+
- `view <path>`: decode, print metadata, and show an ASCII waveform preview.
23+
- `play <path>`: decode, print metadata, and play through the default output
24+
device.
25+
- `list-devices`: list available output devices (platform-dependent).
26+
27+
Supported file types
28+
- `.wav`
29+
- `.ogg` / `.oga` (Vorbis)
30+
31+
## Examples (slash fixture)
32+
33+
The repository includes an OGG Vorbis fixture at:
34+
`crates/lambda-rs-platform/assets/audio/slash_vorbis_stereo_48000.ogg`.
35+
36+
### `info`
37+
38+
```bash
39+
cargo run -p lambda-audio-tool -- info \
40+
crates/lambda-rs-platform/assets/audio/slash_vorbis_stereo_48000.ogg
41+
```
42+
43+
Example output:
44+
45+
```text
46+
path: crates/lambda-rs-platform/assets/audio/slash_vorbis_stereo_48000.ogg
47+
sample_rate: 48000
48+
channels: 2
49+
frames: 53824
50+
samples: 107648
51+
duration_seconds: 1.121
52+
```
53+
54+
### `view`
55+
56+
```bash
57+
cargo run -p lambda-audio-tool -- view \
58+
crates/lambda-rs-platform/assets/audio/slash_vorbis_stereo_48000.ogg
59+
```
60+
61+
Example output:
62+
63+
```text
64+
path: crates/lambda-rs-platform/assets/audio/slash_vorbis_stereo_48000.ogg
65+
sample_rate: 48000
66+
channels: 2
67+
frames: 53824
68+
samples: 107648
69+
duration_seconds: 1.121
70+
71+
###
72+
#####
73+
######
74+
######
75+
######
76+
######## #
77+
#############
78+
#################
79+
###########################
80+
```
81+
82+
### `play`
83+
84+
```bash
85+
cargo run -p lambda-audio-tool -- play \
86+
crates/lambda-rs-platform/assets/audio/slash_vorbis_stereo_48000.ogg
87+
```
88+
89+
Example output (audio plays, then the process exits):
90+
91+
```text
92+
path: crates/lambda-rs-platform/assets/audio/slash_vorbis_stereo_48000.ogg
93+
sample_rate: 48000
94+
channels: 2
95+
frames: 53824
96+
samples: 107648
97+
duration_seconds: 1.121
98+
```
99+
100+
### `list-devices`
101+
102+
```bash
103+
cargo run -p lambda-audio-tool -- list-devices
104+
```
105+
106+
Example output (varies by machine and environment):
107+
108+
```text
109+
no output devices found
110+
```

tools/lambda_audio/src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ use lambda::audio::{
2121

2222
fn main() {
2323
let mut args = std::env::args();
24-
let program_name = args.next().unwrap_or_else(|| "lambda-audio".to_string());
24+
let raw_program_name =
25+
args.next().unwrap_or_else(|| "lambda-audio".to_string());
26+
let program_name = Path::new(&raw_program_name)
27+
.file_name()
28+
.and_then(|value| value.to_str())
29+
.unwrap_or(raw_program_name.as_str())
30+
.to_string();
2531

2632
let command = args.next().unwrap_or_else(|| "help".to_string());
2733

0 commit comments

Comments
 (0)