Csound Csound-dev Csound-tekno Search About

[Csnd-dev] ANNOUNCEMENT: csnum | numpy-style array opcodes for Csound 7

Date2026-09-07 21:58
FromPasquale Mainolfi
Subject[Csnd-dev] ANNOUNCEMENT: csnum | numpy-style array opcodes for Csound 7

Csound-numeric is a C11 library/plugin for Csound 7 that brings numpy-style N-dimensional array operations to Csound. 

The project includes real and complex arrays, broadcasting, indexing, masking, reductions, statistics, linear algebra, interpolation, resampling, FFT/STFT tools, set operations, persistence, and k-rate-aware versioning to avoid unnecessary recomputation.

You can build csn directly from the official repository https://github.com/PasqualeMainolfi/csound-numeric. 

csn is still under active development, so testing is especially welcome. Bug reports, crashes, numerical mismatches, unexpected NumPy-like behavior, shape/broadcasting issues, complex-number edge cases, realtime/k-rate problems, portability issues, and performance observations are all very useful. If you try it, feedback and reproducible test cases are greatly appreciated.

… a small example of the basis workflow, using an FFT:


instr 1 

sig:a = oscili(0.5, 440)

frame:CsnArr, new:k = csnsnap(sig, 1024, 256)

    spectrum:CsnArr = csnrfft(frame, 1024, -1, new)

    magnitude:CsnArr = csnabs(spectrum, new)

    out:a, ready:k  = csnstream(frame, 256)

endin


The goal has been to preserve the essence of Csound while bringing some of the simplicity and composability of NumPy to operations that are especially important in our workflows.

I am currently focusing on optimizing the deeper linear algebra layer, including operations such as determinants, matrix inversion, linear-system solving, and related routines, with particular attention to numerical correctness, memory reuse, and performance.


Pasquale Mainolfi
Composer and Computer Scientist

Professor of Computer Music
Dep. of New Technologies and Musical Languages, 
"G. Martucci” State Conservatoire of Musica (Salerno, IT).
Professor of Electroacoustic Music Analysis at School of Electronic Music, 
“N. Sala” State Conservatoire of Music (Benevento, IT).



Le informazioni contenute nella presente comunicazione e i relativi allegati possono essere riservate e sono, comunque, destinate esclusivamente ai destinatari sopraindicati. La diffusione, distribuzione e/o copiatura del documento trasmesso da parte di qualsiasi soggetto diverso da destinatario è proibita, sia ai sensi dell’art. 616 c.p., che ai sensi del D.Lgs. n. 196/2003.

The information contained in this communication and its attachments may be confidential and is, in any case, intended solely for the recipients indicated above. The dissemination, distribution, and/or copying of the transmitted document by party other than the intended recipient is prohibited, pursuant to Article 616 of the Penal Code and Legislative Decree no. 196/2003.