Re: choir effect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 12 Jan 2012 14:52:59 +0100
Renato <rennabh@xxxxxxxxx> wrote:

> Hi, I'm interested in how to create a "choir" effect - given a single
> instrument playing (I'm personally interested in single drum shots
> from hydrogen and guitar lines, i.e. not chords), I'd like to have n
> copies of the signal (where n would probably be something between 2
> and 20), each with a slightly different delay, volume, eq, pitch. 
> 
> Is this doable in a sane way, at least in part, with the free tools we
> have? I think it should be doable in sc or pd, but I was wondering if
> it's possible with ladspa, lv2 and dssi, and maybe a host like ams or
> ingen.
> 
> cheers,
> renato


Attached is the python script (uses sox) I hacked together, which for
the moment deals only with delay and gain, but it should be easy enough
to add other effects, given the versatility of sox.

Basically it takes a sample, makes many copies of it each with
different gain and quantity of silence at the beggining, and then mixes
all to an output file. 

Tested with snare samples, it gives results close to what I wanted (at
least in the right direction).

usage example:
./choir-sample.py snare.wav 20snares.wav 20

Of course use at your own risk, I take no responsibility if it melts
your hard drive ;) (but it shouldn't)

have fun,
renato

#!/usr/bin/env python2

#this script uses sox to try and achieve the effect of many people hitting
#a drum. It takes a sample, and performs the folowing operations multiple times:
#-adds a randomized quantity of silence at the beginning
#-makes a randomized gain attenuation
#finally it mixes all down to the outfile and normalizes to -1db.

import sys
import os
from random import uniform 

def usage():
    print "USAGE: choir-sample.py infile.wav outfile.wav number_of_copies"

def ran_vector(length, max):
    """Returns list with uniform values between 0 and max """
    
    ret = []
    for j in range(length):
        ret.append(uniform(0,max))
    return ret

def apply(args):
    n = int(args[3])
    print args
    
    #let's get some random values for gains and silence padding
    gains = ran_vector(n, 6)
    pads = ran_vector(n, 0.05)

    tmpdir = "tmp"
    os.system("mkdir {0}".format(tmpdir)) #create working directory
    files = ""
    for i in range(n):
        #here we define the actual sox command. For each iteration of the for loop, new copies
        #of the original file are made with a different gain and some silence at the beginning.
        cmd = "sox {0} {1}/{2}.wav pad {3} gain {4}".format(args[1],tmpdir,i, pads[i], -gains[i]) 
        print cmd
        os.system(cmd)
        files = files + " {0}/{1}.wav".format(tmpdir, i)
    
    #now mix the files to obtain a single .wav file
    cmd = "sox -m {0} {1} norm -1".format(files, args[2])
    os.system(cmd)

    os.system("rm -rf {0}".format(tmpdir)) #remove working directory

if __name__ == "__main__":
    if len(sys.argv) != 4:
        usage()
    else:
        apply(sys.argv)


_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@xxxxxxxxxxxxxxxxxxxx
http://lists.linuxaudio.org/listinfo/linux-audio-user

[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux