|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.softsynth.jmsl.MusicJob com.softsynth.jmsl.MusicShape
public class MusicShape
MusicShape - a MusicJob with an abstract array of data elements. Each data element is an array of
doubles. A MusicShape has any number of elements. Each element has the same number of dimensions
0..n, which can be named with human-friendly monikers (such as "duration", "pitch",
"loudness"...).
A MusicShape's Instrument is handed one element at a time. The interpretation of this element
depends on the Instrument's Interpreter, which reads the array of doubles in a consistent way and
generates some kind of meaningful event with it (ie sounding a MIDI note, doing some drawing,
etc)
MusicShape is Composable, so it can be put in a JMSL hierarchy and launched.
Field Summary |
---|
Fields inherited from class com.softsynth.jmsl.MusicJob |
---|
repeatCount |
Constructor Summary | |
---|---|
MusicShape(DimensionNameSpace dimensionNameSpace)
construct a new MusicShape with same number of dimensions, names, and limits as source |
|
MusicShape(Instrument ins,
int dimensions)
|
|
MusicShape(int dimensions)
construct a new MusicShape with a Printing Instrument |
Method Summary | |
---|---|
void |
add(double d0)
Add element with 1 dimension |
void |
add(double[] d)
Add an element to this MusicShape. |
void |
add(double d0,
double d1)
Add element with 2 dimensions |
void |
add(double d0,
double d1,
double d2)
Add element with 3 dimensions |
void |
add(double d0,
double d1,
double d2,
double d3)
Add element with 4 dimensions |
void |
add(double d0,
double d1,
double d2,
double d3,
double d4)
Add element with 5 dimensions |
void |
add(double d0,
double d1,
double d2,
double d3,
double d4,
double d5)
Add element with 6 dimensions |
void |
add(double d0,
double d1,
double d2,
double d3,
double d4,
double d5,
double d6)
Add element with 7 dimensions |
void |
add(double d0,
double d1,
double d2,
double d3,
double d4,
double d5,
double d6,
double d7)
Add element with 8 dimensions |
void |
add(double d0,
double d1,
double d2,
double d3,
double d4,
double d5,
double d6,
double d7,
double d8)
Add element with 9 dimensions |
void |
add(double d0,
double d1,
double d2,
double d3,
double d4,
double d5,
double d6,
double d7,
double d8,
double d9)
Add element with 10 dimensions |
void |
add(double d0,
double d1,
double d2,
double d3,
double d4,
double d5,
double d6,
double d7,
double d8,
double d9,
double d10)
Add element with 11 dimensions |
void |
add(double d0,
double d1,
double d2,
double d3,
double d4,
double d5,
double d6,
double d7,
double d8,
double d9,
double d10,
double d11)
Add element with 12 dimensions |
void |
calcDimStats(int dim)
called automatically by calcStats(), calculates statistics for specified dimension |
void |
calcStats()
called automatically by print(), calculates statistics for each dimension |
double |
clipValDim(double value,
int dim)
return value clipped to dimension's limits |
java.lang.Object |
clone()
Clones contents of shape. |
void |
convertTimeBaseDim(double srcTicksPerSec,
double destTicksPerSec,
int dim)
(srcTicksPerSec, destTicksPerSec, dim), recalculate all durations in specified dimension |
void |
copyDataFrom(MusicShape source)
Exact duplicate of double[] elements from source MusicShape to this MusicShape. |
void |
copyDataFrom(java.util.Vector source)
Copy double[] elements from source Vector of double[] to this MusicShape. |
void |
copyDimensionNameSpace(DimensionNameSpace source)
Copy dimension names, limits and defaults from source DimensionNameSpace to this MusicShape |
void |
differentiate(double sum,
int dim)
go from absolute to delta time, given sum and dimension. |
int |
dimension()
returns how many dimensions a MusicShape has |
java.util.Enumeration |
dimensionNames()
|
java.lang.String |
dumpSource()
Generate Java source that would recreate this MusicShape |
void |
dumpSource(java.io.PrintWriter pout)
Generate Java source that would recreate this MusicShape, write to a PrintWriter |
void |
dumpSource(java.lang.String filename)
Generate Java source that would recreate this MusicShape, write to a file |
void |
fill(double value,
int start,
int end,
int dimension)
Set all values in specified range to specified value along specified dimension. |
void |
finishAll()
Doesn't contain Composable, so cannot propagate finishAll() to children, just calls finish() on itself instead |
double[] |
get(int i)
|
double |
get(int e,
int d)
returns the value at element i, dimension d |
java.util.Vector |
getData()
|
double |
getDefault(int dim)
|
double[] |
getDefaultArray()
|
static double[] |
getDefaultArray(DimensionNameSpace dns)
|
int |
getDimension(java.lang.String name)
|
java.lang.String |
getDimensionName(int dim)
|
java.lang.String |
getDimName(int dim)
Deprecated. use getDimensionName(int dim), which is part of interface DimensionNameSpace |
double |
getHighLimit(int dim)
return highest allowable value for specified dimension |
int |
getInt(int e,
int d)
same as get(), cast to an int |
double |
getLowLimit(int dim)
return lowest allowable value for specified dimension |
double |
getMax(int dim)
return precalculated maximum value found (calculated by calcStats()) |
double |
getMean(int dim)
return precalculated mean (calculated by calcStats()) |
double |
getMin(int dim)
return precalculated minimim value found (calculated by calcStats()) |
int |
getNumberOfNames()
|
double |
getSum(int dim)
return precalulated sum (calculated by calcStats()) |
void |
insert(double[] dar,
int index)
Behaves just like Vector.insertElementAt(). |
double |
integrate(int dim)
go from delta time to absolute time on specified dimension (typically 0) |
double |
internalRepeat(double playTime)
Execute all elements in shape if an instrument is plugged in. |
void |
invert(double val,
int start,
int end,
int dim)
invert Shape data about a "horizontal line" . |
boolean |
isConstrainedToLimits()
When elements are add()'ed constrain them to the limits of the dimensions or not |
boolean |
isSafeOrdering()
safe ordering flags whether or not to swap start and end arguments if end lessthan start, in methods that use them, like scramble(), reverse(), sort(), etc |
void |
load(java.io.BufferedReader in)
BufferedReader in = new BufferedReader(new FileReader("foo.in")); Replace data with data loaded from a file. |
static void |
main(java.lang.String[] args)
exercise shape building and manipulation |
void |
prefab()
Same as prefab(17) |
void |
prefab(int numElements)
Generate random data with first four dimensions interpreted as duration, pitch, amplitude, and hold time. |
void |
print()
Calls calcStats() to generate statistics, then prints out MusicShape data to JMSL.out |
void |
printDim(int i)
|
void |
printDimNames()
print all names for all dimensions |
void |
printStats()
print statistics to JMSL.out |
static int |
qa()
Quality Assurance |
void |
randomize(double min,
double max,
int start,
int end,
int dim)
set random values into a shape. |
static MusicShape |
readBinaryHMSLShape(java.io.DataInputStream in)
Read a binary file into a new Shape. |
void |
remove(int index)
Remove child at specified index |
void |
remove(int fromIndex,
int toIndex)
Removes from this MusicShape all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive. |
void |
reverse(int start,
int end,
int dim)
reverse the order of Shape data. |
void |
save(java.io.PrintWriter out)
Save a MusicShape to a file PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("foo.out"))); First line is number of dimensions, followed by dimension names, one per line, followed by data, one element per line * |
void |
scale(double scalar,
int start,
int end,
int dim)
multiply each value by a scalar . |
void |
scramble(int start,
int end,
int dim)
randomly reorder data in range. |
void |
set(double[] dar,
int e)
Replace element at position e with double[]. |
void |
set(double value,
int e,
int d)
set(value, elem#, dim#) replace old value at (elem, dim) with new value |
void |
set(int value,
int e,
int d)
|
void |
set(long value,
int e,
int d)
|
void |
setClipped(double value,
int e,
int d)
safer version of set, automatically clips to dimension's limits |
void |
setConstrainedToLimits(boolean constrainedToLimits)
When elements are add()'ed constrain them to the limits of the dimensions or not * |
void |
setDefault(int dim,
double value)
Set a default value for a dimension |
void |
setDimensionName(int dim,
java.lang.String name)
assign a name to a dimension. |
void |
setDimName(int dim,
java.lang.String name)
Give a custom name to a dimension, ex setDimName(3, "Duration") |
void |
setDimName(java.lang.String name,
int dim)
Give a custom name to a dimension, ex setDimName("Duration", 3) |
void |
setLimits(int dim,
double low,
double high)
set the lowest and highest limits for a dimension, used by clipping |
void |
setSafeOrdering(boolean b)
|
void |
sort()
Sort shape on dim 0 |
void |
sort(int dim)
Sort shape in ascending values along specified dim |
void |
sort(int start,
int end,
int dim)
Sort shape in ascending values along specified dim |
void |
sort(int start,
int end,
int dim,
DimensionComparison cf)
sorts using user defined DimensionComparison function. |
double |
start(double startTime)
open() Instrument and return startTime |
boolean |
statsCalculated()
returns whether or not stats have been calculated |
double |
stop(double stopTime)
close() Instrument and return stopTime |
void |
sumSet(double value,
int e,
int d)
add double value to value in shape, like += |
void |
sumSet(int value,
int e,
int d)
add int value to value in shape, like += |
void |
swap(int elm1,
int elm2,
int dim)
swap data, dim <0 signals swap entire element, otherwise swap in specified dim only |
java.lang.String |
toString()
|
MusicShape |
translate(DimensionNameSpace destinationNameSpace)
Create a new MusicShape populated with this MusicShape's data, after translating from this MusicShape's DimensionNameSpace to another |
void |
transpose(double val,
int start,
int end,
int dim)
add val to a range of Shape data, clip to dim limits . |
boolean |
usesStandardInvariants()
|
void |
useStandardDimensionNameSpace()
renames dimension 0..3 as duration, pitch, amplitude, hold with default values and limits. |
void |
useStandardInvariants(boolean f)
If this flag is set, and if the DimensionNameSpace of the instrument != null, then Dimensions 0..3 will be set as DimensionnameSpace invariants. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MusicShape(DimensionNameSpace dimensionNameSpace)
public MusicShape(int dimensions)
public MusicShape(Instrument ins, int dimensions)
Method Detail |
---|
public java.util.Vector getData()
public void useStandardInvariants(boolean f)
public boolean usesStandardInvariants()
public void useStandardDimensionNameSpace()
public double[] getDefaultArray()
public static double[] getDefaultArray(DimensionNameSpace dns)
public void copyDataFrom(MusicShape source)
public void copyDataFrom(java.util.Vector source)
public int dimension()
dimension
in interface DimensionNameSpace
public void set(double[] dar, int e)
public void set(double value, int e, int d)
public void set(int value, int e, int d)
public void set(long value, int e, int d)
public void fill(double value, int start, int end, int dimension)
public void sumSet(int value, int e, int d)
public void sumSet(double value, int e, int d)
public void setDimName(java.lang.String name, int dim)
public void setDimName(int dim, java.lang.String name)
public void insert(double[] dar, int index)
public void remove(int index)
MusicJob
remove
in class MusicJob
public void remove(int fromIndex, int toIndex)
public void add(double[] d)
public void add(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10, double d11)
public void add(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9, double d10)
public void add(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8, double d9)
public void add(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8)
public void add(double d0, double d1, double d2, double d3, double d4, double d5, double d6, double d7)
public void add(double d0, double d1, double d2, double d3, double d4, double d5, double d6)
public void add(double d0, double d1, double d2, double d3, double d4, double d5)
public void add(double d0, double d1, double d2, double d3, double d4)
public void add(double d0, double d1, double d2, double d3)
public void add(double d0, double d1, double d2)
public void add(double d0, double d1)
public void add(double d0)
public void copyDimensionNameSpace(DimensionNameSpace source)
public int getNumberOfNames()
getNumberOfNames
in interface DimensionNameSpace
public java.lang.String getDimensionName(int dim)
getDimensionName
in interface DimensionNameSpace
public int getDimension(java.lang.String name)
getDimension
in interface DimensionNameSpace
public void setDimensionName(int dim, java.lang.String name)
setDimensionName
in interface DimensionNameSpace
public void setDefault(int dim, double value)
setDefault
in interface DimensionNameSpace
public double getDefault(int dim)
getDefault
in interface DimensionNameSpace
public java.util.Enumeration dimensionNames()
dimensionNames
in interface DimensionNameSpace
public MusicShape translate(DimensionNameSpace destinationNameSpace)
public java.lang.String getDimName(int dim)
public double[] get(int i)
public double get(int e, int d)
public int getInt(int e, int d)
public double getMin(int dim)
public double getMean(int dim)
public double getMax(int dim)
public double getSum(int dim)
public double getLowLimit(int dim)
getLowLimit
in interface DimensionNameSpace
public double getHighLimit(int dim)
getHighLimit
in interface DimensionNameSpace
public void setLimits(int dim, double low, double high)
setLimits
in interface DimensionNameSpace
public void calcDimStats(int dim)
public void calcStats()
public boolean statsCalculated()
public void setClipped(double value, int e, int d)
public double clipValDim(double value, int dim)
public void convertTimeBaseDim(double srcTicksPerSec, double destTicksPerSec, int dim)
public double integrate(int dim)
public void differentiate(double sum, int dim)
Durations before (absolute time): 0 1 2 3 3.5 Durations after (delta time, assume sum passed in = 5): 1 1 1 0.5 1.5
public void randomize(double min, double max, int start, int end, int dim)
public void transpose(double val, int start, int end, int dim)
public void scale(double scalar, int start, int end, int dim)
public void invert(double val, int start, int end, int dim)
public void reverse(int start, int end, int dim)
public void swap(int elm1, int elm2, int dim)
public void scramble(int start, int end, int dim)
public void sort(int start, int end, int dim, DimensionComparison cf)
public void sort(int dim)
public void sort(int start, int end, int dim)
public void sort()
public void printDimNames()
public void printStats()
public void printDim(int i)
public void print()
print
in class MusicJob
public void dumpSource(java.lang.String filename) throws java.io.IOException
java.io.IOException
public void dumpSource(java.io.PrintWriter pout) throws java.io.IOException
java.io.IOException
public java.lang.String dumpSource()
public java.lang.String toString()
toString
in class java.lang.Object
public double start(double startTime) throws java.lang.InterruptedException
start
in interface Composable
start
in class MusicJob
java.lang.InterruptedException
- thrown if Thread.interrupt() called.public double stop(double stopTime) throws java.lang.InterruptedException
stop
in interface Composable
stop
in class MusicJob
java.lang.InterruptedException
- thrown if Thread.interrupt() called.public void finishAll()
finishAll
in interface Composable
finishAll
in class MusicJob
public double internalRepeat(double playTime) throws java.lang.InterruptedException
internalRepeat
in interface Composable
internalRepeat
in class MusicJob
java.lang.InterruptedException
- thrown if Thread.interrupt() called.public void prefab()
public void prefab(int numElements)
public java.lang.Object clone()
clone
in class java.lang.Object
public static int qa()
public static MusicShape readBinaryHMSLShape(java.io.DataInputStream in) throws java.io.IOException
java.io.IOException
public void save(java.io.PrintWriter out) throws java.io.IOException
java.io.IOException
public void load(java.io.BufferedReader in) throws java.io.IOException
java.io.IOException
public static void main(java.lang.String[] args)
public boolean isSafeOrdering()
public void setSafeOrdering(boolean b)
b
- public boolean isConstrainedToLimits()
public void setConstrainedToLimits(boolean constrainedToLimits)
constrainedToLimits
- The constrainedToLimits to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |