Skip to main content

Generates simple polyphonic tones and melodies

Project description

Tones

A pure-python module for generating simple tones as audio samples, which can optionally be written directly to a .wav audio file. Supports pitch-bending, vibrato, polyphony, several waveform types (sine, square, triangle, sawtooth), and several other waveform-shaping options.

Installation

Install from the PyPi repository:

pip install tones

Example

from tones import SINE_WAVE, SAWTOOTH_WAVE
from tones.mixer import Mixer

# Create mixer, set sample rate and amplitude
mixer = Mixer(44100, 0.5)

# Create two monophonic tracks that will play simultaneously, and set
# initial values for note attack, decay and vibrato frequency (these can
# be changed again at any time, see documentation for tones.Mixer
mixer.create_track(0, SAWTOOTH_WAVE, vibrato_frequency=7.0, vibrato_variance=30.0, attack=0.01, decay=0.1)
mixer.create_track(1, SINE_WAVE, attack=0.01, decay=0.1)

# Add a 1-second tone on track 0, slide pitch from c# to f#)
mixer.add_note(0, note='c#', octave=5, duration=1.0, endnote='f#')

# Add a 1-second tone on track 1, slide pitch from f# to g#)
mixer.add_note(1, note='f#', octave=5, duration=1.0, endnote='g#')

# Mix all tracks into a single list of samples and write to .wav file
mixer.write_wav('tones.wav')

# Mix all tracks into a single list of samples scaled from 0.0 to 1.0, and
# return the sample list
samples = mixer.mix()

Documentation

Full API documention is here: https://tones.readthedocs.io

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tones-1.0.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file tones-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: tones-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.2.1 requests/2.12.4 setuptools/33.1.1 requests-toolbelt/0.7.0 clint/0.5.1 CPython/3.5.3 Linux/4.9.0-11-amd64

File hashes

Hashes for tones-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 35386ea66a678cb582841170cdfc1070859b9ab2e77fc66fb04d87f0dc47188d
MD5 222304d9f629b52b5f1a57ba1188d375
BLAKE2b-256 8377a7a7474661324453ce97cb7a82b37f39596d84708679f27159e23111ac7c

See more details on using hashes here.

Supported by

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