Skip to main content

soundfactory

Build Status codecov Documentation Status

soundfactory is a simple tool to experiment and be creative with audio taking a data-oriented approach. It is primarily directed to digital artists that want to generate audio samples from diverse data sources, and to audio-engineering students at their first steps into the beautiful world of additive sound synthesis.

The peculiarity about soundfactory is the adoption of fourier-series approximation when square, sawtooth, or triangle wave shapes are chosen. In fact, being approximated the single-oscillator signals will contain upper harmonics with respect to the analytical signal (with the same amplitude, frequency, and wave shape), that can be obtained by scipy (see tests). The result will be a warmer and unexpectedly coloured sound.

It comes from some scripts I have been writing a few years back and thought about having few reusable core modules and a command-line tool for researching new sounds. And I wanted to be able to develop it and have fun with it in my Jupyter Notebook of course!

You can find the documentation at https://soundfactory.readthedocs.io


WARNING

Before installing with pip check the pre-requirements


Examples

Random Sample Generator

from random import uniform, choice
from soundfactory import SignalBuilder, SignalPlotter
import matplotlib.pyplot as plt

n_components = 4
MAX_FREQ = 1000.

fname = ''
freqs, amps, shapes = list(), list(), list()
for _ in range(n_components):
    freq = round(uniform(20., MAX_FREQ), 1)
    freqs.append(freq)
    amp = round(uniform(0.1, 1.), 1)
    amps.append(amp)
    shape = choice(['sine', 'square', 'sawtooth', 'triangle'])
    shapes.append(shape)
    fname += '_'.join([str(freq), str(amp), shape])

s = SignalBuilder(
    freqs, amps, shapes,
    samplerate=96000,
    duration=2.
)
fname += '.wav'
s.export(fname)

# Analyse with SignalPlotter
sig = SignalPlotter(plt, fname, True)
sig.show(wmsec=0.1)

Reproducing a Sound Characteristic at an arbitrary Frequency

from numpy import where, sqrt
import matplotlib.pyplot as plt

from soundfactory import SignalBuilder, SignalPlotter
from soundfactory import Signal
from soundfactory.utils.scale import build_24_tet_scale

SCALE_INIT = {'E0': 20.6}

ref_label = list(SCALE_INIT.keys())[-1]
ref_frequency = list(SCALE_INIT.values())[-1]
scale_24 = build_24_tet_scale(ref_label, ref_frequency, max_octave=3)

ref_signal = Signal('/<path-to-packages>/soundfactory/samples/A3-Calib-220.wav')

freqs = ref_signal.SPECTRA['ch1_fft'][ref_signal.FREQUENCIES]
pws = ref_signal.SPECTRA['ch1_fft'][ref_signal.POWERS]

# Select only few of the spectral components
select_idx = where(pws > 0.00001)[0]
# Get the fundamental frequency to obtain the upper-harmonic orders
fundamental_idx = where(pws == pws.max())[0]
freq_ratios = freqs / freqs[fundamental_idx]

tone = 'E3𝄲'  # Choose an arbitrary tone NOT playble on the keyboard
input_freqs = scale_24[tone] * freq_ratios[select_idx]
input_amps = sqrt(2 * pws[select_idx])

my_signal = SignalBuilder(input_freqs,
                          input_amps, [
                          'sine' for _ in range(len(select_idx))]
                         )

filename = './%s_sample.wav' % tone
my_signal.export(filename)

# Analyse with SignalPlotter
sig = SignalPlotter(plt, filename, True)
sig.show(wmsec=0.1)

Metadata

Release files for soundfactory 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for soundfactory 0.2.1
File Size Uploaded Provenance
soundfactory-0.2.1.tar.gz 5.2 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for soundfactory 0.2.1
File Interpreter ABI Platform
soundfactory-0.2.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details

Total release size: 9.3 MB

Release files / soundfactory-0.2.1.tar.gz

Download URL soundfactory-0.2.1.tar.gz
Size 5.2 MB
Tags Source
SHA-256 checksum
How to use checksums
191d55c25d023930c974716bf6ebe5f2e9cd83ff5703f734d09aa890222567b9
BLAKE2b-256 checksum
How to use checksums
07061c818927ad6acb55fcc4454b5413609a29aae2a181d88e3d60734b843c00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.5

Release files / soundfactory-0.2.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Download URL soundfactory-0.2.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Size 4.1 MB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
efb960fa94d3864fc6a5f29989bc435a8207db7e8662cbb45530b257ac3103a9
BLAKE2b-256 checksum
How to use checksums
5378d5cb004c20773a5cc1277d25101469835d1e84a614f252e9371988934e46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.5

Security for soundfactory 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page