com.softsynth.jmsl.util
Class ScaleMusicShapeEditorOperator
java.lang.Object
com.softsynth.jmsl.util.ScaleMusicShapeEditorOperator
- All Implemented Interfaces:
- Namable, MusicShapeEditorOperator
public class ScaleMusicShapeEditorOperator
- extends java.lang.Object
- implements MusicShapeEditorOperator
transpose and scale selected range of MusicShape by (v2 / v3) or (v3 / v2)
- Author:
- Nick Didkovsky, didkovn@mail.rockefeller.edu
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ScaleMusicShapeEditorOperator
public ScaleMusicShapeEditorOperator(boolean flip)
operate
public void operate(MusicShapeEditor se,
MusicShape s)
- scale by v2 / v3 or v3 / v2 depending on boolean flip value No scaling if denom==0
if (se.getRangeStartIndex() != -1 && se.getRangeEndIndex() != -1
&& Limits.within(se.getDimension(), 0, s.dimension() - 1)) {
double numer = se.getV2();
double denom = se.getV3();
double scaler = 1;
if (flip && numer != 0) {
scaler = denom / numer;
} else if (!flip && denom != 0) {
scaler = numer / denom;
}
s.scale(scaler, se.getRangeStartIndex(), se.getRangeEndIndex(), se.getDimension());
}
- Specified by:
operate
in interface MusicShapeEditorOperator
getName
public java.lang.String getName()
- Specified by:
getName
in interface Namable
setName
public void setName(java.lang.String n)
- Specified by:
setName
in interface Namable