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

wavread with subrange of step >1 gives wrong result #78

Open
baggepinnen opened this issue Aug 8, 2019 · 4 comments
Open

wavread with subrange of step >1 gives wrong result #78

baggepinnen opened this issue Aug 8, 2019 · 4 comments

Comments

@baggepinnen
Copy link
Contributor

baggepinnen commented Aug 8, 2019

See the following example, where I have overloaded getindex on a LazyWAVFile to do wavread(path, format="native", ind)

julia> f[1:10] # Correct
10-element Array{Int16,1}:
 -15
  -8
  -4
 -19
  -3
  -4
 -12
  -2
 -17
  -4

julia> f[1:2:10] # Incorrect, but no error message
5-element Array{Int16,1}:
 -15
  -8
  -4
 -19
  -3

julia> f[collect(1:2:10)] # If range is collected to an array, result is correct
5-element Array{Int16,1}:
 -15
  -4
  -3
 -12
 -17
@dancasimiro
Copy link
Owner

How many channels are in the WAV file?

@baggepinnen
Copy link
Contributor Author

Single channel

@mgkuhn
Copy link
Contributor

mgkuhn commented Aug 1, 2020

The wavread docstring now says:

  • subrange controls which samples are returned.
    The default (:) returns all samples in the file.
    Passing an integer N (or equivalently the range 1:N) returns
    the first N samples of each channel.
    Passing a unitrange I:J returns length(I:J) consecutive
    samples from each channel, starting with the I-th sample.

There is no support for StepRange.

We could assert subrange::Union{Colon, Real, UnitRange{<:Real}} if you want a compiler error.

@mgkuhn
Copy link
Contributor

mgkuhn commented Aug 23, 2020

While testing a patch for this issue, I stumbled over JuliaLang/julia#37169

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

3 participants