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')
11-element Vector{SubString{String}}:
 "Julia Version 1.11.6"
 "Commit 9615af0f269 (2025-07-09 12:58 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"
 "  LLVM: libLLVM-16.0.6 (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.10
  [e30172f5] Documenter v1.14.1
  [98b081ad] Literate v2.20.1
  [170b2178] MIRTjim v0.25.0
  [91a5bcdd] Plots v1.40.18
  [bd7594eb] SampledSignals v2.1.4
  [afe32e48] Sound v0.5.0 `~/work/Sound.jl/Sound.jl`
  [1986cc42] Unitful v1.24.0
  [b77e0a4c] InteractiveUtils v1.11.0
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated`

This page was generated using Literate.jl.