Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for offsetting the phase of a signal #183

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

viktaur
Copy link

@viktaur viktaur commented Feb 27, 2024

Hi, this PR introduces a new struct and a method to specify the initial phase of a signal, represented by a value between 0 and 1.

Example:

use dasp_signal::{self as signal, Signal};

fn main() {
    let step = signal::rate(4.0).const_hz(1.0).offset_phase(0.25);
    let mut phase = step.phase();
    assert_eq!(phase.next(), 0.25);
    assert_eq!(phase.next(), 0.5);
    assert_eq!(phase.next(), 0.75);
    assert_eq!(phase.next(), 0.0);
    assert_eq!(phase.next(), 0.25);
    assert_eq!(phase.next(), 0.5);
}

Feel free to comment on any design choices that could be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant