You are viewing unmaintained documentation for an older version of OpenSesame. Click here to view the current documentation. Your version of OpenSesame: Language:

OpenSesame 3.0.0 will bring amazing new features! Curious? Take it for a test spin, and help us iron out the kinks.

Synth functions

class synth

The synth class provides basic sound synthesis functionality.

Example:

# Generate and play a simple tone
from openexp.synth import synth
my_synth = synth(exp, osc='saw', freq='b2', attack=250, length=500)
my_synth.play()

Function list:

function synth.__init__(experiment, length=100, osc=u’sine’, attack=0, freq=440, decay=5)

Initializes the synthesizer.

Example:

from openexp.synth import synth
my_synth = synth(exp, freq='b2', length=500)

Arguments:

  • experiment – The experiment object.
    • Type: experiment

Keywords:

  • osc – Oscillator, can be “sine”, “saw”, “square” or “white_noise”.
    • Type: str, unicode
    • Default: ‘sine’
  • freq – Frequency, either an integer value (value in hertz) or a string (“A1”, “eb2”, etc.).
    • Type: str, unicode, int, float
    • Default: 440
  • length – The length of the sound in milliseconds.
    • Type: int, float
    • Default: 100
  • attack – The attack (fade-in) time in milliseconds.
    • Type: int, float
    • Default: 0
  • decay – The decay (fade-out) time in milliseconds.
    • Type: int, float
    • Default: 5

property synth.is_playing

See sampler.is_playing.

function synth.key_to_freq(key)

Converts a key (e.g., A1) to a frequency.

Example:

from openexp.synth import synth
my_synth = synth(exp)
print('An a2 is %d Hz' % my_synth.key_to_freq('a2'))

Arguments:

  • key – A string like “A1”, “eb2”, etc, or a numeric frequency (in which case the frequency is simply returned as a float).
    • Type: str, unicode, int, float

Returns:

A frequency in hertz.

  • Type: float

property synth.pan

See sampler.pan.

property synth.pause

See sampler.pause.

property synth.pitch

See sampler.pitch.

property synth.play

See sampler.play.

property synth.resume

See sampler.resume.

property synth.stop_after

See sampler.stop_after.

property synth.volume

See sampler.volume.

property synth.wait

See sampler.wait.