JuliaAudio-LibsndFile Help needed

Hey guys,I am exploring the audio library LibSndFile.jl and WAV.jl and when writing a julia script,I wanted the info printed after load(filename) as a string(can be done by redirect stdout i think)…or better if I can access those details about channels,frames,frame rate,duration and sample rate in some different and better manner…

Hi, welcome to the community.

It’s better to “quote” your text like I do (see PSA thread on it how; and in generl to get help):

julia> using FileIO: load, save, loadstreaming, savestreaming
julia> import LibSndFile
julia> snd = load("dev/GR/examples/Monty_Python.wav");  # the ; suppresses REPL output

julia> display(snd) # you can do this at any time, see help for display, but it's implemented by show, that you can invoke like this:
julia> show(open("myfile", "w"), "text/plain", s)  # not the best way, just showing possible

help?> snd


  data       :: Array{FixedPointNumbers.Fixed{Int16,15},2}  # there must be a way to extract the "2"
  samplerate :: Float64

julia> length(snd)

julia> s.samplerate  # I'm not sure this is the preferred way

I tried LibSndFile in Julia 1.5 and got an error so used in Julia 1.3 (that version is no longer official, and the package seems to require it for some reason). You may want to use WAV.jl if those are the only kind of files you need, then it has other benefits.

In general, you cannot assume that display output goes to stdout (unlike print(x) or show(x) ). For example, display(x) may open up a separate window with an image.

1 Like

Thank You @Palli,My issue has now been resolved and using WAV.jl now for now