Sound overview
This page illustrates the Julia package Sound
.
This page comes from a single Julia file: 01-overview.jl
.
You can access the source code for such Julia documentation using the 'Edit on GitHub' link in the top right. You can view the corresponding notebook in nbviewer here: 01-overview.ipynb
, or open it in binder here: 01-overview.ipynb
.
Setup
Packages needed here.
using Sound
using SampledSignals: SampleBuf
using InteractiveUtils: versioninfo
Overview
The primary purpose of this package, at least initially, was to provide a simple way to hear audio signals in Julia.
S = 8192 # sampling rate in Hz
x = 0.7*cos.(2π*(1:S÷2)*440/S)
y = 0.8*sin.(2π*(1:S÷2)*660/S)
isinteractive() && sound(x, S) # monophonic
false
stereo:
isinteractive() && sound([x y], S)
false
scale to unit amplitude:
isinteractive() && soundsc([x y], S)
false
Using SampleBuf
may provide some convenience.
S = 8192 # sampling rate in Hz
x = 0.7 * cos.(2π*(1:S÷2)*440/S)
y = 0.8 * sin.(2π*(1:S÷2)*660/S)
sb = SampleBuf([x y], S) # stereo data
isinteractive() && sound(sb)
false
Reproducibility
This page was generated with the following version of Julia:
using InteractiveUtils: versioninfo
io = IOBuffer(); versioninfo(io); split(String(take!(io)), '\n')
12-element Vector{SubString{String}}:
"Julia Version 1.10.2"
"Commit bd47eca2c8a (2024-03-01 10:14 UTC)"
"Build Info:"
" Official https://julialang.org/ release"
"Platform Info:"
" OS: Linux (x86_64-linux-gnu)"
" CPU: 4 × AMD EPYC 7763 64-Core Processor"
" WORD_SIZE: 64"
" LIBM: libopenlibm"
" LLVM: libLLVM-15.0.7 (ORCJIT, znver3)"
"Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)"
""
And with the following package versions
import Pkg; Pkg.status()
Status `~/work/Sound.jl/Sound.jl/docs/Project.toml`
[717857b8] DSP v0.7.9
[e30172f5] Documenter v1.4.0
[98b081ad] Literate v2.18.0
[170b2178] MIRTjim v0.23.0
[91a5bcdd] Plots v1.40.4
[bd7594eb] SampledSignals v2.1.4
[afe32e48] Sound v0.5.0 `~/work/Sound.jl/Sound.jl`
[1986cc42] Unitful v1.19.0
[b77e0a4c] InteractiveUtils
This page was generated using Literate.jl.