1660580474
A Julia interface to the sqlite library.
The package is registered in the General registry and so can be installed with ] add SQLite
.
The package is tested against Julia 1.0
and nightly
on Linux, OS X, and Windows.
Contributions are very welcome, as are feature requests and suggestions. Please open an issue if you encounter any problems or would just like to ask a question.
Author: JuliaDatabases
Source Code: https://github.com/JuliaDatabases/SQLite.jl
License: View license
1660580474
A Julia interface to the sqlite library.
The package is registered in the General registry and so can be installed with ] add SQLite
.
The package is tested against Julia 1.0
and nightly
on Linux, OS X, and Windows.
Contributions are very welcome, as are feature requests and suggestions. Please open an issue if you encounter any problems or would just like to ask a question.
Author: JuliaDatabases
Source Code: https://github.com/JuliaDatabases/SQLite.jl
License: View license
1665265800
Basic bindings to libopus
to encode/decode Opus streams. Opus is a low-latency yet high-quality audio codec with an impressive set of features and very simple API. Note that a common surprise with Opus is that it supports a very limited set of samplerates. Do yourself a favor and just resample any audio (with, for example, a polyphase resampler from DSP.jl
) you have to 48 KHz before encoding.
Basic usage is to use load()
and save()
to read/write Opus streams to/from file paths, IO streams, etc., but the real fun to be had is in an IJulia notebook with OpusArrays
. These thin wrapper objects contain a show()
implementation allowing you to output raw audio as Opus to a reasonably modern browser. To try it out, put the following in an IJulia notebook:
using Opus
# Create a seconds worth of 440Hz
t = linspace(0,1,48000)
audio = sin(2*π*440*t)
z = OpusArray(audio)
Author: Staticfloat
Source Code: https://github.com/staticfloat/Opus.jl
License: View license
1665538320
Julia wrapper for the GNU Scientific Library (GSL), for Julia v1.0+. Currently uses GSL v2.7.
The library tries to provide Julia interfaces to all the functions, types and symbols defined in the GSL documentation.
gsl_
prefix, e.g. sf_legendre_Pl
and vector_alloc
.gsl_vector
, gsl_root_fdfsolver_newton
and GSL_SUCCESS
.GSL_CONST_*
can be found under the namespace GSL.Const
, e.g. GSL.Const.MKSA_ANGSTROM
.Some functions have a secondary wrapper on top of the GSL interface, to make Julia usage more convenient, for example by allocating the output array. The low-level C interface to GSL can still be accessed under the namespace GSL.C
. Some examples of functions that are different in the low-level interface:
GSL.strerror(gsl_errno) -> String
GSL.C.strerror(gsl_errno) -> Ptr{Cchar}
and
GSL.sf_legendre_array(norm, lmax, x) -> Array{Float64}
GSL.C.sf_legendre_array(norm, lmax, x, result_array) -> Cint
Parts of GSL are not interfaced to, since they provide functionality already existing in Julia. These are functions with prefixes gsl_spmatrix_
, gsl_splinalg_
, gsl_spblas_
, gsl_eigen_
, gsl_sort
, gsl_blas_
, cblas_
, gsl_fft_
, and gsl_linalg_
. In addition, interfaces to gsl_bst_
functions are currently missing.
See examples in examples/ and tests test/ for more examples.
# Direct call
sf_legendre_P3(0.5)
# Output: -0.4375
# With result struct that stores value and error:
sf_legendre_P3_e(0.5)
# Output: gsl_sf_result_struct(-0.4375, 3.3306690738754696e-16)
# Low-level call with result struct as argument:
result = gsl_sf_result(0,0)
GSL.C.sf_legendre_P3_e(0.5, result)
# Output: GSL_SUCCESS
# result = gsl_sf_result_struct(-0.4375, 3.3306690738754696e-16)
x = 0.5
lmax = 4
result = sf_legendre_array(GSL_SF_LEGENDRE_SPHARM, lmax, x)
# Equivalent using low-level interface:
n = sf_legendre_array_n(lmax)
result = Array{Float64}(undef, n)
GSL.C.sf_legendre_array(GSL_SF_LEGENDRE_SPHARM, lmax, x, result)
f = x -> x^5+1
df = x -> 5*x^4
fdf = @gsl_function_fdf(f, df)
solver = root_fdfsolver_alloc(gsl_root_fdfsolver_newton)
root_fdfsolver_set(solver, fdf, -2)
while abs(f(root_fdfsolver_root(solver))) > 1e-10
root_fdfsolver_iterate(solver)
end
println("x = ", root_fdfsolver_root(solver))
# Output: x = -1.0000000000104232
Extra functionality defined in this package:
hypergeom
and hypergeom_e
for the hypergeometric functions.@gsl_function
, @gsl_function_fdf
, @gsl_multiroot_function
and @gsl_multiroot_function_fdf
that are used for packaging Julia functions so that they can be passed to GSL.wrap_gsl_vector
and wrap_gsl_matrix
that return a Julia array or matrix pointing to the data in a gsl_vector
or gsl_matrix
.In addition, some effort has been put into giving most types and functions proper docstrings, e.g.
help?> GSL.wavelet_free
wavelet_free(w) -> Cvoid
C signature: void gsl_wavelet_free (gsl_wavelet * w)
GSL documentation:
void gsl_wavelet_free (gsl_wavelet * w)
–––––––––––––––––––––––––––––––––––––––––
│ This function frees the wavelet object w.
help?> GSL.gsl_wavelet
mutable struct gsl_wavelet
type::Ptr{gsl_wavelet_type}
h1::Ptr{Cdouble}
g1::Ptr{Cdouble}
h2::Ptr{Cdouble}
g2::Ptr{Cdouble}
nc::Csize_t
offset::Csize_t
end
GSL documentation:
gsl_wavelet
–––––––––––––
│ This structure contains the filter coefficients defining the wavelet and any associated offset parameters.
Author: JuliaMath
Source Code: https://github.com/JuliaMath/GSL.jl
License: View license
1666085100
A package for dense and sparse distributed linear algebra and optimization. The underlying functionality is provided by the C++ library Elemental written originally by Jack Poulson and now maintained by LLNL.
The package is installed with Pkg.add("Elemental")
. For Julia versions 1.3 and later, Elemental uses the binaries provided by BinaryBuilder, which are linked against the MPI (mpich) provided through BinaryBuilder.
Each of these examples should be run in a separate Julia session.
This example runs on a single processor, and initializes MPI under the hood. However, explicit use of MPI.jl is not required in this case, compared to the other examples below.
julia> using LinearAlgebra, Elemental
julia> A = Elemental.Matrix(Float64)
0x0 Elemental.Matrix{Float64}
julia> Elemental.gaussian!(A, 100, 80);
julia> U, s, V = svd(A);
julia> convert(Matrix{Float64}, s)[1:10]
10-element Array{Float64,1}:
19.8989
18.2702
17.3665
17.0475
16.4513
16.3197
16.0989
15.8353
15.5947
15.5079
In this example, @mpi_do
has to be used to send the parallel instructions to all processors.
julia> using MPI, MPIClusterManagers, Distributed
julia> man = MPIManager(np = 4);
julia> addprocs(man);
julia> @everywhere using LinearAlgebra, Elemental
julia> @mpi_do man A = Elemental.DistMatrix(Float64);
julia> @mpi_do man Elemental.gaussian!(A, 1000, 800);
julia> @mpi_do man U, s, V = svd(A);
julia> @mpi_do man println(s[1])
From worker 5: 59.639990420817696
From worker 4: 59.639990420817696
From worker 2: 59.639990420817696
From worker 3: 59.639990420817696
This example is slightly different from the ones above in that it only calculates the singular values. However, it uses the DistributedArrays.jl package, and has a single thread of control. Note, we do not need to use @mpi_do
explicitly in this case.
julia> using MPI, MPIClusterManagers, Distributed
julia> man = MPIManager(np = 4);
julia> addprocs(man);
julia> using DistributedArrays, Elemental
julia> A = drandn(1000, 800);
julia> Elemental.svdvals(A)[1:5]
5-element SubArray{Float64,1,DistributedArrays.DArray{Float64,2,Array{Float64,2}},Tuple{UnitRange{Int64}},0}:
59.4649
59.1984
59.0309
58.7178
58.389
The iterative SVD algorithm is implemented in pure Julia, but the factorized matrix as well as the Lanczos vectors are stored as distributed matrices in Elemental. Notice, that TSVD.jl
doesn't depend on Elemental and is only using Elemental.jl
through generic function calls.
julia> using MPI, MPIClusterManagers, Distributed
julia> man = MPIManager(np = 4);
julia> addprocs(man);
julia> @mpi_do man using Elemental, TSVD, Random
julia> @mpi_do man A = Elemental.DistMatrix(Float64);
julia> @mpi_do man Elemental.gaussian!(A, 5000, 2000);
julia> @mpi_do man Random.seed!(123) # to avoid different initial vectors on the workers
julia> @mpi_do man r = tsvd(A, 5);
julia> @mpi_do man println(r[2][1:5])
From worker 3: [1069.6059089732858,115.44260091060129,115.08319164529792,114.87007788947226,114.48092348847719]
From worker 5: [1069.6059089732858,115.44260091060129,115.08319164529792,114.87007788947226,114.48092348847719]
From worker 2: [1069.6059089732858,115.44260091060129,115.08319164529792,114.87007788947226,114.48092348847719]
From worker 4: [1069.6059089732858,115.44260091060129,115.08319164529792,114.87007788947226,114.48092348847719]
@mpi_do man A = Elemental.DistMatrix(Float32)
@mpi_do man B = Elemental.DistMatrix(Float32)
@mpi_do man copyto!(A, Float32[2 1; 1 2])
@mpi_do man copyto!(B, Float32[4, 5])
Run distributed ridge regression ½|A*X-B|₂² + λ|X|₂²
@mpi_do man X = Elemental.ridge(A, B, 0f0)
Run distributed lasso regression ½|A*X-B|₂² + λ|X|₁
(only supported in recent versions of Elemental)
@mpi_do man X = Elemental.bpdn(A, B, 0.1f0)
Right now, the best way to see if a specific function is available, is to look through the source code. We are looking for help to prepare Documenter.jl based documentation for this package, and also to add more functionality from the Elemental library.
Author: JuliaParallel
Source Code: https://github.com/JuliaParallel/Elemental.jl
License: View license
1665258000
LibSndFile.jl is a wrapper for libsndfile, and supports a wide variety of file and sample formats. The package uses the FileIO load
and save
interface to automatically figure out the file type of the file to be opened, and the file contents are represented as a SampleBuf
. For streaming I/O we support FileIO's loadstreaming
and savestreaming
functions as well. The results are represented as SampleSource
(for reading), or SampleSink
(for writing) subtypes. These buffer and stream types are defined in the SampledSignals package.
Note that the load
/save
/etc. interface is exported from FileIO
, and LibSndFile
registers itself when the loaded, so you should bring in both packages. LibSndFile doesn't export any of its own names.
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
▆▅▆▆▆▆▆▅▆▆▆▇▇▇▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▇▆▆▆▆▆▇▆▇▆▇▆▆▆▅▆▆▆▆▆▆▅▆▆▅▆▅▆▆▇▇▇▇▆▆▆▆▆▆▇▆▆▆▆▆▆▆▇▆▇▂
Read 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 do
block syntax
data = loadstreaming("data/never_gonna_give_you_up.ogg") do f
read(f)
end
See 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.
libopus
and allows you to read and write Opus audio.libsndfile 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.
Author: JuliaAudio
Source Code: https://github.com/JuliaAudio/LibSndFile.jl
License: MIT license