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 pulse wave signal source functions to the signal module #151

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

Conversation

ifacodes
Copy link

@ifacodes ifacodes commented Feb 5, 2021

I added three pulse wave source functions to the dasp::signal module, that I felt would be useful.
I chose to add a selection 12.5%, 25%, and 75% duty cycle pulse waves.

My reasoning for this was due to those 3, (plus 50%, as standard Square Wave) being the most common in chiptune, and old gaming APU's.

Initially I tried extending the signal module in my own project, but came across some difficulty trying to implement it as a trait.

I added three pulse wave source functions to the dasp::signal module, that I felt would be useful.
I chose to add a selection 12.5%, 25%, and 75% duty cycle pulse waves.

My reasoning for this was due to those 3, (plus 50%, as standard Square Wave) being the most common in chiptune, and old gaming APU's.

Initially I tried extending the signal module in my own project, but came across some difficulty trying to implement it as a trait.
@ifacodes ifacodes closed this Feb 5, 2021
@ifacodes ifacodes reopened this Feb 5, 2021
@ifacodes
Copy link
Author

ifacodes commented Feb 5, 2021

turns out VS Code can be really finicky when mass changing the name of things :/

@jdanford
Copy link
Contributor

What about making the duty cycle a parameter? Seems unnecessarily restrictive to have multiple implementations with fixed values.

@mitchmindtree
Copy link
Member

mitchmindtree commented Aug 4, 2021

Thanks for the PR @ifamakes!

I'm also thinking a single type with a duty_cycle field might allow for a little more flexibility than having different types for each fraction, e.g. something along the lines of:

#[derive(Clone)]
pub struct Pulse<S> {
    phase: Phase<S>,
    duty_cycle: S,
}

and then have the implementation could look something like:

        if phase < self.duty_cycle {
            1.0
        } else {
            -1.0
        }

What are your thoughts?

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.

3 participants