def build_grain_synthdef():
    channel_count = 2
    builder = SynthDefBuilder(
        in_=Parameter(value=0, parameter_rate='SCALAR'),
        out=Parameter(value=0, parameter_rate='SCALAR'),
        mix=Parameter(value=0.0, lag=0.25),
        feedback_gain=Parameter(value=-24, lag=0.25),
        density=Parameter(value=1.0),
        duration=Parameter(value=0.01),
        )
    with builder:
        source = ugentools.In.ar(
            bus=builder['in_'],
            channel_count=channel_count,
            )
        source += ugentools.LocalIn.ar(channel_count=channel_count)
        # core algorithm
        buffer_duration = 10
        local_buf = ugentools.LocalBuf(
            channel_count=1,
            frame_count=ugentools.SampleRate.ir() * buffer_duration,
            )
        ugentools.RecordBuf.ar(
            buffer_id=local_buf,
            source=ugentools.Mix.new(source) / 2,
            )
        trigger = ugentools.Dust.kr(density=builder['density'])
        source = ugentools.GrainBuf.ar(
            buffer_id=local_buf,
            channel_count=2,
            trigger=trigger,
            duration=builder['duration'],
            rate=1,
            position=ugentools.WhiteNoise.kr(),
            pan=ugentools.WhiteNoise.kr(),
            )
        source = ugentools.LeakDC.ar(source=source)
        source = source.tanh()
        # bus output
        ugentools.XOut.ar(
            bus=builder['out'],
            crossfade=builder['mix'],
            source=source,
            )
        # feedback algorithm
        feedback = source
        feedback *= -builder['feedback_gain'].db_to_amplitude()
        feedback = ugentools.Limiter.ar(source=feedback, duration=0.01)
        feedback = ugentools.HPF.ar(frequency=150, source=feedback)
        feedback = ugentools.LPF.ar(frequency=5000, source=feedback)
        feedback = ugentools.Rotate2.ar(
            x=feedback[0],
            y=feedback[1],
            position=ugentools.LFNoise2.kr(frequency=0.1)
            )
        ugentools.LocalOut.ar(source=-feedback)
    synthdef = builder.build(name='jams_grain')
    return synthdef
def build_grain_synthdef():
    channel_count = 2
    builder = SynthDefBuilder(
        in_=Parameter(value=0, parameter_rate='SCALAR'),
        out=Parameter(value=0, parameter_rate='SCALAR'),
        mix=Parameter(value=0.0, lag=0.25),
        feedback_gain=Parameter(value=-24, lag=0.25),
        density=Parameter(value=1.0),
        duration=Parameter(value=0.01),
    )
    with builder:
        source = ugentools.In.ar(
            bus=builder['in_'],
            channel_count=channel_count,
        )
        source += ugentools.LocalIn.ar(channel_count=channel_count)
        # core algorithm
        buffer_duration = 10
        local_buf = ugentools.LocalBuf(
            channel_count=1,
            frame_count=ugentools.SampleRate.ir() * buffer_duration,
        )
        ugentools.RecordBuf.ar(
            buffer_id=local_buf,
            source=ugentools.Mix.new(source) / 2,
        )
        trigger = ugentools.Dust.kr(density=builder['density'])
        source = ugentools.GrainBuf.ar(
            buffer_id=local_buf,
            channel_count=2,
            trigger=trigger,
            duration=builder['duration'],
            rate=1,
            position=ugentools.WhiteNoise.kr(),
            pan=ugentools.WhiteNoise.kr(),
        )
        source = ugentools.LeakDC.ar(source=source)
        source = source.tanh()
        # bus output
        ugentools.XOut.ar(
            bus=builder['out'],
            crossfade=builder['mix'],
            source=source,
        )
        # feedback algorithm
        feedback = source
        feedback *= -builder['feedback_gain'].db_to_amplitude()
        feedback = ugentools.Limiter.ar(source=feedback, duration=0.01)
        feedback = ugentools.HPF.ar(frequency=150, source=feedback)
        feedback = ugentools.LPF.ar(frequency=5000, source=feedback)
        feedback = ugentools.Rotate2.ar(
            x=feedback[0],
            y=feedback[1],
            position=ugentools.LFNoise2.kr(frequency=0.1))
        ugentools.LocalOut.ar(source=-feedback)
    synthdef = builder.build(name='jams_grain')
    return synthdef
Example #3
0
def test_03():
    """
    Cannot share output proxies.
    """
    with SynthDefBuilder():
        left, right = supriya.ugens.SinOsc.ar(frequency=[440, 442])
        supriya.ugens.Out.ar(bus=0, source=[right, left])

    with SynthDefBuilder():
        with pytest.raises(ValueError) as exception_info:
            left * right
        assert 'UGen input in different scope' in str(exception_info.value)
Example #4
0
def test_01():
    """
    Cannot share UGens.
    """

    with SynthDefBuilder():
        sine_one = supriya.ugens.SinOsc.ar()
        supriya.ugens.Out.ar(bus=0, source=sine_one)

    with SynthDefBuilder():
        sine_two = supriya.ugens.SinOsc.ar()
        with pytest.raises(ValueError) as exception_info:
            sine_two * sine_one
        assert 'UGen input in different scope' in str(exception_info.value)
def build_delay_synthdef():
    channel_count = 2
    builder = SynthDefBuilder(
        in_=Parameter(value=0, parameter_rate='SCALAR'),
        out=Parameter(value=0, parameter_rate='SCALAR'),
        mix=Parameter(value=0.0, lag=0.25),
        feedback_gain=Parameter(value=-24, lag=0.25),
        depth=Parameter(value=1.0, lag=0.1),
        frequency=Parameter(value=1.0, lag=0.1),
        )
    with builder:
        source = ugentools.In.ar(
            bus=builder['in_'],
            channel_count=channel_count,
            )
        source += ugentools.LocalIn.ar(channel_count=channel_count)
        # core algorithm
        for _ in range(3):
            frequency = [builder['frequency']] * channel_count
            decay_time = ugentools.LFDNoise3.kr(
                frequency=frequency,
                ).squared() * builder['depth']
            delay_time = ugentools.LFDNoise3.kr(
                frequency=frequency,
                ).squared() * builder['depth']
            source = ugentools.AllpassC.ar(
                source=source,
                decay_time=decay_time,
                delay_time=delay_time,
                maximum_delay_time=1.0,
                )
        source = ugentools.LeakDC.ar(source=source)
        # bus output
        ugentools.XOut.ar(
            bus=builder['out'],
            crossfade=builder['mix'],
            source=source,
            )
        # feedback algorithm
        feedback = source
        feedback *= builder['feedback_gain'].db_to_amplitude()
        feedback = ugentools.Limiter.ar(source=feedback, duration=0.01)
        feedback = ugentools.Rotate2.ar(
            x=feedback[0],
            y=feedback[1],
            position=ugentools.LFNoise2.kr(frequency=0.1)
            )
        ugentools.LocalOut.ar(source=-feedback)
    synthdef = builder.build(name='jams_delay')
    return synthdef
Example #6
0
def test_02():
    """
    Cannot share parameters.
    """

    with SynthDefBuilder(bus=0) as builder:
        sine_one = supriya.ugens.SinOsc.ar()
        synth_one_bus = builder['bus']
        supriya.ugens.Out.ar(bus=synth_one_bus, source=sine_one)

    with SynthDefBuilder():
        sine_two = supriya.ugens.SinOsc.ar()
        with pytest.raises(ValueError) as exception_info:
            supriya.ugens.Out.ar(bus=synth_one_bus, source=sine_two)
        assert 'UGen input in different scope' in str(exception_info.value)
def build_freeverb_synthdef():
    channel_count = 2
    builder = SynthDefBuilder(
        in_=Parameter(value=0, parameter_rate='SCALAR'),
        out=Parameter(value=0, parameter_rate='SCALAR'),
        mix=Parameter(value=0.0, lag=0.25),
        feedback_gain=Parameter(value=-96, lag=0.25),
        damping=Parameter(value=1.0, lag=0.25),
        room_size=Parameter(value=1.0, lag=0.25),
        frequency_shift=Parameter(value=0.0, lag=0.1),
        )
    with builder:
        source = ugentools.In.ar(
            bus=builder['in_'],
            channel_count=channel_count,
            )
        source += ugentools.LocalIn.ar(channel_count=channel_count)
        # core algorithm
        source = ugentools.FreeVerb.ar(
            source=source,
            mix=1.0,
            room_size=builder['room_size'],
            damping=builder['damping'],
            )
        source = ugentools.LeakDC.ar(source=source)
        # bus output
        ugentools.XOut.ar(
            bus=builder['out'],
            crossfade=builder['mix'],
            source=source,
            )
        # feedback algorithm
        feedback = ugentools.FreqShift.ar(
            source=source,
            frequency=builder['frequency_shift'],
            )
        feedback *= builder['feedback_gain'].db_to_amplitude()
        feedback = ugentools.Limiter.ar(source=feedback, duration=0.01)
        feedback = ugentools.HPF.ar(frequency=100, source=feedback)
        feedback = ugentools.LPF.ar(frequency=15000, source=feedback)
        feedback = ugentools.Rotate2.ar(
            x=feedback[0],
            y=feedback[1],
            position=ugentools.LFNoise2.kr(frequency=0.1)
            )
        ugentools.LocalOut.ar(source=-feedback)
    synthdef = builder.build(name='jams_freeverb')
    return synthdef
Example #8
0
def test_nonrealtime_releasetime():
    with SynthDefBuilder(out=Parameter(parameter_rate='SCALAR',
                                       value=0), ) as builder:
        supriya.ugens.Line.kr(duration=2),
        supriya.ugens.Out.ar(bus=builder['out'], source=supriya.ugens.DC.ar(1))
    dc_synthdef = builder.build()
    pattern = supriya.patterns.Pbus(
        supriya.patterns.Pbind(
            delta=1,
            duration=1,
            synthdef=dc_synthdef,
        ),
        release_time=1,
    )
    session = supriya.nonrealtime.Session(0, 1)
    with session.at(0):
        session.inscribe(pattern, duration=1)
    d_recv_commands = pytest.helpers.build_d_recv_commands([
        supriya.assets.synthdefs.system_link_audio_1,
        dc_synthdef,
    ])
    assert session.to_lists() == [[
        0.0,
        [
            *d_recv_commands, ['/g_new', 1000, 0, 0],
            [
                '/s_new',
                supriya.assets.synthdefs.system_link_audio_1.anonymous_name,
                1001, 3, 1000, 'fade_time', 1.0, 'in_', 1
            ], ['/s_new', dc_synthdef.anonymous_name, 1002, 0, 1000, 'out', 1]
        ]
    ], [1.0, [
        ['/n_free', 1002],
        ['/n_set', 1001, 'gate', 0],
    ]], [2.0, [['/n_free', 1000], [0]]]]
def build_freeverb_synthdef():
    channel_count = 2
    builder = SynthDefBuilder(
        in_=Parameter(value=0, parameter_rate='SCALAR'),
        out=Parameter(value=0, parameter_rate='SCALAR'),
        mix=Parameter(value=0.0, lag=0.25),
        feedback_gain=Parameter(value=-96, lag=0.25),
        damping=Parameter(value=1.0, lag=0.25),
        room_size=Parameter(value=1.0, lag=0.25),
        frequency_shift=Parameter(value=0.0, lag=0.1),
    )
    with builder:
        source = ugentools.In.ar(
            bus=builder['in_'],
            channel_count=channel_count,
        )
        source += ugentools.LocalIn.ar(channel_count=channel_count)
        # core algorithm
        source = ugentools.FreeVerb.ar(
            source=source,
            mix=1.0,
            room_size=builder['room_size'],
            damping=builder['damping'],
        )
        source = ugentools.LeakDC.ar(source=source)
        # bus output
        ugentools.XOut.ar(
            bus=builder['out'],
            crossfade=builder['mix'],
            source=source,
        )
        # feedback algorithm
        feedback = ugentools.FreqShift.ar(
            source=source,
            frequency=builder['frequency_shift'],
        )
        feedback *= builder['feedback_gain'].db_to_amplitude()
        feedback = ugentools.Limiter.ar(source=feedback, duration=0.01)
        feedback = ugentools.HPF.ar(frequency=100, source=feedback)
        feedback = ugentools.LPF.ar(frequency=15000, source=feedback)
        feedback = ugentools.Rotate2.ar(
            x=feedback[0],
            y=feedback[1],
            position=ugentools.LFNoise2.kr(frequency=0.1))
        ugentools.LocalOut.ar(source=-feedback)
    synthdef = builder.build(name='jams_freeverb')
    return synthdef
def build_delay_synthdef():
    channel_count = 2
    builder = SynthDefBuilder(
        in_=Parameter(value=0, parameter_rate='SCALAR'),
        out=Parameter(value=0, parameter_rate='SCALAR'),
        mix=Parameter(value=0.0, lag=0.25),
        feedback_gain=Parameter(value=-24, lag=0.25),
        depth=Parameter(value=1.0, lag=0.1),
        frequency=Parameter(value=1.0, lag=0.1),
    )
    with builder:
        source = ugentools.In.ar(
            bus=builder['in_'],
            channel_count=channel_count,
        )
        source += ugentools.LocalIn.ar(channel_count=channel_count)
        # core algorithm
        for _ in range(3):
            frequency = [builder['frequency']] * channel_count
            decay_time = ugentools.LFDNoise3.kr(
                frequency=frequency, ).squared() * builder['depth']
            delay_time = ugentools.LFDNoise3.kr(
                frequency=frequency, ).squared() * builder['depth']
            source = ugentools.AllpassC.ar(
                source=source,
                decay_time=decay_time,
                delay_time=delay_time,
                maximum_delay_time=1.0,
            )
        source = ugentools.LeakDC.ar(source=source)
        # bus output
        ugentools.XOut.ar(
            bus=builder['out'],
            crossfade=builder['mix'],
            source=source,
        )
        # feedback algorithm
        feedback = source
        feedback *= builder['feedback_gain'].db_to_amplitude()
        feedback = ugentools.Limiter.ar(source=feedback, duration=0.01)
        feedback = ugentools.Rotate2.ar(
            x=feedback[0],
            y=feedback[1],
            position=ugentools.LFNoise2.kr(frequency=0.1))
        ugentools.LocalOut.ar(source=-feedback)
    synthdef = builder.build(name='jams_delay')
    return synthdef
def build_pitch_shift_synthdef():
    channel_count = 2
    builder = SynthDefBuilder(
        in_=Parameter(value=0, parameter_rate='SCALAR'),
        out=Parameter(value=0, parameter_rate='SCALAR'),
        mix=Parameter(value=0.0, lag=0.25),
        feedback_gain=Parameter(value=-24, lag=0.25),
        transposition=Parameter(value=0.0, lag=0.25),
        fuzz=Parameter(value=0.0, lag=0.25),
        )
    with builder:
        source = ugentools.In.ar(
            bus=builder['in_'],
            channel_count=channel_count,
            )
        source += ugentools.LocalIn.ar(channel_count=channel_count)
        # core algorithm
        window_size = 0.5
        source = ugentools.PitchShift.ar(
            source=source,
            window_size=window_size,
            pitch_ratio=builder['transposition'].semitones_to_ratio(),
            time_dispersion=builder['fuzz'].squared() * (window_size / 2),
            pitch_dispersion=builder['fuzz'].squared(),
            )
        source = ugentools.LeakDC.ar(source=source)
        # bus output
        ugentools.XOut.ar(
            bus=builder['out'],
            crossfade=builder['mix'],
            source=source,
            )
        # feedback algorithm
        source += ugentools.LocalIn.ar(channel_count=channel_count)
        feedback = source
        feedback *= -builder['feedback_gain'].db_to_amplitude()
        feedback = ugentools.Limiter.ar(source=feedback, duration=0.01)
        feedback = ugentools.HPF.ar(frequency=150, source=feedback)
        feedback = ugentools.LPF.ar(frequency=10000, source=feedback)
        feedback = ugentools.Rotate2.ar(
            x=feedback[0],
            y=feedback[1],
            position=ugentools.LFNoise2.kr(frequency=0.1)
            )
        ugentools.LocalOut.ar(source=-feedback)
    synthdef = builder.build(name='jams_pitch_shift')
    return synthdef
Example #12
0
 def _build_rand_seed_synthdef():
     import supriya.ugens
     from supriya import SynthDefBuilder
     with SynthDefBuilder(rand_id=0, rand_seed=0) as builder:
         supriya.ugens.RandID.ir(rand_id=builder['rand_id'])
         supriya.ugens.RandSeed.ir(seed=builder['rand_seed'], trigger=1)
         supriya.ugens.FreeSelf.kr(trigger=1)
     return builder.build()
def build_pitch_shift_synthdef():
    channel_count = 2
    builder = SynthDefBuilder(
        in_=Parameter(value=0, parameter_rate='SCALAR'),
        out=Parameter(value=0, parameter_rate='SCALAR'),
        mix=Parameter(value=0.0, lag=0.25),
        feedback_gain=Parameter(value=-24, lag=0.25),
        transposition=Parameter(value=0.0, lag=0.25),
        fuzz=Parameter(value=0.0, lag=0.25),
    )
    with builder:
        source = ugentools.In.ar(
            bus=builder['in_'],
            channel_count=channel_count,
        )
        source += ugentools.LocalIn.ar(channel_count=channel_count)
        # core algorithm
        window_size = 0.5
        source = ugentools.PitchShift.ar(
            source=source,
            window_size=window_size,
            pitch_ratio=builder['transposition'].semitones_to_ratio(),
            time_dispersion=builder['fuzz'].squared() * (window_size / 2),
            pitch_dispersion=builder['fuzz'].squared(),
        )
        source = ugentools.LeakDC.ar(source=source)
        # bus output
        ugentools.XOut.ar(
            bus=builder['out'],
            crossfade=builder['mix'],
            source=source,
        )
        # feedback algorithm
        source += ugentools.LocalIn.ar(channel_count=channel_count)
        feedback = source
        feedback *= -builder['feedback_gain'].db_to_amplitude()
        feedback = ugentools.Limiter.ar(source=feedback, duration=0.01)
        feedback = ugentools.HPF.ar(frequency=150, source=feedback)
        feedback = ugentools.LPF.ar(frequency=10000, source=feedback)
        feedback = ugentools.Rotate2.ar(
            x=feedback[0],
            y=feedback[1],
            position=ugentools.LFNoise2.kr(frequency=0.1))
        ugentools.LocalOut.ar(source=-feedback)
    synthdef = builder.build(name='jams_pitch_shift')
    return synthdef
Example #14
0
def _make_synthdef(channel_count=2):
    with SynthDefBuilder(
            frequency_1=100,
            frequency_2=1000,
            frequency_3=3000,
            band_1_clamp_time=0.01,
            band_1_gain=1,
            band_1_relax_time=0.1,
            band_1_slope=0.5,
            band_1_threshold=0.9,
            band_2_clamp_time=0.01,
            band_2_gain=1,
            band_2_relax_time=0.1,
            band_2_slope=0.5,
            band_2_threshold=0.9,
            band_3_clamp_time=0.01,
            band_3_gain=1,
            band_3_relax_time=0.1,
            band_3_slope=0.5,
            band_3_threshold=0.9,
            band_4_clamp_time=0.01,
            band_4_gain=1,
            band_4_relax_time=0.1,
            band_4_slope=0.5,
            band_4_threshold=0.9,
            in_=0,
            out=0,
    ) as builder:
        source = ugentools.In.ar(
            bus=builder['in_'],
            channel_count=channel_count,
        )
        band_1 = ugentools.LPF.ar(
            frequency=builder['frequency_1'],
            source=source,
        )
        band_4 = ugentools.HPF.ar(
            frequency=builder['frequency_3'],
            source=source,
        )
        center = source - band_1 - band_4
        band_2 = ugentools.LPF.ar(
            frequency=builder['frequency_2'],
            source=center,
        )
        band_3 = ugentools.HPF.ar(
            frequency=builder['frequency_2'],
            source=center,
        )
        band_1 = ugentools.CompanderD.ar(
            clamp_time=builder['band_1_clamp_time'],
            relax_time=builder['band_1_relax_time'],
            slope_above=builder['band_1_slope'],
            source=band_1,
            threshold=builder['band_1_threshold'],
        )
        band_2 = ugentools.CompanderD.ar(
            clamp_time=builder['band_2_clamp_time'],
            relax_time=builder['band_2_relax_time'],
            slope_above=builder['band_2_slope'],
            source=band_2,
            threshold=builder['band_2_threshold'],
        )
        band_3 = ugentools.CompanderD.ar(
            clamp_time=builder['band_3_clamp_time'],
            relax_time=builder['band_3_relax_time'],
            slope_above=builder['band_3_slope'],
            source=band_3,
            threshold=builder['band_3_threshold'],
        )
        band_4 = ugentools.CompanderD.ar(
            clamp_time=builder['band_4_clamp_time'],
            relax_time=builder['band_4_relax_time'],
            slope_above=builder['band_4_slope'],
            source=band_4,
            threshold=builder['band_4_threshold'],
        )
        band_1 *= builder['band_1_gain']
        band_2 *= builder['band_2_gain']
        band_3 *= builder['band_3_gain']
        band_4 *= builder['band_4_gain']
        source = ugentools.Sum4.new(
            input_one=band_1,
            input_two=band_2,
            input_three=band_3,
            input_four=band_4,
        )
        ugentools.ReplaceOut.ar(bus=builder['out'], source=source)
    return builder.build()
            channel_count=1, frame_count=pair[1],
            file_path=pair[0])  #produces no frame count info or duration info
        buffers.append(buffer_)
# frames = [ugens.BufFrames.ir(buffer_id=0)]
# print(frames)

### BUF NOISE ###

with SynthDefBuilder(
        name="bufnoise",
        amp=1,
        out=0,
        buffer_id=0,
        start=0,
        end=1,
        freq=1,
        atk=0,
        sus=0,
        rel=3,
        c1=1.0,
        c2=-1.0,
        pan=0,
) as builder:
    env = ugens.EnvGen.kr(envelope=synthdefs.Envelope(amplitudes=(0, 1, 1, 0),
                                                      durations=(
                                                          builder['atk'],
                                                          builder['sus'],
                                                          builder['rel'],
                                                      ),
                                                      curves=(
                                                          builder['c1'],
# -*- encoding: utf-8 -*-
from supriya import SynthDefBuilder
from supriya import synthdeftools
from supriya import ugentools


channel_count = 2

with SynthDefBuilder(
    level=synthdeftools.Parameter(value=0.0, lag=15),
    out=0,
    ) as builder:
    source = ugentools.In.ar(
        bus=builder['out'],
        channel_count=channel_count,
        ) * builder['level'].s_curve()
    ugentools.ReplaceOut.ar(
        bus=builder['out'],
        source=source,
        )
volume = builder.build()
Example #17
0
def _make_synthdef(channel_count=2):
    with SynthDefBuilder(
        frequency_1=200,
        frequency_2=2000,
        frequency_3=5000,
        band_1_clamp_time=0.01,
        band_1_postgain=0,
        band_1_pregain=0,
        band_1_relax_time=0.1,
        band_1_slope_above=0.5,
        band_1_slope_below=1.0,
        band_1_threshold=-12,
        band_2_clamp_time=0.01,
        band_2_postgain=0,
        band_2_pregain=0,
        band_2_relax_time=0.1,
        band_2_slope_above=0.5,
        band_2_slope_below=1.0,
        band_2_threshold=-12,
        band_3_clamp_time=0.01,
        band_3_postgain=0,
        band_3_pregain=0,
        band_3_relax_time=0.1,
        band_3_slope_above=0.5,
        band_3_slope_below=1.0,
        band_3_threshold=-12,
        band_4_clamp_time=0.01,
        band_4_postgain=0,
        band_4_pregain=0,
        band_4_relax_time=0.1,
        band_4_slope_above=0.5,
        band_4_slope_below=1.0,
        band_4_threshold=-12,
        pregain=0,
        postgain=0,
        in_=0,
        out=0,
        limiter_lookahead=0.01,
    ) as builder:
        source = supriya.ugens.In.ar(bus=builder["in_"], channel_count=channel_count)
        source *= builder["pregain"].db_to_amplitude()
        band_1 = supriya.ugens.LPF.ar(frequency=builder["frequency_1"], source=source)
        band_4 = supriya.ugens.HPF.ar(frequency=builder["frequency_3"], source=source)
        center = source - band_1 - band_4
        band_2 = supriya.ugens.LPF.ar(frequency=builder["frequency_2"], source=center)
        band_3 = supriya.ugens.HPF.ar(frequency=builder["frequency_2"], source=center)
        band_1 = supriya.ugens.CompanderD.ar(
            clamp_time=builder["band_1_clamp_time"],
            relax_time=builder["band_1_relax_time"],
            slope_above=builder["band_1_slope_above"],
            slope_below=builder["band_1_slope_below"],
            source=band_1 * builder["band_1_pregain"].db_to_amplitude(),
            threshold=builder["band_1_threshold"].db_to_amplitude(),
        )
        band_2 = supriya.ugens.CompanderD.ar(
            clamp_time=builder["band_2_clamp_time"],
            relax_time=builder["band_2_relax_time"],
            slope_above=builder["band_2_slope_above"],
            slope_below=builder["band_2_slope_below"],
            source=band_2 * builder["band_2_pregain"].db_to_amplitude(),
            threshold=builder["band_2_threshold"].db_to_amplitude(),
        )
        band_3 = supriya.ugens.CompanderD.ar(
            clamp_time=builder["band_3_clamp_time"],
            relax_time=builder["band_3_relax_time"],
            slope_above=builder["band_3_slope_above"],
            slope_below=builder["band_3_slope_below"],
            source=band_3 * builder["band_3_pregain"].db_to_amplitude(),
            threshold=builder["band_3_threshold"].db_to_amplitude(),
        )
        band_4 = supriya.ugens.CompanderD.ar(
            clamp_time=builder["band_4_clamp_time"],
            relax_time=builder["band_4_relax_time"],
            slope_above=builder["band_4_slope_above"],
            slope_below=builder["band_4_slope_below"],
            source=band_4 * builder["band_4_pregain"].db_to_amplitude(),
            threshold=builder["band_4_threshold"].db_to_amplitude(),
        )
        band_1 *= builder["band_1_postgain"].db_to_amplitude()
        band_2 *= builder["band_2_postgain"].db_to_amplitude()
        band_3 *= builder["band_3_postgain"].db_to_amplitude()
        band_4 *= builder["band_4_postgain"].db_to_amplitude()
        source = supriya.ugens.Sum4.new(
            input_one=band_1, input_two=band_2, input_three=band_3, input_four=band_4
        )
        source *= builder["postgain"].db_to_amplitude()
        source = supriya.ugens.Limiter.ar(
            source=source, duration=builder["limiter_lookahead"]
        )
        supriya.ugens.ReplaceOut.ar(bus=builder["out"], source=source)
    return builder.build()
Example #18
0
# -*- encoding: utf-8 -*-
from supriya import SynthDefBuilder
from supriya import ugentools


channel_count = 2

with SynthDefBuilder(
    out=0,
    ) as builder:
    source = ugentools.In.ar(
        bus=builder['out'],
        channel_count=channel_count,
        )
    source = ugentools.LeakDC.ar(source=source)
    source = ugentools.Limiter.ar(source=source)
    ugentools.ReplaceOut.ar(
        bus=builder['out'],
        source=source,
        )

limiter = builder.build()
    ]:
        says.append(Say(text, voice=voice))

buffers = []
with session.at(0):
    for say in says:
        buffer_ = session.add_buffer(channel_count=1, file_path=say)
        buffers.append(buffer_)

### WARP BUFFER PLAYER ###

with SynthDefBuilder(
        buffer_id=0,
        gain=0,
        out=0,
        overlaps=32,
        rate=1,
        transpose=0,
        window_size=0.5,
) as builder:
    line = ugens.Line.kr(
        done_action=2,
        duration=ugens.BufDur.kr(builder['buffer_id']) * builder['rate'],
    )
    window = line.hanning_window()
    pointer_scrub = ugens.LFNoise2.kr(frequency=[0.01, 0.01], ) * window * 0.1
    warps = ugens.Warp1.ar(
        buffer_id=builder['buffer_id'],
        channel_count=1,
        frequency_scaling=builder['transpose'].semitones_to_ratio(),
        interpolation=2,