Monday, June 25, 2007

 

automating sound morphing using csound and python

The following is untested as of yet so there may still be bugs. I was looking at the loris opcodes and I couldn't think or a reason why I wanted to do all that work to do some sound morphing. she needs a gui I thought so I have done the palermnary work towards that end.

I started with some small modifications to the instrument listed in the csound manual.. constants were changed to variables.

; This is a modified version from http://csounds.com/manual/html/loris.html
; The text describes the original instrunment.

; Morph the partials in trombone.sdif into the
; partials in meow.sdif. The start and end times
; for the morph are specified by parameters p4
; and p5, respectively. The morph occurs over the
; second of four pitches in each of the sounds,
; from .75 to 1.2 seconds in the flutter-tongued
; trombone tone, and from 1.7 to 2.2 seconds in
; the cat's meow. Different morphing functions are
; used for the frequency and amplitude envelopes,
; so that the partial amplitudes make a faster
; transition from trombone to cat than the frequencies.
; (The bandwidth envelopes use the same morphing
; function as the amplitudes.)
;
instr 1
ionset = p4
imorph = p5 - p4
irelease = p3 - p5

kttbn linseg 0, ionset, p6, imorph, p7, irelease, 2.4
ktmeow linseg 0, ionset, p8, imorph, p9, irelease, 3.4

kmfreq linseg 0, ionset, 0, .75*imorph, .25, .25*imorph, 1, irelease, 1
kmamp linseg 0, ionset, 0, .75*imorph, .9, .25*imorph, 1, irelease, 1

lorisread kttbn, p10, 1, 1, 1, 1, .001
lorisread ktmeow, p11, 2, 1, 1, 1, .001
lorismorph 1, 2, 3, kmfreq, kmamp, kmamp
asig lorisplay 3, 1, 1, 1
out asig
endin


after I did that I made the .sco file so it would work with dex tracker


;instr strt dur morph_start morph_end morph1_start morph1_end morph2_start morph2_end sample1 sample2

i1 0 4 .75 2.75 .75 1.2 1.7 2.2 "trombone.sdif" "meow.sdif"


lastly I created a function in python that I can use from a gui later

def loris_morph(dur, morph_start, morph_end, morph1_start, morph1_end, morph2_start, morph2_end, sample1, sample2):
"this is used to automate the process.. think of it as a command line routine for the loris opcodes outputs as morph.wav and plays the file"
loris = open('ltemp.sco','w')
sp = ' '
morphout = dur + sp + morph_start + sp + morph_end + sp + morph1_start + sp + morph1_end + sp + morph2_start + sp + morph2_end + sp + sample1 + sp + sample2
loris.write('i1 0 ')
loris.write(morphout)
loris.close()
cmd = 'csound loris4morph.orc 1temp.sco -o morph.wav'
os.path = """c://dex_tracker"""
loris_morph = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
os.startfile('morph.wav')

Labels: , , ,


Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?