-
Notifications
You must be signed in to change notification settings - Fork 20
Add signal class and helper function #24
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
Conversation
What is supposed to happen when a function receives multiple signals with different sampling rates?
|
@trettberg Both behaviors are possible choices, we can decide once we actually have a function that takes more than one signal. We could even add an argument that specifies if resampling should be used or not. |
My line of thought was something like: EDIT: |
@trettberg I agree with your edited comment. The sampling rate could be implicit (only handled by However, a signal class could be created without explicit sampling rate and an explicit sampling rate could be used without a signal class. As I said, IMHO the sampling rate should always be explicit, but there could still be a better alternative for the signal class proposed here. Are there any counter-proposals? |
From what i've tried so far, this works nicely for keeping track of processing delays. A suggestion for later: |
I'm not sure if overloading the operators is the right way to go ... but I also don't know if it will be even needed, we'll see about that in the future. I don't think it's a good idea to build too many features into the We should definitely consider using free functions instead of methods and overloaded operators. somedata = ...
sig1 = somedata, 44100
sig1 = sfs.util.as_signal(sig1)
sig2 = sig1 + ([1], 44100, 0.007) I don't think this is the way we want to go, but it is definitely a possibility .... somedata = ...
sig1 = somedata, 44100
sig2 = sfs.util.add_signals(sig1, ([1], 44100, 0.007)) I think this is better, but it would probably be even better not having to add signals at all. Since the main feature of the proposed signal class is the delay, we should probably rename it to something more specific? |
I switched to Any comments? Suggestions for improvements? |
Superposition of signals is necessary e.g. to generate driving functions for data-based SFS. I do not suggest to stuff arbitrary functionality in the class but to get the math right:
These signals live in the same (C x N)-dimensional vector space, for some N large enough. Compare to the sparse matrix classes which (of course) do matrix arithmetics. |
OK, we might need signal superposition at some point, but is it something that has influence on the current PR? I think we can decide later if we use operator overloading or not. But the decision if we use integer or fractional delays indeed has a lot of influence here. The relation to sparse matrices is very interesting, but as you say, it's only valid for integer delays. And even then, there is the difference that we need a way to align the signal data on the time axis. Another detail is that our signals (currently) cannot have "holes". If you add a signal that is non-zero in the first second to another signal that only plays in the 10th second, you'll have to fill the time in-between with zeros.
No, it's not. Another possibility would be to use one delay value per channel instead of one global delay for all channels. What about that? But then we also might think about having numeric weights per channel instead of applying the weights destructively ... |
Go ahead!
Mathematically it's the same fractional delays (even with multiple sampling rates). I think we should stick with a simple
|
6a5197c
to
e7bceef
Compare
We should go ahead with the class and check its application in the toolbox. |
OK, I've merged it, thanks for all the comments! Of course this is not set in stone, we can still change any aspect of it ... |
For now, this is just a proof of concept.
Alternatives are very welcome.
And suggestions for improvements, too.
For now, there are no doc changes yet. I'll do that if we decide to go that way ...