Package jazzparser :: Package harmonical :: Module tones
[hide private]
[frames] | no frames]

Module tones

source code

Tone generation tools.

This is the tone representation and rendering engine for the Harmonical. The Harmonical is an instrument that can play music in any tuning system, including just intonation, by allowing the music to specify a precise pitch for each note. Its name is that given by Helmholtz to his specially tuned harmonium that allowed him to experiment with just tuning systems.


Author: Mark Granroth-Wilding <mark.granroth-wilding@ed.ac.uk>

Classes [hide private]
  ToneMatrix
A timesheet of tones, with pitches, onset times and durations, designed for specifying input to the tone generator.
  BaseToneEvent
A single event in the tone matrix.
  SineToneEvent
A single event in the tone matrix.
  MultiSineToneEvent
Generates a tone by summing several sine waves (simple additive synthesis).
  SineClusterEvent
Generates a tone by summing the notes of a tonal space cluster.
  SineChordEvent
Generates a tone by summing the notes of a chord of a standard type.
Functions [hide private]
 
generate_sine_wave(frequency, duration, amplitude, sample_rate) source code
 
apply_envelope(wave, envelope) source code
 
sum_signals(sigs, norm=1.0)
Sum two wave signals.
source code
 
normalize(wave, level=0.8)
Normalize the amplitude of the wave data.
source code
 
fade_in_out_envelope(precision=200, hold_ratio=10)
Generates an envelope that fades in linearly, holds for a time adjusted by hold_ratio, then fades out linearly.
source code
 
smooth_fade_in_out_envelope(precision=200, hold_ratio=10)
Generates an envelope that fades in with a log curve, holds for a time adjusted by hold_ratio, then fades out similarly.
source code
 
fade_in_envelope(precision=200, hold_ratio=10) source code
 
fade_out_envelope(precision=200, hold_ratio=10) source code
 
adsr_envelope(attack_time, decay_time, sustain_time, release_time, sustain_level=0.6, sustain_level_end=0.4, pause_time=0)
Create an envelope according to ADSR (attack-decay-sustain-release) specifications.
source code
 
piano_envelope()
Produces an envelope designed to sound a tiny bit like a piano.
source code
 
no_envelope() source code
ToneMatrix
path_to_tones(path, tempo=120, chord_types=None, root_octave=0, double_root=False, equal_temperament=False, timings=False)
Takes a tonal space path, given as a list of coordinates, and generates the tones of the roots.
source code
 
render_path_to_file(filename, path, *args, **kwargs)
Convenience function that takes a path and set of timings and uses the harmonical to render audio from it and writes it to a file.
source code
Variables [hide private]
  MAX_SAMPLE = 32767
  logger = logging.getLogger("main_logger")
  ENVELOPES = {'piano': piano_envelope, 'in': fade_in_envelope, ...
  __package__ = 'jazzparser.harmonical'
Function Details [hide private]

adsr_envelope(attack_time, decay_time, sustain_time, release_time, sustain_level=0.6, sustain_level_end=0.4, pause_time=0)

source code 

Create an envelope according to ADSR (attack-decay-sustain-release) specifications. Unlike real ADSR, the timings are all proportional. Attack, decay and release should be absolute, and sustain shouldn't have a time, but this kind of envelope can't do that.

piano_envelope()

source code 

Produces an envelope designed to sound a tiny bit like a piano. Don't expect too much of it!

path_to_tones(path, tempo=120, chord_types=None, root_octave=0, double_root=False, equal_temperament=False, timings=False)

source code 

Takes a tonal space path, given as a list of coordinates, and generates the tones of the roots.

Parameters:
  • path (list of (3d-coordinate,length) tuples) - coordinates of the points in the sequence and the length of each, in beats
  • tempo (int) - speed in beats per second (Maelzel's metronome)
  • chord_types (list of (string,length)) - the type of chord to use for each tone and the time spent on that chord type, in beats. See CHORD_TYPES keys for possible values.
  • equal_temperament (bool) - render all the pitches as they would be played in equal temperament.
Returns: ToneMatrix
a tone matrix that can be used to render the sound

render_path_to_file(filename, path, *args, **kwargs)

source code 

Convenience function that takes a path and set of timings and uses the harmonical to render audio from it and writes it to a file. Additional args/kwargs are passed to the path_to_tones function.


Variables Details [hide private]

ENVELOPES

Value:
{'piano': piano_envelope, 'in': fade_in_envelope, 'out': fade_out_enve\
lope, 'inout': fade_in_out_envelope, 'smooth': smooth_fade_in_out_enve\
lope, 'square': no_envelope,}