diapason - 0.0.4

What is diapason?

diapason is a Python package to generate note sounds.

Contents

diapason library API

This chapter describes diapason’s library API. All diapason classes and functions are defined in sub packages such as diapason.core, but for ease of use, the most important ones are also placed in the diapason package scope.

diapason.core — diapason core logic

Core diapason code.

diapason.core.generate_wav(frequency, duration, rate=44100)

Generate a WAV file reproducing a sound at a given frequency.

Parameters:

frequency : float

Frequency, in hertzs, of the sound.

duration : float

Duration of the sound.

rate : int

Sample rate.

Returns:

BytesIO

The in-memory WAV file.

diapason.core.note_frequency(note, sharp=0, flat=0, octave=4, scientific=False)

Returns the frequency (in hertzs) associated to a given note.

All the frequencies are based on the standard concert pitch or standard piano key frequencies, meaning that A4 (using scientific picth notation) is at 440 hertzs.

Parameters:

note : string

Note to calculate the associated frequency from. Valid notes are characters from A to G.

octave : int

Octave position. Middle C and A440 being in the 4th octave.

sharp : int

Return a frequency higher in pitch by sharp semitones.

flat : int

Return a frequency lower in pitch by flat semitones.

scientific : bool

Use scientific pitch instead: C4 is set to 256 Hz.

Returns:

float

The frequency (in hertzs) associated to the given note.

Indices and tables