Beispiel #1
0
def _vox_filter(vox, freq, a, b, c):
    length = sf.Length(+vox)
    vox = sf.FixSize(polish(vox, freq))
    vox = do_formant(vox, a, b, c, freq)
    vox = polish(vox, freq)
    vox = excite(vox, 0.2, 2.0)
    vox = polish(vox, freq)
    notch = (freq + a) / 2.0
    vox = mix(sf.Pcnt75(sf.RBJNotch(+vox, notch, 0.5)), sf.Pcnt25(vox))

    if length > 1024:
        vibRate = 3.0
        depth = 0.05
        pDepth = 0.1
    else:
        vibRate = 2.5
        depth = 0.025
        pDepth = 0.05
    if length > 2048:
        at = length * 0.75
    else:
        at = length * 0.5
    vox = create_vibrato(vox,
                         length,
                         longer_than=512,
                         rate=vibRate,
                         depth=depth,
                         pitch_depth=pDepth,
                         at=at)

    vox = polish(vox, freq)
    vox = sf.RBJPeaking(vox, freq, 3, 4)
    vox = polish(vox, freq)
    return sf.FixSize(vox)
Beispiel #2
0
def _vox_filter(vox, freq, a, b, c):
    length=sf.Length(+vox)
    vox=sf.FixSize(polish(vox,freq)) 
    vox=do_formant(vox, a, b, c, freq)
    vox=polish(vox, freq)        
    vox=excite(vox, 0.2, 2.0)
    vox=polish(vox, freq)
    notch=(freq + a) / 2.0      
    vox=mix(
        sf.Pcnt75(sf.RBJNotch(+vox, notch, 0.5)),
        sf.Pcnt25(vox)
    )
    
    if length>1024:
        rate = 3.0
        depth = 0.05
        pDepth = 0.1
    else:
        rt = 2.5
        depth = 0.025
        pDepth = 0.05
    if length > 2048:
        at = length*0.75
    else:
        at = length*0.5
    vox=create_vibrato(vox, length, longer_than=512, rate=rate, depth=depth, pitch_depth=pDepth, at=at)
    
    vox=polish(vox, freq)
    vox=sf.RBJPeaking(vox, freq, 3, 4)
    vox=polish(vox, freq)
    return sf.FixSize(vox)
Beispiel #3
0
def distant_wind(length, freq):
    def doWind(lenth, hfreg):
        outF = _distant_wind(length, hfreq)
        outR = _distant_wind(length, hfreq)
        out = sf.FixSize(sf.Reverse(outR), outF)
        if freq > 256:
            out = sf.Power(out, 1.25)
        else:
            out = sf.Power(out, 1.05)
        return sf.FixSize(polish(out, hfreq))

    sigs = []
    harms = range(1, 15)
    for harm in harms:
        hfreq = harm * freq
        if hfreq > 18000.0:
            break
        sigs += [doWind(length, hfreq)]

    harms.reverse()
    for harm in harms:
        sig = sigs.pop()
        sig = sf.LinearVolume(sig, 1.0 / (pow(harm, 4.0)))
        sigs.insert(0, sig)

    out = sf.Mix(sigs)
    return sf.FixSize(polish(out, freq))
Beispiel #4
0
def distant_wind(length, freq):

    @sf_parallel
    def doWind(lenth, hfreg):
        outF = _distant_wind(length, hfreq)
        outR = _distant_wind(length, hfreq)
        out  = sf.FixSize(sf.Reverse(outR), outF)
        if freq > 256:
            out = sf.Power(out, 1.25)
        else:
            out = sf.Power(out, 1.05)
        return sf.FixSize(polish(out, hfreq))

    sigs = []
    harms = range(1, 15)
    for harm in harms:
        hfreq = harm * freq
        if hfreq > 18000.0:
            break
        sigs += [doWind(length, hfreq)]

    harms.reverse()
    for harm in harms:
        sig = sigs.pop()
        sig = sf.NumericVolume(sig, 1.0 / ( pow(harm, 4.0)))
        sigs.insert(0, sig)

    out = sf.Mix(sigs)
    return sf.FixSize(polish(out, freq))
Beispiel #5
0
def tuned_wind(length, freq):

    with SFMemoryZone():

        sigs = []
        for i in range(1, 3):
            sig = byquad_filter(
                'peak',
                byquad_filter(
                    'peak',
                    sf.Mix(clean_noise(length, freq),
                           sf.Pcnt10(sf.SineWave(length, freq))), 1.0, 64),
                freq, 0.1, 64)

            sig = byquad_filter('peak', sig, freq, 1.0, 128)

            sig = sf.FixSize(excite(sig, 1.0, 2.0))
            sig = sf.FixSize(sf.Saturate(sf.LinearVolume(sig, 2.0)))
            sig = create_vibrato(sig,
                                 length,
                                 longer_than=0.5,
                                 rate=2.5,
                                 at=0.45,
                                 depth=0.5,
                                 pitch_depth=0.02)

            sigs.append(sig)
        sig = mix(sigs)
        return sf.FixSize(polish(sig, freq)).keep()
def sing_base(length,freq,z=1.0):
    voxA=[]
    hc=1.0
    freq=float(freq)
    while hc*freq<18000:
        hf=hc*freq
        # at higher frequencies there is less need to
        # richen the sound so do only one pass of creating the 
        # waves, but double the volume of each one by two to 
        # avoid filtering effects
        if freq<5000:
            x=2
            y=1.0
        else:
            x=1
            y=2.0
        for c in range(0,x):
            vol = (1.0/hc)**z
            # cut of at -60 db 
            if vol>0.25e-06:
                vol*=y
                voxA.append(sf.LinearVolume(sf.PhasedTableSineWave(length,hf+random.random()*10.0,random.random()),vol))
                voxA.append(sf.LinearVolume(sf.PhasedTableSineWave(length,hf-random.random()*10.0,random.random()),vol))
                voxA.append(sf.LinearVolume(sf.PhasedTableSineWave(length,hf+random.random()*10.0,random.random()),vol))
                voxA.append(sf.LinearVolume(sf.PhasedTableSineWave(length,hf-random.random()*10.0,random.random()),vol))
        hc+=1

    vox=mix(voxA)       
    vox=sf.Clean(vox)
    vox=polish(sf.FixSize(vox),freq)
    return sf.FixSize(vox)
Beispiel #7
0
 def doWind(lenth, hfreg):
     outF = _distant_wind(length, hfreq)
     outR = _distant_wind(length, hfreq)
     out = sf.FixSize(sf.Reverse(outR), outF)
     if freq > 256:
         out = sf.Power(out, 1.25)
     else:
         out = sf.Power(out, 1.05)
     return sf.FixSize(polish(out, hfreq))
Beispiel #8
0
 def doWind(lenth, hfreg):
     outF = _distant_wind(length, hfreq)
     outR = _distant_wind(length, hfreq)
     out  = sf.FixSize(sf.Reverse(outR), outF)
     if freq > 256:
         out = sf.Power(out, 1.25)
     else:
         out = sf.Power(out, 1.05)
     return sf.FixSize(polish(out, hfreq))
Beispiel #9
0
def femail_soprano_ma_filter(vox, length,freq):
    vox = vox_humana_femail_soprano_a(vox,length,freq)
    if length>128:
        qsh =sf.NumericShape((0,0.1),(120,2),  (length,0.1))
        msh =sf.NumericShape((0,1.0),(120,1.0),(length,0.0))
        mshr=sf.NumericShape((0,0.0),(120,0.0),(length,1.0))
        init=byquad_filter('low',+vox,freq,qsh)
        vox =sf.Multiply(vox ,mshr)
        init=sf.Multiply(init,msh)
        vox =mix(vox,init)
        vox=sf.FixSize(polish(vox,freq))
    return vox
Beispiel #10
0
def additive_resonance(power, qCorrect, saturate, rollOff, post, limit, seed, flat, harmonics, length, freq):

    lowComp = freq < 128
    if lowComp:
        freq *= 2.0
        length *= 0.5

    @sf_parallel
    def doWind(lenth, hfq, vol, reverse=False):
        with SFMemoryZone():
            out = _distant_wind(length, hfq, qCorrect, limit, seed)
            out = sf.Power(out, power)
            if saturate:
                os = sf.Saturate(sf.NumericVolume(sf.FixSize(+out), 2.0))
                out = sf.Mix(sf.NumericVolume(out, 1.0-saturate), sf.NumericVolume(os, saturate))
            out = sf.Realise(out)
            out = sf.NumericVolume(sf.FixSize(out), vol)
            if reverse:
                out = sf.Reverse(out)
            return compress(out).keep()

    harms = []
    base = compress(sf.Silence(length))
    sigs = []
    for harm in harmonics:
        hfreq = harm * freq
        if hfreq > 18000.0:
            break
        harms.append(harm)
        vol = 1.0 / (pow(harm, rollOff))
        if flat:
            sfw = doWind(length, hfreq, vol)
            srv = doWind(length, hfreq, vol, reverse=True)
            sigs += [sfw, srv]
        else:
            sigs += [doWind(lenth, hfq, vol)]
        if len(sigs) >  3:
            sigs += [base]
            base = sf.Realise(sf.Mix(sigs))
            sigs = []

    print 'Done Wind'
    base = decompress(base)
    ret = None
    if lowComp:
        base=sf.DirectRelength(base, 0.5)
        freq *= 0.5
        length *= 2.0
        ret = sf.Realise(sf.FixSize(sf.Clean(base)))
    else:
        ret = sf.Realise(sf.FixSize(polish(base,freq)))
    return post(ret, length, freq) if post else ret
def trumpet_base(length,freq,z=1.0):
    voxA=[]
    hc=1.0
    freq=float(freq)
    while hc*freq<20000:
        hf=hc*freq
        voxA.append(sf.LinearVolume(sf.PhasedSineWave(length,hf,random.random()),(1.0/hc)**z))
        hc+=1
        
    vox=mix(voxA)
    vox=sf.Clean(vox)
    vox=polish(sf.FixSize(vox),freq)
    return sf.FixSize(vox)
Beispiel #12
0
def femail_soprano_ma_filter(vox, freq):
    with SFMemoryZone():
        length = sf.Length(vox)
        vox = vox_humana_femail_soprano_a(vox, length, freq)
        if length > 128:
            qsh = sf.LinearShape((0, 0.1), (120, 2), (length, 0.1))
            msh = sf.LinearShape((0, 1.0), (120, 1.0), (length, 0.0))
            mshr = sf.LinearShape((0, 0.0), (120, 0.0), (length, 1.0))
            init = byquad_filter('low', +vox, freq, qsh)
            vox = sf.Multiply(vox, mshr)
            init = sf.Multiply(init, msh)
            vox = mix(vox, init)
            vox = sf.FixSize(polish(vox, freq))
        return vox.keep()
Beispiel #13
0
def synthichord_filter(sig, freq):

    with SFMemoryZone():
        length = sf.Length(sig)
        vibAbove = 250
        if length > vibAbove:
            # TODO feels a bit crushed - more stages?
            vibStart = length * 0.5 if length > 600 else vibAbove * 0.75
            vibMiddle = length * 0.75 if length > 600 else vibAbove
            vibAmount = 0.5 if length > 1000 else 0.25
            trueLen = sf.Length(+sig)
            l = trueLen
            env = sf.LinearShape((0, 0), (vibStart, 0), (vibMiddle, 1),
                                 (length, 0.75), (l, 0))
            env = sf.LinearVolume(env, vibAmount)
            trem = sf.SineWave(l, 2.0 + random.random())
            trem = sf.MakeTriangle(trem)
            trem = sf.Multiply(env, trem)
            vib = +trem
            trem = sf.DirectMix(1, sf.Pcnt50(trem))
            sig = sf.Multiply(trem, sig)
            vib = sf.DirectMix(1, sf.LinearVolume(vib, 0.01))
            sig = sf.Resample(vib, sig)

        env = sf.ExponentialShape((0, sf.ToDBs(18000)),
                                  (length, sf.ToDBs(freq * 2.5)))
        env = sf.Cut(0, length, env)
        env = sf.Multiply(
            env, sf.LinearShape((0, 1), (length - 35, 1), (length, 0.1)))

        res = None
        if length > 50:
            res = sf.LinearShape((0, 0.5), (length - 50, 0.5), (length, 0.9))
        else:
            res = sf.LinearShape((0, 0.5), (length, 0.8))
        res = sf.Cut(0, length, res)
        sig, env, res = sf.MatchLengths((sig, env, res))
        out = sf.ShapedLadderLowPass(sig, env, res)

        attack = 5
        env = None
        if length > 50:
            env = sf.ExponentialShape((0, -40), (attack, 0), (length, -20))
            env = sf.Multiply(
                env, sf.LinearShape((0, 1), (length - 20, 1), (length, 0)))
        else:
            env = sf.LinearShape((0, 0.00), (attack, 0), (length, 0))
        out = sf.Multiply(env, out)
        return sf.FixSize(polish(out, freq)).keep()
Beispiel #14
0
def trumpet_base(length, freq, z=1.0):
    voxA = []
    hc = 1.0
    freq = float(freq)
    while hc * freq < 20000:
        hf = hc * freq
        voxA.append(
            sf.LinearVolume(sf.PhasedSineWave(length, hf, random.random()),
                            (1.0 / hc)**z))
        hc += 1

    vox = mix(voxA)
    vox = sf.Clean(vox)
    vox = polish(sf.FixSize(vox), freq)
    return sf.FixSize(vox)
Beispiel #15
0
def sing_base(length, freq, z=1.0):
    voxA = []
    hc = 1.0
    freq = float(freq)
    while hc * freq < 18000:
        hf = hc * freq
        # at higher frequencies there is less need to
        # richen the sound so do only one pass of creating the
        # waves, but double the volume of each one by two to
        # avoid filtering effects
        if freq < 5000:
            x = 2
            y = 1.0
        else:
            x = 1
            y = 2.0
        for c in range(0, x):
            vol = (1.0 / hc)**z
            # cut of at -60 db
            if vol > 0.25e-06:
                vol *= y
                voxA.append(
                    sf.LinearVolume(
                        sf.PhasedTableSineWave(length,
                                               hf + random.random() * 10.0,
                                               random.random()), vol))
                voxA.append(
                    sf.LinearVolume(
                        sf.PhasedTableSineWave(length,
                                               hf - random.random() * 10.0,
                                               random.random()), vol))
                voxA.append(
                    sf.LinearVolume(
                        sf.PhasedTableSineWave(length,
                                               hf + random.random() * 10.0,
                                               random.random()), vol))
                voxA.append(
                    sf.LinearVolume(
                        sf.PhasedTableSineWave(length,
                                               hf - random.random() * 10.0,
                                               random.random()), vol))
        hc += 1

    vox = mix(voxA)
    vox = sf.Clean(vox)
    vox = polish(sf.FixSize(vox), freq)
    return sf.FixSize(vox)
Beispiel #16
0
def tuned_wind(length,freq):

    sigs=[]
    for i in range(1,3):
        sig=byquad_filter(
            'peak',
            byquad_filter(
                'peak',
                sf.Mix(
                    clean_noise(length,freq),
                    sf.Pcnt10(sf.SineWave(length,freq))
                ),
                1.0,
                64
            ),
            freq,
            0.1,
            64
        )
        
        sig=byquad_filter(
            'peak',
            sig,
            freq,
            1.0,
            128
        )
    
        sig=sf.FixSize(excite(sig,1.0,2.0))
        sig=sf.FixSize(sf.Saturate(sf.NumericVolume(sig,2.0)))
        sig=create_vibrato(
            sig,length,
            longer_than=0.5,
            rate=2.5,
            at=0.45,
            depth=0.5,
            pitch_depth=0.02
        )
        
        sigs.append(sig)
    sig=mix(sigs)
    return sf.FixSize(polish(sig,freq))
Beispiel #17
0
def stretched_bass(length, freq, z=1.0, s=1.0, d=0.0, at=0):
    freq = float(freq)
    hf = freq
    hc = 1.0
    if at == 0:
        at = length * 0.9
    vox = sf.Silence(length)
    while hf < 20000:
        v = (1.0 / hc)**z
        env = sf.LinearShape((0, v), (at, v - (d**hc - 1.0)),
                             (length, v - (d**hc - 1.0)))
        vox = mix(
            sf.Multiply(sf.PhasedSineWave(length, hf, random.random()), env),
            vox)
        hf += freq * s
        hc += 1

    vox = sf.Clean(vox)
    vox = polish(sf.FixSize(vox), freq)
    return sf.FixSize(vox)
def stretched_bass(length,freq,z=1.0,s=1.0,d=0.0,at=0):
    freq=float(freq)
    hf=freq
    hc=1.0
    if at==0:
        at=length*0.9
    vox=sf.Silence(length)
    while hf<20000:
        v=(1.0/hc)**z
        env=sf.LinearShape((0,v),(at,v-(d**hc-1.0)),(length,v-(d**hc-1.0)))
        vox=mix(
            sf.Multiply(
                sf.PhasedSineWave(length,hf,random.random()),
                env
            ),
            vox
        )
        hf+=freq*s
        hc+=1
        
    vox=sf.Clean(vox)
    vox=polish(sf.FixSize(vox),freq)
    return sf.FixSize(vox)
Beispiel #19
0
def additive_resonance(power, qCorrect, saturate, rollOff, post, limit, seed,
                       flat, harmonics, length, freq):

    lowComp = freq < 128
    if lowComp:
        freq *= 2.0
        length *= 0.5

    def doWind(length, hfq, vol, reverse=False):
        key = (length, _logRoundUp(hfq), vol, reverse)
        if key in _resonanceCache:
            if random.random() < _CACHE_PROBABILITY:
                return _repitch(key[1], hfq,
                                readSwappedCache(_resonanceCache[key]))

        with SFMemoryZone():
            # Put in a little extra and then trim it off reliably.
            upRatio = key[1] * 1.01 / float(hfq)
            out = _distant_wind(length * upRatio, hfq, qCorrect, limit, seed)
            out = sf.Power(out, power)
            if saturate:
                os = sf.Saturate(sf.LinearVolume(sf.FixSize(+out), 2.0))
                out = sf.Mix(sf.LinearVolume(out, 1.0 - saturate),
                             sf.LinearVolume(os, saturate))
            out = sf.Realise(out)
            out = sf.LinearVolume(sf.FixSize(out), vol)
            if reverse:
                out = sf.Reverse(out)
            ret = compress(out)
            if _PERFORM_CACHE:
                # Store no more than the length we need which we work out as the
                # inverse scale of that used to make the signal. This should
                # always give enough signal so out of bounds does not happen.
                toCache = _repitch(hfq, key[1], ret, sf.Length(ret) / upRatio)
                # FIXME: Figure out how to make this long enough.
                # See call to _distant_wind above.
                _resonanceCache[key] = writeSawppedCache(toCache)
                return toCache.keep()
            else:
                return ret.keep()
            return ret

    harms = []
    base = compress(sf.Silence(length))
    sigs = []
    for harm in harmonics:
        hfreq = harm * freq
        if hfreq > 18000.0:
            break
        harms.append(harm)
        vol = 1.0 / (pow(harm, rollOff))
        if flat:
            sfw = doWind(length, hfreq, vol)
            srv = doWind(length, hfreq, vol, reverse=True)
            sigs += [sfw, srv]
        else:
            sigs += [doWind(lenth, hfq, vol)]
        if len(sigs) > 3:
            sigs += [base]
            base = sf.Realise(sf.Mix(sigs))
            sigs = []

    base = decompress(base)
    ret = None
    if lowComp:
        base = sf.DirectRelength(base, 0.5)
        freq *= 0.5
        length *= 2.0
        ret = sf.Realise(sf.FixSize(sf.Clean(base)))
    else:
        ret = sf.Realise(sf.FixSize(polish(base, freq)))
    return post(ret, freq) if post else ret
Beispiel #20
0
def soft_harpsichord_filter(power,
                            resonance,
                            sig,
                            freq,
                            attack=2,
                            triangle=True):

    length = sf.Length(sig)

    if attack > 20:
        raise ValueError('Attack too large; must be <= 20.')

    with SFMemoryZone():
        ring = sf.SineWave(length, 65 * random.random() * 10)
        if triangle:
            ring = sf.MakeTriangle(ring)
        quant = 0.1
        if freq < 256:
            quant = 0.3
        elif freq < 512:
            quant = 0.2
        ring = sf.Multiply(sf.LinearShape((0, quant), (length, 0)), ring)
        ring = sf.DirectMix(1.0, ring)
        sig = sf.Multiply(sig, ring).keep()

    with SFMemoryZone():
        sig = sf.Reverse(sig)
        tot = 10000.0  # 10 Seconds

        max_len = 10000.0
        tLen = max_len if max_len > length else length

        q1 = freq * 7
        q2 = freq * 3
        if freq > 440:
            q2 *= 0.75
            q1 *= 0.75
        if freq > 660:
            q2 *= 0.75
            q1 *= 0.75

        env = None
        if length > 60:
            env = sf.ExponentialShape((0, sf.ToDBs(18000)), (50, sf.ToDBs(q1)),
                                      (max_len, sf.ToDBs(q2)),
                                      (tLen, sf.ToDBs(q1)))
        else:
            env = sf.ExponentialShape((0, sf.ToDBs(18000)),
                                      (max_len, sf.ToDBs(q2)),
                                      (tLen, sf.ToDBs(q2)))
        env = sf.Cut(0, length, env)
        env = sf.Multiply(
            sf.ExponentialShape((0, 0), (length - 10, 0), (length, -20)), env)

        if length > 50:
            env = sf.Multiply(
                env, sf.LinearShape((0, 1), (length - 35, 1), (length, 0.1)))
        else:
            env = sf.Multiply(env, sf.LinearShape((0, 1), (length, 0.1)))

        res = sf.LinearShape((0, 0.2 * resonance), (max_len, 0.5 * resonance),
                             (tLen, 0.5 * resonance))
        res = sf.Cut(0, length, res)
        env = sf.Multiply(
            sf.ExponentialShape((0, 0), (length - 10, 0), (length, 10)), env)
        sig, env, res = sf.MatchLengths((sig, env, res))
        out = sf.ShapedLadderLowPass(sig, env, res)

        length = sf.Length(out)
        if power != 1.0:
            out = sf.FixSize(sf.Power(out, power))

        env = None
        if length > 50:
            env = sf.ExponentialShape((0, -40), (attack, 0), (50, -10),
                                      (max_len, -80), (tLen, -80))
            env = sf.Cut(0, length, env)
            env = sf.Multiply(
                env,
                sf.LinearShape((0, 0), (10, 1), (length - 25, 1), (length, 0)))
        else:
            env = sf.LinearShape((0, 0), (10, 1), (length, 0))
        out = sf.Multiply(env, out)

        return sf.FixSize(polish(out, freq)).keep()