Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - wip

Pages: [1]
1
Host Forum: Sonic Visualiser / cutting the soundfile
« on: February 03, 2008, 22:29:40 »
hi,

i would like to use sonicvisualiser (nice software by the way) to cut a wav. using add new time instants layer, i am able to specify where i want to cut the soundfile (in segmentation mode).

the question is: is there a script / plug-in or a way to take this annotation file and process my soundfile (cutting the sf using the frame)? if not, i will write a python script, but i don't want to rewrite something.

here's something working, but very basic:


Code: [Select]
"""
Sonic Visualiser Splicer
Patrick Sebastien Coulombe

using New Time Instants Layer - Segmentation Plot
exporting in Sonic Visualiser Layer XML
"""
import wave
from xml.dom import minidom

"""
EDIT
"""
svl = "cutam.svl"
sf = "amen.wav"


xmldoc = minidom.parse(svl)

sfwo = wave.open(sf, "r")
nchannels, sampwidth, framerate, nframes, comptype, compname = sfwo.getparams()

i = 0
for ref in xmldoc.getElementsByTagName('point'):
if i == 0:
global position
print "---Position---"
position = ref.attributes["frame"].value
sfwo.setpos(int(position))
i = 1
else:
print "---Splice---"
frame = int(ref.attributes["frame"].value) - int(position)
data = sfwo.readframes(int(frame))
sfww = sf[0:-4]+"_"+ref.attributes["label"].value+".wav"
fo = wave.open(sfww, "w")
fo.setparams((nchannels, sampwidth, framerate, 0, comptype, compname))
fo.writeframes(data)
fo.close()
print sfww
print
i = 0
sfwo.close()

thanks!
pat

Pages: [1]