Using Vamp Plugins and Hosts > Host Forum: Sonic Visualiser

cutting the soundfile

(1/1)

wip:
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: ---"""
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()

--- End code ---

thanks!
pat

cannam:
This may be stating the obvious, but since you didn't mention it: you can export just the selected area as a new audio file straight from Sonic Visualiser, thus effectively slicing it without leaving SV.

File -> Export Audio File will offer the option of exporting just the selected region, if there is a selection active.  If there are multiple selections, you can choose whether to export them to multiple files or splice them together into a single file.

Apart from this feature, I don't know of any other way to achieve what you want with an existing, ready-made script or program.


Chris

tjcrone:
Not sure if this is possible entirely within SV, but if you note the start and end time of your selection, you can use a utility like SoX to slice the sound file: http://sox.sourceforge.net/. Hope this helps.

Navigation

[0] Message Index

Go to full version