コード例 #1
0
ファイル: orc_example.py プロジェクト: hecanjog/pippi-console
def play(voice_id):
    """ Every generator script must define a play() function, which 
        accepts a voice_id integer (so you can read and write params 
        for each voice) and returns a sound.
        
        The shortname and name metadata above are optional, if you 
        don't include them the name will be drawn from the filename 
        and the shortname will be the first two characters of that name.
    """

    # Get the current bpm set in our session
    bpm = C('bpm')

    # Convert it to a length in frames
    beat = dsp.bpm2frames(bpm)

    # Read per-instance param, with a default value
    volume = P(voice_id, 'volume', default=1.0)

    # Get a frequency for the beep
    freq = tune.ntf('a', octave=2)

    # Beep for a beat
    out = dsp.tone(length=beat, freq=freq, wavetype='sine2pi', amp=volume)

    # Be silent for a beat after the beep
    out = dsp.pad(out, 0, beat)

    # Log the length of the computed buffer. 
    # I like to tail -f pippi.log during performance.
    dsp.log('voice %s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out))))

    # Pass along the final buffer for playback
    return out
コード例 #2
0
ファイル: jbutler.py プロジェクト: hecanjog/jbutler
def ding(tone, tlength=88200, nlength=1000):

    def sequence(tonic='g'):
        numdegrees = dsp.randint(2, 8)
        degrees = [1,5,8,11,12]
        #scale = [ dsp.randchoose(degrees) for i in range(numdegrees) ]
        scale = degrees[dsp.randint(0, 3):]
        scale = dsp.randshuffle(scale)
        scale = tune.fromdegrees(scale, 1, tonic, tune.major, tune.terry) 
        
        return scale

    numtones = tlength / nlength
    numtones = 1 if numtones < 1 else numtones

    freqs = [ note / tune.ntf('g', 4) for note in sequence('g') ]

    tones = [ dsp.transpose(tone, freq) for freq in freqs ]
    #tones = [ dsp.cut(tones[i % len(tones)], dsp.mstf(dsp.rand(0, 100)), nlength + dsp.randint(0, 500)) for i in range(numtones) ]
    tones = [ dsp.cut(tones[i % len(tones)], dsp.mstf(dsp.rand(0, 100)), nlength) for i in range(numtones) ]

    #tones = [ dsp.drift(tone, 0.03) for tone in tones ]
    curve = dsp.breakpoint([0] + [ dsp.rand(0, 0.01) for i in range(3) ], len(tones))
    tones = [ dsp.drift(tone, curve[index % len(curve)]) for index, tone in enumerate(tones) ]

    tones = [ fade(tone) for tone in tones ]
    
    return dsp.amp(''.join(tones), 0.5)
コード例 #3
0
ファイル: study.xii.py プロジェクト: hecanjog/pattern.studies
def makeRhodes(length, beat, freqs):
    root = tune.ntf(key, 2)

    for i, freq in enumerate(freqs):
        if freq > root * 2.5:
            freqs[i] = freq * 0.5

    chord = [keys.rhodes(length, freq, dsp.rand(0.4, 0.6)) for freq in freqs]
    chord = dsp.randshuffle(chord)
    pause = 0
    for i, c in enumerate(chord):
        pause = pause + (dsp.randint(1, 4) * beat)
        c = dsp.pan(c, dsp.rand())
        chord[i] = dsp.pad(dsp.fill(c, length - pause), pause, 0)

    chord = dsp.mix(chord)

    chord = dsp.split(chord, dsp.flen(chord) / 16)
    chord = dsp.randshuffle(chord)
    chord = [dsp.env(ch, "phasor") for ch in chord]

    chord = [
        dsp.mix(
            [
                dsp.amp(dsp.pan(grain, dsp.rand()), dsp.rand(0.1, 0.8)),
                dsp.amp(dsp.pan(dsp.randchoose(chord), dsp.rand()), dsp.rand(0.1, 0.8)),
            ]
        )
        for grain in chord
    ]
    chord = "".join(chord)

    return chord
コード例 #4
0
    def __init__(self, instrument='guitar', octave_offset=-0):
        """
        Initialize class
        :param instrument:
        :param octave_offset:
        """
        self.instrument = instrument
        self.octave_offset = octave_offset

        if self.instrument == 'guitar':
            self.base_tone = dsp.read(
                '/home/nik/Projects/pippi/tests/sounds/guitar1s.wav')  #Tone A
            self.original_freq = tune.ntf('A{}'.format(4 - octave_offset))
            print("Frequency of base tone: {} Hz ".format(self.original_freq))

        self.keys = {
            'A0': 0,
            'Bb': 1,
            'B': 2,
            'C': 3,
            'Db': 4,
            'D': 5,
            'Eb': 6,
            'E': 7,
            'F': 8,
            'Gb': 9,
            'G': 10,
            'Ab': 11,
            'A': 12
        }

        self.keys_inverted = {value: key for key, value in self.keys.items()}
コード例 #5
0
ファイル: safari.py プロジェクト: hecanjog/hcj.py
def play(ctl):
    freq = tune.ntf(dsp.randchoose(['eb']), octave=dsp.randint(0,2))

    synth = keys.rhodes(dsp.stf(4), freq)

    s = dsp.vsplit(synth, dsp.mstf(50), dsp.mstf(2000))
    s = dsp.randshuffle(s)
    #s = [ dsp.alias(ss) for ss in s ]
    s = [ dsp.amp(ss, dsp.rand(0.5, 0.75)) for ss in s ]
    s = [ dsp.pan(ss, dsp.rand(0, 1)) for ss in s ]
    s = ''.join(s)
    s = dsp.fill(s, dsp.flen(synth))

    s2 = dsp.vsplit(synth, dsp.mstf(150), dsp.mstf(1500))
    s2 = dsp.randshuffle(s2)
    s2 = [ dsp.transpose(ss, dsp.randchoose([1,1.5,2,3,4,8])) for ss in s2 ]
    s2 = [ dsp.env(ss, 'phasor') for ss in s2 ]
    s2 = ''.join(s2)


    out = dsp.mix([ s, s2 ])

    out = dsp.amp(out, 1.5)

    out = dsp.transpose(out, 1.01) 
#synth = dsp.fill(synth, dsp.flen(main))

#out = synth

    return out
コード例 #6
0
ファイル: bells.py プロジェクト: hecanjog/geodes.py
def play(ctl):
    #out = snds.load('genie/piano.wav')

    lenrange = 300
    minlen = 1

    if dsp.rand() > 0.5:
        lengths = dsp.breakpoint([dsp.rand(0, 1) for _ in range(5)], 50)
    else:
        lengths = dsp.wavetable('sine', 50)

    lengths = [dsp.mstf(l * lenrange + minlen) for l in lengths]

    out = ''

    for length in lengths:
        freq = tune.ntf('f', octave=dsp.randint(2, 5))

        if dsp.rand() > 10.85:
            length = dsp.stf(dsp.rand(0.5, 3))
            freq = dsp.randchoose(
                tune.fromdegrees([1, 3, 4, 5, 6], octave=4, root='f'))

        out += keys.pulsar(freq=freq, length=length, env='phasor')

        if dsp.rand() > 10.75:
            freq = dsp.randchoose(
                tune.fromdegrees([1, 3, 4, 5, 6], octave=4, root='f'))

    return out
コード例 #7
0
def play(voice_id):
    bpm = config('bpm')
    beat = dsp.bpm2frames(bpm)

    root = config('key')
    quality = getattr(tune, config('quality')) 
    ratios = getattr(tune, config('tune')) 

    bar = beat * dsp.randchoose([8, 16, 32])

    groot = tune.ntf('c') 

    scale = tune.fromdegrees([1,3,5,6,8,9], root=root, octave=2, ratios=ratios)

    v = dsp.read('sounds/vibesc1.wav').data

    out = ''

#    lens = [ bar / 5, bar / 8, bar / 12 ]
    lens = [ bar / 6, bar / 8, bar / 16 ]

    maxbend = 2
    maxbend = 0.02

    layers = []

    for nlen in lens:
        layer = ''

        nlen /= 2

        note = dsp.transpose(v, (dsp.randchoose(scale) * 2**dsp.randint(0, 3)) / groot)
        note = dsp.fill(note, nlen)
        note = dsp.env(note, 'phasor')
        note = dsp.amp(note, 0.125)

        nbeats = bar / nlen
        for b in range(nbeats):
            b = dsp.pan(note, dsp.rand())
            b = dsp.drift(b, dsp.rand(0, dsp.rand(0.01, maxbend)))

            if dsp.flen(b) < nlen:
                b = dsp.pad(b, 0, nlen - dsp.flen(b))

#            if dsp.rand() > 0.5:
#                b = dsp.vsplit(b, dsp.flen(b) / 3, dsp.flen(b) / 2)
#                b = dsp.randshuffle(b)
#                b = [ dsp.amp(bb, dsp.rand(0.5, 2)) for bb in b ]
#                b = ''.join(b)

            layer += b

#        layer = dsp.fill(layer, bar)

        layers += [ layer ]

    out = dsp.mix(layers)
    out = dsp.fill(out, bar)

    return out
コード例 #8
0
ファイル: study.xii.py プロジェクト: hecanjog/pattern.studies
def makeRhodes(length, beat, freqs):
    root = tune.ntf(key, 2)

    for i, freq in enumerate(freqs):
        if freq > root * 2.5:
            freqs[i] = freq * 0.5

    chord = [ keys.rhodes(length, freq, dsp.rand(0.4, 0.6)) for freq in freqs ]
    chord = dsp.randshuffle(chord)
    pause = 0
    for i, c in enumerate(chord):
        pause = pause + (dsp.randint(1, 4) * beat)
        c = dsp.pan(c, dsp.rand())
        chord[i] = dsp.pad(dsp.fill(c, length - pause), pause, 0)

    chord = dsp.mix(chord)

    chord = dsp.split(chord, dsp.flen(chord) / 16)
    chord = dsp.randshuffle(chord)
    chord = [ dsp.env(ch, 'phasor') for ch in chord ]

    chord = [ dsp.mix([ dsp.amp(dsp.pan(grain, dsp.rand()), dsp.rand(0.1, 0.8)), dsp.amp(dsp.pan(dsp.randchoose(chord), dsp.rand()), dsp.rand(0.1, 0.8)) ]) for grain in chord ]
    chord = ''.join(chord)

    return chord
コード例 #9
0
def play(voice_id):
    bpm = config('bpm')
    key = config('key')
    quality = getattr(tune, config('quality')) 
    ratios = getattr(tune, config('tune')) 

    beat = dsp.bpm2frames(bpm)
    nlen = beat / dsp.randchoose([4,5,6,7,8,9,10])

    root = 340.0
    target = tune.ntf(key)

    n = dsp.read('sounds/mike.wav').data
    n = dsp.transpose(n, target / root)
    n = dsp.amp(n, 0.4)

    length = dsp.randint(16, 64) * beat
    ngrains = length / nlen

    n = dsp.transpose(n, dsp.randchoose([0.5, 1, 2, 2, 4, 4]))
    n = dsp.split(n, nlen)

    snd = dsp.randchoose(n)
    snd = dsp.env(snd, 'sine')

    grains = [ snd for i in range(ngrains) ]
    grains = [ dsp.pan(grain, dsp.rand()) for grain in grains ]

    out = ''.join(grains)
    out = dsp.env(out, 'sine')

#    out = dsp.pad(out, 0, dsp.stf(dsp.randint(0.5, 3)))

    return out
コード例 #10
0
def ding(tone, tlength=88200, nlength=1000):
    def sequence(tonic='g'):
        numdegrees = dsp.randint(2, 8)
        degrees = [1, 5, 8, 11, 12]
        #scale = [ dsp.randchoose(degrees) for i in range(numdegrees) ]
        scale = degrees[dsp.randint(0, 3):]
        scale = dsp.randshuffle(scale)
        scale = tune.fromdegrees(scale, 1, tonic, tune.major, tune.terry)

        return scale

    numtones = tlength / nlength
    numtones = 1 if numtones < 1 else numtones

    freqs = [note / tune.ntf('g', 4) for note in sequence('g')]

    tones = [dsp.transpose(tone, freq) for freq in freqs]
    #tones = [ dsp.cut(tones[i % len(tones)], dsp.mstf(dsp.rand(0, 100)), nlength + dsp.randint(0, 500)) for i in range(numtones) ]
    tones = [
        dsp.cut(tones[i % len(tones)], dsp.mstf(dsp.rand(0, 100)), nlength)
        for i in range(numtones)
    ]

    #tones = [ dsp.drift(tone, 0.03) for tone in tones ]
    curve = dsp.breakpoint([0] + [dsp.rand(0, 0.01) for i in range(3)],
                           len(tones))
    tones = [
        dsp.drift(tone, curve[index % len(curve)])
        for index, tone in enumerate(tones)
    ]

    tones = [fade(tone) for tone in tones]

    return dsp.amp(''.join(tones), 0.5)
コード例 #11
0
ファイル: keys.py プロジェクト: hecanjog/hcj.py
def bell(length=22050, freq=220, amp=0.5):
    ding = dsp.read('/home/hecanjog/sounds/vibesc1.wav').data
    ding = dsp.amp(ding, dsp.rand(0.5, 0.8))

    bell = dsp.read('/home/hecanjog/sounds/tones/bellc.wav').data
    bell = dsp.amp(bell, dsp.rand(10, 50))
    bell = dsp.amp(bell, 0.3)

    rhodes = dsp.read('/home/hecanjog/sounds/tones/rhodes.wav').data
    rhodes = dsp.transpose(rhodes, 1.2)
    rhodes = dsp.pan(rhodes, dsp.rand())

    glade = dsp.read('/home/hecanjog/sounds/glade.wav').data
    numgs = dsp.randint(2, 6)

    gs = []
    for _ in range(numgs):
        g = dsp.rcut(glade, dsp.mstf(100, 500))
        g = dsp.amp(g, dsp.rand(0.2, 0.5))
        g = dsp.pan(g, dsp.rand())
        g = dsp.transpose(g, dsp.rand(0.15, 0.75))

        gs += [ g ]

    gs = dsp.mix(gs)
    gs = dsp.env(gs, 'phasor')

    clump = dsp.mix([ ding, gs, bell, rhodes ])

    clump = dsp.transpose(clump, freq / tune.ntf('c', octave=4))
    clump = dsp.fill(clump, length, silence=True)
    clump = dsp.env(clump, 'phasor')
    clump = dsp.amp(clump, amp)

    return clump
コード例 #12
0
ファイル: bounce.py プロジェクト: hecanjog/pippi-console
def play(args):
    length = dsp.stf(0.2)
    volume = 0.2 
    octave = 2 
    notes = ['d', 'a']
    quality = tune.major
    waveform = 'sine'
    ratios = tune.terry

    wtypes = ['sine', 'phasor', 'line', 'saw']

    for arg in args:
        a = arg.split(':')

        if a[0] == 't':
            length = dsp.stf(float(a[1]))

        if a[0] == 'v':
            volume = float(a[1]) / 100.0

        if a[0] == 'o':
            octave = int(a[1])

        if a[0] == 'n':
            notes = a[1].split('.')

        if a[0] == 'q':
            if a[1] == 'M':
                quality = tune.major
            elif a[1] == 'm':
                quality = tune.minor
            else:
                quality = tune.major

        if a[0] == 'tr':
            ratios = getattr(tune, a[1], tune.terry)

    harm = range(1, 12)

    layers = []
    for note in notes:
        freq = tune.ntf(note, octave, ratios) 
        #tonic = dsp.env(dsp.amp(dsp.tone(length, freq, 'sine2pi'), 0.2), 'phasor') * 500

        tones = []

        for t in range(4):
            angles = dsp.breakpoint([ freq * dsp.randchoose(harm) for f in range(dsp.randint(2, 20)) ], 100)
            angles = [ dsp.env(dsp.tone(length, a, 'sine2pi'), 'sine', amp=0.2) for a in angles ]
            tones += [ ''.join(angles) ]

        #layer = dsp.benv(dsp.mix(tones), [ dsp.rand(0.1, 0.7) for i in range(dsp.randint(5, 30)) ]) 
        layers += [ dsp.mix(tones) ]
        #layers += [ dsp.mix([layer, tonic]) ]
        #layers += [ layer ]

    out = dsp.mix(layers)

    return dsp.amp(out, volume)
コード例 #13
0
ファイル: guitar.py プロジェクト: hecanjog/geodes-minorg
def play(voice_id):
    bpm = config('bpm')
    key = config('key')
    quality = getattr(tune, config('quality')) 
    ratios = getattr(tune, config('tune')) 

    beat = dsp.bpm2frames(bpm)
    beat = beat / 4

    glitch = False
    alias = False
    nbeats = P(voice_id, 'multiple', dsp.randchoose([8, 16]))

    gs = ['gC1', 'gC2']
    g = dsp.randchoose(gs)
    n = dsp.read('sounds/%s.wav' % g).data

#    speeds = [1, 1.25, 1.5, 1.666, 2, 4]
    speeds = [1, 1.25, 1.5, 2, 3, 4, 6, 8, 16]

    root = tune.ntf('c')
    target = tune.ntf(key)

    n = dsp.transpose(n, target / root)
    n = dsp.fill(n, dsp.stf(20))
    n = dsp.transpose(n, dsp.randchoose(speeds))
    n = dsp.split(n, beat)
    n = dsp.randshuffle(n)
    n = n[:nbeats + 1]

    if alias:
        n = [ dsp.alias(nn) for nn in n ]

    n = [ dsp.amp(nn, dsp.rand(0.1, 0.75)) for nn in n ]
    n = [ dsp.pan(nn, dsp.rand()) for nn in n ]

    n = ''.join(n)

    out = n

    if glitch:
        out = dsp.vsplit(out, dsp.mstf(dsp.rand(80, 140)), dsp.mstf(500))
        out = dsp.randshuffle(out)
        out = ''.join(out)

    return out
コード例 #14
0
def play(voice_id):
    bpm = config('bpm')
    key = config('key')
    quality = getattr(tune, config('quality'))
    ratios = getattr(tune, config('tune'))

    beat = dsp.bpm2frames(bpm)
    beat = beat / 4

    glitch = False
    alias = False
    nbeats = P(voice_id, 'multiple', dsp.randchoose([8, 16]))

    gs = ['gC1', 'gC2']
    g = dsp.randchoose(gs)
    n = dsp.read('sounds/%s.wav' % g).data

    #    speeds = [1, 1.25, 1.5, 1.666, 2, 4]
    speeds = [1, 1.25, 1.5, 2, 3, 4, 6, 8, 16]

    root = tune.ntf('c')
    target = tune.ntf(key)

    n = dsp.transpose(n, target / root)
    n = dsp.fill(n, dsp.stf(20))
    n = dsp.transpose(n, dsp.randchoose(speeds))
    n = dsp.split(n, beat)
    n = dsp.randshuffle(n)
    n = n[:nbeats + 1]

    if alias:
        n = [dsp.alias(nn) for nn in n]

    n = [dsp.amp(nn, dsp.rand(0.1, 0.75)) for nn in n]
    n = [dsp.pan(nn, dsp.rand()) for nn in n]

    n = ''.join(n)

    out = n

    if glitch:
        out = dsp.vsplit(out, dsp.mstf(dsp.rand(80, 140)), dsp.mstf(500))
        out = dsp.randshuffle(out)
        out = ''.join(out)

    return out
コード例 #15
0
ファイル: amber.py プロジェクト: lettersonsounds/amber
                def bass(amp, length, oct=2):
                    if amp == 0:
                        return dsp.pad('', 0, length)

                    #bass_note = ['d', 'g', 'a', 'b'][ bassPlay % 4 ]
                    bass_note = ['e', 'a', 'b', 'c#'][ bassPlay % 4 ]

                    out = dsp.tone(length, wavetype='square', freq=tune.ntf(bass_note, oct), amp=amp*0.2)
                    out = dsp.env(out, 'random')

                    return out
コード例 #16
0
ファイル: study.ix.py プロジェクト: hecanjog/pattern.studies
def makeRhodes(length, beat, freqs, maxbend=0.05):
    backup = Sampler(snds.load('tones/nycrhodes01.wav'), tune.ntf('c'), direction='fw-bw-loop', tails=False)
    chord = [ keys.rhodes(length, freq, dsp.rand(0.4, 0.7)) for freq in freqs ]
    chord = dsp.randshuffle(chord)
    chord = [ dsp.mix([ dsp.env(fx.penv(backup.play(freq * 2**dsp.randint(0,2), length, dsp.rand(0.4, 0.6))), 'line'), c ]) for freq, c in zip(freqs, chord) ]
    pause = 0
    for i, c in enumerate(chord):
        pause = pause + (dsp.randint(1, 4) * beat)
        c = dsp.pan(c, dsp.rand())
        c = fx.bend(c, [ dsp.rand() for _ in range(dsp.randint(5, 10)) ], dsp.rand(0, maxbend))
        chord[i] = dsp.pad(dsp.fill(c, length - pause), pause, 0)

    return dsp.mix(chord)
コード例 #17
0
ファイル: amber.py プロジェクト: lettersonsounds/amber
                def bass(amp, length, oct=2):
                    if amp == 0:
                        return dsp.pad('', 0, length)

                    #bass_note = ['d', 'g', 'a', 'b'][ bassPlay % 4 ]
                    bass_note = ['e', 'a', 'b', 'c#'][bassPlay % 4]

                    out = dsp.tone(length,
                                   wavetype='square',
                                   freq=tune.ntf(bass_note, oct),
                                   amp=amp * 0.2)
                    out = dsp.env(out, 'random')

                    return out
コード例 #18
0
ファイル: study.ix.py プロジェクト: hecanjog/pattern.studies
def makeSwells(cname, numswells, length, key='e', octave=1):
    swells = []

    freqs = tune.chord(cname, key, octave)

    root = tune.ntf(key, octave)

    # Naive pitch wrapping
    for i, freq in enumerate(freqs):
        if freq > root * 2.5:
            freqs[i] = freq * 0.5

    for _ in range(numswells):
        slength = dsp.randint((length / numswells) * 0.85, length / numswells)
        swell = [ keys.pulsar(freq, slength, drift=dsp.rand(0.001, 0.01), speed=dsp.rand(0.1, 0.5), amp=dsp.rand(0.2, 0.5)) for freq in freqs ]
        swell = dsp.mix(swell)
        swell = dsp.env(swell, 'hann')
        swell = dsp.taper(swell, 30)

        swells += [ swell ]

    swells = [ dsp.fill(swell, length / numswells, silence=True) for swell in swells ]

    return ''.join(swells)
コード例 #19
0
def test_ntf():
    assert tune.ntf('a4') == 440
コード例 #20
0
ファイル: amber.py プロジェクト: lettersonsounds/amber
                    basses = bass(0.5, tlen, 1)
                else:
                    basses = drums.make(bass, dsp.rotate(single, vary=True),
                                        seg)

                bassPlay += 1
                layers += [basses]

            if dsp.randint(0, 1) == 0 or canPlay('jam', bigoldsection):
                # Lead synth
                #lead_note = ['d', 'g', 'a', 'b'][ leadPlay % 4 ]
                lead_note = ['e', 'a', 'b', 'c#'][leadPlay % 4]

                lead = dsp.tone(tlen / 2,
                                wavetype='tri',
                                freq=tune.ntf(lead_note, 4),
                                amp=0.2)
                lead = dsp.env(lead, 'phasor')

                leadPlay += 1
                layers += [lead]

        def makeArps(seg, oct=3, reps=4):
            arp_degrees = [1, 2, 3, 5, 8, 9, 10]
            if dsp.randint(0, 1) == 0:
                arp_degrees.reverse()

            arp_degrees = dsp.rotate(arp_degrees, vary=True)
            arp_notes = tune.fromdegrees(arp_degrees[:reps], oct, 'e')

            arps = ''
コード例 #21
0
ファイル: drone.py プロジェクト: hecanjog/geodes-minorg
def play(voice_id):
    bpm = config('bpm')
    beat = dsp.bpm2frames(bpm)
    dsl = P(voice_id, 'drum', 'h.c')

    length = int(P(voice_id, 'length', dsp.stf(dsp.rand(5, 12))))
    volume = P(voice_id, 'volume', 70.0) 
    volume = volume / 100.0 # TODO move into param filter

    octave = P(voice_id, 'octave', 3)
    notes = P(voice_id, 'note', '["%s"]' % config('key'))
    notes = json.loads(notes)
    
    hertz = P(voice_id, 'hertz', False)
    alias = P(voice_id, 'alias', False)
    alias = True
    bend = P(voice_id, 'bend', False)
    env = P(voice_id, 'envelope', 'gauss')
    harmonics = P(voice_id, 'harmonic', '[1,2,3,4]')
    harmonics = json.loads(harmonics)
    reps      = P(voice_id, 'repeats', 1)
    waveform = P(voice_id, 'waveform', 'sine2pi')

    quality = getattr(tune, config('quality')) 
    ratios = getattr(tune, config('tune')) 

    glitch = False
    #glitch = True
    root = 27.5
    pinecone = False
    bbend = False
    wild = False

    if bbend == True:
        bend = True

    tune.a0 = float(root)

    # These are amplitude envelopes for each partial,
    # randomly selected for each. Not to be confused with 
    # the master 'env' param which is the amplit
    wtypes = ['sine', 'phasor', 'line', 'saw']    
    layers = []

    if hertz is not False:
        notes = hertz

    for note in notes:
        tones = []
        for i in range(dsp.randint(2,4)):
            if hertz is not False:
                freq = float(note)

                if octave > 1:
                    freq *= octave
            else:
                freq = tune.ntf(note, octave)

            snds = [ dsp.tone(length, freq * h, waveform, 0.05) for h in harmonics ]
            snds = [ dsp.env(s, dsp.randchoose(wtypes), highval=dsp.rand(0.3, 0.6)) for s in snds ]
            snds = [ dsp.pan(s, dsp.rand()) for s in snds ]

            if bend is not False:
                def bendit(out=''):
                    if bbend == True:
                        bendtable = dsp.randchoose(['impulse', 'sine', 'line', 'phasor', 'cos', 'impulse'])
                        lowbend = dsp.rand(0.8, 0.99)
                        highbend = dsp.rand(1.0, 1.25)
                    else:
                        bendtable = 'sine'
                        lowbend = 0.99
#                        lowbend = 0.75
                        highbend = 1.01
#                        highbend = 1.5

                    out = dsp.split(out, 441)

                    freqs = dsp.wavetable(bendtable, len(out))

                    freqs = [ math.fabs(f) * (highbend - lowbend) + lowbend for f in freqs ]

                    out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ]
                    return ''.join(out)

                snds = [ bendit(snd) for snd in snds ]

            tones += [ dsp.mix(snds) ]

        layer = dsp.mix(tones)

        if wild != False:
            layer = dsp.vsplit(layer, 41, 4410)
            layer = [ dsp.amp(dsp.amp(l, dsp.rand(10, 20)), 0.5) for l in layer ]
            layer = ''.join(layer)
        
        if pinecone != False:
            layer = dsp.pine(layer, length, freq, 4)

        if glitch == True:
            layer = dsp.vsplit(layer, dsp.mstf(10), dsp.flen(layer) / 4)
            layer = dsp.randshuffle(layer)
            layer = ''.join(layer)

        layer = dsp.env(layer, env)

        layers += [ layer ]

    out = dsp.mix(layers) * reps

    return dsp.amp(out, volume)
コード例 #22
0
#
xaxis = ny.arange(samples, dtype=ny.float)  #
ydata = volume * ny.sin(xaxis * omega)  #
# blanks填充获取numpy数字信号                                       #
signal = ny.resize(ydata, (samples, ))  #
scipy.io.wavfile.write('test.wav', samplerate, signal)  #
#
##################################################################

#读取test.wav文件
raw = dsp.read('test.wav')

##########  输入原先创建的正弦波,通过pippi创建一个C3调谐  ##############
#
freqs = tune.chord('I', key='C', octave=3, ratios=tune.just)  #
original_freq = tune.ntf('A1')  #
speeds = [new_freq / original_freq for new_freq in freqs]  #
pos = 0  #
beat = 1.5  #
out = dsp.buffer()  #
#参考:https://pippi.world/docs/tutorials/001-soundbuffers/        #
for speed in speeds:  #
    # 创建原始输入文件音高偏移副本                                     #
    note = raw.speed(speed)  #
    #
    # 复制到输出缓冲区中                                             #
    out.dub(note, pos)  #
    #
    # 复制高八度副本                                                #
    note = raw.speed(speed * 2)  #
    out.dub(note, pos + 0.8)  #
コード例 #23
0
ファイル: drone.py プロジェクト: hecanjog/geodes-minorg
def play(voice_id):
    bpm = config('bpm')
    beat = dsp.bpm2frames(bpm)
    dsl = P(voice_id, 'drum', 'h.c')

    length = int(P(voice_id, 'length', dsp.stf(dsp.rand(5, 12))))
    volume = P(voice_id, 'volume', 70.0)
    volume = volume / 100.0  # TODO move into param filter

    octave = P(voice_id, 'octave', 3)
    notes = P(voice_id, 'note', '["%s"]' % config('key'))
    notes = json.loads(notes)

    hertz = P(voice_id, 'hertz', False)
    alias = P(voice_id, 'alias', False)
    alias = True
    bend = P(voice_id, 'bend', False)
    env = P(voice_id, 'envelope', 'gauss')
    harmonics = P(voice_id, 'harmonic', '[1,2,3,4]')
    harmonics = json.loads(harmonics)
    reps = P(voice_id, 'repeats', 1)
    waveform = P(voice_id, 'waveform', 'sine2pi')

    quality = getattr(tune, config('quality'))
    ratios = getattr(tune, config('tune'))

    glitch = False
    #glitch = True
    root = 27.5
    pinecone = False
    bbend = False
    wild = False

    if bbend == True:
        bend = True

    tune.a0 = float(root)

    # These are amplitude envelopes for each partial,
    # randomly selected for each. Not to be confused with
    # the master 'env' param which is the amplit
    wtypes = ['sine', 'phasor', 'line', 'saw']
    layers = []

    if hertz is not False:
        notes = hertz

    for note in notes:
        tones = []
        for i in range(dsp.randint(2, 4)):
            if hertz is not False:
                freq = float(note)

                if octave > 1:
                    freq *= octave
            else:
                freq = tune.ntf(note, octave)

            snds = [
                dsp.tone(length, freq * h, waveform, 0.05) for h in harmonics
            ]
            snds = [
                dsp.env(s, dsp.randchoose(wtypes), highval=dsp.rand(0.3, 0.6))
                for s in snds
            ]
            snds = [dsp.pan(s, dsp.rand()) for s in snds]

            if bend is not False:

                def bendit(out=''):
                    if bbend == True:
                        bendtable = dsp.randchoose([
                            'impulse', 'sine', 'line', 'phasor', 'cos',
                            'impulse'
                        ])
                        lowbend = dsp.rand(0.8, 0.99)
                        highbend = dsp.rand(1.0, 1.25)
                    else:
                        bendtable = 'sine'
                        lowbend = 0.99
                        #                        lowbend = 0.75
                        highbend = 1.01
#                        highbend = 1.5

                    out = dsp.split(out, 441)

                    freqs = dsp.wavetable(bendtable, len(out))

                    freqs = [
                        math.fabs(f) * (highbend - lowbend) + lowbend
                        for f in freqs
                    ]

                    out = [
                        dsp.transpose(out[i], freqs[i])
                        for i in range(len(out))
                    ]
                    return ''.join(out)

                snds = [bendit(snd) for snd in snds]

            tones += [dsp.mix(snds)]

        layer = dsp.mix(tones)

        if wild != False:
            layer = dsp.vsplit(layer, 41, 4410)
            layer = [dsp.amp(dsp.amp(l, dsp.rand(10, 20)), 0.5) for l in layer]
            layer = ''.join(layer)

        if pinecone != False:
            layer = dsp.pine(layer, length, freq, 4)

        if glitch == True:
            layer = dsp.vsplit(layer, dsp.mstf(10), dsp.flen(layer) / 4)
            layer = dsp.randshuffle(layer)
            layer = ''.join(layer)

        layer = dsp.env(layer, env)

        layers += [layer]

    out = dsp.mix(layers) * reps

    return dsp.amp(out, volume)
コード例 #24
0
ファイル: drone.py プロジェクト: hecanjog/pippi-console
def play(params=None):
    params = params or {}

    length = params.get('length', dsp.stf(dsp.rand(5, 12)))
    volume = params.get('volume', 20.0) 
    volume = volume / 100.0 # TODO move into param filter
    octave = params.get('octave', 1)
    notes = params.get('note', ['c', 'g'])
    hertz = params.get('hertz', False)
    quality = params.get('quality', tune.major)
    glitch = params.get('glitch', False)
    waveform = params.get('waveform', 'sine')
    ratios = params.get('ratios', tune.terry)
    alias = params.get('alias', False)
    wild = params.get('wii', False)
    bend = params.get('bend', False)
    bbend = params.get('bbend', False)
    env = params.get('envelope', 'gauss')
    harmonics = params.get('harmonic', [1,2])
    reps      = params.get('repeats', 1)
    root = params.get('root', 27.5)
    pinecone = params.get('pinecone', False)

    if bbend == True:
        bend = True

    tune.a0 = float(root)

    # These are amplitude envelopes for each partial,
    # randomly selected for each. Not to be confused with 
    # the master 'env' param which is the amplit
    wtypes = ['sine', 'phasor', 'line', 'saw']    
    layers = []

    if hertz is not False:
        notes = hertz

    for note in notes:
        tones = []
        for i in range(dsp.randint(2,4)):
            if hertz is not False:
                freq = float(note)

                if octave > 1:
                    freq *= octave
            else:
                freq = tune.ntf(note, octave)

            snds = [ dsp.tone(length, freq * h, waveform, 0.05) for h in harmonics ]
            snds = [ dsp.env(s, dsp.randchoose(wtypes), highval=dsp.rand(0.2, 0.4)) for s in snds ]
            snds = [ dsp.pan(s, dsp.rand()) for s in snds ]

            if bend is not False:
                def bendit(out=''):
                    if bbend == True:
                        bendtable = dsp.randchoose(['impulse', 'sine', 'line', 'phasor', 'cos', 'impulse'])
                        lowbend = dsp.rand(0.8, 0.99)
                        highbend = dsp.rand(1.0, 1.25)
                    else:
                        bendtable = 'sine'
                        lowbend = 0.99
                        highbend = 1.01

                    out = dsp.split(out, 441)

                    freqs = dsp.wavetable(bendtable, len(out))

                    freqs = [ math.fabs(f) * (highbend - lowbend) + lowbend for f in freqs ]

                    out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ]
                    return ''.join(out)

                snds = [ bendit(snd) for snd in snds ]

            tones += [ dsp.mix(snds) ]

        layer = dsp.mix(tones)

        if wild != False:
            layer = dsp.vsplit(layer, 41, 4410)
            layer = [ dsp.amp(dsp.amp(l, dsp.rand(10, 20)), 0.5) for l in layer ]
            layer = ''.join(layer)
        
        if pinecone != False:
            layer = dsp.pine(layer, length, freq, 4)

        layer = dsp.env(layer, env)

        layers += [ layer ]

    out = dsp.mix(layers) * reps

    # Format is: [ path, offset, id, value ]
    if hertz is not False:
        osc_message = ['/dac', 0.0, 0, tune.fts(notes[0])]
    else:
        osc_message = ['/dac', 0.0, 0, tune.nts(notes[0], octave - 1)]

    #return (dsp.amp(out, volume), {'osc': [ osc_message ]})
    return dsp.amp(out, volume)
コード例 #25
0
def folds(length, pos, total_length):
    print('FOLDS', length, pos)
    freq = tune.ntf('e', octave=3)
    out = dsp.mix([ rhodes.rhodes(length, freq, 0.3) for freq in scale ])
    return mixdrift(out)
コード例 #26
0
    def get_notes(self,
                  mml: str,
                  *,
                  max_length: int = None,
                  max_notes: int = None):
        matches = re.finditer(self.pattern, mml)

        T = self.tempo or 120
        L = self.length or 4
        dotted = False
        V = self.volume or 8
        O = self.octave or 4
        tie = False

        notes = []
        pos = 0
        track = Track(max_length=max_length, max_notes=max_notes)

        for m in matches:
            if m[0].startswith('/'):
                #comment, ignore
                continue

            if m[0] == '<':
                O -= 1
            elif m[0] == '>':
                O += 1
            elif m[0] == '&':
                tie = True
            elif m[1] == 't':
                T = int(m[3])
            elif m[1] == 'l':
                L = int(m[3])
                dotted = bool(m[4])
            elif m[1] == 'v':
                V = int(m[3])
            elif m[1] == 'o':
                O = int(m[3])

            elif m[1] in 'abcdefgrn':
                try:
                    if m[1] == 'n':
                        length = 240 / (L * T)
                    else:
                        length = 240 / ((int(m[3]) if m[3] else L) * T)
                    if dotted or m[4]:
                        length *= 1.5
                    if tie:
                        #tie
                        track.extend_last(length)
                        tie = False
                    elif m[1] == 'r':
                        #do nothing, advence position
                        track.rest(length)
                    else:
                        #every other note
                        note = m[1]
                        if m[2] in {'+', '#'}:
                            note += '#'
                        elif m[2] == '-':
                            note += 'b'

                        if note == 'cb':
                            o = O - 1
                        elif note == 'b#':
                            o = O + 1
                        else:
                            o = O
                        if note == 'n':
                            # Handle midi notes
                            freq = tune.mtof(note + m[3])
                        else:
                            freq = tune.ntf(note, o)

                        track.add_note(
                            Note(track.position, freq, length, [V / 8] * 2))
                except ExceededLength:
                    print("No more notes can be added due to length limit.")
                    break
        return track
コード例 #27
0
ファイル: ppulsar.py プロジェクト: hecanjog/pippi-console
def play(params):
    volume      = params.get('volume', dsp.rand(70.0, 100.0)) / 100.0

    notes       = params.get('note', [ dsp.randchoose(['c', 'f', 'e', 'a', 'd']) for i in range(2) ])

    octave =    params.get('octave', dsp.randint(1, 5)) 

    root        = params.get('root', 27.5)
    bpm         = params.get('bpm', 75.0)

    if dsp.randint(0, 1) == 0:
        length      = params.get('length', dsp.mstf(dsp.rand(10, 2000)))
    else:
        length      = params.get('length', int(dsp.randint(1, 4) * dsp.bpm2frames(bpm) * 0.25))

    env         = params.get('envelope', 'random')
    env         = params.get('envelope', 'tri')
    mod         = params.get('mod', 'random')
    modFreq     = params.get('modfreq', dsp.rand(1.0, 1.5) / dsp.fts(length))
    modRange    = params.get('speed', 0.01)
    modRange    = dsp.rand(0, modRange)

    pulsewidth  = params.get('pulsewidth', dsp.rand(0.01, 0.8))
    window      = params.get('window', 'gauss')
    #waveform    = params.get('waveform', 'random')
    waveform    = params.get('waveform', 'tri')

    glitch    = params.get('glitch', True)

    pulsewidth = 1.0


    freqs   = [ tune.ntf(note, octave) for note in notes ]

    tune.a0 = float(root)

    mod = dsp.wavetable(mod, 512)
    window = dsp.wavetable(window, 512)
    waveform = dsp.wavetable(waveform, 512)

    layers = []

    for freq in freqs:
        layers += [ dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, volume) ]

    out = dsp.mix(layers)

    try:
        out = dsp.env(out, env)
    except TypeError:
        out = dsp.env(out, 'sine')

    if glitch:
        bitlen = dsp.randint(dsp.mstf(10), dsp.mstf(500))
        bit = dsp.cut(out, dsp.randint(0, len(out) - bitlen), bitlen)
        out = dsp.vsplit(out, dsp.mstf(10), dsp.mstf(500))
        out.insert(dsp.randint(0, len(out) - 2), bit)

        out = ''.join(out)

    out = dsp.pan(out, dsp.rand())

    return out
コード例 #28
0
ファイル: curvebeats.py プロジェクト: hecanjog/sketches
    #kicks = dsp.fill(kick, dsp.flen(layers), silence=True)

    hats = drums.parsebeat(hatp, 8, beat, dsp.flen(layers), makeHat, 12)
    kicks = drums.parsebeat(kickp, 4, beat, dsp.flen(layers), makeKick, 0)
    snares = drums.parsebeat(snarep, 8, beat, dsp.flen(layers), makeSnare, 0)

    #dr = dsp.mix([ hats, kicks, snares ])
    dr = dsp.mix([ kicks, snares ])
    d = dsp.split(dr, beat / 8)
    d = dsp.randshuffle(d)
    #print len(d)
    #d = dsp.packet_shuffle(d, dsp.randint(2, 4))
    #print len(d)
    d = [ dd * dsp.randint(1, 2) for dd in d ]
    d = ''.join(d)
    d = dsp.fill(dsp.mix([d, dr]), dsp.flen(layers))

    d = dsp.amp(d, 3)

    layers = dsp.mix([ layers, d, drone ])

    ost = keys.rhodes(beat, tune.ntf('c', octave=4), 0.6)
    ost = dsp.env(ost, 'phasor')
    numosts = dsp.flen(layers) / dsp.flen(ost)
    ost = ''.join([ dsp.alias(ost) for _ in range(numosts) ]) 
    layers = dsp.mix([ layers, ost ])

    out += layers

dsp.write(out, 'out')
コード例 #29
0
ファイル: mmlparser.py プロジェクト: ioistired/mml2music
    def get_notes(self, mml):
        matches = re.finditer(self.pattern, mml)

        T = 120
        L = 4
        dotted = False
        V = 8
        O = 4
        tie = False

        notes = []
        pos = 0
        track = Track()


        for m in matches:
            if m[0].startswith('/'):
                #comment, ignore
                continue

            if m[0] == '<':
                O -= 1
            elif m[0] == '>':
                O += 1
            elif m[0] == '&':
                tie = True
            elif m[1] == 't':
                T = int(m[3])
            elif m[1] == 'l':
                L = int(m[3])
                dotted = bool(m[4])
            elif m[1] == 'v':
                V = int(m[3])
            elif m[1] == 'o':
                O = int(m[3])

            elif m[1] in 'abcdefgrn':
                if m[1] == 'n':
                    length = 240 / (L * T)
                else:
                    length = 240 / ((int(m[3]) if m[3] else L) * T)
                if dotted or m[4]:
                    length *= 1.5
                if tie:
                    #tie
                    track.extend_last(length)
                    tie = False
                elif m[1] == 'r':
                    #do nothing, advence position
                    track.rest(length)
                else:
                    #every other note
                    note = m[1]
                    if m[2] in {'+', '#'}:
                        note += '#'
                    elif m[2] == '-':
                        note += 'b'

                    if note == 'cb':
                        o = O-1
                    elif note == 'b#':
                        o = O+1
                    else:
                        o = O
                    if note == 'n':
                        # Handle midi notes
                        freq = tune.mtof(note+m[3])
                    else:
                        freq = tune.ntf(note, o)
                    track.add_note(Note(track.position, freq, length, [V/8]*2))
        return track
コード例 #30
0
ファイル: 001-soundbuffers.py プロジェクト: jshuadvd/pippi
mixed_guitars = slow_guitar & guitar
mixed_guitars.write('renders/001-guitar-mixed.wav')

print('I am a mixed %s -- %s frames and %.2f seconds long' %
      (type(mixed_guitars), len(mixed_guitars), mixed_guitars.dur))

out = dsp.buffer()

from pippi import tune

freqs = tune.chord('I', key='C', octave=3, ratios=tune.just)

print('Cmaj: %s' % freqs)

original_freq = tune.ntf('A2')

speeds = [new_freq / original_freq for new_freq in freqs]

pos = 0
beat = 1.5
for speed in speeds:
    # Create a pitch-shifted copy of the original guitar
    note = guitar.speed(speed)

    # Dub it into the output buffer at the current position in seconds
    out.dub(note, pos)

    # Just for fun, lets also dub another copy 400 milliseconds (0.4 seconds) later that's an octave higher
    note = guitar.speed(speed * 2)
    out.dub(note, pos + 0.4)
コード例 #31
0
ファイル: formant.py プロジェクト: hecanjog/pippi-console
def play(args):
    length = dsp.stf(30)
    volume = 0.2 
    octave = 2 
    notes = ['d', 'a']
    quality = tune.major
    waveform = 'sine'
    ratios = tune.terry

    wtypes = ['sine', 'phasor', 'line', 'saw']

    for arg in args:
        a = arg.split(':')

        if a[0] == 't':
            length = dsp.stf(float(a[1]))

        if a[0] == 'v':
            volume = float(a[1]) / 100.0

        if a[0] == 'o':
            octave = int(a[1])

        if a[0] == 'n':
            notes = a[1].split('.')

        if a[0] == 'q':
            if a[1] == 'M':
                quality = tune.major
            elif a[1] == 'm':
                quality = tune.minor
            else:
                quality = tune.major

        if a[0] == 'tr':
            ratios = getattr(tune, a[1], tune.terry)

    harm = range(1, 30)
    layers = []
    for note in notes:
        tones = []
        freq = tune.ntf(note, octave, ratios) 

        for i in range(30):
            angles = dsp.breakpoint([freq * dsp.randchoose(harm) for f in range(dsp.randint(3, 50))], dsp.randint(350, 500))
            alen = int(length / len(angles)) * 2

            angles = [ dsp.env(dsp.tone(alen, a, 'random'), 'sine') for a in angles ]

            # Each overtone blip should overlap by about 50% with its neighbor...
            lowangles = ''.join([ angle for i, angle in enumerate(angles) if i % 2 == 0 ])

            highangles = [ angle for i, angle in enumerate(angles) if i % 2 != 0 ]
            highangles[0] = dsp.cut(highangles[0], dsp.flen(highangles[0]) / 2, dsp.flen(highangles[0]) / 2)
            highangles = ''.join(highangles)

            tones += [ dsp.benv(dsp.amp(dsp.mix([lowangles, highangles]), 0.9), [dsp.rand(0.1, 0.9) for i in range(dsp.randint(5, 30))]) ]

        tones = dsp.mix(tones)
        #tonic = dsp.env(dsp.amp(dsp.tone(int(length * 0.6), freq, 'sine2pi'), 0.1), 'flat')

        #layers += [ dsp.mix([tones, tonic], False) ]
        layers += [ tones ]

    out = dsp.mix(layers)

    return dsp.amp(out, volume)
コード例 #32
0
ファイル: amber.py プロジェクト: lettersonsounds/amber
                    return out

                if bassPlay % 5 == 0:
                    basses = bass(0.5, tlen, 1)
                else:
                    basses = drums.make(bass, dsp.rotate(single, vary=True), seg)

                bassPlay += 1
                layers += [ basses ]

            if dsp.randint(0,1) == 0 or canPlay('jam', bigoldsection):
                # Lead synth
                #lead_note = ['d', 'g', 'a', 'b'][ leadPlay % 4 ]
                lead_note = ['e', 'a', 'b', 'c#'][ leadPlay % 4 ]

                lead = dsp.tone(tlen / 2, wavetype='tri', freq=tune.ntf(lead_note, 4), amp=0.2)
                lead = dsp.env(lead, 'phasor')

                leadPlay += 1
                layers += [ lead ]

        def makeArps(seg, oct=3, reps=4):
            arp_degrees = [1,2,3,5,8,9,10]
            if dsp.randint(0,1) == 0:
                arp_degrees.reverse()

            arp_degrees = dsp.rotate(arp_degrees, vary=True)
            arp_notes = tune.fromdegrees(arp_degrees[:reps], oct, 'e')

            arps = ''
コード例 #33
0
def test_ntf():
    assert tune.ntf('a4') == 440
コード例 #34
0
ファイル: wash.py プロジェクト: hecanjog/geodes.py
def play(ctl):
    param = ctl.get('param')
    lpd = ctl.get('midi').get('lpd')

    pc = ctl.get('midi').get('pc')
    #pc.setOffset(111)

    gamut = {
        'high': [
            (10000, 15000),
            (5000, 15000),
            (5000, 10000),
        ],

        'mid': [
            (1000, 5000),
            (1000, 2000),
        ],

        'pitch': [
            tuple([ dsp.rand(500, 2000) for p in range(2) ]),
            tuple([ dsp.rand(100, 1000) for p in range(2) ]),
            tuple([ dsp.rand(1000, 5000) for p in range(2) ]),
        ],

        'low': [
            (20, 5000),
            (30, 10000),
            (40, 10000),
        ]
    }

    area = param.get('wash-area', default='high')
    area = dsp.randchoose(['high', 'mid', 'pitch', 'low'])
    area = 'pitch'

    dsp.log(area)

    freqs = dsp.randchoose(gamut[area])

    freqscale = pc.get(16, low=0.125, high=2, default=1)
    #freqscale = dsp.rand(0.125, 2)

    low = freqs[0] * freqscale
    high = freqs[1] * freqscale

    wform = dsp.randchoose(['sine2pi', 'tri', 'vary', 'square'])

    timescale = pc.get(17, low=1, high=4, default=1)
    #timescale = dsp.rand(1, 4)
    lengthscale = pc.get(18, low=0.125, high=2.5)
    #lengthscale = dsp.rand(0.125, 2.5)

    amp = pc.get(0, low=0, high=0.5, default=0.5)
    #amp = dsp.rand(0, 0.5)

    if area == 'high':
        low = dsp.rand(low * 0.9, low)
        high = dsp.rand(high, high * 1.1)

        length = dsp.stf(dsp.rand(0.01, 0.3) * lengthscale)
        out = dsp.bln(length, low, high, wform)
        out = dsp.env(out, 'phasor')

        if dsp.rand() > 10.5:
            beep = dsp.tone(dsp.flen(out), high * 2, amp=dsp.rand(0.5, 1))
            out = dsp.mix([out, beep])

        out = dsp.pad(out, 0, dsp.mstf(dsp.rand(1, 400) * timescale))
        out = out * dsp.randint(1, 3)
        out = dsp.drift(out, dsp.rand(0, 1))

    elif area == 'mid':
        low = dsp.rand(low * 0.9, low)
        high = dsp.rand(high, high * 1.1)

        length = dsp.stf(dsp.rand(0.01, 0.5) * lengthscale)
        out = dsp.bln(length, low, high, wform)
        out = dsp.env(out, 'random')

        if timescale > 1:
            out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5)))


    elif area == 'pitch':
        low = dsp.rand(low * 0.9, low)
        high = dsp.rand(high, high * 1.1)

        length = dsp.stf(dsp.rand(0.01, 0.5) * lengthscale)
        out = dsp.bln(length, low, high, wform)
        out = dsp.env(out, 'random')

        if timescale > 1:
            out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5)))


    elif area == 'low':
        low = dsp.rand(low * 0.9, low)
        high = dsp.rand(high, high * 1.1)

        length = dsp.stf(dsp.rand(0.2, 2) * lengthscale)
        out = dsp.bln(length, low, high, wform)
        out = dsp.env(out, 'random')
        out = dsp.mix([out, dsp.tone(length, low)])

        if dsp.rand() > 0.5:
            beep = dsp.tone(dsp.flen(out), high, amp=dsp.rand(0.015, 0.1), wavetype=dsp.randchoose(['hann', 'impulse', 'square', 'vary', 'sine']))
            out = dsp.mix([out, beep])


        if timescale > 1:
            out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5)))


    if dsp.rand() > pc.get(19, low=0, high=1, default=0.75):
        plength = length * dsp.randint(2, 6)
        freq = tune.ntf(param.get('key', default='c'), octave=dsp.randint(0, 4))
        out = dsp.mix([ dsp.pine(out, plength, freq), dsp.pine(out, plength, freq * 1.25) ])
        out = dsp.fill(out, length)

    out = dsp.pan(out, dsp.rand())
    out = dsp.amp(out, amp)

    return out
コード例 #35
0
        frags += [g]

    # concat all frags
    layer = ''.join(frags)

    # add frags to layers
    layers += [layer]

# mix down frag layers
out = dsp.mix(layers)

# Add sine buildup

sines = []

lowfreq = tune.ntf('g', octave=2)

sines += [dsp.tone((dsp.flen(out) / 4) * 3, lowfreq, amp=0.4)]
sines += [dsp.tone((dsp.flen(out) / 4) * 3, lowfreq * 1.067, amp=0.4)]
sines += [dsp.tone((dsp.flen(out) / 4) * 3, lowfreq * 1.667, amp=0.25)]

sines = [dsp.mix([fx.penv(s), s]) for s in sines]

sines = dsp.mix(sines)
sines = dsp.env(sines, 'line')
sines = dsp.pad(sines, dsp.flen(out) - dsp.flen(sines), 0)

out = dsp.mix([intro, out, sines])

dsp.write(out, '01-friction_i')
コード例 #36
0
        frags += [ g ]

    # concat all frags
    layer = ''.join(frags)

    # add frags to layers
    layers += [ layer ]

# mix down frag layers
out = dsp.mix(layers)

# Add sine buildup

sines = []

lowfreq = tune.ntf('g', octave=2)

sines += [ dsp.tone((dsp.flen(out) / 4) * 3, lowfreq, amp=0.4) ]
sines += [ dsp.tone((dsp.flen(out) / 4) * 3, lowfreq * 1.067, amp=0.4) ]
sines += [ dsp.tone((dsp.flen(out) / 4) * 3, lowfreq * 1.667, amp=0.25) ]

sines = [ dsp.mix([ fx.penv(s), s ]) for s in sines ]

sines = dsp.mix(sines)
sines = dsp.env(sines, 'line')
sines = dsp.pad(sines, dsp.flen(out) - dsp.flen(sines), 0)

out = dsp.mix([ intro, out, sines ])

dsp.write(out, '01-friction_i')
コード例 #37
0
ファイル: climbing.py プロジェクト: hecanjog/geodes.py
    drone = dsp.randshuffle(drone)
    drone = ''.join(drone)

    hats = drums.parsebeat(hatp, 16, beat, dsp.flen(layers), makeHat, 12)
    kicks = drums.parsebeat(kickp, 4, beat, dsp.flen(layers), makeKick, 0)
    snares = drums.parsebeat(snarep, 8, beat, dsp.flen(layers), makeSnare, 0)

    dr = dsp.mix([kicks, snares])

    d = dsp.split(dr, beat / 8)
    d = dsp.randshuffle(d)
    d = [dd * dsp.randint(1, 2) for dd in d]
    d = ''.join(d)
    d = dsp.fill(dsp.mix([d, dr, dsp.env(hats, 'hann')]), dsp.flen(layers))

    d = dsp.amp(d, 3)

    layers = dsp.mix([layers, d, drone])

    ost = keys.rhodes(beat, tune.ntf('c', octave=4), 0.6)
    ost = dsp.env(ost, 'phasor')
    numosts = dsp.flen(layers) / dsp.flen(ost)
    ost = ''.join([dsp.alias(ost) for _ in range(numosts)])
    layers = dsp.mix([layers, ost])

    out += layers

    b += 1

dsp.write(out, 'climbing')