#copies a wav and names it ###_name.wav
#everytime that 0-byte receives any value
#create 1 pattern named 'copy file' or something
#and put in your sequence everytime you want 
#a new file copied.
#
#wrote this so i could quickly create sample
#libraries with buzz using this script and
#either morex wordout or fuk freqout
#
#we need a stereo hdd .wav writer for buzz.
#

import sys

from buzz import *

line = "Mute's .wav copy on switch script (03/25/04) loaded."
print line

avalue=1

def OnParameter(track,index,value):

	global avalue 

	print "[%02i] %i: %i" % (track,index,value)
	if (index == 2):
		SendPeerCtrlChange(0,0,SWITCH_ON);

		## file copy ##

					
		original=open("pybuzz.wav", 'rb') 

		new=open("%03i_pybuzz.wav" %avalue,'wb') 
		
		chunk=1 

		while chunk:
			chunk=original.read(65536) # 64 KB
			new.write(chunk)

		new.close()
		original.close()
		avalue += 1


		## end file copy ##


SetEventTarget("OnParameter",OnParameter)

SetPeerCtrlName(0,"Record")

