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

sample rate of 48000 in streams #17

Open
m4b opened this issue Feb 5, 2022 · 3 comments
Open

sample rate of 48000 in streams #17

m4b opened this issue Feb 5, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@m4b
Copy link

m4b commented Feb 5, 2022

I'm hitting this assert here: https://docs.rs/twang/latest/src/twang/synth.rs.html#54

Is this intended? I have a sample rate of 44100 coming from default cpal config, is it a requirement the sample rate is 48000, if i want to do, e.g.:

        let mut audio = Audio::<Ch32, 1>::with_silence(self.sample_rate.0, nsamples);
        synth.stream(audio.sink());
@AldaronLau
Copy link
Collaborator

@m4b Currently, that's how it works (48000 only) but I'm starting to re-think that decision (it should work at any sample rate). In the meantime, fon::Stream can be used to resample the audio if it must be 44100.

@m4b
Copy link
Author

m4b commented Feb 5, 2022

Ah interesting; yea I can try resampling with Stream; just curious, what is the reason the sample rate is hardcoded?

@AldaronLau
Copy link
Collaborator

@m4b It was a simplification I did when changing the API. In the new twang, all of the oscillators are independent of each other and do not share state with the Synth, like they did in the previous version. The Synth used to store sample rate, and decide how much to move the frequency counter based on that. Now there's no frequency counter, so no way for the oscillators to know what the sample rate is, so I made them all assume 48000. I should be able to change it, once I figure out #16. There might be another way to support other sample rates before that, but it needs some thought.

@AldaronLau AldaronLau added the enhancement New feature or request label Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants