File tree Expand file tree Collapse file tree 2 files changed +2
-36
lines changed Expand file tree Collapse file tree 2 files changed +2
-36
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ biquad.connect(&context.destination());
46
46
src . start ();
47
47
48
48
// enjoy listening
49
- loop { }
49
+ std :: thread :: sleep ( std :: time :: Duration :: from_secs ( 4 ));
50
50
```
51
51
52
52
Check out the [ docs] ( https://docs.rs/web-audio-api ) for more info.
Original file line number Diff line number Diff line change 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
- //! ```
1
+ #![ doc = include_str ! ( "../README.md" ) ]
36
2
37
3
#![ warn( rust_2018_idioms) ]
38
4
#![ warn( rust_2021_compatibility) ]
You can’t perform that action at this time.
0 commit comments