summaryrefslogtreecommitdiffstats
path: root/share/extensions/ffscale.py
diff options
context:
space:
mode:
authorAaron Spike <aaron@ekips.org>2006-05-08 15:28:17 +0000
committeracspike <acspike@users.sourceforge.net>2006-05-08 15:28:17 +0000
commit5003d4122450f1ea8d75a5f77f96b829908a7dee (patch)
treebc478eb71aab76366fd036b788fa2fd4ae9be807 /share/extensions/ffscale.py
parentMore snapping cleanups. (diff)
downloadinkscape-5003d4122450f1ea8d75a5f77f96b829908a7dee.tar.gz
inkscape-5003d4122450f1ea8d75a5f77f96b829908a7dee.zip
standardize indents on 4 spaces
Python hates mixed whitespace (bzr r770)
Diffstat (limited to 'share/extensions/ffscale.py')
-rwxr-xr-xshare/extensions/ffscale.py88
1 files changed, 44 insertions, 44 deletions
diff --git a/share/extensions/ffscale.py b/share/extensions/ffscale.py
index f9afa0b02..74bc6b989 100755
--- a/share/extensions/ffscale.py
+++ b/share/extensions/ffscale.py
@@ -21,53 +21,53 @@
import math
def ETScale(tones, octave=2.0):
- octave, tones = float(octave), float(tones)
- scale = {'steps':[[1.0,1.0]], 'title':'', 'errors':0, 'errorstring':''}
- if not tones:
- scale['errors'] += 1
- scale['errorstring'] = 'Error: Number of tones must be non zero!'
- else:
- ratio = octave**(1/tones)
- scale['title'] = '%s root of %s Equal Temperament' % (tones, octave)
- scale['steps'].append([ratio,1])
- return scale
+ octave, tones = float(octave), float(tones)
+ scale = {'steps':[[1.0,1.0]], 'title':'', 'errors':0, 'errorstring':''}
+ if not tones:
+ scale['errors'] += 1
+ scale['errorstring'] = 'Error: Number of tones must be non zero!'
+ else:
+ ratio = octave**(1/tones)
+ scale['title'] = '%s root of %s Equal Temperament' % (tones, octave)
+ scale['steps'].append([ratio,1])
+ return scale
def ScalaScale(scala):
- #initial step 0 or 1/1 is implicit
- scale = {'steps':[[1.0,1.0]], 'title':'', 'errors':0, 'errorstring':''}
+ #initial step 0 or 1/1 is implicit
+ scale = {'steps':[[1.0,1.0]], 'title':'', 'errors':0, 'errorstring':''}
- #split scale discarding commments
- lines = [l.strip() for l in scala.strip().splitlines() if not l.strip().startswith('!')]
+ #split scale discarding commments
+ lines = [l.strip() for l in scala.strip().splitlines() if not l.strip().startswith('!')]
- #first line may be blank and contains the title
- scale['title'] = lines.pop(0)
+ #first line may be blank and contains the title
+ scale['title'] = lines.pop(0)
- #second line indicates the number of note lines that should follow
- expected = int(lines.pop(0))
+ #second line indicates the number of note lines that should follow
+ expected = int(lines.pop(0))
- #discard blank lines and anything following whitespace
- lines = [l.split()[0] for l in lines if l != '']
-
- if len(lines) != expected:
- scale['errors'] += 1
- scale['errorstring'] = 'Error: expected %s more tones but found %s!' % (expected,len(lines))
- else:
- for l in lines:
- #interpret anyline containing a dot as cents
- if l.find('.') >= 0:
- num = 2**(float(l)/1200)
- denom = 1
- #everything else is a ratio
- elif l.find('/') >=0:
- l = l.split('/')
- num = float(int(l[0]))
- denom = float(int(l[1]))
- else:
- num = float(int(l))
- denom = 1.0
- scale['steps'].append([num,denom])
-
- if (num < 0) ^ (denom <= 0):
- scale['errors'] += 1
- scale['errorstring'] += 'Error at "'+l+'": Negative and undefined ratios are not allowed!\n'
- return scale
+ #discard blank lines and anything following whitespace
+ lines = [l.split()[0] for l in lines if l != '']
+
+ if len(lines) != expected:
+ scale['errors'] += 1
+ scale['errorstring'] = 'Error: expected %s more tones but found %s!' % (expected,len(lines))
+ else:
+ for l in lines:
+ #interpret anyline containing a dot as cents
+ if l.find('.') >= 0:
+ num = 2**(float(l)/1200)
+ denom = 1
+ #everything else is a ratio
+ elif l.find('/') >=0:
+ l = l.split('/')
+ num = float(int(l[0]))
+ denom = float(int(l[1]))
+ else:
+ num = float(int(l))
+ denom = 1.0
+ scale['steps'].append([num,denom])
+
+ if (num < 0) ^ (denom <= 0):
+ scale['errors'] += 1
+ scale['errorstring'] += 'Error at "'+l+'": Negative and undefined ratios are not allowed!\n'
+ return scale