Home 
 
function webtones(fname,scl,adj,stp,range,addr,patch,lng,guide,glength) {
	f = open(fname,"r")
	fifoctl(f,"type","b")
	r = ''
	times = ["sixteenth"=1b/4,"eight"=1b/2,"32nd"=1b/8];
	if ( stp in times )
		st = times[stp]
	else
		st = 1b/4
	
	if ( range == "wide" ) {
		rng=100
		low=20
	}
	else if ( range == "narrow" ) {
		rng=40
		low=60
	}
	else {
		rng=80
		low=40
	}
	if ( lng == "Long" )
		nnotes=500
	else
		nnotes=200
	for ( n=0; n<nnotes && (c=get(f)) != Eof; n++ ) {
		r += makenote(low+c%rng,st,110);
	}
	sclnt = phrase("'"+scl+"'")

	if ( guide == "major" || guide == "minor" ) {
		bskey = 'e-o-2'
		bsmajor = []
		bsmajor[ 1 ]= 'e-o-2'
		bsmajor[ 2 ]= 'e-o-2,f,g,b-'
		bsmajor[ 3 ]= 'e-o-2,b-'
		bsmajor[ 4 ]= 'e-o-2,b-'
		bsmajor[ 5 ]= 'e-o-2,f,g,b-'
		bsmajor[ 6 ]= 'e-o-2,b-'
		bsmajor[ 7 ]= 'e-o-2,f,g,b-'
		bsmajor[ 8 ]= 'e-o-2,b-'
		bsminor = []
		bsminor[ 1 ]= 'e-o-2'
		bsminor[ 2 ]= 'e-o-2,f,g-,b-'
		bsminor[ 3 ]= 'e-o-2,b-'
		bsminor[ 4 ]= 'e-o-2,b-'
		bsminor[ 5 ]= 'e-o-2,f,g-,b-'
		bsminor[ 6 ]= 'e-o-2,b-'
		bsminor[ 7 ]= 'e-o-2,f,g-,b-'
		bsminor[ 8 ]= 'e-o-2,b-'

		gdleng = 0 + integer(glength)
		gd = r{(??.number % gdleng)==0}

		r = bsguide((guide=="major"?bsmajor:bsminor),bskey,r,gd,st,r.length)
	}

	if ( adj == "adjust" ) {
		r = scadjust(r,transpose(scale_aeolian(),sclnt))
	}
	else {
		r = scafilt(r,transpose(scale_aeolian(),sclnt))
	}

	if ( addr == "yes" )
		r = addrootevery(r,1b)

	if ( patch == "piano" )
		r = ('l96'|progchange(1,1)) + r
	else if ( patch == "celeste" )
		r = ('l96'|progchange(9,1)) + r
	else if ( patch == "viola" )
		r = ('l96'|progchange(42,1)) + r
	else if ( patch == "drums" )
		r.chan = 10
	writemf(r,"www.mid")
	writelines(r,"www.lines")
}