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

Use function call syntax for interpolated/unitful indexing with offsets #46

Open
ssfrr opened this issue Oct 24, 2018 · 2 comments
Open
Milestone

Comments

@ssfrr
Copy link
Collaborator

ssfrr commented Oct 24, 2018

Currently we use buf[...] indexing for everything, and guess the user's intent by whether they provide units or not. Another option would be to only use [...] for regular 1-based Array indexing, and use function call syntax (parentheses) to do sampling, so buf[0.5] is an error, but buf(0.5) would give you a value (subject to some interpolation rule, e.g. nearest, linear, cubic, etc.). By default buf(0) would be the beginning of the signal, but we could also have signals store their starting location (seconds or hz).

Things I like about this:

  1. parentheses notation is usually used for evaluating continuous functions, and square brackets for discrete.
  2. Currently we're not using function call syntax for anything
  3. storing the offset of the file allows us to do things like creating a beep with a certain offset, and adding that to a longer continuous noise signal, and having the beep be correctly located in the composite sound
  4. plotting regions of spectra make more sense.
  5. signals collected from different data sources can be more easily aligned (this was a big motivation for AxisArrays).

I've been tempted by the offset thing before, but was always put off by the fact that buf[1] would no longer be the first sample as people would expect. This way we can have both.

@mchitre
Copy link

mchitre commented Mar 18, 2020

Any plans to implement this?

@ssfrr
Copy link
Collaborator Author

ssfrr commented Mar 18, 2020

No concrete plans. I'm pretty swamped with other stuff at the moment and haven't had much time for open-source maintenance. I still like the idea though, so it'll probably happen eventually.

@ssfrr ssfrr added this to the v3.0 milestone Mar 20, 2020
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

No branches or pull requests

2 participants