1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! # Broad Audio Engine (BAE)
//! 
//! [![Latest version](https://img.shields.io/crates/v/bae_rs.svg)](https://crates.io/crates/bae_rs "bae_rs on crates.io")
//! [![Documentation](https://docs.rs/bae_rs/badge.svg)](https://docs.rs/bae_rs "bae_rs documentation")
//! [![License](https://img.shields.io/crates/l/bae_rs.svg)](https://github.com/ChylerDev/BAE#license "bae_rs license")
//! 
//! The Broad Audio Engine presents the ability to process sounds and audio
//! files for applications like video games and DAWs.
//! 
//! This engine was born out of a frustration with other audio systems for their
//! lack of readable code that results from the large monolithic structures and
//! architecture-specific systems they contain. I do understand why
//! structures and systems are the way they are, but nevertheless they are a
//! pain to work with in most cases. With this audio engine, I intend to create
//! an interface that is well documented and has minimal time to start writing
//! code and calculate samples.
//! 
//! To get started, there is always the [documentation], but additionally I
//! recommend taking a look at the [`Generator`], [`Modifier`], and
//! [`SimpleSound`] structures to get you started. In the world of BAE, sources
//! of sound (e.g. simple sine, wav file, etc.) are called "Generators" and
//! filters (e.g. low pass, reverb, etc.) are called "Modifiers". There's no
//! particular reason for this naming convention other than I like them.
//! Utilizing the [`Generator`], [`Modifier`], and [`SimpleSound`] you can get
//! started with a simple system for generating your samples. In truth you could
//! get your samples from a [`Generator`] on its own, and that functionality is
//! allowed, but for more advanced sounds and systems you'll likely need a more
//! complex way of representing those systems. For that purpose there is the
//! [`Sound`] trait, giving the ability to operate many [`Generator`]s and
//! [`Modifier`]s as a single unit, as you might find with some digital
//! synthesizers.
//! 
//! [documentation]: https://docs.rs/bae_rs
//! [`Generator`]: generators/trait.Generator.html
//! [`Modifier`]: modifiers/trait.Modifier.html
//! [`Sound`]: sounds/trait.Sound.html
//! [`SimpleSound`]: sounds/simple_sound/struct.SimpleSound.html
//! 
//! ## Dependencies
//! 
//! * [`lazy_static`](https://crates.io/crates/lazy_static): For initializing
//! large arrays at run-time for some systems that use a wavetable.
//! * [`petgrah`](https://crates.io/crates/petgraph): For the graph structure
//! used by the [`ComplexSound`](sounds/complex_sound/struct.ComplexSound.html)
//! struct.
//! * [`rand`](https://crates.io/crates/rand): To generate white noise.
//! * [`wav`](https://crates.io/crates/wav): To read and write WAV files.
//! 
//! ## Future Expansion
//! 
//! In no particular order
//! 
//! * Generators:
//! * Modifiers:
//! * Features:
//!   * Side-chain (?)
//!   * FFT (use FFTW?)
//!   * Read/write multiple audio formats (not just WAV)
//! 
//! ## License
//! 
//! This library is licensed under the MIT license. The loud words can be found
//! [here](https://github.com/ChylerDev/BAE/blob/master/LICENSE)

#![warn(missing_docs)]

use std::vec::Vec;

/// Type to perform infrequent mathematical operations with when accuracy is needed.
pub type MathT = f64;
/// Type to calculate samples with.
pub type SampleT = f32;
/// Shorthand for a vector containing sample data.
pub type TrackT = Vec<SampleT>;

/// The sampling rate the engine is set to run at.
pub const SAMPLE_RATE:u64 = 48_000;
/// The inverse of the sampling rate for easy referencing and calculating.
pub const INV_SAMPLE_RATE:MathT = 1.0/(SAMPLE_RATE as MathT);

pub mod channels;
pub mod generators;
pub mod modifiers;
pub mod sounds;
pub mod sample_format;
pub mod utils;

pub use sample_format::*;