|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectddf.minim.ugens.WavetableGenerator
public abstract class WavetableGenerator
WavetableGenerator is a helper class for generating Wavetables. The method names are likely to change in a future release to be a bit more descriptive.
| Constructor Summary | |
|---|---|
WavetableGenerator()
|
|
| Method Summary | |
|---|---|
static Wavetable |
gen10(int size,
float[] amp)
Generate a Wavetable given a list of amplitudes for successive partials (harmonics). |
static Wavetable |
gen7(int size,
float[] val,
int[] dist)
Generate a piecewise linear waveform given an array of sample values and the distances between them. |
static Wavetable |
gen9(int size,
float[] partial,
float[] amp,
float[] phase)
Generates a Wavetable from a list of partials with matching amplitudes and phases. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WavetableGenerator()
| Method Detail |
|---|
public static Wavetable gen7(int size,
float[] val,
int[] dist)
dist array should contain one value less than the val
array. The values in the dist array should also add up to size. For instance, a
call like this:
Wavetable table = WavetableGenerator.gen7( 4096, new float[] { 1.0, -1.0, 1.0 }, new int[] { 2048, 2048 } );
Would generate a Wavetable that was 4096 samples long and the values of those samples would start at 1.0, linearly decrease to -1.0 over 2048 samples, and then increase to 1.0 over the next 2048 samples.
If you wanted to generate a triangle wavetable with 4096 samples, you'd do this:
Wavetable table = WavetableGenerator.gen7( 4069, new float[] { 0.0, 1.0, 0.0, -1.0, 0.0 }, new int[] { 1024, 1024, 1024, 1024 } );
size - the size of the Wavetable that you want generateval - the sample values used as control points for generating the waveformdist - the sample distances between control points in val
public static Wavetable gen9(int size,
float[] partial,
float[] amp,
float[] phase)
Wavetable sine = WavetableGenerator.gen9(4096, new float[] { 1 }, new float[] { 1 }, new float[] { 0 });
But what this method lets you do, is create a Wavetable that contains several different partials, each with a particular amplitude or phase shift. For instance, you could create a Wavetable that plays two pitches an octave apart like this:
Wavetable octave = WavetableGenerator.gen9(4096, new float[] { 1, 2 }, new float[] { 1, 1 }, new float[] { 0, 0 });
If this is something you want a particular instrument you write to do, then creating a Wavetable that already contains the octave and using that in an Oscil will be less computationally expensive than creating two Oscils and setting their frequencies an octave apart.
size - how many samples the Wavetable should containpartial - a list of partials to generateamp - the amplitude of each partialphase - the phase of each partial
public static Wavetable gen10(int size,
float[] amp)
Wavetable table = WavetableGenerator.gen9(4096, new float[] { 1, 2, 3 }, new float[] { 1, 0.5, 0.2 }, new float[] { 0, 0, 0 });
Wavetable table = WavetableGenerator.gen10(4096, new float[] { 1, 0.5, 0.2 });
size - the number of samples the Wavetable should containamp - the amplitude of each successive partial, beginning with partial 1.gen9(int, float[], float[], float[])
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||