Update of /cvsroot/pure-data/abstractions/footils/tunetof In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32099/tunetof
Added Files: ptolemy.scl ptolemy.scl.tab scl2pd.py stopper.scl stopper.scl.tab tunetof-help.pd tunetof.pd Log Message: tunetof - an mtof for alternative tunings.
--- NEW FILE: stopper.scl.tab --- 1 1.05952606181 1.12259548214 1.1894191702 1.26022061653 1.33523658684 1.41471797061 1.49893055998 1.58815600232 1.68269267468 1.78285675314 1.88898319442 2.00142693638 2.1205639999 2.24679283661 2.38053556588 2.52223948769 2.67237847134 2.83145465376 3.0 --- NEW FILE: tunetof-help.pd --- #N canvas 308 62 810 693 10; #X obj 314 210 r $0-tune; #X obj 503 208 openpanel; #X obj 503 309 s $0-tune; #X msg 503 185 bang; #X symbolatom 512 230 16 0 0 0 - - -; #X obj 503 281 textfile; #X msg 503 257 read $1 , rewind , bang; #X obj 130 191 notein; #X floatatom 92 268 5 0 0 0 - - -; #X floatatom 191 141 5 0 0 0 - - -; #X obj 191 106 mtof; #X floatatom 191 86 5 0 0 0 - - -; #X text 195 62 set base frequency; #X text 259 277 to "midi" synth; #X floatatom 215 291 5 0 0 0 - - -; #X obj 130 316 pack 0 100; #X floatatom 53 131 5 0 0 0 - - -; #X floatatom 252 192 5 0 0 2 notes_per_oct - -; #X obj 44 514 osc~; #X obj 89 512 vline~; #X obj 44 538 *~; #X obj 88 556 *~; #X obj 87 534 *~; #X obj 45 493 t f b; #X obj 612 473 catch~ $0-out; #X obj 612 582 dac~; #X obj 612 551 *~ 0; #X obj 635 527 dbtorms; #X floatatom 635 505 0 0 100 0 - - -; #X obj 220 513 osc~; #X obj 265 511 vline~; #X obj 220 537 *~; #X obj 264 555 *~; #X obj 263 533 *~; #X obj 221 492 t f b; #X obj 399 511 osc~; #X obj 444 509 vline~; #X obj 399 535 *~; #X obj 443 553 *~; #X obj 442 531 *~; #X obj 400 490 t f b; #X obj 129 389 route 1 2 3; #X obj 129 363 pack 0 0 0; #X obj 399 580 throw~ $0-out; #X obj 220 582 throw~ $0-out; #X obj 44 583 throw~ $0-out; #X obj 215 271 ftom; #X floatatom 656 551 5 0 0 0 - - -; #X obj 130 342 poly 3 1; #X obj 130 287 stripnote; #X msg 88 492 0.6 20 , 0 1000 20; #X msg 264 491 0.6 20 , 0 1000 20; #X msg 443 489 0.6 20 , 0 1000 20; #X obj 53 148 makenote 100 1000; #X obj 461 334 list-len; #X floatatom 461 357 5 0 0 0 - - -; #X text 377 41 Arguments (all are optional):; #X text 452 66 1) base frequency; #X text 452 104 3) filename of tuning table; #X text 453 85 2) number of notes in scale; #X obj 130 237 tunetof 8 7 ptolemy.scl.tab; #X obj 233 329 pack 0 0; #X obj 233 351 s NOTES; #X obj 53 246 mtof; #X floatatom 53 267 5 0 0 0 - - -; #X connect 0 0 60 3; #X connect 1 0 6 0; #X connect 1 0 4 0; #X connect 3 0 1 0; #X connect 5 0 2 0; #X connect 5 0 54 0; #X connect 6 0 5 0; #X connect 7 0 60 0; #X connect 7 1 49 1; #X connect 7 1 61 1; #X connect 9 0 60 1; #X connect 10 0 9 0; #X connect 11 0 10 0; #X connect 15 0 48 0; #X connect 16 0 53 0; #X connect 17 0 60 2; #X connect 18 0 20 0; #X connect 19 0 22 0; #X connect 19 0 22 1; #X connect 20 0 45 0; #X connect 21 0 20 1; #X connect 22 0 21 0; #X connect 22 0 21 1; #X connect 23 0 18 0; #X connect 23 1 50 0; #X connect 24 0 26 0; #X connect 26 0 25 0; #X connect 26 0 25 1; #X connect 27 0 26 1; #X connect 27 0 47 0; #X connect 28 0 27 0; #X connect 29 0 31 0; #X connect 30 0 33 0; #X connect 30 0 33 1; #X connect 31 0 44 0; #X connect 32 0 31 1; #X connect 33 0 32 0; #X connect 33 0 32 1; #X connect 34 0 29 0; #X connect 34 1 51 0; #X connect 35 0 37 0; #X connect 36 0 39 0; #X connect 36 0 39 1; #X connect 37 0 43 0; #X connect 38 0 37 1; #X connect 39 0 38 0; #X connect 39 0 38 1; #X connect 40 0 35 0; #X connect 40 1 52 0; #X connect 41 0 23 0; #X connect 41 1 34 0; #X connect 41 2 40 0; #X connect 42 0 41 0; #X connect 46 0 14 0; #X connect 46 0 61 0; #X connect 48 0 42 0; #X connect 48 1 42 1; #X connect 48 2 42 2; #X connect 49 0 15 0; #X connect 49 1 15 1; #X connect 50 0 19 0; #X connect 51 0 30 0; #X connect 52 0 36 0; #X connect 53 0 60 0; #X connect 53 0 63 0; #X connect 53 1 49 1; #X connect 54 0 55 0; #X connect 60 0 8 0; #X connect 60 0 46 0; #X connect 60 0 49 0; #X connect 61 0 62 0; #X connect 63 0 64 0;
--- NEW FILE: stopper.scl --- ! stopper.scl ! Bernard Stopper, piano tuning with 19th root of 3 (1988) 19 ! 100.10289 200.20579 300.30868 400.41158 500.51447 600.61737 700.72026 800.82316 900.92605 1001.02895 1101.13184 1201.23474 1301.33763 1401.44053 1501.54342 1601.64632 1701.74921 1801.85211 3/1
--- NEW FILE: tunetof.pd --- #N canvas 408 112 737 667 10; #X obj 489 378 table $0-tuning; #X obj 52 214 t a a; #X obj 52 172 inlet; #X obj 52 551 outlet; #X obj 52 504 * 1; #X obj 211 136 inlet; #X obj 526 333 s $0-tuning; #X obj 447 155 inlet; #X obj 52 403 tabread $0-tuning; #X obj 447 194 route symbol; #X msg 556 306 const 0; #X msg 447 237 read $1; #X obj 269 182 inlet; #X obj 526 274 list prepend 0; #X obj 526 228 t a b; #X text 184 116 base frequency; #X obj 188 463 * $1; #X obj 232 381 div $2; #X obj 52 379 mod $2; #N canvas 0 0 450 300 length 0; #X obj 126 70 inlet; #X obj 161 209 + 1; #X obj 72 183 b; #X obj 116 249 f; #X obj 116 276 outlet; #X obj 148 183 1; #X obj 132 211 f 1; #X obj 206 213 0; #X obj 126 104 t a b b; #X text 37 37 list-len: calculate length of a list.; #N canvas 0 0 533 407 drip 0; #X obj 64 206 list split 1; #X obj 64 123 until; #X obj 64 181 list append; #X obj 194 206 bang; #X text 146 90 First store list , then start the loop; #X text 163 118 "until" bangs its output until told to stop by a "bang" to its right inlet.; #X text 182 160 Store the remaining list.; #X text 239 205 third outlet of "split" tells us to stop.; #X obj 64 243 outlet; #X obj 64 57 inlet; #X text 237 44 From list-help.pd; #X obj 143 243 outlet; #X obj 64 86 t b a; #X connect 0 0 8 0; #X connect 0 1 2 1; #X connect 0 2 3 0; #X connect 0 2 11 0; #X connect 1 0 2 0; #X connect 2 0 0 0; #X connect 3 0 1 1; #X connect 9 0 12 0; #X connect 12 0 1 0; #X connect 12 1 2 1; #X restore 72 152 pd drip; #X connect 0 0 8 0; #X connect 1 0 6 1; #X connect 2 0 6 0; #X connect 3 0 4 0; #X connect 5 0 6 1; #X connect 6 0 1 0; #X connect 6 0 3 1; #X connect 7 0 3 1; #X connect 8 0 10 0; #X connect 8 1 5 0; #X connect 8 2 7 0; #X connect 10 0 2 0; #X connect 10 1 3 0; #X restore 353 312 pd length; #X obj 353 334 - 1; #X obj 471 480 symbol $3; #X obj 471 458 loadbang; #X obj 471 509 select 0; #X msg 552 609 read $1; #X obj 552 633 s $0-tuning; #X text 37 18 Arguments (all are optional):; #X text 112 43 1) base frequency; #X text 112 81 3) filename of tuning table; #X text 410 130 filename or float list to set tuning table; #X text 432 434 Init tuning table from file $3; #X obj 232 402 expr pow($f2 , $f1); #X text 221 162 number of notes in scale; #X text 113 62 2) number of notes in scale; #X obj 353 378 tabread $0-tuning; #X text 368 403 use last step to wrap arround; #X obj 522 573 t b a; #X obj 522 603 f $2; #X connect 1 0 18 0; #X connect 1 1 17 0; #X connect 2 0 1 0; #X connect 4 0 3 0; #X connect 5 0 16 1; #X connect 7 0 9 0; #X connect 8 0 4 0; #X connect 9 0 11 0; #X connect 9 1 14 0; #X connect 10 0 6 0; #X connect 11 0 6 0; #X connect 12 0 17 1; #X connect 12 0 18 1; #X connect 12 0 34 0; #X connect 13 0 6 0; #X connect 14 0 13 0; #X connect 14 0 19 0; #X connect 14 1 10 0; #X connect 16 0 4 1; #X connect 17 0 31 0; #X connect 18 0 8 0; #X connect 19 0 20 0; #X connect 20 0 17 1; #X connect 20 0 18 1; #X connect 20 0 34 0; #X connect 21 0 23 0; #X connect 22 0 21 0; #X connect 23 1 36 0; #X connect 24 0 25 0; #X connect 31 0 16 0; #X connect 34 0 31 1; #X connect 36 0 37 0; #X connect 36 1 24 0; #X connect 37 0 34 0;
--- NEW FILE: ptolemy.scl.tab --- 1 1.125 1.25 1.33333333333 1.5 1.66666666667 1.875 2.0 --- NEW FILE: scl2pd.py --- #!/usr/bin/python import sys from math import pow
# Set "write_pd" to 1 to automatically write files to use in a Pd table, set to # 0 to only print the analysis. # # Files written will have the same name as the input files with ".tab" # appended. write_pd = 1
# converters: def cent2float(cval): cval = float(cval) return pow(2, cval/1200.0)
def ratio2float(rval): r = rval.split("/",2) if len(r) < 2: return r[0] return float(r[0]) / float(r[1])
def convert_scala(scala_filename): """converts scala file to a list of floats suitable for use in a Pd table""" try: scale = open(scala_filename) except: print >> sys.stderr, "Could not open scale file:", scala_filename
debug = 0 desc = "" numnotes = 0
# 1/1 is implicit in scala files, but not in Pd tables: tab = [1]
# walk through scala file: for l in scale: l = l.strip()
if not l: continue
if l.startswith("!"): continue
if not desc: desc = l continue if not numnotes: numnotes = int(l) continue
# some people write lines like: "88.0000 cents", duh l = l.split()[0] # while others break the specs with: "88.0000! illegal comment", duh l = l.split("!")[0]
if l.find(".") > 0: if debug: print >> sys.stderr, """CENT: %s """ % l tab.append(cent2float(l)) continue
if debug: print """RATIO: %s """ % l tab.append(ratio2float(l))
print >> sys.stderr, "Description:\t", desc print >> sys.stderr, "Scala length:\t", numnotes print >> sys.stderr, "Pd table:\t", " ".join([str(x) for x in tab]) print >> sys.stderr, "Table length:\t", len(tab) return tab scale.close()
if __name__ == "__main__": for file in sys.argv[1:]: print "\n#--- FILE: %s ---#" % file tab = convert_scala(file) tab = [str(x) for x in tab] if write_pd: pdfile = "%s.tab" % file p = open(pdfile,"w") p.write(" ".join(tab)) p.close() print >> sys.stderr, "Written to:\t", pdfile print
--- NEW FILE: ptolemy.scl --- ! ptolemy.scl ! Intense Diatonic Syntonon, also Zarlino's scale 7 ! 9/8 5/4 4/3 3/2 5/3 15/8 2/1