-
Notifications
You must be signed in to change notification settings - Fork 64
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
Change the Signal
trait to return Self::Frame
rather than Option<Self::Item>
#57
Conversation
I'm going to go ahead and merge this now as I'd like to make some progress that builds on this, but will give it a few more days before publishing. |
Sorry, I've been out of programming mode for a few days. Trying to wrap my brain around what exactly this API change entails. First, I fully support the semantics of Main question - why not use the default Second, more abstract concern - The I'll integrate all this into my existing projects as well, which use windowing and FFT analysis pretty heavily. |
Which types in particular would you like to see this for? It might be helpful if you could give an example of the ergonomic gain too.
I agree it would be nice add some benchmarks to the lib, although I'd be surprised if we could get much faster than the
I guess I'm not sure I understand why the current implementation would stop us from doing any of these things? E.g. if a user wants to cycle over a slice, they could do |
Ahh, I just realised I've been assuming that the I think we can avoid this issue by removing the |
@@ -169,6 +184,18 @@ impl<'a, F, W> Iterator for Windower<'a, F, W> | |||
} | |||
} | |||
|
|||
impl<S, W> Iterator for Windowed<S, W> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels suspicious to me. I pretty quickly got stuck in an infinite loop when I just called collect()
on a Windowed
signal in some existing code. I think I'd rather have API compilation breakage than silent code failure. Here's an example of my usage:
let bin = 2048;
for chunk in window::Windower::hanning(&vector[..], bin, 1024) {
// Why do we need to pass bin again, after we've already told the Window how long it should be?
let chunk_data: Vec<[f64; 1]> = chunk.take(bin).collect();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is a good point. I have a couple uncertainties with the window API atm, maybe I'll open another issue.
Right, although LLVM might optimize that away since I see your point that /// Plays a slice once, and then outputs F::equilibrium()
struct OneShot { ... }
/// Cycles a slice for eternity
struct Cycle { ... }
pub fn one_shot_from_slice( ... );
pub fn cycle_from_slice( ... );
signal::from_slice::<OneShot>(slice);
let one_shot: OneShot = signal::from_slice(slice);
let one_shot: OneShot = slice.into(); // if we impl From<&[S: Sample]> for OneShot
signal::from_slice::<Cycle>(slice); Unfortunately,
My mistake, sorry. First off, turns out I was thinking of another part of the library ( I'm still working through things, but somewhat gradually because there's silent breakage in the windowing functionality now that we have infinite signals. I'm wondering whether it makes sense to move away from using |
True true, the more I think about it and look at the
Hmmm I'm struggling to think of a more efficient implementation than this - do you have one in mind?
I can see where you're coming from. I'm happy to just remove the |
Sure, if it's not too much feature creep for you. Really, the As far as |
This publish includes: - Signal Map and ZipMap RustAudio#68 - impl Signal for Box<Signal> RustAudio#67 - Change Signal::next return type from Option<Frame> to Frame RustAudio#57 - Make `Bus` more memory efficient RustAudio#58
Closes #54.
cc @andrewcsmith would you mind reviewing this? The Signal changes affect quite a lot of the lib, but I think it turned out well. For now I must 💤
Non-sleepy Edit:
This also removes the need for the
Interpolator::is_exhausted
method and simplifies some of the Interpolator implementations now thatSignal
s are infinite.