在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:JuliaAudio/LibSndFile.jl开源软件地址:https://github.com/JuliaAudio/LibSndFile.jl开源编程语言:Julia 100.0%开源软件介绍:LibSndFile.jlLibSndFile.jl is a wrapper for libsndfile, and supports a wide variety of file and sample formats. The package uses the FileIO Note that the julia> using FileIO: load, save, loadstreaming, savestreaming
julia> import LibSndFile
julia> load("audiofile.wav")
2938384-frame, 1-channel SampleBuf{FixedPointNumbers.Fixed{Int16,15}, 2}
66.63002267573697s sampled at 44100.0Hz
▆▅▆▆▆▆▆▅▆▆▆▇▇▇▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▇▆▆▆▆▆▇▆▇▆▇▆▆▆▅▆▆▆▆▆▆▅▆▆▅▆▅▆▆▇▇▇▇▆▆▆▆▆▆▇▆▆▆▆▆▆▆▇▆▇▂ ExamplesRead ogg file, write first 1024 samples of the first channel to new wav file x = load("myfile.ogg")
save("myfile_short.wav", x[1:1024]) Read file, write the first second of all channels to a new file x = load("myfile.ogg")
save("myfile_short.wav", x[0s..1s, :]) Read stereo file, write mono mix x = load("myfile.wav")
save("myfile_mono.wav", x[:, 1] + x[:, 2]) Plot the left channel x = load("myfile.wav")
plot(x[:, 1]) # plots with samples on the x axis
plot(domain(x), x[:, 1]) # plots with time on the x axis Plot the spectrum of the left channel x = load("myfile.wav")
f = fft(x) # returns a FrequencySampleBuf
fmin = 0Hz
fmax = 10000Hz
fs = Float32[float(f_i) for f_i in domain(f[fmin..fmax])]
plot(fs, abs.(f[fmin..fmax]).data, xlim=(fs[1],fs[end]), ylim=(0,20000)) Load a long file as a stream and plot the left channel from 2s to 3s stream = loadstreaming("myfile.ogg")
x = read(stream, 4s)[2s..3s, 1]
close(stream)
plot(domain(x), x) To handle closing the file automatically (including in the case of unexpected exceptions), we support the data = loadstreaming("data/never_gonna_give_you_up.ogg") do f
read(f)
end Supported FormatsSee the libsndfile homepage for details, but in summary it supports reading and writing:
Note not all file formats support all samplerates and bit depths. Currently LibSndFile.jl supports WAV, Ogg Vorbis, and FLAC files. Please file an issue if support for other formats would be useful. Related Packages
A Note on Licensinglibsndfile is licensed under the LGPL, which is very permissive providing that libsndfile is dynamically linked. LibSndFile.jl is licensed under the MIT license, allowing you to statically compile the wrapper into your Julia application. Remember that you must still abide by the terms of the libsndfile license when using this wrapper, in terms of whether libsndfile is statically or dynamically linked. Note that this is to the best of my understanding, but I am not an attorney and this should not be considered legal advice. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论