aboutsummaryrefslogtreecommitdiff
path: root/soxresample.bqn
blob: 89fbffc43d7f630dfbc18ff25c11dc813a269058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Binding for sox's resample library

u  "u64"
soxR  "/usr/lib/libsoxr.so" •FFI 
  u,"soxr_oneshot","f64","f64","u32"
  "*f32",u,u
  "&f32",u,"&u64:u32"
  u,u,u


# Resample pcm data 𝕩 from frequency fIn to frequency fOut.
{ iFroFr 𝕊 𝕩:
  {
    oMax   (oFr÷iFr) × iLen𝕩 # Input and maximum output lengths
    soutoLen  SoxR iFr,oFr,1, 𝕩,iLen,0, oMax0,oMax,⟨1,0⟩, 0,0,0
    ! 0 = s
    (oLen)out
  }1(iFroFr) 𝕩
}