[go: up one dir, main page]

File: convert.tcl

package info (click to toggle)
cecilia 2.0.5-2.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,440 kB
  • ctags: 833
  • sloc: tcl: 9,786; sh: 1,085; makefile: 69; csh: 13
file content (114 lines) | stat: -rw-r--r-- 2,926 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#
# 	Fonctions de conversions variees
# 	(c) 1995-7 Alexandre Burton
# 	v. 1.80a (10/08/97)
#

proc floatToScreenX { xFloat } {  
	global limite
	expr ($xFloat * $limite(rangeX)) + $limite(pad)
}

proc floatToScreenY { yFloat } {
    	global limite relation
    	expr (abs($yFloat-1) * $limite(rangeY)) + $limite(pad)	
}

proc screenToFloatX { xScreen } {
    	global limite
    	expr ($xScreen - $limite(pad)) / $limite(rangeX)
}

proc screenToFloatY { yScreen } {
    	global limite
    	expr abs((($yScreen - $limite(pad)) / $limite(rangeY)) -1)
}

proc paramToFloat {param cible} {
    	global seuil ambitus actif relation tcl_precision
    	if {$cible == "actif"} {set cible $actif}
    	switch -glob -- $relation($cible) {
		li* {
		    return [expr 1.0 * (($param - $seuil($cible)) / $ambitus($cible))]
		}
		ra* {
		    return [expr 1.0 * (($param - $seuil($cible)) / $ambitus($cible))]
		}
		lo* { 	
		    set tcl_precision 12
		    set val [expr 1.0* log10($param/$seuil($cible)) / log10(1.0*($seuil($cible)+$ambitus($cible))/$seuil($cible))] 
		    set tcl_precision 6
		    return $val
		}
		default { bell ;  puts "$relation($cible)?????" }
    	}
}

proc floatToParam {float cible} {
    global limite ambitus seuil relation fenetre pad
    switch -glob -- $relation($cible) {
	li* {
	    set param [expr ($float  * $ambitus($cible)) + $seuil($cible)]
	}
	ra* {
	    set param [expr ($float  * $ambitus($cible)) + $seuil($cible)]
	}
	lo* { 	
	    set param [expr pow(($ambitus($cible)+$seuil($cible))/$seuil($cible),$float )* $seuil($cible) ]
	}
	default { bell ;  puts "$relation($cible)?????" }
    }
	set param [format %.5f $param]	
    return $param 
}

proc timeToFloat {time} {
    global soundOutInfo value 
    if {![info exists soundOutInfo(duree)]} {return "-"}
    expr 1.0 * $time / $soundOutInfo(duree)
}

proc floatToTime {float cible} {
    global soundOutInfo tcl_precision value
    if {![info exists soundOutInfo(duree)]} {return "-"}
    set tcl_precision 6
    set time [expr $float * $soundOutInfo(duree)] 
    set tcl_precision 10
    return $time
}

proc floatToTable {float cible} {
    global tableSize tcl_precision gensize soundOutInfo
    if ![info exists gensize($cible)] {
	set tableSize $soundOutInfo(userGEN)
    } else {
	set tableSize $gensize($cible)
    }
    set table [expr $float * $tableSize]
    set table [format %.3f $table]
    return $table    
}

proc getMaxY { stuff } {
    array set dataCourant $stuff
    set maxY 0
    foreach x [array names dataCourant] {
	if {$dataCourant($x) > $maxY} {set maxY $dataCourant($x)}
    }
   return $maxY
}

proc getMinY { stuff } {
    array set dataCourant $stuff
    set minY 1
    foreach x [array names dataCourant] {
	if {$dataCourant($x) < $minY} {set minY $dataCourant($x)}
    }
    return $minY
}

proc rawrand {} {
    global lastvalue
    set lastvalue [expr (46965277*$lastvalue+13849)%65536]
	return $lastvalue	
}