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

wavplay(y, fs) does not work #89

Closed
terasakisatoshi opened this issue Aug 29, 2020 · 11 comments · Fixed by #93
Closed

wavplay(y, fs) does not work #89

terasakisatoshi opened this issue Aug 29, 2020 · 11 comments · Fixed by #93

Comments

@terasakisatoshi
Copy link

I'm trying to this package by running an example written in README.md

using WAV
fs = 8e3
t = 0.0:1/fs:prevfloat(1.0)
f = 1e3
y = sin.(2pi * f * t) * 0.1
wavwrite(y, "example.wav", Fs=fs)

y, fs = wavread("example.wav")
y = sin.(2pi * 2f * t) * 0.1
wavappend(y, "example.wav")

y, fs = wavread("example.wav")
wavplay(y, fs)

However, wavplay(y, fs) does not work due to the following error

julia> wavplay(y, fs)
ERROR: MethodError: no method matching wavplay(::Array{Float64,2}, ::Float32)
Closest candidates are:
  wavplay(::Any) at /Users/terasakisatoshi/.julia/packages/WAV/T2P9V/src/WAV.jl:38
Stacktrace:
 [1] top-level scope at REPL[11]:1

Here is my environment:

julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 16
@EdoAlvarezR
Copy link

I'm having the same problem. It seems like the these lines under WAV.jl are not doing their job:

function wavplay end
wavplay(fname::AbstractString) = wavplay(wavread(fname)[1:2]...)
@static if Sys.islinux()
    include("wavplay-pulse.jl")
elseif Sys.isapple()
    include("wavplay-audioqueue.jl")
elseif Sys.iswindows()
    include("wavplay-win32.jl")
else
    wavplay(data, fs) = @warn "wavplay is not currently implemented on $(Sys.KERNEL)"
end

@EdoAlvarezR
Copy link

Turns out it is an issue with WAV v1.0.3. I solved it by removing the package and pulling the master:

] rm WAV
] add https://github.com/dancasimiro/WAV.jl

@terasakisatoshi
Copy link
Author

Thank you!

I look forward to the release of the new version. 1.0.4 😄

@mgkuhn
Copy link
Contributor

mgkuhn commented Oct 3, 2020

@dancasimiro Could you please tag the current main branch head as the v1.0.4 release? At the moment, the latest release tag is still v1.0.3, where wavplay() does not work at all on any currently supported Julia version.

@dancasimiro
Copy link
Owner

@mgkuhn I have attempted to tag v1.0.4. You can follow the progress at JuliaRegistries/General#22393

@mgkuhn
Copy link
Contributor

mgkuhn commented Oct 5, 2020

@dancasimiro In v1.0.3, Project.toml said

version = "1.0.3"

[compat]
FileIO = "≥ 0.2.0"
julia = "≥ 0.7.0"

but in the current main branch it says

version = "1.0.4"

[compat]
FileIO = "0.2, 1.4"
julia = "0.7, 1.5"

That has at least two problems:

  • If you make any changes to the [compat] section, I believe you will also have to change to version = "1.1.0", as this no longer counts as a “patch” under semantic versioning.
  • Did you really intend to say that Julia 1.0, 1.1, ..., 1.4, are not compatible?
  • The FileIO compatibility requirements look similarly odd (i.e., explicitly incompatible with FileIO 0.3.x–1.3.x).

See: https://julialang.github.io/Pkg.jl/v1/compatibility/ and in particular Behavior of versions with leading zeros.

On reflection, I now believe the changes (e.g., wavplay() works again, the way the documentation is formatted) are significant enough to count as a minor release, not as a (third-level increment) “patch”, therefore I would suggest to move to

version = "1.1.0"

The compatible Julia versions should probably be specified as

julia = "0.7, 1"

In fact, it is probably time to drop 0.7, as that hasn't been officially supported for a long time, i.e.

julia = "1"

is also fine.

I don't know anything about the actual compatibility requirements of FileIO, but I suspect you also meant to say something like

FileIO = "0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1"

and perhaps

FileIO = "1"

is also fine now?

Or just keep

[compat]
FileIO = "≥ 0.2.0"
julia = "≥ 0.7.0"

as it was. (As long as there is no breaking Julia 2 or FileIO 2 on the horizon to worry about.)

@mgkuhn
Copy link
Contributor

mgkuhn commented Oct 5, 2020

@dancasimiro Is deploying CompatHelper actually useful here? The compatibility requirements of WAV.jl seem extremely simple currently, so I don't understand what problems CompatHelper would solve here (rather than create!).

@mgkuhn mgkuhn mentioned this issue Oct 18, 2020
@mgkuhn
Copy link
Contributor

mgkuhn commented Oct 18, 2020

PR #93 is how I would suggest to proceed.

@mgkuhn
Copy link
Contributor

mgkuhn commented Oct 31, 2020

@dancasimiro Any chance you could merge PR #93 to make JuliaRegistrator happier and then tag/release v1.1.0?

(My students have to do a signal-processing exercise in the coming weeks where Julia+WAV.jl is one of the recommended platforms. The current master fixes all the problems that my students encountered last year with wavplay and the documentation in that exercise, so it would be great to get it released asap.)

@anandijain
Copy link

Small note for future people: if you are using julia and WAV.jl within the windows subsystem for linux (WSL) then wavplay fails with the following error. This may have been fixed in WSL v2, but at least for v1 it's broken.

shared memfd open() failed: Function not implemented
pa_simple_new failed

error(::String)@error.jl:33
wavplay(::Array{Float64,2}, ::Float32)@wavplay-pulse.jl:118
wavplay(::String)@WAV.jl:1075
top-level scope@Local: 1

@mgkuhn
Copy link
Contributor

mgkuhn commented Oct 31, 2020

[That should have been a new issue really]

Are you running pulseaudio there? Do other Linux audio applications work? Via pulseaudio or via other audio APIs?

If not, I would not have expected WAV.wavplay to work.

I'm no expert on the state of audio device access on WSL and WSL2 in general. From a quick web search, I gather that neither WSL or WSL2 have any access to an audio device, but people have succeeded in running PulseAudio on both WSL and Windows simultaneously and then configuring them to pass over the sound from one to the other via TCP: https://www.reddit.com/r/bashonubuntuonwindows/comments/hrn1lz/wsl_sound_through_pulseaudio_solved/

Based on that, I don't see what better WAV.jl could do than to be a PulseAudio client, which it already is.

P.S.: WSL[2] will probably always remain a horrendous hack. For the best experience with hardware I/O, I recommend to get a proper operating system, not stacks of kernel emulation layers or VMs.

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

Successfully merging a pull request may close this issue.

5 participants