Skip to main content

Make audio

Project description

A small library for audio manipulation.

import soundit as s
s.play_output_chunks(s.chunked(s.exact(1, s.sine(440))))

Installation

Simply run:

$ pip install soundit[sounddevice]

The [sounddevice] extra installs sounddevice for playing audio through speakers.

Usage

A longer example:

import itertools
import soundit as s

indices = s.make_indices_dict()
frequencies = s.make_frequencies_dict()
notes = "a3 c e a g e c e d e d c a3 c a3 g3".split()

s.play_output_chunks(s.chunked(itertools.chain.from_iterable(
    s.exact(0.5, s.sine(frequencies[indices[note]]))
    for note in notes
)))

An even longer example:

import soundit as s
s.init_piano()  # See its documentation for details on its setup

names = "do di re ri mi fa fi so si la li ti".split()
indices = s.make_indices_dict(names)
music = '''
    . mi mi mi
    fa do . do
    . so mi do
    re mi,re - mi
'''

s.play_output_chunks(s.chunked(
    s.volume(2, s._notes_to_sound(
        s.music_to_notes(music, line_length=1.15),
        lambda name, length: s.piano(indices[name] + 1),
    ))
))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

soundit-0.4.tar.gz (24.4 kB view hashes)

Uploaded Source

Built Distribution

soundit-0.4-py3-none-any.whl (23.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page