Skip to content

Commit b69938a

Browse files
authored
Merge pull request #431 from orottier/feature/readme-and-docs
Unify README.md and crate docs
2 parents 80232b5 + 0d174bd commit b69938a

File tree

2 files changed

+3
-39
lines changed

2 files changed

+3
-39
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use it in desktop apps, command line utilities, headless execution, etc.
1818

1919
## Example usage
2020

21-
```rust
21+
```rust,no_run
2222
use web_audio_api::context::{AudioContext, BaseAudioContext};
2323
use web_audio_api::node::{AudioNode, AudioScheduledSourceNode};
2424
@@ -46,7 +46,7 @@ biquad.connect(&context.destination());
4646
src.start();
4747
4848
// enjoy listening
49-
loop { }
49+
std::thread::sleep(std::time::Duration::from_secs(4));
5050
```
5151

5252
Check out the [docs](https://docs.rs/web-audio-api) for more info.
@@ -59,7 +59,6 @@ deviations could not be avoided:
5959
- naming: snake_case instead of CamelCase
6060
- getters/setters methods instead of exposed attributes
6161
- introduced some namespacing
62-
- AudioWorklet functionality is provided in a more rust-friendly way
6362
- inheritance is modelled with traits
6463
- ...
6564

src/lib.rs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,4 @@
1-
//! A high-level API for processing and synthesizing audio.
2-
//!
3-
//! # Example
4-
//! ```no_run
5-
//! use std::fs::File;
6-
//! use web_audio_api::context::{BaseAudioContext, AudioContext};
7-
//! use web_audio_api::node::{AudioNode, AudioScheduledSourceNode};
8-
//!
9-
//! // set up AudioContext with optimized settings for your hardware
10-
//! let context = AudioContext::default();
11-
//!
12-
//! // create an audio buffer from a given file
13-
//! let file = File::open("samples/sample.wav").unwrap();
14-
//! let buffer = context.decode_audio_data_sync(file).unwrap();
15-
//!
16-
//! // play the buffer at given volume
17-
//! let volume = context.create_gain();
18-
//! volume.connect(&context.destination());
19-
//! volume.gain().set_value(0.5);
20-
//!
21-
//! let mut buffer_source = context.create_buffer_source();
22-
//! buffer_source.connect(&volume);
23-
//! buffer_source.set_buffer(buffer);
24-
//!
25-
//! // create oscillator branch
26-
//! let mut osc = context.create_oscillator();
27-
//! osc.connect(&context.destination());
28-
//!
29-
//! // start the sources
30-
//! buffer_source.start();
31-
//! osc.start();
32-
//!
33-
//! // enjoy listening
34-
//! std::thread::sleep(std::time::Duration::from_secs(4));
35-
//! ```
36-
1+
#![doc = include_str!("../README.md")]
372
#![warn(rust_2018_idioms)]
383
#![warn(rust_2021_compatibility)]
394
#![warn(clippy::missing_panics_doc)]

0 commit comments

Comments
 (0)