Skip to content

Commit

Permalink
Organize tree module
Browse files Browse the repository at this point in the history
  • Loading branch information
AldaronLau committed May 5, 2024
1 parent b527e48 commit 64201f4
Show file tree
Hide file tree
Showing 38 changed files with 259 additions and 423 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
tc: [1.60.0, stable, beta, nightly]
tc: [beta, nightly]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
tc: [1.60.0]
tc: [1.70.0]
cc:
- aarch64-fuchsia
- aarch64-linux-android
Expand All @@ -52,7 +52,7 @@ jobs:
strategy:
matrix:
os: [macos-latest]
tc: [1.60.0]
tc: [1.70.0]
cc: [aarch64-apple-ios]
steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to `twang` will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://github.com/AldaronLau/semver).

## [0.10.0] - Unreleased
### Changed
- Bump MSRV to 1.70.0

## [0.9.0] - 2022-10-23
### Changed
- Bump MSRV to 1.60.0
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

[package]
name = "twang"
version = "0.9.0"
version = "0.10.0"
license = "Apache-2.0 OR BSL-1.0 OR MIT"
edition = "2021"
rust-version = "1.60.0"
rust-version = "1.70.0"
documentation = "https://docs.rs/twang"
homepage = "https://aldaronlau.github.io/twang"
repository = "https://github.com/AldaronLau/twang"
Expand All @@ -37,6 +37,7 @@ include = ["README.md", "Cargo.toml", "src/*", "build.rs"]
[dependencies]
libm = "0.2"
fon = "0.6"
traitful = "0.3"

[dev-dependencies]
splotch = "0.0.1"
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ Examples can be found in the [Documentation](https://docs.rs/twang) and the
examples folder.

## MSRV
The minimum supported Rust version of twang is 1.60.0. MSRV may only be updated
The minimum supported Rust version of twang is 1.70.0. MSRV may only be updated
when increasing the leftmost version number of twang.

## License
Copyright © 2018-2024 The Twang Contributors.

Licensed under either of
- Apache License, Version 2.0
([LICENSE_APACHE_2_0.txt](https://github.com/AldaronLau/twang/blob/stable/LICENSE_APACHE_2_0.txt) or
Expand Down
15 changes: 6 additions & 9 deletions examples/sine.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
use fon::{chan::Ch16, Audio, Frame};

Check warning on line 1 in examples/sine.rs

View workflow job for this annotation

GitHub Actions / test (windows-latest, nightly)

unused import: `Frame`
use twang::tree::{Synth, Sine, Hz, Wave};
use twang::tree::{osc::{Osc, Sine}, Synth, Wave};

mod wav;

// Define waveform
const fn waveform() -> impl Wave {
Sine(Hz(440.0))
}
//mod plot;

fn main() {
// Define waveform
let waveform = const { Osc(440.0).sine() };
// Initialize audio, and create synthesizer
let mut audio = Audio::<Ch16, 2>::with_silence(48_000, 48_000 * 5);
let mut synth = Synth::new(waveform());
let mut synth = Synth::new(waveform);

// Synthesize 5 seconds of audio
synth.stream(audio.sink(), &[]);

// Plot synthesized audio, and write to a WAV file
// plot::write(&audio);
//plot::write(&audio);
wav::write(audio, "sine.wav").expect("Failed to write WAV file");
}
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
# Currently using beta for tests, MSRV of examples is 1.79
channel = "beta"
11 changes: 2 additions & 9 deletions src/file.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

//! Twang synthesis file format
#![allow(warnings)]

use alloc::vec::Vec;
use fon::chan::{Ch32, Channel};
use fon::{Audio, Sink};
Expand Down
11 changes: 1 addition & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

//! Library for pure Rust advanced audio synthesis.
//!
//! Most audio DSP (Digital Signal Processing) libraries have a concept of an
Expand Down Expand Up @@ -105,8 +96,8 @@
variant_size_differences
)]

extern crate std; // FIXME: for debugging
extern crate alloc;
extern crate std; // FIXME: for debugging

mod math;
mod synth;
Expand Down
9 changes: 1 addition & 8 deletions src/math.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).
#![allow(warnings)]

use core::ops::Rem;

Expand Down
11 changes: 2 additions & 9 deletions src/next.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

//! # Twang File Format (Alpha)
//! The twang file format is a simple list of 32-bit instructions and data. The
//! file must begin with magic bytes: `\xFF\xFETwAnG\0`. Suggested file
Expand Down Expand Up @@ -117,6 +108,8 @@
//! ### 17 - MAX
//! - `index` points to input node.
#![allow(warnings)]

use fon::Sink;

use alloc::vec::Vec;
Expand Down
9 changes: 0 additions & 9 deletions src/noise.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

//! A collection of noise generators.
mod pink;
Expand Down
9 changes: 0 additions & 9 deletions src/noise/pink.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

use fon::chan::Ch16;

// Constants PFIRA and PFIRB
Expand Down
9 changes: 0 additions & 9 deletions src/noise/white.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

use core::num::Wrapping;
use fon::chan::Ch24;

Expand Down
11 changes: 2 additions & 9 deletions src/ops.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

//! A collection of auditory effects.
#![allow(warnings)]

mod clip;
mod far;
mod gain;
Expand Down
9 changes: 0 additions & 9 deletions src/ops/clip.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

#[cfg(not(test))]
use crate::math::Libm;

Expand Down
9 changes: 0 additions & 9 deletions src/ops/far.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

#[cfg(not(test))]
use crate::math::Libm;

Expand Down
9 changes: 0 additions & 9 deletions src/ops/gain.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

#[cfg(not(test))]
use crate::math::Libm;

Expand Down
9 changes: 0 additions & 9 deletions src/ops/gate.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

use fon::chan::{Ch32, Channel};

/// Noise gate.
Expand Down
9 changes: 0 additions & 9 deletions src/ops/invert.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

use fon::chan::Ch32;

/// Signal inverter.
Expand Down
9 changes: 0 additions & 9 deletions src/ops/limiter.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

#[cfg(not(test))]
use crate::math::Libm;

Expand Down
9 changes: 0 additions & 9 deletions src/ops/max.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

use fon::chan::{Ch32, Channel};

/// Maximum value of two samples (warning: -0.25 > -0.5, if you want maximum
Expand Down
9 changes: 0 additions & 9 deletions src/ops/min.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

use fon::chan::{Ch32, Channel};

/// Minimum value of two samples (warning: -0.5 < -0.25, if you want minimum
Expand Down
9 changes: 0 additions & 9 deletions src/ops/near.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

#[cfg(not(test))]
use crate::math::Libm;

Expand Down
9 changes: 0 additions & 9 deletions src/ops/room.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

use alloc::collections::VecDeque;
use fon::chan::{Ch32, Channel};

Expand Down
11 changes: 2 additions & 9 deletions src/osc.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

//! A collection of basic oscillators (wave generators).
#![allow(warnings)]

mod pulse;
mod sawtooth;
mod sine;
Expand Down
9 changes: 0 additions & 9 deletions src/osc/pulse.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
// Copyright © 2018-2022 The Twang Contributors.
//
// Licensed under any of:
// - Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// - Boost Software License, Version 1.0 (https://www.boost.org/LICENSE_1_0.txt)
// - MIT License (https://mit-license.org/)
// At your choosing (See accompanying files LICENSE_APACHE_2_0.txt,
// LICENSE_MIT.txt and LICENSE_BOOST_1_0.txt).

#[cfg(not(test))]
use crate::math::Libm;

Expand Down
Loading

0 comments on commit 64201f4

Please sign in to comment.