will be used to invoke this
+ * the key-value pair <String "x", float 0.5f> will be used to invoke this
* method. Errors are caught and printed (actually, not right now...).
*
* Be aware that this may not work as expected with all objects. Use with
@@ -175,7 +175,7 @@ public void configureObject(Object o) {
* This method is a useful way to update float parameters in a
* class:
*
- * float param = startval;
+ * float param = startval;
* ...
* param = databead.getFloat("paramKey", param);
*
diff --git a/src/beads_main/net/beadsproject/beads/data/DataBeadReceiver.java b/src/beads_main/java/net/beadsproject/beads/data/DataBeadReceiver.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/DataBeadReceiver.java
rename to src/beads_main/java/net/beadsproject/beads/data/DataBeadReceiver.java
diff --git a/src/beads_main/java/net/beadsproject/beads/data/Pitch.java b/src/beads_main/java/net/beadsproject/beads/data/Pitch.java
new file mode 100644
index 0000000..2401ec2
--- /dev/null
+++ b/src/beads_main/java/net/beadsproject/beads/data/Pitch.java
@@ -0,0 +1,177 @@
+/*
+ * This file is part of Beads. See http://www.beadsproject.net for all information.
+ */
+package net.beadsproject.beads.data;
+
+/**
+ * A set of static fields and utility methods associated with pitch.
+ *
+ * @author ollie
+ */
+public abstract class Pitch {
+
+ /** The constant log(2) = 0.6931472. */
+ public final static float LOG2 = 0.6931472f;
+
+ /**
+ * Convert frequency to MIDI note number.
+ *
+ * @param frequency
+ * the required frequency.
+ *
+ * @return the resulting MIDI note number.
+ */
+ public static final float ftom(float frequency) {
+ return Math.max(0f, (float)Math.log(frequency / 440.0f) / LOG2 * 12f + 69f);
+ }
+
+ /**
+ * Convert MIDI note number to frequency.
+ *
+ * @param midi
+ * the required MIDI note number.
+ *
+ * @return the resulting frequency.
+ */
+ public static final float mtof(float midi) {
+ return 440.0f * (float)Math.pow(2.0f, (midi - 69f) / 12.0f);
+ }
+
+ /**
+ * Takes a pitch and returns that pitch adjusted downwards to the nearest pitch in the given scale.
+ *
+ * @param pitch the pitch to modify.
+ * @param scale the scale to use.
+ * @param notesPerOctave how many notes in your octave (12 if you're not sure).
+ * @return adjusted pitch.
+ */
+ public static final int forceToScale(int pitch, int[] scale, int notesPerOctave) {
+ int pitchClass = pitch % notesPerOctave;
+ int register = pitch / notesPerOctave;
+ int newPitchClass = -1;
+ for(int i = scale.length - 1; i >= 0; i--) {
+ if(pitchClass >= scale[i]) {
+ newPitchClass = scale[i];
+ break;
+ }
+ }
+ if(newPitchClass == -1) {
+ newPitchClass = pitchClass;
+ }
+ return register * notesPerOctave + newPitchClass;
+ }
+
+ /**
+ * Takes a pitch and returns that pitch adjusted downwards to the nearest pitch in the given scale. Assumes 12 pitches per octave.
+ *
+ * @param pitch the pitch to modify.
+ * @param scale the scale to use.
+ * @return adjusted pitch.
+ */
+ public static final int forceToScale(int pitch, int[] scale) {
+ return forceToScale(pitch, scale, 12);
+ }
+
+ public static final float forceFrequencyToScale(float freq, int[] scale) {
+ return mtof(forceToScale((int)ftom(freq), scale));
+ }
+
+ /** Pitch names for scale starting at C. */
+ public static final String[] pitchNames = new String[]{"C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"};
+
+ /** The dorian scale relative to root. */
+ public static final int[] dorian = {0, 2, 3, 5, 7, 9, 10};
+
+ /** The major scale relative to root. */
+ public static final int[] major = {0, 2, 4, 5, 7, 9, 11};
+
+ /** The minor scale relative to root. */
+ public static final int[] minor = {0, 2, 3, 5, 7, 8, 10};
+
+ /** The circle of fifths relative to root. */
+ public static final int[] circleOfFifths = {0, 5, 10, 3, 8, 1, 6, 11, 4, 9, 2, 7};
+
+ /** Pentatonic. */
+ public static final int[] pentatonic = {0, 2, 4, 7, 9};
+
+ /**
+ * Calculate the MIDI note that would be required given the tonic of a scale, the numbers
+ * in the scale relative to the tonic, and the index using zero based reference
+ * For example, with Midi Note C3 (60), using the Major scale, and scaleIndex of 8 (being major 9th)
+ * we would get 60 + 12 + 2 = 74 (D4)
+ * @param scaleTonic The note number that would be the zero index of the scale
+ * @param scaleData An array of notes for which to define our scale
+ * @param scaleIndex The index within the scale to find the value to add
+ * @return The scaleTonic + scaleIndex in the index. If scaleIndex is outside the range of array
+ * eg (scaleIndex < 0 || scaleIndex >= scaleData.length) then modulo mathematics will be used to
+ * return note from next or previous register
+ */
+ public static int getRelativeMidiNote (int scaleTonic, int[] scaleData, int scaleIndex){
+ int ret = scaleTonic; // this will be if a scaleIndex is zero
+
+ // Note our comment text will assume scaleData is Picth.major for ease of understanding
+ if (scaleIndex > 0){
+ // get the scale degree from the scale
+ // eg, if scaleIndex is 9, scale_degree = 9 % 7 = 2
+ int scale_degree = scaleIndex % scaleData.length;
+
+ // If our scale pitch is 2,Pitch.major[2] = 4 (major third)
+ int scale_pitch = scaleData[scale_degree];
+
+ // Now get the register of our note
+ // eg, if scaleIndex is 9, note_register = 9 / 7 = 1
+ int note_register = scaleIndex / scaleData.length;
+
+ // we multiply our register x 12 because that is an octave in MIDI
+ // if scaleIndex is 9 then 1 x 12 + 4 = 16
+ int note_pitch = note_register * 12 + scale_pitch;
+
+ // add the number to our base tonic to get the note based on key. Assume our scaleTonic is C2 (48)
+ // if scaleIndex is 9 then 48 + 16 = 64. This is E3 in MIDI
+ ret = scaleTonic + note_pitch;
+
+ }
+ else if (scaleIndex < 0){
+ int negative_index = scaleIndex * -1;
+
+ // get the scale degree from the scale we need to reduce by
+ // eg, if scaleIndex is -9, scale_degree = 9 % 7 = 2 (we got absoly=te value of scaleIndex)
+ // We need to get index below this figure = eg, 2 array index points from end
+ int scale_degree = negative_index % scaleData.length;
+
+ // If our scale scale_degree is 2, Pitch.major[7-2] = 9 (major sixth)
+ int scale_pitch = scaleData[(scaleData.length - scale_degree) % scaleData.length];
+
+ // Now get the register of our note
+ // eg, if scaleIndex is -9, note_register = -9 / 7 = -1
+ int note_register = scaleIndex / scaleData.length;
+
+ // if it is not exactly an octave, we need to calculate our range from and extra register below
+ if (scale_pitch != 0){
+ // if scaleIndex is -9 then note_register = -2
+ note_register -= 1;
+ }
+ // we multiply our register x 12 because that is an octave in MIDI
+ // if scaleIndex is -9 then -2 x 12 + 9 = -15
+ int note_pitch = note_register * 12 + scale_pitch;
+
+ // add the number to our base tonic to get the note based on key. Assume our Base Note C3 (60)
+ // if scaleIndex is -9 then 60 - 15 = 45. This is A1 in MIDI
+ ret = scaleTonic + note_pitch;
+ }
+
+ return ret;
+ }
+
+ /**
+ * Shift the Pitch based on the number of semitones
+ * @param frequency The frequency we want shifted
+ * @param midiDegree the number of semitones we want to shift
+ * @return the frequency value shifted by the number of semitones
+ */
+ public static double shiftPitch (float frequency, int midiDegree){
+ final double SEMITONE_CONSTANT = Math.pow(2 , 1f/12f);
+ return Math.pow(SEMITONE_CONSTANT, midiDegree) * frequency;
+
+ }
+}
diff --git a/src/beads_main/net/beadsproject/beads/data/Sample.java b/src/beads_main/java/net/beadsproject/beads/data/Sample.java
similarity index 91%
rename from src/beads_main/net/beadsproject/beads/data/Sample.java
rename to src/beads_main/java/net/beadsproject/beads/data/Sample.java
index da0319f..82a8548 100644
--- a/src/beads_main/net/beadsproject/beads/data/Sample.java
+++ b/src/beads_main/java/net/beadsproject/beads/data/Sample.java
@@ -11,18 +11,20 @@
import net.beadsproject.beads.data.audiofile.AudioFileReader;
import net.beadsproject.beads.data.audiofile.AudioFileType;
import net.beadsproject.beads.data.audiofile.AudioFileWriter;
+import net.beadsproject.beads.data.audiofile.FileFormatException;
+import net.beadsproject.beads.data.audiofile.OperationUnsupportedException;
/**
* A Sample encapsulates audio data, either loaded from an audio file (such as
- * an MP3) or written by a Recorder.
+ * an MP3) or written by a Recorder.
* The typical use of a Sample is through
* {@link net.beadsproject.beads.data.SampleManager}. For example, to load an
- * mp3, you would do the following.
- *
+ * mp3, you would do the following.
+ *
*
* Sample wicked = SampleManager.sample("wickedTrack.mp3");
- *
- *
+ *
+ *
*
*
* Samples are usually played with a
@@ -32,8 +34,7 @@
* {@link #getFrames(int, float[][]) getFrames}. Sample data can be written
* with: {@link #putFrame(int, float[]) putFrame} or
* {@link #putFrames(int, float[][]) putFrames}.
- *
- * @beads.category data
+ *
* @see SampleManager
* @see net.beadsproject.beads.ugens.RecordToSample
* @author Beads Team
@@ -81,7 +82,7 @@ public class Sample {
try {
defaultAudioFileWriterClass = (Class extends AudioFileWriter>) Class.forName("net.beadsproject.beads.data.audiofile.WavFileReaderWriter");
} catch (ClassNotFoundException e2) {
- defaultAudioFileReaderClass = null;
+ defaultAudioFileWriterClass = null;
}
}
}
@@ -139,11 +140,10 @@ public Sample(double length, int nChannels, float sampleRate) {
/**
* Create a sample from a file. This constructor immediately loads the
* entire audio file into memory.
- *
- * @throws UnsupportedAudioFileException
+ *
* @throws IOException
*/
- public Sample(String filename) throws IOException {
+ public Sample(String filename) throws IOException, OperationUnsupportedException, FileFormatException {
loadAudioFile(filename);
this.filename = filename;
}
@@ -354,7 +354,7 @@ public void clear() {
* isWriteable() is false, the behaviour is undefined/unstable.
*
* @param frame
- * The frame to write into. Must be >=0 and theRealAudioFileReaderClass = audioFileReaderClass == null ? defaultAudioFileReaderClass : audioFileReaderClass;
if(file.endsWith(".wav") || file.endsWith(".WAV")) {
try {
@@ -641,7 +654,7 @@ private void loadAudioFile(String file) throws IOException {
try {
this.theSampleData = audioFileReader.readAudioFile(file);
} catch (Exception e) {
- throw new IOException(e);
+ throw e;
}
this.sampleRate = audioFileReader.getSampleAudioFormat().sampleRate;
this.nChannels = theSampleData.length;
diff --git a/src/beads_main/net/beadsproject/beads/data/SampleAudioFormat.java b/src/beads_main/java/net/beadsproject/beads/data/SampleAudioFormat.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/SampleAudioFormat.java
rename to src/beads_main/java/net/beadsproject/beads/data/SampleAudioFormat.java
diff --git a/src/beads_main/net/beadsproject/beads/data/SampleManager.java b/src/beads_main/java/net/beadsproject/beads/data/SampleManager.java
similarity index 95%
rename from src/beads_main/net/beadsproject/beads/data/SampleManager.java
rename to src/beads_main/java/net/beadsproject/beads/data/SampleManager.java
index f916fab..1f07971 100644
--- a/src/beads_main/net/beadsproject/beads/data/SampleManager.java
+++ b/src/beads_main/java/net/beadsproject/beads/data/SampleManager.java
@@ -5,6 +5,7 @@
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URL;
@@ -16,10 +17,12 @@
import java.util.Set;
import java.util.TreeMap;
+import net.beadsproject.beads.data.audiofile.FileFormatException;
+import net.beadsproject.beads.data.audiofile.OperationUnsupportedException;
+
/**
* SampleManager provides a static repository for {@link Sample} data and provides methods to organise samples into groups.
- *
- * @beads.category data
+ *
*/
public class SampleManager {
@@ -77,10 +80,14 @@ public static Sample sample(String ref, String fn) {
try {
sample = new Sample(fn);
samples.put(ref, sample);
- if(verbose) System.out.println("Loaded " + fn);
- } catch (Exception e) {
- //swallow exception
- }
+ if(verbose) System.out.println("Sample loaded " + fn);
+ } catch (OperationUnsupportedException e) {
+ System.out.println("OperationUnsupportedException: The reading operation failed " + fn);
+ } catch (FileFormatException e) {
+ System.out.println("FileFormatException: Sample format malformed " + fn);
+ } catch (IOException e) {
+ System.out.println("IOException: Sample not found/supported " + fn);
+ }
}
return sample;
}
diff --git a/src/beads_main/net/beadsproject/beads/data/audiofile/AudioFileReader.java b/src/beads_main/java/net/beadsproject/beads/data/audiofile/AudioFileReader.java
similarity index 55%
rename from src/beads_main/net/beadsproject/beads/data/audiofile/AudioFileReader.java
rename to src/beads_main/java/net/beadsproject/beads/data/audiofile/AudioFileReader.java
index b1a6616..605eb11 100644
--- a/src/beads_main/net/beadsproject/beads/data/audiofile/AudioFileReader.java
+++ b/src/beads_main/java/net/beadsproject/beads/data/audiofile/AudioFileReader.java
@@ -15,23 +15,20 @@ public interface AudioFileReader {
/**
* Single method to read an entire audio file in one go.
- * @param data - upon return, this will point to a 2D array containing all the audio data.
- * The first dimension (data.length) is the number of channels.
- * The second dimension (data[0].length) is the number of frames.
* @param filename - the name of the file to be read
- * @param saf - upon return, this will point to a SampleAudioFormat object containing the details of the sample data that was read.
+ * @return the samples as arrays
*/
- public float[][] readAudioFile(String filename) throws IOException, OperationUnsupportedException, FileFormatException;
+ float[][] readAudioFile(String filename) throws IOException, OperationUnsupportedException, FileFormatException;
/**
* After reading, the SampleAudioFormat can be obtained.
* @return the SampleAudioFormat object describing the sample data that has been read in.
*/
- public SampleAudioFormat getSampleAudioFormat();
+ SampleAudioFormat getSampleAudioFormat();
/**
* Get the supported file types.
* @return - the supported file types.
*/
- public HashSet getSupportedFileTypesForReading();
+ HashSet getSupportedFileTypesForReading();
}
diff --git a/src/beads_main/net/beadsproject/beads/data/audiofile/AudioFileType.java b/src/beads_main/java/net/beadsproject/beads/data/audiofile/AudioFileType.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/audiofile/AudioFileType.java
rename to src/beads_main/java/net/beadsproject/beads/data/audiofile/AudioFileType.java
diff --git a/src/beads_main/net/beadsproject/beads/data/audiofile/AudioFileWriter.java b/src/beads_main/java/net/beadsproject/beads/data/audiofile/AudioFileWriter.java
similarity index 84%
rename from src/beads_main/net/beadsproject/beads/data/audiofile/AudioFileWriter.java
rename to src/beads_main/java/net/beadsproject/beads/data/audiofile/AudioFileWriter.java
index bbb1b6c..a1ec20a 100644
--- a/src/beads_main/net/beadsproject/beads/data/audiofile/AudioFileWriter.java
+++ b/src/beads_main/java/net/beadsproject/beads/data/audiofile/AudioFileWriter.java
@@ -19,8 +19,9 @@ public interface AudioFileWriter {
* @param filename - the name of the file to be written
* @param type - the type of audio file to be written (mp3, wav, etc.)
* @param saf - a SampleAudioFormat object specifying the attributes of the sample data to be written. Can be NULL, in which case default values will be used.
+ *
*/
- public void writeAudioFile(float[][] data, String filename, AudioFileType type, SampleAudioFormat saf) throws IOException, OperationUnsupportedException, FileFormatException;
+ void writeAudioFile(float[][] data, String filename, AudioFileType type, SampleAudioFormat saf) throws IOException, OperationUnsupportedException, FileFormatException;
/**
* Get the supported file types.
diff --git a/src/beads_main/net/beadsproject/beads/data/audiofile/FileFormatException.java b/src/beads_main/java/net/beadsproject/beads/data/audiofile/FileFormatException.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/audiofile/FileFormatException.java
rename to src/beads_main/java/net/beadsproject/beads/data/audiofile/FileFormatException.java
diff --git a/src/beads_main/net/beadsproject/beads/data/audiofile/OperationUnsupportedException.java b/src/beads_main/java/net/beadsproject/beads/data/audiofile/OperationUnsupportedException.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/audiofile/OperationUnsupportedException.java
rename to src/beads_main/java/net/beadsproject/beads/data/audiofile/OperationUnsupportedException.java
diff --git a/src/beads_main/net/beadsproject/beads/data/audiofile/WavFileReaderWriter.java b/src/beads_main/java/net/beadsproject/beads/data/audiofile/WavFileReaderWriter.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/audiofile/WavFileReaderWriter.java
rename to src/beads_main/java/net/beadsproject/beads/data/audiofile/WavFileReaderWriter.java
diff --git a/src/beads_main/java/net/beadsproject/beads/data/audiofile/package.html b/src/beads_main/java/net/beadsproject/beads/data/audiofile/package.html
new file mode 100644
index 0000000..a0d10f0
--- /dev/null
+++ b/src/beads_main/java/net/beadsproject/beads/data/audiofile/package.html
@@ -0,0 +1,8 @@
+
+
+
+
+ Provides classes involved in handling audio files. Mostly these would not be
+ handled by the user, but accessed via Sample.
+
+
\ No newline at end of file
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/CosineWindow.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/CosineWindow.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/CosineWindow.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/CosineWindow.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/CurveBuffer.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/CurveBuffer.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/CurveBuffer.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/CurveBuffer.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/Exp01Buffer.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/Exp01Buffer.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/Exp01Buffer.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/Exp01Buffer.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/HanningWindow.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/HanningWindow.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/HanningWindow.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/HanningWindow.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/Log01Buffer.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/Log01Buffer.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/Log01Buffer.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/Log01Buffer.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/MeanFilter.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/MeanFilter.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/MeanFilter.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/MeanFilter.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/NoiseBuffer.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/NoiseBuffer.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/NoiseBuffer.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/NoiseBuffer.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/OneWindow.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/OneWindow.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/OneWindow.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/OneWindow.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/RampBuffer.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/RampBuffer.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/RampBuffer.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/RampBuffer.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/SawBuffer.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/SawBuffer.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/SawBuffer.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/SawBuffer.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/SineBuffer.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/SineBuffer.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/SineBuffer.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/SineBuffer.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/SquareBuffer.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/SquareBuffer.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/SquareBuffer.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/SquareBuffer.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/TriangleBuffer.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/TriangleBuffer.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/TriangleBuffer.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/TriangleBuffer.java
diff --git a/src/beads_main/net/beadsproject/beads/data/buffers/TriangularWindow.java b/src/beads_main/java/net/beadsproject/beads/data/buffers/TriangularWindow.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/data/buffers/TriangularWindow.java
rename to src/beads_main/java/net/beadsproject/beads/data/buffers/TriangularWindow.java
diff --git a/src/beads_main/java/net/beadsproject/beads/data/buffers/package.html b/src/beads_main/java/net/beadsproject/beads/data/buffers/package.html
new file mode 100644
index 0000000..abe0cf2
--- /dev/null
+++ b/src/beads_main/java/net/beadsproject/beads/data/buffers/package.html
@@ -0,0 +1,7 @@
+
+
+
+
+ Provides BufferFactories for generating various types of wavetables and windows.
+
+
\ No newline at end of file
diff --git a/src/beads_main/java/net/beadsproject/beads/data/package.html b/src/beads_main/java/net/beadsproject/beads/data/package.html
new file mode 100644
index 0000000..d33247a
--- /dev/null
+++ b/src/beads_main/java/net/beadsproject/beads/data/package.html
@@ -0,0 +1,7 @@
+
+
+
+
+ Provides classes for handling buffers of data, including samples and common waveforms and windows.
+
+
\ No newline at end of file
diff --git a/src/beads_main/net/beadsproject/beads/events/AudioContextStopTrigger.java b/src/beads_main/java/net/beadsproject/beads/events/AudioContextStopTrigger.java
similarity index 68%
rename from src/beads_main/net/beadsproject/beads/events/AudioContextStopTrigger.java
rename to src/beads_main/java/net/beadsproject/beads/events/AudioContextStopTrigger.java
index 1ff102a..195cdeb 100644
--- a/src/beads_main/net/beadsproject/beads/events/AudioContextStopTrigger.java
+++ b/src/beads_main/java/net/beadsproject/beads/events/AudioContextStopTrigger.java
@@ -9,13 +9,13 @@
/**
* Use AudioContextStopTrigger to cause the {@link AudioContext} to stop in response to a given event.
*
- * For example, to cause the {@link AudioContext} to stop when a sample has finished playing:
+ * For example, to cause the {@link AudioContext} to stop when a sample has finished playing:
*
- *
AudioContext context = new AudioContext();
- *
SamplePlayer samplePlayer = new SamplePlayer(SampleManager.sample(pathToAudioFile));
- *
context.out.addInput(samplePlayer);
- *
samplePlayer.setKillListener(new AudioContextStopTrigger(context));
- *
context.start();
+ * AudioContext context = new AudioContext();
+ * SamplePlayer samplePlayer = new SamplePlayer(SampleManager.sample(pathToAudioFile));
+ * context.out.addInput(samplePlayer);
+ * samplePlayer.setKillListener(new AudioContextStopTrigger(context));
+ * context.start();
*
*/
public class AudioContextStopTrigger extends Bead {
diff --git a/src/beads_main/net/beadsproject/beads/events/FloatBead.java b/src/beads_main/java/net/beadsproject/beads/events/FloatBead.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/events/FloatBead.java
rename to src/beads_main/java/net/beadsproject/beads/events/FloatBead.java
diff --git a/src/beads_main/net/beadsproject/beads/events/IntegerBead.java b/src/beads_main/java/net/beadsproject/beads/events/IntegerBead.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/events/IntegerBead.java
rename to src/beads_main/java/net/beadsproject/beads/events/IntegerBead.java
diff --git a/src/beads_main/net/beadsproject/beads/events/KillTrigger.java b/src/beads_main/java/net/beadsproject/beads/events/KillTrigger.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/events/KillTrigger.java
rename to src/beads_main/java/net/beadsproject/beads/events/KillTrigger.java
diff --git a/src/beads_main/net/beadsproject/beads/events/PauseTrigger.java b/src/beads_main/java/net/beadsproject/beads/events/PauseTrigger.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/events/PauseTrigger.java
rename to src/beads_main/java/net/beadsproject/beads/events/PauseTrigger.java
diff --git a/src/beads_main/net/beadsproject/beads/events/SoundEvent.java b/src/beads_main/java/net/beadsproject/beads/events/SoundEvent.java
similarity index 93%
rename from src/beads_main/net/beadsproject/beads/events/SoundEvent.java
rename to src/beads_main/java/net/beadsproject/beads/events/SoundEvent.java
index a7ef909..fddbc91 100644
--- a/src/beads_main/net/beadsproject/beads/events/SoundEvent.java
+++ b/src/beads_main/java/net/beadsproject/beads/events/SoundEvent.java
@@ -10,7 +10,7 @@
/**
* A general purpose interface for defining sound events. A SoundEvent is created with
- * the method @link {@link #play(UGen, DataBead)} and can be passed a {@link DataBead}
+ * the method @link {@link #play(UGen, Map)} and can be passed a {@link DataBead}
* which can contain additional classes for controlling the event after it has been
* triggered. The SoundEvent also gets passed a {@link UGen} which it should connect to.
* It should also return the {@link UGen} which is its root, so that callers of the
diff --git a/src/beads_main/net/beadsproject/beads/events/SoundEventManager.java b/src/beads_main/java/net/beadsproject/beads/events/SoundEventManager.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/events/SoundEventManager.java
rename to src/beads_main/java/net/beadsproject/beads/events/SoundEventManager.java
diff --git a/src/beads_main/net/beadsproject/beads/events/StartTrigger.java b/src/beads_main/java/net/beadsproject/beads/events/StartTrigger.java
similarity index 100%
rename from src/beads_main/net/beadsproject/beads/events/StartTrigger.java
rename to src/beads_main/java/net/beadsproject/beads/events/StartTrigger.java
diff --git a/src/beads_main/java/net/beadsproject/beads/events/package.html b/src/beads_main/java/net/beadsproject/beads/events/package.html
new file mode 100644
index 0000000..12cf842
--- /dev/null
+++ b/src/beads_main/java/net/beadsproject/beads/events/package.html
@@ -0,0 +1,7 @@
+
+
+
+
+ Provides classes for handling events.
+
+
\ No newline at end of file
diff --git a/src/beads_main/net/beadsproject/beads/ugens/ADSR.java b/src/beads_main/java/net/beadsproject/beads/ugens/ADSR.java
similarity index 65%
rename from src/beads_main/net/beadsproject/beads/ugens/ADSR.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/ADSR.java
index b63a8b0..b09d37e 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/ADSR.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/ADSR.java
@@ -26,6 +26,15 @@ public ADSR(AudioContext context, UGen src, float... adsr) {
addInput(src);
}
+ /**
+ * Create an ADSR with the given {@link UGen} as input. The array of float arguments should consist of a series of pairs [x,t] where x is the destination value and t is the time to destination, finishing with a single time value to zero. For example the array 1, 0, 1000 would give you an instant attack to 1, followed by a 1s decay to zero. The array 1, 500, 1000 would give you a ramp up from 0 to 1 over 500ms followed by a 1s decay to zero. An array with an even number of elements is incorrectly formed, but as a rule, the final value in the array will always dictate the decay time to zero. This object will self-destruct once the envelope has completed. The number of channels of this {@link UGen} is dictated by the number of channels of the src {@link UGen}.
+ * @param src the source UGen, which is plugged into this ADSR {@link UGen}.
+ * @param adsr the adsr parameters.
+ */
+ public ADSR(UGen src, float... adsr) {
+ this(getDefaultContext(), src, adsr);
+ }
+
/**
* Create an ADSR with the given number of channels. The array of float arguments should consist of a series of pairs [x,t] where x is the destination value and t is the time to destination, finishing with a single time value to zero. For example the array 1, 0, 1000 would give you an instant attack to 1, followed by a 1s decay to zero. The array 1, 500, 1000 would give you a ramp up from 0 to 1 over 500ms followed by a 1s decay to zero. An array with an even number of elements is incorrectly formed, but as a rule, the final value in the array will always dictate the decay time to zero. This object will self-destruct once the envelope has completed.
* @param context the {@link AudioContext}.
@@ -42,6 +51,16 @@ public ADSR(AudioContext context, int inouts, float... adsr) {
env.addSegment(0, adsr[adsr.length - 1], new KillTrigger(this));
}
+ /**
+ * Create an ADSR with the given number of channels. The array of float arguments should consist of a series of pairs [x,t] where x is the destination value and t is the time to destination, finishing with a single time value to zero. For example the array 1, 0, 1000 would give you an instant attack to 1, followed by a 1s decay to zero. The array 1, 500, 1000 would give you a ramp up from 0 to 1 over 500ms followed by a 1s decay to zero. An array with an even number of elements is incorrectly formed, but as a rule, the final value in the array will always dictate the decay time to zero. This object will self-destruct once the envelope has completed.
+ * @param inouts the number of channels.
+ * @param adsr the adsr parameters.
+ */
+ public ADSR(int inouts, float... adsr) {
+ this(getDefaultContext(), inouts, adsr);
+ }
+
+
public void calculateBuffer() {
env.update();
gain.update();
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Add.java b/src/beads_main/java/net/beadsproject/beads/ugens/Add.java
similarity index 78%
rename from src/beads_main/net/beadsproject/beads/ugens/Add.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Add.java
index d6918bf..80cf6b4 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Add.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Add.java
@@ -9,8 +9,7 @@
/**
* Takes an incoming signal (or signals in the multi-channel case) and adds
* something (either a float value or another signal) to it (them).
- *
- * @beads.category utilities
+ *
* @author ollie
* @author Benito Crawford
* @version 0.9.5
@@ -35,6 +34,20 @@ public Add(AudioContext context, int channels, UGen adderUGen) {
super(context, channels, channels);
setAdder(adderUGen);
}
+
+ /**
+ * Constructor for an Add object that sets a UGen to control the value to
+ * add.
+ *
+ * @param channels
+ * The number of channels.
+ * @param adderUGen
+ * The adder UGen controller.
+ */
+ public Add(int channels, UGen adderUGen) {
+ this(getDefaultContext(), channels, adderUGen);
+ }
+
/**
* Constructor for an Add object with a given UGen as input and another as adder.
* i.e., use this as quickest way to add two UGens together.
@@ -49,9 +62,20 @@ public Add(AudioContext context, UGen input, UGen adderUGen) {
addInput(input);
}
+ /**
+ * Constructor for an Add object with a given UGen as input and another as adder.
+ * i.e., use this as quickest way to add two UGens together.
+ *
+ * @param input the input UGen.
+ * @param adderUGen the adder UGen.
+ */
+ public Add(UGen input, UGen adderUGen) {
+ this(getDefaultContext(), input, adderUGen);
+ }
+
/**
* Constructor for an Add object that sets a static adder value.
- *
+ *
* @param context
* The audio context.
* @param channels
@@ -64,6 +88,18 @@ public Add(AudioContext context, int channels, float adder) {
setAdder(adder);
}
+ /**
+ * Constructor for an Add object that sets a static adder value.
+ *
+ * @param channels
+ * The number of channels.
+ * @param adder
+ * The value to add.
+ */
+ public Add(int channels, float adder) {
+ this(getDefaultContext(), channels, adder);
+ }
+
/*
* (non-Javadoc)
*
diff --git a/src/beads_main/net/beadsproject/beads/ugens/AllpassFilter.java b/src/beads_main/java/net/beadsproject/beads/ugens/AllpassFilter.java
similarity index 80%
rename from src/beads_main/net/beadsproject/beads/ugens/AllpassFilter.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/AllpassFilter.java
index 6df8e9d..23d6bdf 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/AllpassFilter.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/AllpassFilter.java
@@ -14,8 +14,7 @@
* formula: Y(n) = X(n-d) + g * (Y(n-d) - X(n)),
*
* for delay time d and factor g.
- *
- * @beads.category filter
+ *
* @author Benito Crawford
* @version 0.9.5
*/
@@ -44,6 +43,20 @@ public AllpassFilter(AudioContext context, int maxdel, int idel, float ig) {
setDelay(idel).setG(ig);
}
+ /**
+ * Constructor with delay and g specified by floats.
+ *
+ * @param maxdel
+ * The maximum delay in samples; cannot be changed.
+ * @param idel
+ * The initial delay in samples.
+ * @param ig
+ * The initial g parameter.
+ */
+ public AllpassFilter(int maxdel, int idel, float ig) {
+ this(getDefaultContext(), maxdel, idel, ig);
+ }
+
/**
* Constructor with delay specified by a UGen and g specified by a float.
*
@@ -61,9 +74,23 @@ public AllpassFilter(AudioContext context, int maxdel, UGen idel, float ig) {
setDelay(idel).setG(ig);
}
+ /**
+ * Constructor with delay specified by a UGen and g specified by a float.
+ *
+ * @param maxdel
+ * The maximum delay in samples; cannot be changed.
+ * @param idel
+ * The delay UGen.
+ * @param ig
+ * The initial g parameter.
+ */
+ public AllpassFilter(int maxdel, UGen idel, float ig) {
+ this(getDefaultContext(), maxdel, idel, ig);
+ }
+
/**
* Constructor with delay specified by a float and g specified by a UGen.
- *
+ *
* @param context
* The AudioContext.
* @param maxdel
@@ -78,9 +105,23 @@ public AllpassFilter(AudioContext context, int maxdel, int idel, UGen ig) {
setDelay(idel).setG(ig);
}
+ /**
+ * Constructor with delay specified by a float and g specified by a UGen.
+ *
+ * @param maxdel
+ * The maximum delay in samples; cannot be changed.
+ * @param idel
+ * The initial delay in samples.
+ * @param ig
+ * The g UGen.
+ */
+ public AllpassFilter(int maxdel, int idel, UGen ig) {
+ this(getDefaultContext(), maxdel, idel, ig);
+ }
+
/**
* Constructor with delay and g specified by UGens.
- *
+ *
* @param context
* The AudioContext.
* @param maxdel
@@ -95,6 +136,21 @@ public AllpassFilter(AudioContext context, int maxdel, UGen idel, UGen ig) {
setDelay(idel).setG(ig);
}
+ /**
+ * Constructor with delay and g specified by UGens.
+ *
+ * @param maxdel
+ * The maximum delay in samples; cannot be changed.
+ * @param idel
+ * The delay UGen.
+ * @param ig
+ * The g UGen.
+ */
+ public AllpassFilter(int maxdel, UGen idel, UGen ig) {
+ this(getDefaultContext(), maxdel, idel, ig);
+ }
+
+
private AllpassFilter(AudioContext context, int maxdel) {
super(context, 1, 1);
maxDelay = Math.max(maxdel, 1);
@@ -145,7 +201,7 @@ public void calculateBuffer() {
/**
* Gets the current g parameter.
- *
+ *
* @return The g parameter.
*/
public float getG() {
@@ -154,7 +210,7 @@ public float getG() {
/**
* Sets the g parameter. This clears the g UGen if there is one.
- *
+ *
* @param g
* The g parameter.
* @return This filter instance.
@@ -172,7 +228,7 @@ public AllpassFilter setG(float g) {
/**
* Sets a UGen to determine the g value.
- *
+ *
* @param g
* The g UGen.
* @return This filter instance.
@@ -191,7 +247,7 @@ public AllpassFilter setG(UGen g) {
/**
* Gets the g UGen, if there is one.
- *
+ *
* @return The g UGen.
*/
public UGen getGUGen() {
@@ -204,7 +260,7 @@ public UGen getGUGen() {
/**
* Gets the current delay in samples.
- *
+ *
* @return The delay in samples.
*/
public int getDelay() {
@@ -213,7 +269,7 @@ public int getDelay() {
/**
* Sets the delay.
- *
+ *
* @param del
* The delay in samples. This will remove the delay UGen if there
* is one.
@@ -239,7 +295,7 @@ public AllpassFilter setDelay(int del) {
/**
* Sets a UGen to determine the delay in samples. Delay times are converted
* to integers. Passing a null value freezes the delay at its current value.
- *
+ *
* @param del
* The delay UGen.
* @return This filter instance.
@@ -262,7 +318,7 @@ public AllpassFilter setDelay(UGen del) {
/**
* Gets the delay UGen, if there is one.
- *
+ *
* @return The delay UGen.
*/
public UGen getDelayUGen() {
@@ -282,7 +338,7 @@ public UGen getDelayUGen() {
* "delay": (float or UGen)
* "g": (float or UGen)
*
- *
+ *
* @param paramBead
* The DataBead specifying parameters.
* @return This filter instance.
@@ -320,7 +376,7 @@ public void messageReceived(Bead message) {
/**
* Gets a DataBead with properties "delay" and "g" set to the corresponding
* filter parameters.
- *
+ *
* @return The parameter DataBead.
*/
public DataBead getParams() {
@@ -343,7 +399,7 @@ public DataBead getParams() {
/**
* Gets a DataBead with properties "delay" and "g" set to static float
* values corresponding to the current filter parameters.
- *
+ *
* @return The static parameter DataBead.
*/
public DataBead getStaticParams() {
@@ -355,7 +411,7 @@ public DataBead getStaticParams() {
/**
* Sets the filter's parameters with a DataBead.
- *
+ *
* @return This filter instance.
* @see #setParams(DataBead)
*/
diff --git a/src/beads_main/net/beadsproject/beads/ugens/BiquadCustomCoeffCalculator.java b/src/beads_main/java/net/beadsproject/beads/ugens/BiquadCustomCoeffCalculator.java
similarity index 95%
rename from src/beads_main/net/beadsproject/beads/ugens/BiquadCustomCoeffCalculator.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/BiquadCustomCoeffCalculator.java
index 2796f6d..a96936a 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/BiquadCustomCoeffCalculator.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/BiquadCustomCoeffCalculator.java
@@ -16,8 +16,7 @@
* according to the input parameters freq, q, and gain, as well as the useful
* class variables {@link #sampFreq} and {@link #two_pi_over_sf}.
*
- *
- * @beads.category filter
+ *
* @author Benito Crawford
* @version .9.1
*/
diff --git a/src/beads_main/net/beadsproject/beads/ugens/BiquadFilter.java b/src/beads_main/java/net/beadsproject/beads/ugens/BiquadFilter.java
similarity index 87%
rename from src/beads_main/net/beadsproject/beads/ugens/BiquadFilter.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/BiquadFilter.java
index 229a9b3..c76f586 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/BiquadFilter.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/BiquadFilter.java
@@ -30,8 +30,7 @@
*
* BiquadFilterMulti can also implement a user-defined filter algorithm by
* calling {@link #setCustomType(CustomCoeffCalculator)}.
- *
- * @beads.category filter
+ *
* @author Benito Crawford
* @version 0.9.6
*/
@@ -178,6 +177,17 @@ public BiquadFilter(AudioContext context, int channels) {
this(context, channels, LP);
}
+ /**
+ * Constructor for a multi-channel low-pass biquad filter UGen with the
+ * specified number of channels.
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public BiquadFilter(int channels) {
+ this(getDefaultContext(), channels);
+ }
+
/**
* Constructor for a multi-channel biquad filter UGen of specified type with
* the specified number of channels. See {@link #setType(int) setType} for a
@@ -205,6 +215,21 @@ public BiquadFilter(AudioContext context, int channels, Type itype) {
setFrequency(freq).setQ(q).setGain(gain);
}
+ /**
+ * Constructor for a multi-channel biquad filter UGen of specified type with
+ * the specified number of channels. See {@link #setType(int) setType} for a
+ * list of supported filter types.
+ *
+ * @param channels
+ * The number of channels.
+ * @param itype
+ * The initial filter type, e.g. {@link #LP}, {@link #HP},
+ * {@link #BP_SKIRT}, etc.
+ */
+ public BiquadFilter(int channels, Type itype) {
+ this(getDefaultContext(), channels, itype);
+ }
+
/**
* Constructor for a multi-channel biquad filter UGen with the specified
* number of channels and parameters specified by a DataBead.
@@ -222,6 +247,20 @@ public BiquadFilter(AudioContext context, int channels, DataBead params) {
setParams(params);
}
+ /**
+ * Constructor for a multi-channel biquad filter UGen with the specified
+ * number of channels and parameters specified by a DataBead.
+ *
+ * @param channels
+ * The number of channels.
+ * @param params
+ * A DataBead specifying parameter values; see
+ * {@link #setParams(DataBead)}.
+ */
+ public BiquadFilter(int channels, DataBead params) {
+ this(getDefaultContext(), channels, params);
+ }
+
/**
* Constructor for a multi-channel biquad filter UGen of specified type,
* with the specified number of channels, and with parameters specified by a
@@ -244,6 +283,26 @@ public BiquadFilter(AudioContext context, int channels, Type itype,
setParams(params);
}
+ /**
+ * Constructor for a multi-channel biquad filter UGen of specified type,
+ * with the specified number of channels, and with parameters specified by a
+ * DataBead.
+ *
+ * @param channels
+ * The number of channels.
+ * @param itype
+ * The initial filter type, e.g. {@link #LP}, {@link #HP},
+ * {@link #BP_SKIRT}, etc.
+ * @param params
+ * A DataBead specifying parameter values; see
+ * {@link #setParams(DataBead)}.
+ */
+ public BiquadFilter(int channels, Type itype,
+ DataBead params) {
+
+ this(getDefaultContext(), channels, itype, params);
+ }
+
/**
* Constructor for frequency and Q as floats. See {@link #setType(int)
* setType} for a list of supported filter types.
@@ -264,6 +323,24 @@ public BiquadFilter(AudioContext context, Type itype, float ifreq,
setFrequency(ifreq).setQ(iqval);
}
+ /**
+ * Constructor for frequency and Q as floats. See {@link #setType(int)
+ * setType} for a list of supported filter types.
+ *
+ * @param itype
+ * The initial filter type, e.g. {@link #LP}, {@link #HP},
+ * {@link #BP_SKIRT}, etc.
+ * @param ifreq
+ * The initial frequency.
+ * @param iqval
+ * The initial Q-value.
+ */
+ public BiquadFilter(Type itype, float ifreq,
+ float iqval) {
+
+ this(getDefaultContext(), itype, ifreq, iqval);
+ }
+
/**
* Constructor for frequency as a UGen and Q as a float. See
* {@link #setType(int) setType} for a list of supported filter types.
@@ -283,6 +360,22 @@ public BiquadFilter(AudioContext context, Type itype, UGen ifreq, float iqval) {
setFrequency(ifreq).setQ(iqval);
}
+ /**
+ * Constructor for frequency as a UGen and Q as a float. See
+ * {@link #setType(int) setType} for a list of supported filter types.
+ *
+ * @param itype
+ * The initial filter type, {@link #LP}, {@link #HP},
+ * {@link #BP_SKIRT}, etc.
+ * @param ifreq
+ * The frequency UGen.
+ * @param iqval
+ * The initial Q-value.
+ */
+ public BiquadFilter(Type itype, UGen ifreq, float iqval) {
+ this(getDefaultContext(), itype, ifreq, iqval);
+ }
+
/**
* Constructor for frequency as a float and Q as a UGen. See
* {@link #setType(int) setType} for a list of supported filter types.
@@ -302,6 +395,22 @@ public BiquadFilter(AudioContext context, Type itype, float ifreq, UGen iqval) {
setFrequency(ifreq).setQ(iqval);
}
+ /**
+ * Constructor for frequency as a float and Q as a UGen. See
+ * {@link #setType(int) setType} for a list of supported filter types.
+ *
+ * @param itype
+ * The initial filter type, e.g. {@link #LP}, {@link #HP},
+ * {@link #BP_SKIRT}, etc.
+ * @param ifreq
+ * The initial frequency.
+ * @param iqval
+ * The Q-value UGen.
+ */
+ public BiquadFilter(Type itype, float ifreq, UGen iqval) {
+ this(getDefaultContext(), itype, ifreq, iqval);
+ }
+
/**
* Constructor for frequency and Q as UGens. See {@link #setType(int)
* setType} for a list of supported filter types.
@@ -321,6 +430,22 @@ public BiquadFilter(AudioContext context, Type itype, UGen ifreq, UGen iqval) {
setFrequency(ifreq).setQ(iqval);
}
+ /**
+ * Constructor for frequency and Q as UGens. See {@link #setType(int)
+ * setType} for a list of supported filter types.
+ *
+ * @param itype
+ * The initial filter type, e.g. {@link #LP}, {@link #HP},
+ * {@link #BP_SKIRT}, etc.
+ * @param ifreq
+ * The frequency UGen.
+ * @param iqval
+ * The Q-value UGen.
+ */
+ public BiquadFilter(Type itype, UGen ifreq, UGen iqval) {
+ this(getDefaultContext(), itype, ifreq, iqval);
+ }
+
private void checkStaticStatus() {
if (isFreqStatic && isQStatic && isGainStatic) {
areAllStatic = true;
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Change.java b/src/beads_main/java/net/beadsproject/beads/ugens/Change.java
similarity index 83%
rename from src/beads_main/net/beadsproject/beads/ugens/Change.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Change.java
index ece26bb..45f689a 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Change.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Change.java
@@ -11,8 +11,7 @@
/**
* Outputs 1 if the input signal is increasing; -1 if it is decreasing; 0 if it
* is the same. Use {@link Delta} to find how much a signal is changing.
- *
- * @beads.category lowlevel
+ *
* @author Benito Crawford
* @version 0.9.5
*/
@@ -31,6 +30,14 @@ public Change(AudioContext context) {
super(context, 1, 1);
}
+ /**
+ * Bare constructor.
+ */
+ public Change() {
+
+ this(getDefaultContext());
+ }
+
/**
* Constructor for a given input UGen.
*
@@ -44,6 +51,16 @@ public Change(AudioContext context, UGen ugen) {
addInput(0, ugen, 0);
}
+ /**
+ * Constructor for a given input UGen.
+ *
+ * @param ugen
+ * The input UGen.
+ */
+ public Change(UGen ugen) {
+ this(getDefaultContext(), ugen);
+ }
+
@Override
public void calculateBuffer() {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Clicker.java b/src/beads_main/java/net/beadsproject/beads/ugens/Clicker.java
similarity index 83%
rename from src/beads_main/net/beadsproject/beads/ugens/Clicker.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Clicker.java
index 5ce8da1..554e864 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Clicker.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Clicker.java
@@ -9,7 +9,6 @@
/**
* A very simple {@link UGen} that generates one click and then kills itself.
*
- * @beads.category synth
* @author ollie
*/
public class Clicker extends UGen {
@@ -30,6 +29,15 @@ public Clicker(AudioContext context, float strength) {
done = false;
}
+ /**
+ * Instantiates a new Clicker.
+ *
+ * @param strength the volume of the click (max = 1).
+ */
+ public Clicker(float strength) {
+ this(getDefaultContext(), strength);
+ }
+
/* (non-Javadoc)
* @see com.olliebown.beads.core.UGen#calculateBuffer()
*/
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Clip.java b/src/beads_main/java/net/beadsproject/beads/ugens/Clip.java
similarity index 91%
rename from src/beads_main/net/beadsproject/beads/ugens/Clip.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Clip.java
index 6b366e1..6deb9cc 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Clip.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Clip.java
@@ -12,8 +12,7 @@
* Clip constrains a signal within a range. The range may be defined either by
* static values, or by UGens. Use {@link RangeLimiter} to strictly (and more
* efficiently) constrain a signal in the range [-1,1].
- *
- * @beads.category lowlevel
+ *
* @author Benito Crawford
* @version 0.9.5
*
@@ -47,6 +46,17 @@ public Clip(AudioContext context, int channels) {
setRange(-1, 1);
}
+ /**
+ * Constructor for a new Clip with the specified number of channels.
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public Clip(int channels) {
+
+ this(getDefaultContext(), channels);
+ }
+
@Override
public void calculateBuffer() {
if (isMinStatic && isMaxStatic) {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Clock.java b/src/beads_main/java/net/beadsproject/beads/ugens/Clock.java
similarity index 88%
rename from src/beads_main/net/beadsproject/beads/ugens/Clock.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Clock.java
index 0adde5f..4f51caa 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Clock.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Clock.java
@@ -14,7 +14,6 @@
/**
* A sample rate Clock. A Clock generates timing data at two levels: ticks and beats. It notifies an {@link BeadArray} of listeners at each tick. These listeners can query the Clock to find out the current tick count, if it is on a beat, and the current beat count. The rate of ticking of the Clock is controlled by an interval envelope.
*
- * @beads.category control
* @author ollie
*/
public class Clock extends UGen implements IntegerBead {
@@ -40,7 +39,7 @@ public class Clock extends UGen implements IntegerBead {
/** The strength (gain) of the audible click. */
private float clickStrength;
- /** Used so that other objects can discover what */
+ /** Used so that other objects can discover what the tick times were from the last buffer update. */
private double[] subticks;
/**
@@ -51,7 +50,15 @@ public class Clock extends UGen implements IntegerBead {
public Clock(AudioContext context) {
this(context, 1000.0f);
}
-
+
+ /**
+ * Instantiates a new Clock with a static interval of 1000ms.
+ */
+ public Clock() {
+
+ this(getDefaultContext());
+ }
+
/**
* Instantiates a new Clock with the given static interval in milliseconds.
*
@@ -62,7 +69,21 @@ public Clock(AudioContext context, float interval) {
this(context, new Static(context, interval));
ticksPerBeat = 16;
}
-
+
+ /**
+ * Instantiates a new Clock with the given static interval in milliseconds.
+ * @param interval the interval in milliseconds.
+ */
+ public Clock(float interval) {
+
+ this(getDefaultContext(), interval);
+
+ if (getDefaultContext() != null)
+ {
+ getDefaultContext().out.addDependent(this);
+ }
+ }
+
/**
* Instantiates a new Clock with the given interval envelope.
*
@@ -78,7 +99,21 @@ public Clock(AudioContext context, UGen env) {
clickStrength = 0.1f;
subticks = new double[context.getBufferSize()];
}
-
+
+ /**
+ * Instantiates a new Clock with the given interval envelope.
+ *
+ * @param env the interval envelope.
+ */
+ public Clock(UGen env) {
+ this(getDefaultContext(), env);
+
+ if (getDefaultContext() != null)
+ {
+ getDefaultContext().out.addDependent(this);
+ }
+ }
+
/**
* Checks if the Clock is set to make an audible click.
*
@@ -87,7 +122,7 @@ public Clock(AudioContext context, UGen env) {
public boolean isClicking() {
return click;
}
-
+
/**
* Starts/stops the audible click.
*
@@ -129,8 +164,7 @@ public ArrayList getMessageListeners() {
*/
public void reset() {
point = 0.0f;
- count = -1; //OLLIE - hack to get the first tick to be a beat
-// tick(); //OLLIE - this must be pointless, if we haven't connect the clock to anything
+ count = -1;
}
/**
@@ -156,8 +190,8 @@ public void setIntervalEnvelope(UGen intervalEnvelope) {
* Gets the interval envelope.
*
* @return the interval envelope.
- *
* @deprecated
+ *
*/
public UGen getIntervalEnvelope() {
return intervalEnvelope;
diff --git a/src/beads_main/net/beadsproject/beads/ugens/CombFilter.java b/src/beads_main/java/net/beadsproject/beads/ugens/CombFilter.java
similarity index 93%
rename from src/beads_main/net/beadsproject/beads/ugens/CombFilter.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/CombFilter.java
index 61952e3..a19b210 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/CombFilter.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/CombFilter.java
@@ -15,8 +15,7 @@
* components.
*
* y(n) = a * x(n) + g * x(n - d) - h * y(n - d)
- *
- * @beads.category filter
+ *
* @author Benito Crawford
* @version 0.9.1
*/
@@ -47,6 +46,16 @@ public CombFilter(AudioContext con, int maxdel) {
setA(a).setG(g).setH(h).setDelay(1);
}
+ /**
+ * Constructor.
+ *
+ * @param maxdel
+ * The maximum delay in samples.
+ */
+ public CombFilter(int maxdel) {
+ this(getDefaultContext(), maxdel);
+ }
+
private void checkStaticStatus() {
if (isAStatic && isGStatic && isGStatic && isDelayStatic) {
areAllStatic = true;
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Compressor.java b/src/beads_main/java/net/beadsproject/beads/ugens/Compressor.java
similarity index 82%
rename from src/beads_main/net/beadsproject/beads/ugens/Compressor.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Compressor.java
index d6c033c..b19dd13 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Compressor.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Compressor.java
@@ -15,7 +15,7 @@
* The amount of compression can also be controlled by an alternate side-chain.
*
* The following are the default parameter values:
- *
+ *
*
* - {@link #setThreshold(float) threshold} - .5
* - {@link #setAttack(float) attack} - 1
@@ -24,8 +24,7 @@
* - {@link #setRatio(float) ratio} - 2
* - {@link #setSideChain(UGen) side-chain} - the input audio
*
- *
- * @beads.category dynamics
+ *
* @author Benito Crawford
* @version 0.9.5
*/
@@ -57,6 +56,15 @@ public Compressor(AudioContext context) {
this(context, 1);
}
+ /**
+ * Constructor for a 1-channel compressor with no look-ahead time and other
+ * parameters set to their default values.
+ *
+ */
+ public Compressor() {
+ this(getDefaultContext());
+ }
+
/**
* Constructor for a multi-channel compressor with no look-ahead time and
* other parameters set to their default values.
@@ -70,6 +78,17 @@ public Compressor(AudioContext context, int channels) {
this(context, channels, 0, null);
}
+ /**
+ * Constructor for a multi-channel compressor with no look-ahead time and
+ * other parameters set to their default values.
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public Compressor(int channels){
+ this(getDefaultContext(), channels);
+ }
+
/**
* Constructor for a multi-channel compressor with the specified side-chain,
* no look-ahead time, and other parameters set to their default values.
@@ -85,6 +104,19 @@ public Compressor(AudioContext context, int channels, UGen sideChain) {
this(context, channels, 0, sideChain);
}
+ /**
+ * Constructor for a multi-channel compressor with the specified side-chain,
+ * no look-ahead time, and other parameters set to their default values.
+ *
+ * @param channels
+ * The number of channels.
+ * @param sideChain
+ * The UGen to use as the side-chain.
+ */
+ public Compressor( int channels, UGen sideChain){
+ this(getDefaultContext(), channels, sideChain);
+ }
+
/**
* Constructor for a multi-channel compressor with the specified look-ahead
* time and other parameters set to their default values.
@@ -100,6 +132,18 @@ public Compressor(AudioContext context, int channels, float lookAheadDelay) {
this(context, channels, lookAheadDelay, null);
}
+ /**
+ * Constructor for a multi-channel compressor with the specified look-ahead
+ * time and other parameters set to their default values.
+ * @param channels
+ * The number of channels.
+ * @param lookAheadDelay
+ * The look-ahead time in milliseconds.
+ */
+ public Compressor(int channels, float lookAheadDelay) {
+ this(getDefaultContext(), channels, lookAheadDelay);
+ }
+
/**
* Constructor for a multi-channel compressor with the specified look-ahead
* time and side-chain, and other parameters set to their default values.
@@ -141,6 +185,22 @@ public void calculateBuffer() {
.setThreshold(.5f).setKnee(.5f);
}
+ /**
+ * Constructor for a multi-channel compressor with the specified look-ahead
+ * time and side-chain, and other parameters set to their default values.
+ * @param channels
+ * The number of channels.
+ * @param lookAheadDelay
+ * The look-ahead time in milliseconds.
+ * @param sideChain
+ * The UGen to use as the side-chain.
+ */
+ public Compressor(int channels, float lookAheadDelay,
+ UGen sideChain) {
+
+ this(getDefaultContext(), channels, lookAheadDelay, sideChain);
+ }
+
@Override
public void calculateBuffer() {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/CrossFade.java b/src/beads_main/java/net/beadsproject/beads/ugens/CrossFade.java
similarity index 87%
rename from src/beads_main/net/beadsproject/beads/ugens/CrossFade.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/CrossFade.java
index 095ca0f..597d808 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/CrossFade.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/CrossFade.java
@@ -9,8 +9,7 @@
* Note that UGen has it's own simpler crossFade method.
*
* TODO: non-linear fades.
- *
- * @beads.category utilities
+ *
* @author ollie
*
*/
@@ -34,7 +33,15 @@ public CrossFade(AudioContext context, int channels) {
incoming = new Static(context, 0f);
pauseAfterComplete = false;
}
-
+
+ /**
+ * Create a new CrossFade with given number of channels. The CrossFade has no inputs
+ * since the input UGens are assigned in the method {@link #fadeTo(UGen, float)}.
+ * @param channels the number of output channels.
+ */
+ public CrossFade(int channels) {
+ this(getDefaultContext(), channels);
+ }
/**
* Create a new CrossFade with given start UGen.
@@ -46,7 +53,15 @@ public CrossFade(AudioContext context, UGen start) {
incoming = start;
pauseAfterComplete = false;
}
-
+
+ /**
+ * Create a new CrossFade with given start UGen.
+ * @param start the UGen to start on.
+ */
+ public CrossFade(UGen start) {
+ this(getDefaultContext(), start);
+ }
+
/**
* Cross fades from the current UGen to the specified UGen the specified number of milliseconds.
* @param target the new target UGen.
diff --git a/src/beads_main/net/beadsproject/beads/ugens/CrossoverFilter.java b/src/beads_main/java/net/beadsproject/beads/ugens/CrossoverFilter.java
similarity index 89%
rename from src/beads_main/net/beadsproject/beads/ugens/CrossoverFilter.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/CrossoverFilter.java
index b6a2e31..5086ff9 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/CrossoverFilter.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/CrossoverFilter.java
@@ -13,20 +13,17 @@
* A multi-channel 4th-order Linkwitz-Riley crossover filter. For each input
* channel, the filter outputs both a low-pass and a high-pass channel. If the
* filter has two inputs, for example, then it will output four channels:
- *
*
* - 0: Low-pass of input 0
* - 1: High-pass of input 0
* - 2: Low-pass of input 1
* - 3: High-pass of input 1
*
- *
* A key feature of Linkwitz-Riley filters is that the low- and high-pass bands
* added together produce a flat frequency response, making them particularly
* useful as crossover filters. A 4th-order version is equivalent to cascading
* two identical 2nd-order Butterworth filters.
- *
- * @beads.category filter
+ *
* @author Benito Crawford
* @version 0.9.5
*
@@ -70,6 +67,15 @@ public CrossoverFilter(AudioContext context) {
this(context, 1, 800);
}
+ /**
+ * Constructor for a one-channel crossover filter, initialized with a cutoff
+ * frequency of 800Hz.
+ *
+ */
+ public CrossoverFilter() {
+ this(getDefaultContext());
+ }
+
/**
* Constructor for a crossover filter with the specified number of channels,
* initialized with a cutoff frequency of 800Hz.
@@ -83,6 +89,17 @@ public CrossoverFilter(AudioContext context, int channels) {
this(context, channels, 800);
}
+ /**
+ * Constructor for a crossover filter with the specified number of channels,
+ * initialized with a cutoff frequency of 800Hz.
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public CrossoverFilter(int channels) {
+ this(getDefaultContext(), channels);
+ }
+
/**
* Constructor for a crossover filter with the specified number of channels,
* set at the specified frequency.
@@ -109,6 +126,19 @@ public CrossoverFilter(AudioContext context, int channels, float freq) {
setFrequency(freq);
}
+ /**
+ * Constructor for a crossover filter with the specified number of channels,
+ * set at the specified frequency.
+ *
+ * @param channels
+ * The number of channels.
+ * @param freq
+ * The initial cutoff frequency.
+ */
+ public CrossoverFilter(int channels, float freq) {
+ this(getDefaultContext(), channels, freq);
+ }
+
@Override
public void calculateBuffer() {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/DelayData.java b/src/beads_main/java/net/beadsproject/beads/ugens/DelayData.java
similarity index 78%
rename from src/beads_main/net/beadsproject/beads/ugens/DelayData.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/DelayData.java
index 95c97ff..25f62e0 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/DelayData.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/DelayData.java
@@ -41,6 +41,22 @@ public DelayData(AudioContext context, double delay,
this.dataBead = db;
}
+ /**
+ * Instantiates a new DelayMessage with the specified millisecond delay,
+ * receiver, and DataBead message.
+ *
+ * @param delay
+ * The delay time in milliseconds.
+ * @param receiver
+ * The DataBead receiver.
+ * @param db
+ * The DataBead to send.
+ */
+ public DelayData(double delay,
+ DataBeadReceiver receiver, DataBead db) {
+ this(getDefaultContext(), delay, receiver, db);
+ }
+
@Override
public void trigger() {
if (receiver != null) {
@@ -82,7 +98,7 @@ public DataBead getData() {
/**
* Sets the message to send when the DelayData fires.
*
- * @param dataBead
+ * @param db
* The DataBead to be sent.
* @return This DelayData instance.
*/
diff --git a/src/beads_main/net/beadsproject/beads/ugens/DelayEvent.java b/src/beads_main/java/net/beadsproject/beads/ugens/DelayEvent.java
similarity index 77%
rename from src/beads_main/net/beadsproject/beads/ugens/DelayEvent.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/DelayEvent.java
index 306866a..6105051 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/DelayEvent.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/DelayEvent.java
@@ -36,13 +36,23 @@ public abstract class DelayEvent extends UGen {
* The audio context.
* @param delay
* The delay time in milliseconds.
- * @param receiver
- * The receiver.
*/
public DelayEvent(AudioContext context, double delay) {
this(context, delay, false);
}
+ /**
+ * Instantiates a new DelayEvent with the specified millisecond delay and
+ * receiver. By default, the object will be triggered at the beginning of
+ * the frame in which the delay time expires.
+ *
+ * @param delay
+ * The delay time in milliseconds.
+ */
+ public DelayEvent(double delay){
+ this(getDefaultContext(), delay);
+ }
+
/**
* Instantiates a new DelayEvent with the specified millisecond delay and
* receiver. triggerAfter indicates whether the object is
@@ -53,8 +63,6 @@ public DelayEvent(AudioContext context, double delay) {
* The audio context.
* @param delay
* The delay in milliseconds.
- * @param receiver
- * The receiver.
* @param triggerAfter
* Whether the object fires just before or just after the delay
* time expires.
@@ -68,6 +76,23 @@ public DelayEvent(AudioContext context, double delay, boolean triggerAfter) {
triggeredAfter(triggerAfter);
}
+ /**
+ * Instantiates a new DelayEvent with the specified millisecond delay and
+ * receiver. triggerAfter indicates whether the object is
+ * triggered at the beginning of the frame in which the delay time elapses (
+ * false), or after (true).
+ *
+ * @param delay
+ * The delay in milliseconds.
+ * @param triggerAfter
+ * Whether the object fires just before or just after the delay
+ * time expires.
+ */
+ public DelayEvent(double delay, boolean triggerAfter) {
+ this(getDefaultContext(), delay, triggerAfter);
+
+ }
+
/**
* Reset timer to zero.
*/
diff --git a/src/beads_main/net/beadsproject/beads/ugens/DelayTrigger.java b/src/beads_main/java/net/beadsproject/beads/ugens/DelayTrigger.java
similarity index 76%
rename from src/beads_main/net/beadsproject/beads/ugens/DelayTrigger.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/DelayTrigger.java
index 113e2d7..dbb0964 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/DelayTrigger.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/DelayTrigger.java
@@ -5,8 +5,7 @@
/**
* A DelayTrigger waits for a specified duration and then notifies a receiver.
- *
- * @beads.category utilities
+ *
* @author ollie
* @author Benito Crawford
* @version 0.9.5
@@ -37,6 +36,19 @@ public DelayTrigger(AudioContext context, double delay, Bead receiver) {
this.message = this;
}
+ /**
+ * Instantiates a new DelayTrigger with the specified millisecond delay and
+ * receiver. By default, a DelayTrigger object will send itself as the
+ * message.
+ * @param delay
+ * the delay in milliseconds.
+ * @param receiver
+ * the receiver.
+ */
+ public DelayTrigger(double delay, Bead receiver) {
+ this(getDefaultContext(), delay, receiver);
+ }
+
/**
* Instantiates a new DelayTrigger with the specified millisecond delay,
* receiver, and message.
@@ -55,6 +67,21 @@ public DelayTrigger(AudioContext context, double delay, Bead receiver,
this.message = message;
}
+ /**
+ * Instantiates a new DelayTrigger with the specified millisecond delay,
+ * receiver, and message.
+ *
+ * @param delay
+ * The delay in milliseconds.
+ * @param receiver
+ * The receiver.
+ */
+ public DelayTrigger(double delay, Bead receiver,
+ Bead message) {
+
+ this(getDefaultContext(), delay, receiver, message);
+ }
+
@Override
public void trigger() {
if (receiver != null) {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Delta.java b/src/beads_main/java/net/beadsproject/beads/ugens/Delta.java
similarity index 76%
rename from src/beads_main/net/beadsproject/beads/ugens/Delta.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Delta.java
index 9b7811c..ee1dbad 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Delta.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Delta.java
@@ -8,8 +8,7 @@
/**
* Outputs the change in the input signal from the previous sample to the current one.
- *
- * @beads.category lowlevel
+ *
* @author Benito Crawford
* @version 0.9
*/
@@ -27,6 +26,14 @@ public Delta(AudioContext context) {
super(context, 1, 1);
}
+ /**
+ * Bare constructor.
+ *
+ */
+ public Delta() {
+ this(getDefaultContext());
+ }
+
/**
* Constructor for a given input UGen.
*
@@ -40,6 +47,16 @@ public Delta(AudioContext context, UGen ugen) {
addInput(0, ugen, 0);
}
+ /**
+ * Constructor for a given input UGen.
+ *
+ * @param ugen
+ * The input UGen.
+ */
+ public Delta(UGen ugen) {
+ this(getDefaultContext(), ugen);
+ }
+
@Override
public void calculateBuffer() {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Drain.java b/src/beads_main/java/net/beadsproject/beads/ugens/Drain.java
similarity index 92%
rename from src/beads_main/net/beadsproject/beads/ugens/Drain.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Drain.java
index bb1ca32..6bf40e1 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Drain.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Drain.java
@@ -40,7 +40,15 @@ public Drain(AudioContext context, int outs) {
super(context, outs);
grains = new LinkedList();
}
-
+
+ /**
+ * Instantiates a new Drain.
+ *
+ * @param outs the number of output channels.
+ */
+ public Drain( int outs){
+ this(getDefaultContext(), outs);
+ }
/**
* Adds a new grain of audio data.
*
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Envelope.java b/src/beads_main/java/net/beadsproject/beads/ugens/Envelope.java
similarity index 96%
rename from src/beads_main/net/beadsproject/beads/ugens/Envelope.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Envelope.java
index 93cba85..afc7d43 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Envelope.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Envelope.java
@@ -25,7 +25,6 @@
* can be used. The curve is defined as the mapping of the range [0,1]
* from y=x to y=x^p with a given exponent p.
*
- * @beads.category control
* @author ollie
*/
public class Envelope extends UGen {
@@ -117,7 +116,15 @@ public Envelope(AudioContext context) {
myBufOut = new float[bufferSize];
bufOut[0] = myBufOut;
}
-
+
+ /**
+ * Instantiates a new Envelope with start value 0.
+ *
+ */
+ public Envelope() {
+ this(getDefaultContext());
+ }
+
/**
* Instantiates a new Envelope with the specified start value.
*
@@ -130,6 +137,16 @@ public Envelope(AudioContext context, float value) {
this(context);
setValue(value);
}
+
+ /**
+ * Instantiates a new Envelope with the specified start value.
+ *
+ * @param value
+ * the start value.
+ */
+ public Envelope(float value) {
+ this(getDefaultContext(), value);
+ }
/**
* Locks/unlocks the Envelope.
diff --git a/src/beads_main/java/net/beadsproject/beads/ugens/FastGranularSamplePlayer.java b/src/beads_main/java/net/beadsproject/beads/ugens/FastGranularSamplePlayer.java
new file mode 100644
index 0000000..95ad4b6
--- /dev/null
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/FastGranularSamplePlayer.java
@@ -0,0 +1,831 @@
+/*
+ * This file is part of Beads. See http://www.beadsproject.net for all information.
+ */
+package net.beadsproject.beads.ugens;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import net.beadsproject.beads.core.AudioContext;
+import net.beadsproject.beads.core.Bead;
+import net.beadsproject.beads.core.UGen;
+import net.beadsproject.beads.data.Buffer;
+import net.beadsproject.beads.data.Sample;
+import net.beadsproject.beads.data.SampleManager;
+import net.beadsproject.beads.data.buffers.CosineWindow;
+
+/**
+ * FastGranularSamplePlayer functions exactly the same as {@link GranularSamplePlayer} but trades off variable automation functionality to reduce
+ * computational costs and allow for more instances to be run simultaneously. As with GranularSamplePlayer, it inherits its main behaviour
+ * from {@link SamplePlayer} but replaces the direct {@link Sample} lookup with a granular process. {@link UGen}s can be used to control
+ * playback rate, pitch, loop points, grain size, grain interval, grain randomness and position (this last case assumes that the playback
+ * rate is zero).
+ *
+ * @see SamplePlayer Sample
+ */
+public class FastGranularSamplePlayer extends SamplePlayer {
+
+ /** The pitch envelope. */
+ private UGen pitchEnvelope;
+
+ /** The grain interval envelope. */
+ private float grainIntervalEnvelope;
+
+ /** The grain size envelope. */
+ private float grainSizeEnvelope;
+
+ /** The randomness envelope. */
+ private float randomnessEnvelope;
+
+ /** The time in milliseconds since the last grain was activated. */
+ private float timeSinceLastGrain;
+
+ /** The starting point of the loop as a float. */
+ private float loopStart;
+
+ /** The starting point of the loop as a float. */
+ private float loopEnd;
+
+ /** The length of one sample in milliseconds. */
+ private double msPerSample;
+
+ /** The pitch, bound to the pitch envelope. */
+ protected float pitch;
+
+ /** The list of current grains. */
+ private LinkedList grains;
+
+ /** A list of free grains. */
+ private LinkedList freeGrains;
+
+ /** The window used by grains. */
+ private Buffer window;
+
+ /** Flag to determine whether, looping occurs within individual grains. */
+ private boolean loopInsideGrains;
+
+ /**
+ * The nested class Grain. Stores information about the start time, current position, age, and grain size of the grain.
+ */
+ private static class Grain {
+
+ /** The position in millseconds. */
+ double position;
+
+ /** The age of the grain in milliseconds. */
+ double age;
+
+ /** The grain size of the grain. Fixed at instantiation. */
+ double grainSize;
+
+ /** The grain's position in the buffer */
+ int bufferPointer;
+ }
+
+ /**
+ * Instantiates a new GranularSamplePlayer.
+ *
+ * @param context the AudioContext.
+ * @param outs the number of outputs.
+ */
+ public FastGranularSamplePlayer(AudioContext context, int outs) {
+ super(context, outs);
+ grains = new LinkedList();
+ freeGrains = new LinkedList();
+ pitchEnvelope = new Static(context, 1f);
+ setGrainInterval(new Static(context, 70.0f));
+ setGrainSize(new Static(context, 100.0f));
+ setRandomness(new Static(context, 0.0f));
+ setWindow(new CosineWindow().getDefault());
+ msPerSample = context.samplesToMs(1f);
+ loopInsideGrains = false;
+ }
+
+ /**
+ * Instantiates a new GranularSamplePlayer.
+ *
+ * @param outs the number of outputs.
+ */
+ public FastGranularSamplePlayer(int outs) {
+ this(getDefaultContext(), outs);
+ }
+
+ /**
+ * Instantiates a new GranularSamplePlayer.
+ *
+ * @param context the AudioContext.
+ * @param buffer the Sample played by the GranularSamplePlayer.
+ */
+ public FastGranularSamplePlayer(AudioContext context, Sample buffer) {
+ this(context, buffer.getNumChannels());
+ setSample(buffer);
+ loopStart = 0.0f;
+ loopEnd = (float)buffer.getLength();
+ }
+
+ /**
+ * Instantiates a new GranularSamplePlayer.
+ *
+ * @param buffer the Sample played by the GranularSamplePlayer.
+ */
+ public FastGranularSamplePlayer(Sample buffer) {
+ this(getDefaultContext(), buffer);
+ }
+
+ /**
+ * Gets the rate envelope.
+ *
+ * @deprecated use {@link #getRateUGen()} instead.
+ *
+ * @return the rate envelope.
+ */
+ @Deprecated
+ public UGen getRateEnvelope() {
+ return new Static(rate);
+ }
+
+ /**
+ * Gets the rate value as a UGen.
+ *
+ * @return the rate UGen.
+ */
+ public UGen getRateUGen() {
+ return new Static(rate);
+ }
+
+ /**
+ * Sets the rate envelope.
+ *
+ * @deprecated use {@link #setRate(float)} instead.
+ *
+ * @param rateEnvelope
+ * the new rate envelope.
+ */
+ @Deprecated
+ public void setRateEnvelope(UGen rateEnvelope) {
+ rateEnvelope.update();
+ this.rate = rateEnvelope.getValue();
+ }
+
+ /**
+ * Sets the rate to the UGen's current value.
+ * For better performance, use {@link #setRate(float)}
+ *
+ * @param rateUGen
+ * the new rate UGen.
+ */
+ public void setRate(UGen rateUGen) {
+ rateUGen.update();
+ this.rate = rateUGen.getValue();
+ }
+
+ /**
+ * Sets the rate.
+ *
+ * @param rate
+ * the new rate.
+ */
+ public void setRate(float rate) {
+ this.rate = rate;
+ }
+
+ /**
+ * Gets the pitch envelope.
+ *
+ * @deprecated use {@link #getPitchUGen()}.
+ * @return the pitch envelope.
+ */
+ @Deprecated
+ public UGen getPitchEnvelope() {
+ return pitchEnvelope;
+ }
+
+
+ /**
+ * Gets the pitch value as a UGen.
+ *
+ * @return the pitch UGen.
+ */
+ public UGen getPitchUGen() {
+ return pitchEnvelope;
+ }
+
+ /**
+ * Sets the pitch envelope.
+ *
+ * @deprecated Use {@link #setPitch(UGen)} instead.
+ *
+ * @param pitchEnvelope
+ * the new pitch envelope.
+ */
+ @Deprecated
+ public void setPitchEnvelope(UGen pitchEnvelope) {
+ pitchEnvelope.update();
+ this.pitchEnvelope = pitchEnvelope;
+ }
+
+ /**
+ * Sets the pitch to the UGen's value.
+ *
+ * @param pitchUGen
+ * the new pitch Ugen.
+ */
+ public void setPitch(UGen pitchUGen) {
+ pitchUGen.update();
+ this.pitchEnvelope = pitchUGen;
+ }
+
+ /**
+ * Gets the loop end envelope.
+ *
+ * @deprecated Use {@link #getLoopEndUGen()} instead.
+ *
+ * @return the loop end envelope.
+ */
+ @Deprecated
+ public UGen getLoopEndEnvelope() {
+ return new Static(loopEnd);
+ }
+
+ /**
+ * Gets the loop end value as a UGen.
+ *
+ * @return the loop end UGen.
+ */
+ public UGen getLoopEndUGen() {
+ return new Static(loopEnd);
+ }
+
+ /**
+ * Sets the loop end envelope.
+ *
+ * @deprecated Use {@link #setLoopEnd(float)} instead.
+ *
+ * @param loopEndEnvelope
+ * the new loop end envelope.
+ */
+ @Deprecated
+ public void setLoopEndEnvelope(UGen loopEndEnvelope) {
+ loopEndEnvelope.update();
+ this.loopEnd = loopEndEnvelope.getValue();
+ }
+
+ /**
+ * Sets the loop end to the UGen's value.
+ * For better performance, use {@link #setLoopEnd(float)} instead.
+ *
+ * @param loopEndUGen
+ * the new loop end UGen.
+ */
+ public void setLoopEnd(UGen loopEndUGen) {
+ loopEndUGen.update();
+ this.loopEnd = loopEndUGen.getValue();
+ }
+
+ /**
+ * Sets the loop end.
+ *
+ * @param loopEnd
+ * the new loop end.
+ */
+ public void setLoopEnd(float loopEnd) {
+ this.loopEnd = loopEnd;
+ }
+
+ /**
+ * Gets the loop start envelope.
+ *
+ * @deprecated Use {@link #getLoopStartUGen()} instead.
+ * @return the loop start envelope
+ */
+ @Deprecated
+ public UGen getLoopStartEnvelope() {
+ return new Static(loopStart);
+ }
+
+ /**
+ * Gets the loop start value as a UGen.
+ *
+ * @return the loop start UGen
+ */
+ public UGen getLoopStartUGen() {
+ return new Static(loopStart);
+ }
+
+ /**
+ * Sets the loop start envelope.
+ *
+ * @deprecated Use {@link #setLoopStart(float)} instead.
+ *
+ * @param loopStartEnvelope
+ * the new loop start envelope.
+ */
+ @Deprecated
+ public void setLoopStartEnvelope(UGen loopStartEnvelope) {
+ loopStartEnvelope.update();
+ this.loopStart = loopStartEnvelope.getValue();
+ }
+
+ /**
+ * Sets the loop start as the UGen's value.
+ * For better performance, use {@link #setLoopStart(float)} instead.
+ *
+ * @param loopStartUGen
+ * the new loop start UGen.
+ */
+ public void setLoopStart(UGen loopStartUGen) {
+ loopStartUGen.update();
+ this.loopStart = loopStartUGen.getValue();
+ }
+
+ /**
+ * Sets the loop start.
+ *
+ * @param loopStart
+ * the new loop start.
+ */
+ public void setLoopStart(float loopStart) {
+ this.loopStart = loopStart;
+ }
+
+ /**
+ * Sets both loop points to static values as fractions of the Sample length,
+ * overriding any UGens that were controlling the loop points.
+ *
+ * @param start
+ * the start value, as fraction of the Sample length.
+ * @param end
+ * the end value, as fraction of the Sample length.
+ */
+ public void setLoopPointsFraction(float start, float end) {
+ loopStart = start * (float) sample.getLength();
+ loopEnd = end * (float) sample.getLength();
+ }
+
+ /**
+ * Gets the grain interval envelope.
+ *
+ * @deprecated Use {@link #getGrainIntervalUGen()} instead.
+ *
+ * @return the grain interval envelope.
+ */
+ @Deprecated
+ public UGen getGrainIntervalEnvelope() {
+ return new Static(grainIntervalEnvelope);
+ }
+
+ /**
+ * Gets the grain interval as a UGen.
+ *
+ * @return the grain interval UGen.
+ */
+ public UGen getGrainInterval() {
+ return new Static(grainIntervalEnvelope);
+ }
+
+ /**
+ * Sets the grain interval envelope.
+ *
+ * @deprecated Use {@link #setGrainInterval(float)} instead.
+ *
+ * @param grainIntervalEnvelope
+ * the new grain interval envelope.
+ */
+ @Deprecated
+ public void setGrainIntervalEnvelope(UGen grainIntervalEnvelope) {
+ grainIntervalEnvelope.update();
+ this.grainIntervalEnvelope = grainIntervalEnvelope.getValue();
+ }
+
+ /**
+ * Sets the grain interval as the UGen's value.
+ * For better performance, use {@link #setGrainInterval(float)} instead.
+ *
+ * @param grainIntervalUGen
+ * the new grain interval UGen.
+ */
+ public void setGrainInterval(UGen grainIntervalUGen) {
+ grainIntervalUGen.update();
+ this.grainIntervalEnvelope = grainIntervalUGen.getValue();
+ }
+
+ /**
+ * Sets the grain interval.
+ *
+ * @param grainInterval
+ * the new grain interval.
+ */
+ public void setGrainInterval(float grainInterval) {
+ this.grainIntervalEnvelope = grainInterval;
+ }
+
+ /**
+ * Gets the grain size envelope.
+ *
+ * @deprecated Use {@link #getGrainSizeUGen()} instead.
+ *
+ * @return the grain size envelope.
+ */
+ @Deprecated
+ public UGen getGrainSizeEnvelope() {
+ return new Static(grainSizeEnvelope);
+ }
+
+
+ /**
+ * Gets the grain size as a UGen.
+ *
+ * @return the grain size UGen.
+ */
+ public UGen getGrainSize() {
+ return new Static(grainSizeEnvelope);
+ }
+
+ /**
+ * Sets the grain size envelope.
+ *
+ * @deprecated Use {@link #setGrainSize(float)} instead.
+ *
+ * @param grainSizeEnvelope the new grain size envelope.
+ */
+ @Deprecated
+ public void setGrainSizeEnvelope(UGen grainSizeEnvelope) {
+ grainSizeEnvelope.update();
+ this.grainSizeEnvelope = grainSizeEnvelope.getValue();
+ }
+
+ /**
+ * Sets the grain size as the UGen's value.
+ * For better performance, use {@link #setGrainSize(float)} instead.
+ *
+ * @param grainSizeUGen the new grain size UGen.
+ */
+ public void setGrainSize(UGen grainSizeUGen) {
+ grainSizeUGen.update();
+ this.grainSizeEnvelope = grainSizeUGen.getValue();
+ }
+
+ /**
+ * Sets the grain size.
+ *
+ * @param grainSize the new grain size.
+ */
+ public void setGrainSize(float grainSize) {
+ this.grainSizeEnvelope = grainSize;
+ }
+
+ public Buffer getWindow() {
+ return window;
+ }
+
+
+ public void setWindow(Buffer window) {
+ this.window = window;
+ }
+
+ /**
+ * Gets the randomness envelope.
+ *
+ * @deprecated Use {@link #getRandomnessUGen()} instead.
+ *
+ * @return the randomness envelope.
+ */
+ @Deprecated
+ public UGen getRandomnessEnvelope() {
+ return new Static(randomnessEnvelope);
+ }
+
+ /**
+ * Gets the randomness as a UGen.
+ *
+ * @return the randomness UGen.
+ */
+ public UGen getRandomness() {
+ return new Static(randomnessEnvelope);
+ }
+
+ /**
+ * Sets the randomness envelope.
+ *
+ * @deprecated Use {@link #setRandomness(float)} instead.
+ *
+ * @param randomnessEnvelope the new randomness envelope.
+ */
+ @Deprecated
+ public void setRandomnessEnvelope(UGen randomnessEnvelope) {
+ randomnessEnvelope.update();
+ this.randomnessEnvelope = randomnessEnvelope.getValue();
+ }
+
+ /**
+ * Sets the randomness as the UGen's value.
+ * For better performance, use {@link #setRandomness(float)} instead.
+ *
+ * @param randomnessUGen the new randomness UGen.
+ */
+ public void setRandomness(UGen randomnessUGen) {
+ randomnessUGen.update();
+ this.randomnessEnvelope = randomnessUGen.getValue();
+ }
+
+ /**
+ * Sets the randomness.
+ *
+ * @param randomness the new randomness value.
+ */
+ public void setRandomness(float randomness) {
+ this.randomnessEnvelope = randomness;
+ }
+
+ /**
+ * @deprecated Use {@link #setSample(Sample)} instead.
+ */
+ @Deprecated
+ public synchronized void setBuffer(Sample buffer) {
+ super.setSample(buffer);
+ grains.clear();
+ timeSinceLastGrain = 0f;
+ }
+
+ /* (non-Javadoc)
+ * @see net.beadsproject.beads.ugens.SamplePlayer#setBuffer(net.beadsproject.beads.data.Sample)
+ */
+ public synchronized void setSample(Sample buffer) {
+ super.setSample(buffer);
+ grains.clear();
+ timeSinceLastGrain = 0f;
+ }
+
+ /* (non-Javadoc)
+ * @see com.olliebown.beads.core.UGen#start()
+ */
+ @Override
+ public void start() {
+ super.start();
+ timeSinceLastGrain = 0;
+ }
+
+ /**
+ * Sets the given Grain to start immediately.
+ *
+ * @param g
+ * the grain
+ */
+ private void resetGrain(Grain g, int bufferPointer) {
+ g.position = position + grainSizeEnvelope * randomnessEnvelope * (Math.random() * 2.0 - 1.0);
+ g.age = 0f;
+ g.grainSize = grainSizeEnvelope;
+ g.bufferPointer = bufferPointer;
+ }
+
+ @Override
+ public void reset() {
+ super.reset();
+ firstGrain = true;
+ }
+
+ /** Flag to indicate special case for the first grain. */
+ private boolean firstGrain = true;
+
+ /** Special case method for playing first grain. */
+ private void firstGrain() {
+ if(firstGrain) {
+ Grain g = new Grain();
+ g.position = position;
+ g.age = grainSizeEnvelope / 4f;
+ g.grainSize = grainSizeEnvelope;
+ grains.add(g);
+ firstGrain = false;
+ timeSinceLastGrain = grainIntervalEnvelope / 2f;
+ g.bufferPointer = 0;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.olliebown.beads.ugens.SamplePlayer#calculateBuffer()
+ */
+ @Override
+ public synchronized void calculateBuffer() {
+ //special condition for first grain
+ //update the various envelopes
+ if(sample != null) {
+ if(positionEnvelope != null) {
+ positionEnvelope.update();
+ }
+ pitchEnvelope.update();
+ firstGrain();
+
+ //now loop through the buffer and calculate the required grains
+ for (int i = 0; i < bufferSize; i++) {
+ //determine if we need a new grain
+ if (timeSinceLastGrain > grainIntervalEnvelope) {
+ Grain g = null;
+ if(freeGrains.size() > 0) {
+ g = freeGrains.pollFirst();
+ } else {
+ g = new Grain();
+ }
+ resetGrain(g, i);
+ grains.add(g);
+ timeSinceLastGrain = 0f;
+ }
+ //for mono channel, start by resetting current output frame
+ bufOut[0][i] = 0.0f;
+
+ //increment time and stuff
+ calculateNextPosition(i);
+
+ //increment timeSinceLastGrain
+ timeSinceLastGrain += msPerSample;
+ }
+
+ //gather the output from each grain
+ Iterator currentGrain = grains.iterator();
+ while (currentGrain.hasNext()) {
+ //calculate value of grain window
+ Grain g = currentGrain.next();
+ pitch = Math.abs(pitchEnvelope.getValue(0, g.bufferPointer));
+
+ while (g.age <= g.grainSize) {
+ float windowScale = window.getValueFraction((float)(g.age / g.grainSize));
+ //get position in sample for this grain
+ //get the frame for this grain
+ switch (interpolationType) {
+ case ADAPTIVE:
+ if(pitch > ADAPTIVE_INTERP_HIGH_THRESH) {
+ sample.getFrameNoInterp(g.position, frame);
+ } else if(pitch > ADAPTIVE_INTERP_LOW_THRESH) {
+ sample.getFrameLinear(g.position, frame);
+ } else {
+ sample.getFrameCubic(g.position, frame);
+ }
+ break;
+ case LINEAR:
+ sample.getFrameLinear(g.position, frame);
+ break;
+ case CUBIC:
+ sample.getFrameCubic(g.position, frame);
+ break;
+ case NONE:
+ sample.getFrameNoInterp(g.position, frame);
+ break;
+ }
+
+ //add it to the current output frame
+ bufOut[0][g.bufferPointer++] += windowScale * frame[0 % sample.getNumChannels()];
+
+ //if grain's buffer position exceeds bufferSize,
+ //exit loop at start at index 0 of next buffer.
+ if (g.bufferPointer >= bufferSize) {
+ g.bufferPointer = 0;
+ break;
+ }
+
+ //increment time and stuff
+ pitch = Math.abs(pitchEnvelope.getValue(0, g.bufferPointer));
+ calculateNextGrainPosition(g);
+ }
+ //see if this grain is dead
+ if (g.age > g.grainSize) {
+ freeGrains.add(g);
+ currentGrain.remove();
+ }
+ }
+ }
+ }
+
+ /**
+ * Calculate next position for the given Grain.
+ *
+ * @param g the Grain.
+ */
+ private void calculateNextGrainPosition(Grain g) {
+ int direction = rate >= 0 ? 1 : -1; //this is a bit odd in the case when controlling grain from positionEnvelope
+ g.age += msPerSample;
+ if(loopInsideGrains) {
+ switch(loopType) {
+ case NO_LOOP_FORWARDS:
+ g.position += direction * positionIncrement * pitch;
+ break;
+ case NO_LOOP_BACKWARDS:
+ g.position -= direction * positionIncrement * pitch;
+ break;
+ case LOOP_FORWARDS:
+ g.position += direction * positionIncrement * pitch;
+ if(rate > 0 && g.position > Math.max(loopStart, loopEnd)) {
+ g.position = Math.min(loopStart, loopEnd);
+ } else if(rate < 0 && g.position < Math.min(loopStart, loopEnd)) {
+ g.position = Math.max(loopStart, loopEnd);
+ }
+ break;
+ case LOOP_BACKWARDS:
+ g.position -= direction * positionIncrement * pitch;
+ if(rate > 0 && g.position < Math.min(loopStart, loopEnd)) {
+ g.position = Math.max(loopStart, loopEnd);
+ } else if(rate < 0 && g.position > Math.max(loopStart, loopEnd)) {
+ g.position = Math.min(loopStart, loopEnd);
+ }
+ break;
+ case LOOP_ALTERNATING:
+ g.position += direction * (forwards ? positionIncrement * pitch : -positionIncrement * pitch);
+ if(forwards ^ (rate < 0)) {
+ if(g.position > Math.max(loopStart, loopEnd)) {
+ g.position = 2 * Math.max(loopStart, loopEnd) - g.position;
+ }
+ } else if(g.position < Math.min(loopStart, loopEnd)) {
+ g.position = 2 * Math.min(loopStart, loopEnd) - g.position;
+ }
+ break;
+ }
+ } else {
+ g.position += direction * positionIncrement * pitch;
+ }
+ }
+
+ /**
+ * Used at each sample in the perform routine to determine the next playback
+ * position.
+ *
+ * @param i
+ * the index within the buffer loop.
+ */
+ @Override
+ protected void calculateNextPosition(int i) {
+ if (positionEnvelope != null) {
+ position = positionEnvelope.getValueDouble(0, i);
+ } else {
+ switch (loopType) {
+ case NO_LOOP_FORWARDS:
+ position += positionIncrement * rate;
+ if (position > sample.getLength() || position < 0)
+ atEnd();
+ break;
+ case NO_LOOP_BACKWARDS:
+ position -= positionIncrement * rate;
+ if (position > sample.getLength() || position < 0)
+ atEnd();
+ break;
+ case LOOP_FORWARDS:
+ position += positionIncrement * rate;
+ if (rate > 0 && position > Math.max(loopStart, loopEnd)) {
+ position = Math.min(loopStart, loopEnd);
+ } else if (rate < 0 && position < Math.min(loopStart, loopEnd)) {
+ position = Math.max(loopStart, loopEnd);
+ }
+ break;
+ case LOOP_BACKWARDS:
+ position -= positionIncrement * rate;
+ if (rate > 0 && position < Math.min(loopStart, loopEnd)) {
+ position = Math.max(loopStart, loopEnd);
+ } else if (rate < 0 && position > Math.max(loopStart, loopEnd)) {
+ position = Math.min(loopStart, loopEnd);
+ }
+ break;
+ case LOOP_ALTERNATING:
+ position += forwards ? positionIncrement * rate
+ : -positionIncrement * rate;
+ if (forwards ^ (rate < 0)) {
+ if (position > Math.max(loopStart, loopEnd)) {
+ forwards = (rate < 0);
+ position = 2 * Math.max(loopStart, loopEnd) - position;
+ }
+ } else if (position < Math.min(loopStart, loopEnd)) {
+ forwards = (rate > 0);
+ position = 2 * Math.min(loopStart, loopEnd) - position;
+ }
+ break;
+ }
+ }
+ }
+ /**
+ * Calculates the average number of Grains given the current grain size and grain interval.
+ * @return the average number of Grains.
+ */
+ public float getAverageNumberOfGrains() {
+ return grainSizeEnvelope / grainIntervalEnvelope;
+ }
+
+
+// public static void main(String[] args) {
+// AudioContext ac = new AudioContext();
+// ac.start();
+// //clock
+// Clock c = new Clock(ac, 500);
+// ac.out.addDependent(c);
+// GranularSamplePlayer gsp = new GranularSamplePlayer(ac, SampleManager.sample("/Users/ollie/git/HappyBrackets/HappyBrackets/data/audio/guit.wav"));
+// gsp.getRateUGen().setValue(0.1f);
+// ac.out.addInput(gsp);
+// c.addMessageListener(new Bead() {
+// @Override
+// protected void messageReceived(Bead bead) {
+// if (c.getCount() % 32 == 0) {
+// gsp.reset();
+// }
+// }
+// });
+// }
+
+
+}
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Function.java b/src/beads_main/java/net/beadsproject/beads/ugens/Function.java
similarity index 98%
rename from src/beads_main/net/beadsproject/beads/ugens/Function.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Function.java
index fda8b61..00e5b9a 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Function.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Function.java
@@ -8,7 +8,6 @@
/**
* Function is an abstract class which can be quickly subclassed to make a custom {@link UGen} on the fly. Subclasses of Function must implement {@link #calculate()}, getting data from the array {@link #x}, and returning the result. {@link #x} provides access to the array of {@link UGen}s that are passed to Function's constructor.
*
- * @beads.category utilities
* @author ollie
*/
public abstract class Function extends UGen {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Gain.java b/src/beads_main/java/net/beadsproject/beads/ugens/Gain.java
similarity index 82%
rename from src/beads_main/net/beadsproject/beads/ugens/Gain.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Gain.java
index 91021f6..8e38cca 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Gain.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Gain.java
@@ -11,8 +11,7 @@
/**
* Gain modifies the gain of a multi-channel audio signal. The gain value can be
* controlled by an audio signal.
- *
- * @beads.category effect
+ *
* @author ollie
*/
public class Gain extends UGen implements DataBeadReceiver {
@@ -33,6 +32,16 @@ public Gain(AudioContext context, int inouts, UGen gainEnvelope) {
setGain(gainEnvelope);
}
+ /**
+ * Instantiates a new Gain.
+ *
+ * @param inouts the number of inputs (= number of outputs).
+ * @param gainEnvelope the gain envelope.
+ */
+ public Gain(int inouts, UGen gainEnvelope) {
+ this(getDefaultContext(), inouts, gainEnvelope);
+ }
+
/**
* Instantiates a new Gain with a {@link Static} gain envelop with the given
* value.
@@ -46,6 +55,17 @@ public Gain(AudioContext context, int inouts, float gain) {
setGain(gain);
}
+ /**
+ * Instantiates a new Gain with a {@link Static} gain envelop with the given
+ * value.
+ *
+ * @param inouts the number of inputs (= number of outputs).
+ * @param gain the fixed gain level.
+ */
+ public Gain(int inouts, float gain) {
+ this(getDefaultContext(), inouts, gain);
+ }
+
/**
* Instantiates a new Gain with {@link Static} gain envelop set to 1.
*
@@ -58,6 +78,16 @@ public Gain(AudioContext context, int inouts) {
this(context, inouts, 1f);
}
+ /**
+ * Instantiates a new Gain with {@link Static} gain envelop set to 1.
+ *
+ * @param inouts
+ * the number of inputs (= number of outputs).
+ */
+ public Gain(int inouts) {
+ this(getDefaultContext(), inouts);
+ }
+
/**
* Gets the gain envelope.
*
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Glide.java b/src/beads_main/java/net/beadsproject/beads/ugens/Glide.java
similarity index 82%
rename from src/beads_main/net/beadsproject/beads/ugens/Glide.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Glide.java
index 83f27a1..471f824 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Glide.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Glide.java
@@ -9,8 +9,7 @@
/**
*
* Simple UGen that ramps between given values over a given duration (e.g., for portamento).
- *
- * @beads.category control
+ *
* @author ollie
*/
public class Glide extends UGen {
@@ -43,7 +42,18 @@ public Glide(AudioContext context, float currentValue, float glideTimeMS) {
bufOut[0] = new float[bufferSize];
setGlideTime(glideTimeMS);
}
-
+
+ /**
+ * Creates a new Glide with the default AudioContext, initial value and glide time in milliseconds.
+ * @param currentValue
+ * the initial value.
+ * @param glideTimeMS
+ * the glide time in milliseconds.
+ */
+ public Glide(float currentValue, float glideTimeMS) {
+ this(getDefaultContext(), currentValue, glideTimeMS);
+ }
+
/**
* Creates a new Glide with the specified AudioContext, initial value. Uses the
* default glide time of 100 milliseconds.
@@ -55,7 +65,17 @@ public Glide(AudioContext context, float currentValue, float glideTimeMS) {
public Glide(AudioContext context, float currentValue) {
this(context, currentValue, 100);
}
-
+
+ /**
+ * Creates a new Glide with the default AudioContext, initial value. Uses the
+ * default glide time of 100 milliseconds.
+ * @param currentValue
+ * the initial value.
+ */
+ public Glide(float currentValue) {
+ this(getDefaultContext(), currentValue);
+ }
+
/**
* Creates a new Glide with the specified AudioContext. Uses the
* default inital value of zero and glide time of 100 milliseconds.
@@ -66,6 +86,13 @@ public Glide(AudioContext context) {
this(context, 0f);
}
+ /**
+ * Creates a new Glide with the default AudioContext. Uses the
+ * default inital value of zero and glide time of 100 milliseconds.
+ */
+ public Glide() {
+ this(getDefaultContext());
+ }
/**
* Sets the target glide value. From its current value Glide immediately interpolates
* its way to that value over the specified glideTime.
diff --git a/src/beads_main/net/beadsproject/beads/ugens/GranularSamplePlayer.java b/src/beads_main/java/net/beadsproject/beads/ugens/GranularSamplePlayer.java
similarity index 97%
rename from src/beads_main/net/beadsproject/beads/ugens/GranularSamplePlayer.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/GranularSamplePlayer.java
index d445039..7b19d16 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/GranularSamplePlayer.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/GranularSamplePlayer.java
@@ -20,7 +20,6 @@
* {@link UGen}s can be used to control playback rate, pitch, loop points, grain size, grain interval, grain randomness and position (this last case assumes that the playback rate is zero).
*
* @see SamplePlayer Sample
- * @beads.category sample players
* @author ollie
*/
public class GranularSamplePlayer extends SamplePlayer {
@@ -103,6 +102,15 @@ public GranularSamplePlayer(AudioContext context, int outs) {
loopInsideGrains = false;
}
+ /**
+ * Instantiates a new GranularSamplePlayer.
+ *
+ * @param outs the number of outputs.
+ */
+ public GranularSamplePlayer(int outs) {
+ this(getDefaultContext(), outs);
+ }
+
/**
* Instantiates a new GranularSamplePlayer.
*
@@ -116,6 +124,15 @@ public GranularSamplePlayer(AudioContext context, Sample buffer) {
loopEndEnvelope = new Static(context, (float)buffer.getLength());
}
+ /**
+ * Instantiates a new GranularSamplePlayer.
+ *
+ * @param buffer the Sample played by the GranularSamplePlayer.
+ */
+ public GranularSamplePlayer(Sample buffer) {
+ this(getDefaultContext(), buffer);
+ }
+
/**
* Gets the pitch envelope.
*
@@ -447,6 +464,7 @@ public synchronized void calculateBuffer() {
for (int j = 0; j < outs; j++) {
bufOut[j][i] = 0.0f;
}
+
//gather the output from each grain
for(Grain g : grains) {
//calculate value of grain window
@@ -498,7 +516,7 @@ public synchronized void calculateBuffer() {
}
}
}
-
+
/**
* Calculate next position for the given Grain.
*
diff --git a/src/beads_main/net/beadsproject/beads/ugens/IIRFilter.java b/src/beads_main/java/net/beadsproject/beads/ugens/IIRFilter.java
similarity index 93%
rename from src/beads_main/net/beadsproject/beads/ugens/IIRFilter.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/IIRFilter.java
index 3fc20db..d16eb83 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/IIRFilter.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/IIRFilter.java
@@ -10,8 +10,7 @@
* An abstract class that provides methods for analyzing infinite impulse
* response (IIR) filters. IIR filters built on this class should implement
* {@link #getFilterResponse(float)} appropriately.
- *
- * @beads.category filter
+ *
* @author Benito Crawford
* @version 0.9.5
*/
@@ -21,6 +20,10 @@ public IIRFilter(AudioContext context, int ins, int outs) {
super(context, ins, outs);
}
+ public IIRFilter(int ins, int outs) {
+ this(getDefaultContext(), ins, outs);
+ }
+
public abstract IIRFilterAnalysis getFilterResponse(float freq);
/**
@@ -102,9 +105,8 @@ protected static double calculateGroupDelay(float[] bs, float[] as,
/**
* Does our analysis at the specified frequency.
- *
- * @param freq
- * The frequency to analyze.
+ *
+ * @param freq The frequency to analyze.
*/
protected static IIRFilterAnalysis analyzeFilter(float[] bs, float[] as,
float freq, float samplingFreq) {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/LPRezFilter.java b/src/beads_main/java/net/beadsproject/beads/ugens/LPRezFilter.java
similarity index 78%
rename from src/beads_main/net/beadsproject/beads/ugens/LPRezFilter.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/LPRezFilter.java
index 1e8c4db..94f1ed9 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/LPRezFilter.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/LPRezFilter.java
@@ -23,8 +23,7 @@
* or by passing a DataBead with "frequency" and "resonance" properties to
* {@link #setParams(DataBead)}. (Messaging this object with a DataBead achieves
* the same.)
- *
- * @beads.category filter
+ *
* @author Benito Crawford
* @version 0.9.5
*/
@@ -52,6 +51,15 @@ public LPRezFilter(AudioContext con) {
this(con, 1);
}
+ /**
+ * Constructor for a single-channel LPRezFilter with default values for
+ * frequency and resonance.
+ *
+ */
+ public LPRezFilter(){
+ this(getDefaultContext());
+ }
+
/**
* Constructor for a multi-channel LPRezFilter with default values for
* frequency and resonance.
@@ -70,6 +78,17 @@ public LPRezFilter(AudioContext con, int channels) {
setFrequency(freq).setRes(res);
}
+ /**
+ * Constructor for a multi-channel LPRezFilter with default values for
+ * frequency and resonance.
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public LPRezFilter(int channels) {
+ this(getDefaultContext(), channels);
+ }
+
/**
* Constructor for a single-channel LPRezFilter with frequency and resonance
* specified by floats.
@@ -85,6 +104,19 @@ public LPRezFilter(AudioContext con, float freq, float res) {
this(con, 1, freq, res);
}
+ /**
+ * Constructor for a single-channel LPRezFilter with frequency and resonance
+ * specified by floats.
+ *
+ * @param freq
+ * The filter cut-off frequency.
+ * @param res
+ * The resonance.
+ */
+ public LPRezFilter(float freq, float res) {
+ this(getDefaultContext(), freq, res);
+ }
+
/**
* Constructor for a single-channel LPRezFilter with frequency specified by
* a UGen and resonance specified by a float.
@@ -100,6 +132,19 @@ public LPRezFilter(AudioContext con, UGen freq, float res) {
this(con, 1, freq, res);
}
+ /**
+ * Constructor for a single-channel LPRezFilter with frequency specified by
+ * a UGen and resonance specified by a float.
+ *
+ * @param freq
+ * The filter cut-off frequency UGen.
+ * @param res
+ * The resonance.
+ */
+ public LPRezFilter(UGen freq, float res) {
+ this(getDefaultContext(), freq, res);
+ }
+
/**
* Constructor for a single-channel LPRezFilter with frequency specified by
* a float and resonance specified by a UGen.
@@ -115,6 +160,19 @@ public LPRezFilter(AudioContext con, float freq, UGen res) {
this(con, 1, freq, res);
}
+ /**
+ * Constructor for a single-channel LPRezFilter with frequency specified by
+ * a float and resonance specified by a UGen.
+ *
+ * @param freq
+ * The filter cut-off frequency.
+ * @param res
+ * The resonance UGen.
+ */
+ public LPRezFilter(float freq, UGen res) {
+ this(getDefaultContext(), freq, res);
+ }
+
/**
* Constructor for a single-channel LPRezFilter with frequency and resonance
* specified by UGens.
@@ -130,6 +188,19 @@ public LPRezFilter(AudioContext con, UGen freq, UGen res) {
this(con, 1, freq, res);
}
+ /**
+ * Constructor for a single-channel LPRezFilter with frequency and resonance
+ * specified by UGens.
+ *
+ * @param freq
+ * The filter cut-off frequency UGen.
+ * @param res
+ * The resonance UGen.
+ */
+ public LPRezFilter(UGen freq, UGen res) {
+ this(getDefaultContext(), freq, res);
+ }
+
/**
* Constructor for a multi-channel LPRezFilter with frequency and resonance
* specified by floats.
@@ -148,6 +219,21 @@ public LPRezFilter(AudioContext con, int channels, float freq, float res) {
setFrequency(freq).setRes(res);
}
+ /**
+ * Constructor for a multi-channel LPRezFilter with frequency and resonance
+ * specified by floats.
+ *
+ * @param channels
+ * The number of channels.
+ * @param freq
+ * The filter cut-off frequency.
+ * @param res
+ * The resonance.
+ */
+ public LPRezFilter(int channels, float freq, float res) {
+ this(getDefaultContext(), channels, freq, res);
+ }
+
/**
* Constructor for a multi-channel LPRezFilter with frequency specified by a
* UGen and resonance specified by a float.
@@ -166,6 +252,21 @@ public LPRezFilter(AudioContext con, int channels, UGen freq, float res) {
setFrequency(freq).setRes(res);
}
+ /**
+ * Constructor for a multi-channel LPRezFilter with frequency specified by a
+ * UGen and resonance specified by a float.
+ *
+ * @param channels
+ * The number of channels.
+ * @param freq
+ * The filter cut-off frequency UGen.
+ * @param res
+ * The resonance.
+ */
+ public LPRezFilter(int channels, UGen freq, float res) {
+ this(getDefaultContext(), channels, freq, res);
+ }
+
/**
* Constructor for a multi-channel LPRezFilter with frequency specified by a
* float and resonance specified by a UGen.
@@ -184,6 +285,21 @@ public LPRezFilter(AudioContext con, int channels, float freq, UGen res) {
setFrequency(freq).setRes(res);
}
+ /**
+ * Constructor for a multi-channel LPRezFilter with frequency specified by a
+ * float and resonance specified by a UGen.
+ *
+ * @param channels
+ * The number of channels.
+ * @param freq
+ * The filter cut-off frequency.
+ * @param res
+ * The resonance UGen.
+ */
+ public LPRezFilter(int channels, float freq, UGen res) {
+ this(getDefaultContext(), channels, freq, res);
+ }
+
/**
* Constructor for a multi-channel LPRezFilter with frequency and resonance
* specified by UGens.
@@ -202,6 +318,21 @@ public LPRezFilter(AudioContext con, int channels, UGen freq, UGen res) {
setFrequency(freq).setRes(res);
}
+ /**
+ * Constructor for a multi-channel LPRezFilter with frequency and resonance
+ * specified by UGens.
+ *
+ * @param channels
+ * The number of channels.
+ * @param freq
+ * The filter cut-off frequency UGen.
+ * @param res
+ * The resonance UGen.
+ */
+ public LPRezFilter(int channels, UGen freq, UGen res) {
+ this(getDefaultContext(), channels, freq, res);
+ }
+
protected void calcVals() {
a1 = -2 * res * cosw;
a2 = res * res;
@@ -497,10 +628,9 @@ public float getRes() {
/**
* Sets the filter resonance to a float value. This removes the resonance
- * UGen, if it exists. (Should be >= 0 and < 1.)
+ * UGen, if it exists. (Should be >= 0 and < 1.)
*
- * @param r
- * The resonance.
+ * @param r The resonance.
* @return This filter instance.
*/
public LPRezFilter setRes(float r) {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Maximum.java b/src/beads_main/java/net/beadsproject/beads/ugens/Maximum.java
similarity index 68%
rename from src/beads_main/net/beadsproject/beads/ugens/Maximum.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Maximum.java
index acb2237..3c38f62 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Maximum.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Maximum.java
@@ -8,8 +8,7 @@
/**
* For each sample, outputs the maximum of its two inputs.
- *
- * @beads.category lowlevel
+ *
* @author Benito Crawford
* @version 0.9
*/
@@ -25,6 +24,14 @@ public Maximum(AudioContext context) {
super(context, 2, 1);
}
+ /**
+ * Constructor with no assigned inputs.
+ *
+ */
+ public Maximum() {
+ this(getDefaultContext());
+ }
+
/**
* Constructor for 1 UGen input and a static maximum value.
*
@@ -41,6 +48,18 @@ public Maximum(AudioContext context, UGen ugen, float maxVal) {
addInput(1, new Static(context, maxVal), 0);
}
+ /**
+ * Constructor for 1 UGen input and a static maximum value.
+ *
+ * @param ugen
+ * The input UGen.
+ * @param maxVal
+ * The minimum value.
+ */
+ public Maximum( UGen ugen, float maxVal) {
+ this(getDefaultContext(), ugen, maxVal);
+ }
+
/**
* Constructor for 2 UGen inputs.
*
@@ -57,6 +76,17 @@ public Maximum(AudioContext context, UGen ugen1, UGen ugen2) {
addInput(1, ugen2, 0);
}
+ /**
+ * Constructor for 2 UGen inputs.
+ * @param ugen1
+ * The first UGen input.
+ * @param ugen2
+ * The second UGen input.
+ */
+ public Maximum(UGen ugen1, UGen ugen2) {
+ this(getDefaultContext(), ugen1, ugen2);
+ }
+
@Override
public void calculateBuffer() {
float[] bi1 = bufIn[0];
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Minimum.java b/src/beads_main/java/net/beadsproject/beads/ugens/Minimum.java
similarity index 65%
rename from src/beads_main/net/beadsproject/beads/ugens/Minimum.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Minimum.java
index 7ed5759..54c0758 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Minimum.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Minimum.java
@@ -8,8 +8,7 @@
/**
* For each sample, outputs the minimum of its two inputs.
- *
- * @beads.category lowlevel
+ *
* @author Benito Crawford
* @version 0.9
*/
@@ -26,22 +25,41 @@ public Minimum(AudioContext context) {
}
/**
- * Constructor for 1 UGen input and a static minimum value.
- *
- * @param context
- * The audio context.
- * @param ugen
- * The input UGen.
- * @param minVal
- * The minimum value.
+ * Constructor with no assigned inputs.
+ *
*/
+ public Minimum() {
+ this(getDefaultContext());
+ }
+ /**
+ * Constructor for 1 UGen input and a static minimum value.
+ *
+ * @param context
+ * The audio context.
+ * @param ugen
+ * The input UGen.
+ * @param minVal
+ * The minimum value.
+ */
public Minimum(AudioContext context, UGen ugen, float minVal) {
super(context, 2, 1);
addInput(0, ugen, 0);
addInput(1, new Static(context, minVal), 0);
}
+ /**
+ * Constructor for 1 UGen input and a static minimum value.
+ *
+ * @param ugen
+ * The input UGen.
+ * @param minVal
+ * The minimum value.
+ */
+ public Minimum(UGen ugen, float minVal) {
+ this(getDefaultContext(), ugen, minVal);
+ }
+
/**
* Constructor for 2 UGen inputs.
*
@@ -58,6 +76,18 @@ public Minimum(AudioContext context, UGen ugen1, UGen ugen2) {
addInput(1, ugen2, 0);
}
+ /**
+ * Constructor for 2 UGen inputs.
+ *
+ * @param ugen1
+ * The first UGen input.
+ * @param ugen2
+ * The second UGen input.
+ */
+ public Minimum(UGen ugen1, UGen ugen2) {
+ this(getDefaultContext(), ugen1, ugen2);
+ }
+
@Override
public void calculateBuffer() {
float[] bi1 = bufIn[0];
diff --git a/src/beads_main/net/beadsproject/beads/ugens/MonoPlug.java b/src/beads_main/java/net/beadsproject/beads/ugens/MonoPlug.java
similarity index 88%
rename from src/beads_main/net/beadsproject/beads/ugens/MonoPlug.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/MonoPlug.java
index f1a1fd1..dd575ea 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/MonoPlug.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/MonoPlug.java
@@ -9,8 +9,7 @@
/**
* MonoPlug performs the simple task of channelling a single output from a multi-channel
* {@link UGen}.
- *
- * @beads.category utilities
+ *
* @author ollie
*/
public class MonoPlug extends UGen {
@@ -26,6 +25,14 @@ public MonoPlug(AudioContext context) {
outputPauseRegime = OutputPauseRegime.ZERO;
}
+ /**
+ * Instantiates a new MonoPlug.
+ *
+ */
+ public MonoPlug() {
+ this(getDefaultContext());
+ }
+
/* (non-Javadoc)
* @see net.beadsproject.beads.core.UGen#calculateBuffer()
*/
diff --git a/src/beads_main/net/beadsproject/beads/ugens/MouseResponder.java b/src/beads_main/java/net/beadsproject/beads/ugens/MouseResponder.java
similarity index 93%
rename from src/beads_main/net/beadsproject/beads/ugens/MouseResponder.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/MouseResponder.java
index b412b58..fa089b5 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/MouseResponder.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/MouseResponder.java
@@ -12,9 +12,7 @@
/**
* A MouseResponder is a way of getting mouse input to control audio rate data. The mouse doesn't generate audio rate data, but it is interpolated.
- *
- * @beads.category utilities
- * @beads.category control
+ *
*/
public class MouseResponder extends UGen {
@@ -49,6 +47,13 @@ public MouseResponder(AudioContext context) {
prevY = 0;
}
+ /**
+ * Instantiates a new MouseResponder.
+ *
+ */
+ public MouseResponder() {
+ this(getDefaultContext());
+ }
/**
* Gets the current point.
*
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Mult.java b/src/beads_main/java/net/beadsproject/beads/ugens/Mult.java
similarity index 78%
rename from src/beads_main/net/beadsproject/beads/ugens/Mult.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Mult.java
index 3c1c848..07dfb6c 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Mult.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Mult.java
@@ -9,8 +9,7 @@
/**
* Takes an incoming signal (or signals in the multi-channel case) and
* multiplies it with something (another signal or a float value).
- *
- * @beads.category utilities
+ *
* @author ollie
* @author Benito Crawford
*/
@@ -34,6 +33,18 @@ public Mult(AudioContext context, int channels, float multiplier) {
setMultiplier(multiplier);
}
+ /**
+ * Constructor for a Mult object with a static multiplier value.
+ *
+ * @param channels
+ * The number of channels.
+ * @param multiplier
+ * The multiplier value.
+ */
+ public Mult(int channels, float multiplier) {
+ this(getDefaultContext(), channels, multiplier);
+ }
+
/**
* Constructor for a Mult object with a UGen controlling the multiplier
* value.
@@ -49,7 +60,20 @@ public Mult(AudioContext context, int channels, UGen multiplierUGen) {
super(context, channels, channels);
setMultiplier(multiplierUGen);
}
-
+
+ /**
+ * Constructor for a Mult object with a UGen controlling the multiplier
+ * value.
+ *
+ * @param channels
+ * The number of channels.
+ * @param multiplierUGen
+ * The UGen controlling the multiplier value.
+ */
+ public Mult(int channels, UGen multiplierUGen) {
+ this(getDefaultContext(), channels, multiplierUGen);
+ }
+
/**
* Constructor for a Mult object with a given UGen as input and another as multiplier.
* i.e., use this as quickest way to multiply two UGens together.
@@ -64,6 +88,17 @@ public Mult(AudioContext context, UGen input, UGen multiplierUGen) {
addInput(input);
}
+ /**
+ * Constructor for a Mult object with a given UGen as input and another as multiplier.
+ * i.e., use this as quickest way to multiply two UGens together.
+ *
+ * @param input the input UGen.
+ * @param multiplierUGen the multiplier UGen.
+ */
+ public Mult(UGen input, UGen multiplierUGen) {
+ this(getDefaultContext(), input, multiplierUGen);
+ }
+
/*
* (non-Javadoc)
*
diff --git a/src/beads_main/net/beadsproject/beads/ugens/MultiWrapper.java b/src/beads_main/java/net/beadsproject/beads/ugens/MultiWrapper.java
similarity index 79%
rename from src/beads_main/net/beadsproject/beads/ugens/MultiWrapper.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/MultiWrapper.java
index 90d67f4..6c7134a 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/MultiWrapper.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/MultiWrapper.java
@@ -39,10 +39,26 @@ public MultiWrapper(AudioContext context, int channels) {
this(context, channels, 1, 1);
}
+ /**
+ * Constructor for an multi-channel wrapper for 1-in/1-out UGens on each
+ * channel. {@link #buildUGens(int)} should be implemented to construct a
+ * UGen for each channel.
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public MultiWrapper(int channels){
+ this(getDefaultContext(), channels);
+ }
+
private MultiWrapper(AudioContext context, int numIns, int numOuts) {
super(context, numIns, numOuts);
}
+ private MultiWrapper(int numIns, int numOuts){
+ this(getDefaultContext(), numIns, numOuts);
+ }
+
/**
* Constructor for an n-channel wrapper for UGens with a certain number
* inputs and a certain number outputs on each channel.
@@ -76,6 +92,24 @@ public MultiWrapper(AudioContext context, int channels, int insPerChannel,
}
+ /**
+ * Constructor for an n-channel wrapper for UGens with a certain number
+ * inputs and a certain number outputs on each channel.
+ * {@link #buildUGens(int)} should be implemented to construct a UGen for
+ * each channel.
+ *
+ * @param channels
+ * The number of channels.
+ * @param insPerChannel
+ * The number of inputs per channel UGen.
+ * @param outsPerChannel
+ * The number of outputs per channel UGen.
+ */
+ public MultiWrapper(int channels, int insPerChannel,
+ int outsPerChannel) {
+ this(getDefaultContext(), channels, insPerChannel, outsPerChannel);
+ }
+
/**
* Constructor for a multi-channel wrapper for an array of UGens that
* represent separate "channels".
@@ -103,6 +137,21 @@ public MultiWrapper(AudioContext context, UGen[] ugens, int insPerChannel,
}
+ /**
+ * Constructor for a multi-channel wrapper for an array of UGens that
+ * represent separate "channels".
+ *
+ * @param ugens
+ * The array of UGens to wrap.
+ * @param insPerChannel
+ * The number of inputs per channel.
+ * @param outsPerChannel
+ * The number of ouputs per channel.
+ */
+ public MultiWrapper(UGen[] ugens, int insPerChannel,
+ int outsPerChannel) {
+ this(getDefaultContext(), ugens, insPerChannel, outsPerChannel );
+ }
private void setupUGens() {
for (int i = 0; i < channels; i++) {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/NBitsConverter.java b/src/beads_main/java/net/beadsproject/beads/ugens/NBitsConverter.java
similarity index 79%
rename from src/beads_main/net/beadsproject/beads/ugens/NBitsConverter.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/NBitsConverter.java
index e9904f6..2898e6d 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/NBitsConverter.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/NBitsConverter.java
@@ -10,8 +10,7 @@
* Converts a signal to have n-bits, useful for 8-bit synthesis.
* PRE: Signal must be in (-1,1) range
* POST: Signal is in (-1,1) range
- *
- * @beads.category effect
+ *
* @author ben
*
*/
@@ -32,6 +31,15 @@ public NBitsConverter(AudioContext ac, int n) {
}
+
+ /**
+ * Creates a new NBitsConverter with the default {@link AudioContext} and number of bits to convert to.
+
+ * @param n the number of bits to convert to.
+ */
+ public NBitsConverter(int n) {
+ this(getDefaultContext(), n);
+ }
public void calculateBuffer()
{
// for each float value (-1,1)
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Noise.java b/src/beads_main/java/net/beadsproject/beads/ugens/Noise.java
similarity index 92%
rename from src/beads_main/net/beadsproject/beads/ugens/Noise.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Noise.java
index db7c137..5a353f1 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Noise.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Noise.java
@@ -10,8 +10,7 @@
/**
* Noise generates white noise. It uses a long buffer of sampled noise.
- *
- * @beads.category synth
+ *
* @author ollie
*/
public class Noise extends UGen {
@@ -35,6 +34,13 @@ public Noise(AudioContext context) {
index = (int)(Math.random() * noiseBuffer.buf.length);
}
+ /**
+ * Instantiates a new Noise.
+ */
+ public Noise() {
+ this(getDefaultContext());
+ }
+
/* (non-Javadoc)
* @see net.beadsproject.beads.core.UGen#calculateBuffer()
*/
diff --git a/src/beads_main/net/beadsproject/beads/ugens/OnePoleFilter.java b/src/beads_main/java/net/beadsproject/beads/ugens/OnePoleFilter.java
similarity index 89%
rename from src/beads_main/net/beadsproject/beads/ugens/OnePoleFilter.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/OnePoleFilter.java
index ebd966b..49e7ac5 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/OnePoleFilter.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/OnePoleFilter.java
@@ -14,8 +14,7 @@
* either by UGen or a float.
*
* It uses the formula: y(n) = a * x(n) + (1 - a) * y(n - 1)
- *
- * @beads.category filter
+ *
* @author Benito Crawford
* @version 0.9
*/
@@ -41,6 +40,16 @@ public OnePoleFilter(AudioContext con, float freq) {
setFrequency(freq);
}
+ /**
+ * Constructor for cut-off frequency specified by a static float.
+ *
+ * @param freq
+ * The cut-off frequency.
+ */
+ public OnePoleFilter(float freq) {
+ this(getDefaultContext(), freq);
+ }
+
/**
* Constructor for cut-off frequency specified by a UGen.
*
@@ -57,6 +66,16 @@ public OnePoleFilter(AudioContext con, UGen freq) {
setFrequency(freq);
}
+ /**
+ * Constructor for cut-off frequency specified by a UGen.
+ *
+ * @param freq
+ * The cut-off frequency UGen.
+ */
+ public OnePoleFilter(UGen freq) {
+ this(getDefaultContext(), freq);
+ }
+
protected void calcVals() {
a1 = (b0 = (float) Math.sin(two_pi_over_sf * freq)) - 1;
}
diff --git a/src/beads_main/net/beadsproject/beads/ugens/OscillatorBank.java b/src/beads_main/java/net/beadsproject/beads/ugens/OscillatorBank.java
similarity index 93%
rename from src/beads_main/net/beadsproject/beads/ugens/OscillatorBank.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/OscillatorBank.java
index d59393e..9697583 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/OscillatorBank.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/OscillatorBank.java
@@ -10,7 +10,6 @@
/**
* An OscillatorBank sums the output of a set of oscillators with assignable frequencies and amplitudes. The frequencies and amplitudes of the set of oscillators can be assigned using arrays.
*
- * @beads.category synth
* @author ollie
*/
public class OscillatorBank extends UGen {
@@ -49,8 +48,17 @@ public OscillatorBank(AudioContext context, Buffer buffer, int numOscillators) {
setNumOscillators(numOscillators);
gain = 1f / (float)numOscillators;
}
-
-
+
+ /**
+ * Instantiates a new OscillatorBank.
+ *
+ * @param buffer the buffer used as a lookup table by the oscillators.
+ * @param numOscillators the number of oscillators.
+ */
+ public OscillatorBank(Buffer buffer, int numOscillators) {
+ this(getDefaultContext(), buffer, numOscillators);
+ }
+
/**
* Sets the number of oscillators.
*
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Panner.java b/src/beads_main/java/net/beadsproject/beads/ugens/Panner.java
similarity index 87%
rename from src/beads_main/net/beadsproject/beads/ugens/Panner.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Panner.java
index fbbb2d3..f1217bb 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Panner.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Panner.java
@@ -16,8 +16,7 @@
* channel as a result. A pan value of -1 pans completely to the left, 1 pans
* completely to the right, and 0 results in center panning. It uses an array to
* approximate square roots for efficiency.
- *
- * @beads.category utilities
+ *
* @author Benito Crawford
* @version 0.9.1
*/
@@ -39,6 +38,14 @@ public Panner(AudioContext con) {
this(con, 0);
}
+ /**
+ * Constructor that sets the pan to the middle by default.
+ *
+ */
+ public Panner(){
+ this (getDefaultContext());
+ }
+
/**
* Constructor that sets the pan to a static value.
*
@@ -52,6 +59,16 @@ public Panner(AudioContext con, float ipos) {
setPos(ipos);
}
+ /**
+ * Constructor that sets the pan to a static value.
+ *
+ * @param ipos
+ * The initial pan value.
+ */
+ public Panner(float ipos) {
+ this(getDefaultContext(), ipos);
+ }
+
/**
* Constructor that sets a UGen to specify the pan value.
*
@@ -65,6 +82,16 @@ public Panner(AudioContext con, UGen posUGen) {
setPos(posUGen);
}
+ /**
+ * Constructor that sets a UGen to specify the pan value.
+ *
+ * @param posUGen
+ * The pan UGen.
+ */
+ public Panner(UGen posUGen) {
+ this(getDefaultContext(), posUGen);
+ }
+
@Override
public void calculateBuffer() {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Phasor.java b/src/beads_main/java/net/beadsproject/beads/ugens/Phasor.java
similarity index 81%
rename from src/beads_main/net/beadsproject/beads/ugens/Phasor.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Phasor.java
index 6260391..136ba5f 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Phasor.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Phasor.java
@@ -29,6 +29,14 @@ public Phasor(AudioContext con) {
one_over_sr = 1d / con.getSampleRate();
}
+ /**
+ * Basic constructor.
+ *
+ */
+ public Phasor() {
+ this(getDefaultContext());
+ }
+
/**
* Constructor that sets the initial frequency to a float value.
*
@@ -42,6 +50,16 @@ public Phasor(AudioContext con, float frequency) {
setFrequency(frequency);
}
+ /**
+ * Constructor that sets the initial frequency to a float value.
+ *
+ * @param frequency
+ * The initial frequency.
+ */
+ public Phasor(float frequency) {
+ this(getDefaultContext(), frequency);
+ }
+
/**
* Constructor that sets a UGen to control the frequency.
*
@@ -55,6 +73,16 @@ public Phasor(AudioContext con, UGen frequencyUGen) {
setFrequency(frequencyUGen);
}
+ /**
+ * Constructor that sets a UGen to control the frequency.
+ *
+ * @param frequencyUGen
+ * The frequency controller UGen.
+ */
+ public Phasor(UGen frequencyUGen) {
+ this(getDefaultContext(), frequencyUGen);
+ }
+
@Override
public void calculateBuffer() {
float[] bo = bufOut[0];
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Plug.java b/src/beads_main/java/net/beadsproject/beads/ugens/Plug.java
similarity index 61%
rename from src/beads_main/net/beadsproject/beads/ugens/Plug.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Plug.java
index bd6c6a1..52e76d6 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Plug.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Plug.java
@@ -28,13 +28,22 @@ public Plug(AudioContext context) {
this(context, 1);
}
+ /**
+ * Constructor for a one-channel Plug using the specified audio
+ * context.
+ *
+ */
+ public Plug(){
+ this(getDefaultContext());
+ }
+
/**
* Constructor for a mono Plug that takes input from the specified source
* UGen.
*
* @param context
* The audio context.
- * @param souceUGen
+ * @param sourceUGen
* The source UGen.
*/
public Plug(AudioContext context, UGen sourceUGen) {
@@ -42,13 +51,24 @@ public Plug(AudioContext context, UGen sourceUGen) {
this.addInput(sourceUGen);
}
+ /**
+ * Constructor for a mono Plug that takes input from the specified source
+ * UGen.
+ *
+ * @param sourceUGen
+ * The source UGen.
+ */
+ public Plug(UGen sourceUGen) {
+ this (getDefaultContext(), sourceUGen);
+ }
+
/**
* Constructor for a mono Plug that takes input from the specified output
* channel of a source UGen.
*
* @param context
* The audio context.
- * @param souceUGen
+ * @param sourceUGen
* The source UGen.
* @param sourceOutputChannel
* The channel from the source UGen to take as input.
@@ -58,6 +78,19 @@ public Plug(AudioContext context, UGen sourceUGen, int sourceOutputChannel) {
this.addInput(0, sourceUGen, sourceOutputChannel);
}
+ /**
+ * Constructor for a mono Plug that takes input from the specified output
+ * channel of a source UGen.
+ *
+ * @param sourceUGen
+ * The source UGen.
+ * @param sourceOutputChannel
+ * The channel from the source UGen to take as input.
+ */
+ public Plug(UGen sourceUGen, int sourceOutputChannel) {
+ this (getDefaultContext(), sourceUGen, sourceOutputChannel);
+ }
+
/**
* Constructor for a Plug with the specified number of channels, using
* the specified audio context.
@@ -73,6 +106,17 @@ public Plug(AudioContext context, int channels) {
bufOut = bufIn;
}
+ /**
+ * Constructor for a Plug with the specified number of channels, using
+ * the specified audio context.
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public Plug(int channels) {
+ this(getDefaultContext(), channels);
+ }
+
@Override
public void calculateBuffer() {
}
diff --git a/src/beads_main/net/beadsproject/beads/ugens/PolyLimit.java b/src/beads_main/java/net/beadsproject/beads/ugens/PolyLimit.java
similarity index 92%
rename from src/beads_main/net/beadsproject/beads/ugens/PolyLimit.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/PolyLimit.java
index 3cab618..9a4f086 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/PolyLimit.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/PolyLimit.java
@@ -14,8 +14,7 @@
* An upper limit is given. If a new UGen is added but this takes the number of connected UGens over that
* upper limit then the oldest connected UGen is dropped in order to allow
* the new UGen to be connected.
- *
- * @beads.category utilities
+ *
*/
public class PolyLimit extends UGen {
@@ -40,7 +39,17 @@ public PolyLimit(AudioContext context, int inouts, int maxInputs) {
setMaxInputs(maxInputs);
existingInputs = new LinkedList();
}
-
+
+ /**
+ * Instantiates a new PolyLimit.
+ *
+ * @param inouts the number of channels.
+ * @param maxInputs the max number of connected inputs.
+ */
+ public PolyLimit(int inouts, int maxInputs) {
+ this(getDefaultContext(), inouts, maxInputs);
+ }
+
/**
* Overrides {@link UGen#addInput(UGen)} such that if a new UGen pushes the total number of
* connected UGens above the upper limit, the oldest UGen is removed.
diff --git a/src/beads_main/net/beadsproject/beads/ugens/RMS.java b/src/beads_main/java/net/beadsproject/beads/ugens/RMS.java
similarity index 83%
rename from src/beads_main/net/beadsproject/beads/ugens/RMS.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/RMS.java
index c79c0bd..b94c495 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/RMS.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/RMS.java
@@ -11,8 +11,7 @@
* over a given time frame. The algorithm accounts for multi-channel input by
* summing the squares of each channel and dividing by the square root of the
* number of channels.
- *
- * @beads.category lowlevel
+ *
* @author Benito Crawford
* @version 0.9.5
*/
@@ -41,6 +40,18 @@ public RMS(AudioContext context, int channels, int memorySize) {
memScale = 1f / memorySize;
}
+ /**
+ * Constructor.
+ *
+ * @param channels
+ * The number of channels.
+ * @param memorySize
+ * The number of samples over which to compute the RMS.
+ */
+ public RMS(int channels, int memorySize) {
+ this(getDefaultContext(), channels, memorySize);
+ }
+
@Override
public void calculateBuffer() {
float[] bo = bufOut[0];
diff --git a/src/beads_main/net/beadsproject/beads/ugens/RandomPWM.java b/src/beads_main/java/net/beadsproject/beads/ugens/RandomPWM.java
similarity index 88%
rename from src/beads_main/net/beadsproject/beads/ugens/RandomPWM.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/RandomPWM.java
index 554162f..c2091b5 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/RandomPWM.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/RandomPWM.java
@@ -25,8 +25,7 @@
* {@link #RAMPED_NOISE} - for random-length ramps between random values between -1 and 1.
* {@link #NOISE_ENVELOPE} - for random-length ramps between random values between 0 and 1.
*
- *
- * @beads.category synth
+ *
* @author Benito Crawford
* @version 0.9.6
*
@@ -64,7 +63,20 @@ public enum Mode {
public RandomPWM(AudioContext context, Mode mode, float minl, float maxl) {
this(context, mode, minl, maxl, 1);
}
-
+
+ /**
+ * Constructor specifying mode, and minumum and maximum pulse lengths.
+ * @param mode
+ * The pulse mode; see {@link #setMode(Mode) setMode}.
+ * @param minl
+ * The minimum pulse length.
+ * @param maxl
+ * The maximum pulse length.
+ */
+ public RandomPWM(Mode mode, float minl, float maxl){
+ this(getDefaultContext(), mode, minl, maxl);
+ }
+
/**
* Constructor specifying all parameters
*
@@ -85,6 +97,25 @@ public RandomPWM(AudioContext context, Mode mode, float minl, float maxl,
setParams(mode, minl, maxl, lexp);
}
+ /**
+ * Constructor specifying all parameters
+ *
+ * @param mode
+ * The pulse mode; see {@link #setMode(Mode) setMode}.
+ * @param minl
+ * The minimum pulse length.
+ * @param maxl
+ * The maximum pulse length.
+ * @param lexp
+ * The pulse length exponent.
+ */
+ public RandomPWM(Mode mode, float minl, float maxl,
+ float lexp) {
+
+ this(getDefaultContext(), mode, minl, maxl, lexp);
+ }
+
+
public void calculateBuffer() {
float[] bo = bufOut[0];
diff --git a/src/beads_main/net/beadsproject/beads/ugens/RangeLimiter.java b/src/beads_main/java/net/beadsproject/beads/ugens/RangeLimiter.java
similarity index 85%
rename from src/beads_main/net/beadsproject/beads/ugens/RangeLimiter.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/RangeLimiter.java
index b138b1c..a00a81d 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/RangeLimiter.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/RangeLimiter.java
@@ -9,8 +9,7 @@
/**
* RangeLimiter forces a signal within the range [-1,1]. Use {@link Clip} for
* constraining to other ranges.
- *
- * @beads.category utilities
+ *
* @author ollie
* @author benito
* @version 0.9.5
@@ -29,6 +28,16 @@ public RangeLimiter(AudioContext context, int channels) {
super(context, channels, channels);
}
+ /**
+ * Instantiates a new RangeLimiter.
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public RangeLimiter(int channels) {
+ this(getDefaultContext(), channels);
+ }
+
/*
* (non-Javadoc)
*
diff --git a/src/beads_main/net/beadsproject/beads/ugens/RecordToSample.java b/src/beads_main/java/net/beadsproject/beads/ugens/RecordToSample.java
similarity index 91%
rename from src/beads_main/net/beadsproject/beads/ugens/RecordToSample.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/RecordToSample.java
index b494de2..473c9a1 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/RecordToSample.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/RecordToSample.java
@@ -30,8 +30,7 @@
* ADVANCED: When resizing a sample in INFINITE mode, the recorder uses a set of parameters
* that specify how it behaves. If necessary you can modify the parameters on a per-recorder basis. See
* {@link #setResizingParameters(double, double)}.
- *
- * @beads.category utilities
+ *
*
*/
public class RecordToSample extends UGen {
@@ -79,12 +78,23 @@ public enum Mode {
* the AudioContext.
* @param sample
* the Sample.
- * @throws Exception if sample is not writeable.
+ * //@throws Exception if sample is not writeable.
*/
public RecordToSample(AudioContext context, Sample sample) {
this(context, sample, Mode.FINITE);
}
-
+
+ /**
+ * Instantiates a new RecordToSample.
+ *
+ * @param sample
+ * the Sample.
+ * //@throws Exception if sample is not writeable.
+ */
+ public RecordToSample(Sample sample){
+ this(getDefaultContext(), sample);
+ }
+
/**
* Instantiates a new RecordToSample.
*
@@ -94,20 +104,36 @@ public RecordToSample(AudioContext context, Sample sample) {
* the Sample.
* @param mode
* the Recording Mode to use.
- * @throws Exception if sample is not writeable.
+ * //@throws Exception if sample is not writeable.
*/
public RecordToSample(AudioContext context, Sample sample, Mode mode) {
this(context, sample.getNumChannels());
this.mode = mode;
setSample(sample);
}
-
+
+ /**
+ * Instantiates a new RecordToSample.
+ *
+ * @param sample
+ * the Sample.
+ * @param mode
+ * the Recording Mode to use.
+ * //@throws Exception if sample is not writeable.
+ */
+ public RecordToSample(Sample sample, Mode mode) {
+ this(getDefaultContext(), sample, mode);
+ }
+
public RecordToSample(AudioContext context, int numChannels) {
super(context, numChannels, 0);
mode = Mode.FINITE;
sample = null;
}
+ public RecordToSample(int numChannels) {
+ this(getDefaultContext(), numChannels);
+ }
/**
* Gets the Sample.
*
@@ -293,6 +319,7 @@ public void setResizingParameters(double doubleUpTime, double constantResizeLeng
*
* @return true if loop record mode is enabled.
* @deprecated Use {@link #getMode()} instead.
+ * //@Deprecated Use {@link #getMode()} instead.
*/
public boolean isLoopRecord() {
return mode==Mode.LOOPING;
@@ -303,6 +330,7 @@ public boolean isLoopRecord() {
*
* @param loopRecord true to enable loop record mode.
* @deprecated Use {@link #setMode(Mode)} instead.
+ * //@Deprecated Use {@link #setMode(Mode)} instead.
*/
public void setLoopRecord(boolean loopRecord) {
mode = Mode.LOOPING;
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Reverb.java b/src/beads_main/java/net/beadsproject/beads/ugens/Reverb.java
similarity index 92%
rename from src/beads_main/net/beadsproject/beads/ugens/Reverb.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Reverb.java
index 6327385..0889662 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Reverb.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Reverb.java
@@ -12,8 +12,7 @@
* A basic reverb unit with adjustable room size, high-frequency damping, and
* early reflections and late reverb levels. If specified, creates a
* de-correlated multi-channel effect.
- *
- * @beads.category effect
+ *
* @author Benito Crawford
* @version 0.9.5
*/
@@ -40,6 +39,14 @@ public Reverb(AudioContext context) {
this(context, 1);
}
+ /**
+ * Constructor for a reverb unit with one output channel.
+ *
+ */
+ public Reverb() {
+ this(getDefaultContext());
+ }
+
/**
* Constructor for a reverb unit with the specified number of output
* channels.
@@ -131,6 +138,17 @@ public Reverb(AudioContext context, int outChannels) {
.setLateReverbLevel(1);
}
+ /**
+ * Constructor for a reverb unit with the specified number of output
+ * channels.
+ *
+ * @param outChannels
+ * The number of output channels.
+ */
+ public Reverb(int outChannels) {
+ this(getDefaultContext(), outChannels);
+ }
+
@Override
protected void preFrame() {
delayModulator.update();
diff --git a/src/beads_main/net/beadsproject/beads/ugens/SamplePlayer.java b/src/beads_main/java/net/beadsproject/beads/ugens/SamplePlayer.java
similarity index 72%
rename from src/beads_main/net/beadsproject/beads/ugens/SamplePlayer.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/SamplePlayer.java
index d202e3b..2e58d13 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/SamplePlayer.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/SamplePlayer.java
@@ -17,17 +17,14 @@
* {@link Sample} argument, the number of outputs of SamplePlayer is determined
* by the number of channels of the {@link Sample}. {@link Sample} playback can
* use either linear or cubic interpolation.
- *
- * TODO: Loop cross-fading has not been implemented yet.
- *
- * @beads.category sample players
+ *
* @author ollie
*/
public class SamplePlayer extends UGen {
public static final float ADAPTIVE_INTERP_LOW_THRESH = 0.5f;
public static final float ADAPTIVE_INTERP_HIGH_THRESH = 2.5f;
-
+
/**
* Used to determine what kind of interpolation is used when access samples.
*/
@@ -133,7 +130,7 @@ public static enum EnvelopeType {
protected LoopType loopType;
/** The loop cross fade in milliseconds. */
- protected float loopCrossFade; // TODO loop crossfade behaviour
+ protected float loopCrossFade;
/**
* Flag to determine whether playback starts at the beginning of the sample
@@ -164,6 +161,12 @@ public static enum EnvelopeType {
/** Bead responding to sample at end (only applies when not in loop mode). */
private Bead endListener;
+
+ /**
+ * Boolean array for determining whether or not the current
+ * sample is looping for each i in bufferSize.
+ */
+ private boolean[] isLooping;
/**
* Instantiates a new SamplePlayer with given number of outputs.
@@ -185,6 +188,18 @@ public SamplePlayer(AudioContext context, int outs) {
loopStartEnvelope = new Static(context, 0.0f);
loopEndEnvelope = new Static(context, 0.0f);
positionIncrement = context.samplesToMs(1);
+ loopCrossFade = 0;
+ isLooping = new boolean[bufferSize];
+ }
+
+ /**
+ * Instantiates a new SamplePlayer with given number of outputs.
+ *
+ * @param outs
+ * the number of outputs.
+ */
+ public SamplePlayer(int outs) {
+ this(getDefaultContext(), outs);
}
/**
@@ -203,8 +218,18 @@ public SamplePlayer(AudioContext context, Sample buffer) {
}
/**
- * Sets the Sample.
+ * Instantiates a new SamplePlayer with given Sample. Number of outputs is
+ * determined by number of channels in Sample.
+ *
+ * @param buffer
+ * the Sample.
*/
+ public SamplePlayer(Sample buffer) {
+ this(getDefaultContext(), buffer);
+ }
+ /**
+ * Sets the Sample.
+ */
public void setSample(Sample sample) {
this.sample = sample;
// sampleRate = sample.getSampleRate();
@@ -484,24 +509,24 @@ public void setInterpolationType(InterpolationType interpolationType) {
this.interpolationType = interpolationType;
}
-// /**
-// * Gets the loop cross fade.
-// *
-// * @return the loop cross fade in milliseconds.
-// */
-// public float getLoopCrossFade() {
-// return loopCrossFade;
-// }
+ /**
+ * Gets the loop cross fade.
+ *
+ * @return the loop cross fade in milliseconds.
+ */
+ public float getLoopCrossFade() {
+ return loopCrossFade;
+ }
-// /**
-// * Sets the loop cross fade.
-// *
-// * @param loopCrossFade
-// * the new loop cross fade in milliseconds.
-// */
-// public void setLoopCrossFade(float loopCrossFade) {
-// this.loopCrossFade = loopCrossFade;
-// }
+ /**
+ * Sets the loop cross fade.
+ *
+ * @param loopCrossFade
+ * the new loop cross fade in milliseconds.
+ */
+ public void setLoopCrossFade(float loopCrossFade) {
+ this.loopCrossFade = loopCrossFade;
+ }
/**
* Gets the loop end envelope.
@@ -746,33 +771,158 @@ public void calculateBuffer() {
} else // envelopeType==EnvelopeType.FINE
{
for (int i = 0; i < bufferSize; i++) {
- // calculate the samples
+ // update the position, loop state, direction
+ calculateNextPosition(i);
+
+ // Crossfade using sound before Loop Start: Requires loop start to be set after 0 for crossfade
+ // If half of crossfade is greater than gap at the start or at the end, set loopCrossFade to be that length.
+ if ((loopCrossFade / 2 > Math.min(loopStart, loopEnd))
+ || (loopCrossFade / 2 > (sample.getLength() - Math.max(loopStart, loopEnd))))
+ {
+ loopCrossFade = (float) (Math.min(
+ Math.min(loopStart, loopEnd), sample.getLength() - Math.max(loopStart, loopEnd)) * 2
+ );
+ }
+
+ // if crossfade ends up larger than the length of the loop
+ // set it so it's exactly the same length, and if it
+ // is negative, set it to 0 length.
+ if (loopCrossFade > Math.abs(loopEnd - loopStart)) {
+ loopCrossFade = Math.abs(loopEnd - loopStart);
+ } else if (loopCrossFade < 0) {
+ loopCrossFade = 0;
+ }
+
+ float[] crossfadeFrame = new float[sample.getNumChannels()];
+ double crossPosition = -1;
+ double sampleLevel = 1;
+
+ // Calculate the position of the crossfade frame, and the sample level for the current position
+ // provided there is a set loopCrossFade value, for backwards or forwards loops
+ if (isLooping[i] && loopCrossFade > 0
+ && (loopType == LoopType.LOOP_FORWARDS
+ || loopType == LoopType.LOOP_BACKWARDS)) {
+ if (loopStart < loopEnd) {
+ // If current position is within the end segment of the loop
+ if (position > loopEnd - loopCrossFade / 2) {
+ // Set cross position to be the relative starting segment
+ // And set sample level to be relative decreasing (1 -> 0.5) for the end segment
+ crossPosition = loopStart - (loopEnd - position);
+ sampleLevel = 1 - Math.max(
+ Math.min(
+ ((position - (loopEnd - loopCrossFade / 2)) / loopCrossFade),
+ 0.5f),
+ 0);
+ // If current position is within the start segment of the loop
+ } else if (position < loopStart + loopCrossFade / 2) {
+ // Set cross position to be the relative ending segment
+ // And set sample level to be relative increasing (0.5 -> 1) for the start segment
+ crossPosition = loopEnd + (position - loopStart);
+ sampleLevel = Math.max(
+ Math.min(
+ ((position - (loopStart - loopCrossFade / 2)) / loopCrossFade),
+ 1),
+ 0.5f);
+ }
+ } else {
+ if (position < loopEnd + loopCrossFade / 2) {
+ crossPosition = loopStart + (position - loopEnd);
+ sampleLevel = 1 - Math.max(
+ Math.min(
+ (((loopEnd + loopCrossFade / 2) - position) / loopCrossFade),
+ 0.5f),
+ 0);
+ } else if (position > loopStart - loopCrossFade / 2) {
+ crossPosition = loopEnd - (loopStart - position);
+ sampleLevel = Math.max(
+ Math.min(
+ (((loopStart + loopCrossFade / 2) - position) / loopCrossFade),
+ 1),
+ 0.5f);
+ }
+ }
+ // Calculate crossfade frame and sample level for alternating loops
+ } else if (isLooping[i] && loopCrossFade > 0
+ && loopType == LoopType.LOOP_ALTERNATING) {
+ // Alternating loops only reach the end of the loop by going LOOP_FORWARD,
+ // and only reach the beginning of the loop by going LOOP_BACKWARD.
+
+ // If current position is within the end segment of the loop (LOOP_FORWARD)
+ if (position > loopEnd - loopCrossFade / 2) {
+ // Set cross position to be the relative starting segment for LOOP_BACKWARDS
+ // And set sample level to be relative decreasing (1 -> 0.5 forwards, 0.5 -> 1 backwards)
+ crossPosition = loopEnd + (loopEnd - position);
+ sampleLevel = 1 - Math.max(
+ Math.min(
+ ((position - (loopEnd - loopCrossFade / 2)) / loopCrossFade),
+ 0.5f),
+ 0);
+ // If current position is within the start segment of the loop (LOOP_BACKWARDS)
+ } else if (position < loopStart + loopCrossFade / 2) {
+ // Set cross position to be the relative ending segment for LOOP_FORWARDS
+ // And set sample level to be relative increasing (1 -> 0.5 backwards, 0.5 -> 1 forwards)
+ crossPosition = loopStart - (position - loopStart);
+ sampleLevel = Math.max(
+ Math.min(
+ ((position - (loopStart - loopCrossFade / 2)) / loopCrossFade),
+ 1),
+ 0.5f);
+ }
+ // Set isLooping once the first 'start segment' has played
+ // and we have reached the non crossfade section of the loop
+ } else if (!isLooping[i]){
+ if (loopStart < loopEnd &&
+ position > loopStart + loopCrossFade / 2) {
+ isLooping[i] = true;
+ } else if (loopEnd < loopStart &&
+ position < loopStart - loopCrossFade / 2) {
+ isLooping[i] = true;
+ }
+ }
+
+ // Reset crossfade position if it is not within the boundaries of loopStart - crossLength < p < loopStart
+ // or loopStart + crossLength > p > loopStart if LoopEnd < loopStart
+ if (crossPosition < (Math.min(loopStart, loopEnd) - loopCrossFade/2)
+ || crossPosition > (Math.max(loopStart, loopEnd) + loopCrossFade/2))
+ crossPosition = -1;
+ //----
+
+ // calculate the samples using position and crossPosition pointers.
+ // if either are out of bounds, getFrame() handles this by returning 0-filled array.
switch (interpolationType) {
case ADAPTIVE:
if (rate > ADAPTIVE_INTERP_HIGH_THRESH) {
sample.getFrameNoInterp(position, frame);
+ sample.getFrameNoInterp(crossPosition, crossfadeFrame);
} else if (rate > ADAPTIVE_INTERP_LOW_THRESH) {
sample.getFrameLinear(position, frame);
+ sample.getFrameLinear(crossPosition, crossfadeFrame);
} else {
sample.getFrameCubic(position, frame);
+ sample.getFrameCubic(crossPosition, crossfadeFrame);
}
break;
case LINEAR:
sample.getFrameLinear(position, frame);
+ sample.getFrameLinear(crossPosition, crossfadeFrame);
break;
case CUBIC:
sample.getFrameCubic(position, frame);
+ sample.getFrameCubic(crossPosition, crossfadeFrame);
break;
case NONE:
sample.getFrameNoInterp(position, frame);
+ sample.getFrameNoInterp(crossPosition, crossfadeFrame);
break;
}
+
+
for (int j = 0; j < outs; j++) {
- bufOut[j][i] = frame[j % sample.getNumChannels()];
- //TODO loop crossfades here?
+ bufOut[j][i] = (crossPosition != -1) ?
+ (float) sampleLevel * frame[j % sample.getNumChannels()]
+ + (float) (1 - sampleLevel) * crossfadeFrame[j % sample.getNumChannels()] :
+ (float) sampleLevel * frame[j % sample.getNumChannels()];
}
- // update the position, loop state, direction
- calculateNextPosition(i);
}
}
}
@@ -804,7 +954,7 @@ public boolean getKillOnEnd() {
* Called when at the end of the Sample, assuming the loop mode is
* non-looping, or beginning, if the SamplePlayer is playing backwards..
*/
- private void atEnd() {
+ protected void atEnd() {
if (endListener != null) {
endListener.message(this);
}
@@ -818,7 +968,7 @@ private void atEnd() {
* the end. This occurs when the SamplePlayer's position reaches then end
* when playing forwards in a non-looping mode, or reaches the the beginning
* when playing backwards in a non-looping mode. It is never triggered in a
- * looping mode. As an alternative, you can use the method {@link Bead.#setKillListener(Bead)} as long as {@link #setKillOnEnd(boolean)} is
+ * looping mode. As an alternative, you can use the method {@link Bead#setKillListener(Bead)} as long as {@link #setKillOnEnd(boolean)} is
* set to true. In other words, you set this SamplePlayer to kill itself
* when it reaches the end of the sample, and then use the functionality of
* {@link Bead}, which allows you to create a trigger whenever a Bead is
@@ -835,7 +985,7 @@ public void setEndListener(Bead endListener) {
/**
* Gets the current endListener.
*
- * @see {#setEndListener(Bead)}.
+ * //@see {@link #setEndListener(Bead)}
* @return the current endListener.
*/
public Bead getEndListener() {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/ScalingMixer.java b/src/beads_main/java/net/beadsproject/beads/ugens/ScalingMixer.java
similarity index 81%
rename from src/beads_main/net/beadsproject/beads/ugens/ScalingMixer.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/ScalingMixer.java
index 227db0b..3b07417 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/ScalingMixer.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/ScalingMixer.java
@@ -9,7 +9,6 @@
/**
* ScalingMixer scales the gain of the signal at each input by the number of {@link UGen}s connected to that input, passing the scaled signal to the corresponding output.
*
- * @beads.category effect
* @author ollie
*/
public class ScalingMixer extends UGen {
@@ -23,7 +22,15 @@ public class ScalingMixer extends UGen {
public ScalingMixer(AudioContext context) {
this(context, 1);
}
-
+
+ /**
+ * Instantiates a new ScalingMixer.
+ *
+ */
+ public ScalingMixer() {
+ this(getDefaultContext());
+ }
+
/**
* Instantiates a new ScalingMixer.
*
@@ -35,7 +42,17 @@ public ScalingMixer(AudioContext context) {
public ScalingMixer(AudioContext context, int inouts) {
super(context, inouts, inouts);
}
-
+
+ /**
+ * Instantiates a new ScalingMixer.
+ *
+ * @param inouts
+ * the number of inputs (= the number of outputs).
+ */
+ public ScalingMixer(int inouts) {
+ this(getDefaultContext(), inouts);
+ }
+
/* (non-Javadoc)
* @see com.olliebown.beads.core.UGen#calculateBuffer()
*/
diff --git a/src/beads_main/net/beadsproject/beads/ugens/SignalReporter.java b/src/beads_main/java/net/beadsproject/beads/ugens/SignalReporter.java
similarity index 81%
rename from src/beads_main/net/beadsproject/beads/ugens/SignalReporter.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/SignalReporter.java
index 7576871..f55da99 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/SignalReporter.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/SignalReporter.java
@@ -8,8 +8,7 @@
/**
* An easy way to monitor a signal; useful for debugging signal chains.
- *
- * @beads.category lowlevel
+ *
* @author Benito Crawford
* @version 0.9.3
*/
@@ -40,6 +39,20 @@ public SignalReporter(AudioContext context, float reportInterval,
context.out.addDependent(this);
}
+ /**
+ * Constructor for a SignalReporter that calls {@link #notify()} at the
+ * specified interval, with the specified name.
+ *
+ * @param reportInterval
+ * The interval between reports, in milliseconds.
+ * @param name
+ * The SignalReporter name (used in reports).
+ */
+ public SignalReporter(float reportInterval,
+ String name) {
+
+ this(getDefaultContext(), reportInterval, name);
+ }
/**
* Sets the report interval.
*
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Spatial.java b/src/beads_main/java/net/beadsproject/beads/ugens/Spatial.java
similarity index 90%
rename from src/beads_main/net/beadsproject/beads/ugens/Spatial.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Spatial.java
index ddae6ed..d7493cb 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Spatial.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Spatial.java
@@ -17,7 +17,7 @@
import net.beadsproject.beads.core.UGen;
/**
- * A mixer for a speaker config in any number of dimensions (we haven't tested D>3 yet).
+ * A mixer for a speaker config in any number of dimensions (we haven't tested D > 3 yet).
* Add sources (UGens) and control their locations using other UGens. Locations are changed on a per-channel basis,
* so that multichannel files can be located in the mixer independently.
*
@@ -32,8 +32,7 @@
* the x-axis follows the line joining 1 and 4
* the y-axis follows the line joining 1 and 2
* the z-axis follows the line joining 1 and 5
- *
- * @beads.category utilities
+ *
* @author ollie
*
*/
@@ -192,7 +191,17 @@ void mixInAudio(float[][] output) {
public Spatial(AudioContext context, int dimensions) {
this(context, dimensions, (float)Math.sqrt(dimensions));
}
-
+
+ /**
+ * Instantiates a new Spatial with given AudioContext and dimensions. The default speaker config for the dimensionality
+ * is used, and the default sphereDiameter (equal to Math.sqrt(dimensions)).
+ *
+ * @param dimensions the dimensions
+ */
+ public Spatial(int dimensions) {
+ this(getDefaultContext(), dimensions);
+ }
+
/**
* Instantiates a new Spatial with given AudioContext and sphereDiameter.
*
@@ -239,10 +248,20 @@ public Spatial(AudioContext context, int dimensions, float sphereDiameter) {
setup();
}
+ /**
+ * Instantiates a new Spatial with given AudioContext and sphereDiameter.
+ *
+ * @param dimensions the number of dimensions, between 1 and 3.
+ * @param sphereDiameter the sphere diameter.
+ */
+ public Spatial(int dimensions, float sphereDiameter) {
+ this(getDefaultContext(), dimensions, sphereDiameter);
+ }
+
/**
* Instantiates a new Spatial with given AudioContext, dimensions and locations. The locations array
* is an array of the form float[speakerNumber][dimension].
- *
+ *
* @param context the context.
* @param dimensions the dimensions.
* @param locations the locations.
@@ -250,11 +269,22 @@ public Spatial(AudioContext context, int dimensions, float sphereDiameter) {
public Spatial(AudioContext context, int dimensions, float[][] locations) {
this(context, dimensions, locations, (float)Math.sqrt(dimensions));
}
-
+
+ /**
+ * Instantiates a new Spatial with given AudioContext, dimensions and locations. The locations array
+ * is an array of the form float[speakerNumber][dimension].
+ *
+ * @param dimensions the dimensions.
+ * @param locations the locations.
+ */
+ public Spatial( int dimensions, float[][] locations) {
+ this(getDefaultContext(), dimensions, locations);
+ }
+
/**
* Instantiates a new Spatial with the given AudioContext, dimensions, locations and sphereDiamater. The locations array
* is an array of the form float[speakerNumber][dimension].
- *
+ *
* @param context the context
* @param dimensions the dimensions
* @param locations the locations
@@ -267,7 +297,19 @@ public Spatial(AudioContext context, int dimensions, float[][] locations, float
setSphereDiameter(sphereDiameter);
setup();
}
-
+
+ /**
+ * Instantiates a new Spatial with the given AudioContext, dimensions, locations and sphereDiamater. The locations array
+ * is an array of the form float[speakerNumber][dimension].
+ *
+ * @param dimensions the dimensions
+ * @param locations the locations
+ * @param sphereDiameter the sphere diameter
+ */
+ public Spatial(int dimensions, float[][] locations, float sphereDiameter) {
+ this(getDefaultContext(), dimensions, locations, sphereDiameter);
+ }
+
/**
* Setup.
*/
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Static.java b/src/beads_main/java/net/beadsproject/beads/ugens/Static.java
similarity index 95%
rename from src/beads_main/net/beadsproject/beads/ugens/Static.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Static.java
index bb5b670..cca6c0b 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Static.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Static.java
@@ -9,7 +9,6 @@
/**
* Static represents a {@link UGen} with a fixed value. Since the value is fixed, Static doesn't actually calculate anything, and overrides the methods {@link #getValue()} and {@link #getValue(int, int)} to return its fixed value.
*
- * @beads.category utilities
* @author ollie
*/
public class Static extends UGen {
@@ -33,6 +32,10 @@ public Static(AudioContext context, float x) {
pause(true); //might as well be muted
}
+ public Static(float x) {
+ this(getDefaultContext(), x);
+ }
+
/* (non-Javadoc)
* @see com.olliebown.beads.core.UGen#calculateBuffer()
*/
diff --git a/src/beads_main/net/beadsproject/beads/ugens/TapIn.java b/src/beads_main/java/net/beadsproject/beads/ugens/TapIn.java
similarity index 92%
rename from src/beads_main/net/beadsproject/beads/ugens/TapIn.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/TapIn.java
index 34042b1..cd9fc0b 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/TapIn.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/TapIn.java
@@ -11,8 +11,7 @@
/**
* TapIn stores and serves sound data. Can be used with TapOut to implement
* delays, etc.
- *
- * @beads.category effect
+ *
* @author ben
* @author Benito Crawford
* @version 0.9
@@ -42,6 +41,14 @@ public TapIn(AudioContext ac, float maxDelayInMS) {
counter = 0;
}
+ /**
+ * @param maxDelayInMS
+ * The size of the tapin memory buffer in milliseconds.
+ */
+ public TapIn(float maxDelayInMS) {
+ this(getDefaultContext(), maxDelayInMS);
+ }
+
public float getMaxDelayMS() {
return (float) context.samplesToMs(maxDelay);
}
diff --git a/src/beads_main/net/beadsproject/beads/ugens/TapOut.java b/src/beads_main/java/net/beadsproject/beads/ugens/TapOut.java
similarity index 72%
rename from src/beads_main/net/beadsproject/beads/ugens/TapOut.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/TapOut.java
index 5918e1d..588af40 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/TapOut.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/TapOut.java
@@ -12,8 +12,7 @@
* interpolation), and {@link #ALLPASS} (all-pass interpolation). Delay time is
* specified in milliseconds and can be set by either a static float value or a
* UGen.
- *
- * @beads.category effect
+ *
* @author ben
* @author Benito Crawford
* @version 0.9
@@ -42,7 +41,20 @@ public class TapOut extends UGen {
public static final InterpolationType ALLPASS = InterpolationType.ALLPASS;
public enum InterpolationType {
- NO_INTERP, LINEAR, ALLPASS
+ /**
+ * No Interpolation
+ */
+ NO_INTERP,
+
+ /**
+ * for linear interpolation
+ */
+ LINEAR,
+
+ /**
+ * all-pass interpolation
+ */
+ ALLPASS
}
protected TapOut(AudioContext ac, TapIn ti) {
@@ -69,6 +81,19 @@ public TapOut(AudioContext ac, TapIn ti, float delay) {
setDelay(delay);
}
+ /**
+ * Constructor for a given TapIn object with a static float delay. The mode
+ * is set to the default (no interpolation).
+ *
+ * @param ti
+ * The TapIn from which to draw the delayed signal.
+ * @param delay
+ * The delay time in milliseconds.
+ */
+ public TapOut(TapIn ti, float delay) {
+ this(getDefaultContext(), ti, delay);
+ }
+
/**
* Constructor for a given TapIn object with a delay time specified by a
* UGen. The mode is set to the default (no interpolation).
@@ -85,6 +110,19 @@ public TapOut(AudioContext ac, TapIn ti, UGen delayUGen) {
setDelay(delayUGen);
}
+ /**
+ * Constructor for a given TapIn object with a delay time specified by a
+ * UGen. The mode is set to the default (no interpolation).
+ *
+ * @param ti
+ * The TapIn from which to draw the delayed signal.
+ * @param delayUGen
+ * The UGen specifying the delay time in milliseconds.
+ */
+ public TapOut(TapIn ti, UGen delayUGen) {
+ this(getDefaultContext(), ti, delayUGen);
+ }
+
/**
* Constructor for a given TapIn object with a static float delay, using the
* specified delay mode.
@@ -103,6 +141,21 @@ public TapOut(AudioContext ac, TapIn ti, InterpolationType mode, float delay) {
setDelay(delay).setMode(mode);
}
+ /**
+ * Constructor for a given TapIn object with a static float delay, using the
+ * specified delay mode.
+ *
+ * @param ti
+ * The TapIn from which to draw the delayed signal.
+ * @param mode
+ * The delay mode; see {@link #setMode(InterpolationType)}.
+ * @param delay
+ * The delay time in milliseconds.
+ */
+ public TapOut(TapIn ti, InterpolationType mode, float delay) {
+ this(getDefaultContext(), ti, mode, delay);
+ }
+
/**
* Constructor for a given TapIn object with a delay time specified by a
* UGen, using the specified delay mode.
@@ -121,6 +174,21 @@ public TapOut(AudioContext ac, TapIn ti, InterpolationType mode, UGen delayUGen)
setDelay(delay).setMode(mode);
}
+ /**
+ * Constructor for a given TapIn object with a delay time specified by a
+ * UGen, using the specified delay mode.
+ *
+ * @param ti
+ * The TapIn from which to draw the delayed signal.
+ * @param mode
+ * The delay mode; see {@link #setMode(InterpolationType)}.
+ * @param delayUGen
+ * The UGen specifying the delay time in milliseconds.
+ */
+ public TapOut(TapIn ti, InterpolationType mode, UGen delayUGen) {
+ this(getDefaultContext(), ti, mode, delayUGen);
+ }
+
@Override
public void calculateBuffer() {
@@ -217,13 +285,7 @@ public UGen getDelayUGen() {
}
/**
- * Sets the delay mode. Use the following values:
- *
- *
- * - {@value #NO_INTERP} for no interpolation.
- * - {@value #LINEAR} for linear interpolation.
- * - {@value #ALLPASS} for all-pass interpolation.
- *
+ * Sets the delay mode as {@link InterpolationType}.
*
* @param mode
* The delay mode.
diff --git a/src/beads_main/net/beadsproject/beads/ugens/Throughput.java b/src/beads_main/java/net/beadsproject/beads/ugens/Throughput.java
similarity index 69%
rename from src/beads_main/net/beadsproject/beads/ugens/Throughput.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/Throughput.java
index e285e9f..750f9c0 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/Throughput.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/Throughput.java
@@ -27,6 +27,14 @@ public Throughput(AudioContext context) {
this(context, 1);
}
+ /**
+ * Constructor for a one-channel Throughput using the defualt audio
+ * context.
+ */
+ public Throughput() {
+ this(getDefaultContext());
+ }
+
/**
* Constructor for a Throughput with the specified number of channels, using
* the specified audio context.
@@ -42,6 +50,17 @@ public Throughput(AudioContext context, int channels) {
bufOut = bufIn;
}
+ /**
+ * Constructor for a Throughput with the specified number of channels, using
+ * the default audio context.
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public Throughput(int channels) {
+ this(getDefaultContext(), channels);
+ }
+
@Override
public void calculateBuffer() {
}
diff --git a/src/beads_main/net/beadsproject/beads/ugens/TrapezoidWave.java b/src/beads_main/java/net/beadsproject/beads/ugens/TrapezoidWave.java
similarity index 94%
rename from src/beads_main/net/beadsproject/beads/ugens/TrapezoidWave.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/TrapezoidWave.java
index 1bda27c..dd23608 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/TrapezoidWave.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/TrapezoidWave.java
@@ -44,6 +44,14 @@ public TrapezoidWave(AudioContext con) {
calcVals();
}
+ /**
+ * Constructor.
+ *
+ */
+ public TrapezoidWave() {
+ this(getDefaultContext());
+ }
+
@Override
public void calculateBuffer() {
float[] bo = bufOut[0];
diff --git a/src/beads_main/net/beadsproject/beads/ugens/WavePlayer.java b/src/beads_main/java/net/beadsproject/beads/ugens/WavePlayer.java
similarity index 91%
rename from src/beads_main/net/beadsproject/beads/ugens/WavePlayer.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/WavePlayer.java
index 867fd5e..a3fcdc9 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/WavePlayer.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/WavePlayer.java
@@ -23,8 +23,7 @@
* @see SineBuffer
* @see SawBuffer
* @see SquareBuffer
- *
- * @beads.category synth
+ *
* @author ollie
*/
public class WavePlayer extends UGen {
@@ -72,6 +71,20 @@ public WavePlayer(AudioContext context, UGen frequencyController,
setFrequency(frequencyController);
}
+ /**
+ * Instantiates a new WavePlayer with given frequency envelope and Buffer.
+ *
+ * @param frequencyController
+ * the frequency envelope.
+ * @param buffer
+ * the Buffer.
+ */
+ public WavePlayer(UGen frequencyController,
+ Buffer buffer) {
+ this(getDefaultContext(), frequencyController, buffer);
+
+ }
+
/**
* Instantiates a new WavePlayer with given static frequency and Buffer.
*
@@ -87,6 +100,18 @@ public WavePlayer(AudioContext context, float frequency, Buffer buffer) {
setFrequency(frequency);
}
+ /**
+ * Instantiates a new WavePlayer with given static frequency and Buffer.
+ *
+ * @param frequency
+ * the frequency in Hz.
+ * @param buffer
+ * the Buffer.
+ */
+ public WavePlayer(float frequency, Buffer buffer) {
+ this(getDefaultContext(), frequency, buffer);
+ }
+
/*
* (non-Javadoc)
*
diff --git a/src/beads_main/net/beadsproject/beads/ugens/WaveShaper.java b/src/beads_main/java/net/beadsproject/beads/ugens/WaveShaper.java
similarity index 85%
rename from src/beads_main/net/beadsproject/beads/ugens/WaveShaper.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/WaveShaper.java
index 2582941..987abe2 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/WaveShaper.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/WaveShaper.java
@@ -12,7 +12,6 @@
/**
* A simple wave-shaper. WaveShaper takes an incoming signal, maps it onto a
* stored wave shape, and outputs the result. For each sample it:
- *
*
* - Multiplies by the
preGain.
* - Clips between -1 and 1, and maps onto the stored wave shape, with linear
@@ -27,8 +26,7 @@
* This UGen is a {@link DataBeadReceiver}, so you can set its parameters with a
* DataBead.
*
- *
- * @beads.category synth
+ *
* @author Benito Crawford
* @version 0.9.5
*/
@@ -54,6 +52,15 @@ public WaveShaper(AudioContext context) {
this(context, 1);
}
+ /**
+ * Constructor for a mono-channel wave shaper that uses a default
+ * cosine-based wave shape.
+ *
+ */
+ public WaveShaper() {
+ this(getDefaultContext());
+ }
+
/**
* Constructor for a multi-channel wave shaper that uses a default
* cosine-based wave shape.
@@ -70,6 +77,17 @@ public WaveShaper(AudioContext context, int channels) {
setShape(generateCosineShape(1025));
}
+ /**
+ * Constructor for a multi-channel wave shaper that uses a default
+ * cosine-based wave shape.
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public WaveShaper(int channels) {
+ this(getDefaultContext(), channels);
+ }
+
/**
* Constructor for a mono-channel wave shaper that uses the provided float
* array for its wave shape.
@@ -84,6 +102,17 @@ public WaveShaper(AudioContext context, float[] shape) {
setShape(shape);
}
+ /**
+ * Constructor for a mono-channel wave shaper that uses the provided float
+ * array for its wave shape.
+ *
+ * @param shape
+ * The float array.
+ */
+ public WaveShaper(float[] shape) {
+ this(getDefaultContext(), shape);
+ }
+
/**
* Constructor for a multi-channel wave shaper that uses the provided float
* array for its wave shape.
@@ -100,6 +129,19 @@ public WaveShaper(AudioContext context, int channels, float[] shape) {
setShape(shape);
}
+ /**
+ * Constructor for a multi-channel wave shaper that uses the provided float
+ * array for its wave shape.
+ *
+ * @param channels
+ * The number of channels.
+ * @param shape
+ * The float array.
+ */
+ public WaveShaper(int channels, float[] shape) {
+ this(getDefaultContext(), channels, shape);
+ }
+
/**
* Constructor for a mono-channel wave shaperthat uses the float array from
* a Buffer for its wave shape.
@@ -114,6 +156,17 @@ public WaveShaper(AudioContext context, Buffer shapeBuffer) {
setShape(shapeBuffer.buf);
}
+ /**
+ * Constructor for a mono-channel wave shaperthat uses the float array from
+ * a Buffer for its wave shape.
+ *
+ * @param shapeBuffer
+ * The Buffer from which to get the wave shape.
+ */
+ public WaveShaper(Buffer shapeBuffer) {
+ this(getDefaultContext(), shapeBuffer);
+ }
+
/**
* Constructor for a multi-channel wave shaper that uses the float array
* from a Buffer for its wave shape.
@@ -130,6 +183,19 @@ public WaveShaper(AudioContext context, int channels, Buffer shapeBuffer) {
setShape(shapeBuffer.buf);
}
+ /**
+ * Constructor for a multi-channel wave shaper that uses the float array
+ * from a Buffer for its wave shape.
+ *
+ * @param channels
+ * The number of channels.
+ * @param shapeBuffer
+ * The Buffer from which to get the wave shape.
+ */
+ public WaveShaper(int channels, Buffer shapeBuffer) {
+ this(getDefaultContext(), channels, shapeBuffer);
+ }
+
/**
* Generates a nice cosine-based waveform in a float array that will provide
* a little warmth when used for wave-shaping.
diff --git a/src/beads_main/net/beadsproject/beads/ugens/ZMap.java b/src/beads_main/java/net/beadsproject/beads/ugens/ZMap.java
similarity index 90%
rename from src/beads_main/net/beadsproject/beads/ugens/ZMap.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/ZMap.java
index 04b9b0e..390e6b8 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/ZMap.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/ZMap.java
@@ -13,8 +13,7 @@
* controlled by specifying the ranges from and to which to map, or by
* specifying a multiplier and shift (addition) value. Optionally, the signal
* can be clipped to the specified range.
- *
- * @beads.category lowlevel
+ *
* @author Benito Crawford
* @version 0.9.5
*/
@@ -38,6 +37,16 @@ public ZMap(AudioContext context) {
this(context, 1);
}
+ /**
+ * Constructor for a 1-channel mapping object with default parameters
+ * (mapping [0,1] to [0,1] with no clipping, or multiplying by 1 and adding
+ * 0).
+ *
+ */
+ public ZMap() {
+ this(getDefaultContext());
+ }
+
/**
* Constructor for a mapping object with the specified number of channels
* and the default parameters (mapping [0,1] to [0,1] with no clipping, or
@@ -54,6 +63,18 @@ public ZMap(AudioContext context, int channels) {
clear();
}
+ /**
+ * Constructor for a mapping object with the specified number of channels
+ * and the default parameters (mapping [0,1] to [0,1] with no clipping, or
+ * multiplying by 1 and adding 0).
+ *
+ * @param channels
+ * The number of channels.
+ */
+ public ZMap(int channels) {
+ this(getDefaultContext(), channels);
+ }
+
@Override
public void calculateBuffer() {
for (int j = 0; j < channels; j++) {
diff --git a/src/beads_main/net/beadsproject/beads/ugens/ZeroCross.java b/src/beads_main/java/net/beadsproject/beads/ugens/ZeroCross.java
similarity index 81%
rename from src/beads_main/net/beadsproject/beads/ugens/ZeroCross.java
rename to src/beads_main/java/net/beadsproject/beads/ugens/ZeroCross.java
index 3c0aba1..3973fd8 100644
--- a/src/beads_main/net/beadsproject/beads/ugens/ZeroCross.java
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/ZeroCross.java
@@ -9,8 +9,7 @@
/**
* Counts and outputs as a signal the number of zero crossings in its input
* signal over a specified time frame.
- *
- * @beads.category lowlevel
+ *
* @author Benito Crawford
* @version 0.9.5
*/
@@ -35,6 +34,17 @@ public ZeroCross(AudioContext context, float memSizeInMS) {
cross = new boolean[memSize];
}
+ /**
+ * Constructor. The specified memory size indicates the time frame over
+ * which zero crossings are counted.
+ *
+ * @param memSizeInMS
+ * The time frame in milliseconds.
+ */
+ public ZeroCross(float memSizeInMS) {
+ this(getDefaultContext(), memSizeInMS);
+ }
+
@Override
public void calculateBuffer() {
diff --git a/src/beads_main/java/net/beadsproject/beads/ugens/package.html b/src/beads_main/java/net/beadsproject/beads/ugens/package.html
new file mode 100644
index 0000000..6653476
--- /dev/null
+++ b/src/beads_main/java/net/beadsproject/beads/ugens/package.html
@@ -0,0 +1,7 @@
+
+
+
+
+ Provides a set of useful UGens.
+
+
\ No newline at end of file
diff --git a/src/beads_main/net/beadsproject/beads/data/Pitch.java b/src/beads_main/net/beadsproject/beads/data/Pitch.java
deleted file mode 100644
index 51b8747..0000000
--- a/src/beads_main/net/beadsproject/beads/data/Pitch.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * This file is part of Beads. See http://www.beadsproject.net for all information.
- */
-package net.beadsproject.beads.data;
-
-/**
- * A set of static fields and utility methods associated with pitch.
- *
- * @beads.category data
- * @author ollie
- */
-public abstract class Pitch {
-
- /** The constant log(2) = 0.6931472. */
- public final static float LOG2 = 0.6931472f;
-
- /**
- * Convert frequency to MIDI note number.
- *
- * @param frequency
- * the required frequency.
- *
- * @return the resulting MIDI note number.
- */
- public static final float ftom(float frequency) {
- return Math.max(0f, (float)Math.log(frequency / 440.0f) / LOG2 * 12f + 69f);
- }
-
- /**
- * Convert MIDI note number to frequency.
- *
- * @param midi
- * the required MIDI note number.
- *
- * @return the resulting frequency.
- */
- public static final float mtof(float midi) {
- return 440.0f * (float)Math.pow(2.0f, (midi - 69f) / 12.0f);
- }
-
- /**
- * Takes a pitch and returns that pitch adjusted downwards to the nearest pitch in the given scale.
- *
- * @param pitch the pitch to modify.
- * @param scale the scale to use.
- * @param notesPerOctave how many notes in your octave (12 if you're not sure).
- * @return adjusted pitch.
- */
- public static final int forceToScale(int pitch, int[] scale, int notesPerOctave) {
- int pitchClass = pitch % notesPerOctave;
- int register = pitch / notesPerOctave;
- int newPitchClass = -1;
- for(int i = scale.length - 1; i >= 0; i--) {
- if(pitchClass >= scale[i]) {
- newPitchClass = scale[i];
- break;
- }
- }
- if(newPitchClass == -1) {
- newPitchClass = pitchClass;
- }
- return register * notesPerOctave + newPitchClass;
- }
-
- /**
- * Takes a pitch and returns that pitch adjusted downwards to the nearest pitch in the given scale. Assumes 12 pitches per octave.
- *
- * @param pitch the pitch to modify.
- * @param scale the scale to use.
- * @return adjusted pitch.
- */
- public static final int forceToScale(int pitch, int[] scale) {
- return forceToScale(pitch, scale, 12);
- }
-
- public static final float forceFrequencyToScale(float freq, int[] scale) {
- return mtof(forceToScale((int)ftom(freq), scale));
- }
-
- /** Pitch names for scale starting at C. */
- public static final String[] pitchNames = new String[]{"C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"};
-
- /** The dorian scale relative to root. */
- public static final int[] dorian = {0, 2, 3, 5, 7, 9, 10};
-
- /** The major scale relative to root. */
- public static final int[] major = {0, 2, 4, 5, 7, 9, 11};
-
- /** The minor scale relative to root. */
- public static final int[] minor = {0, 2, 3, 5, 7, 8, 10};
-
- /** The circle of fifths relative to root. */
- public static final int[] circleOfFifths = {0, 5, 10, 3, 8, 1, 6, 11, 4, 9, 2, 7};
-
- /** Pentatonic. */
- public static final int[] pentatonic = {0, 2, 4, 7, 9};
-
-}
diff --git a/packages/Beads/beads_tutorial/Lesson01_AudioContext.java b/src/beads_tutorial/java/Lesson01_AudioContext.java
similarity index 70%
rename from packages/Beads/beads_tutorial/Lesson01_AudioContext.java
rename to src/beads_tutorial/java/Lesson01_AudioContext.java
index 53a1806..b901baf 100644
--- a/packages/Beads/beads_tutorial/Lesson01_AudioContext.java
+++ b/src/beads_tutorial/java/Lesson01_AudioContext.java
@@ -19,6 +19,9 @@ public static void main(String[] args) {
* Beads project. You need it to define various things to do with audio
* processing. It also connects the the JavaSound system and provides
* you with an output device.
+ *
+ * UPDATE: As of Beads (v3.2), Default Audio Contexts (defaultcontext)
+ * can now be used. Please see below for more details.
*/
ac = new AudioContext();
/*
@@ -52,6 +55,19 @@ public static void main(String[] args) {
* Finally, start things running.
*/
ac.start();
+
+ /*
+ * UPDATE: As of Beads v3.2, all UGens have a shared default Audio
+ * Context in them that can be accessed through AudioContext.getDefaultContext().
+ * You will no longer need to explicitly create AudioContext ac and insert this
+ * when making new UGen objects. This defaultcontext will provide the same effects
+ * as creating a new AudioContext without any information. If you want to specify
+ * particular information such as the device or AudioIO you want to use, you will
+ * need to make your own AudioContext object for that, as shown in this lesson.
+ *
+ * Lesson02_EnvelopeAndWavePlayer onwards will instead be using the
+ * defaultcontext.
+ */
}
}
diff --git a/packages/Beads/beads_tutorial/Lesson02_EnvelopeAndWavePlayer.java b/src/beads_tutorial/java/Lesson02_EnvelopeAndWavePlayer.java
similarity index 56%
rename from packages/Beads/beads_tutorial/Lesson02_EnvelopeAndWavePlayer.java
rename to src/beads_tutorial/java/Lesson02_EnvelopeAndWavePlayer.java
index d4dfe09..732924a 100644
--- a/packages/Beads/beads_tutorial/Lesson02_EnvelopeAndWavePlayer.java
+++ b/src/beads_tutorial/java/Lesson02_EnvelopeAndWavePlayer.java
@@ -10,23 +10,33 @@
public class Lesson02_EnvelopeAndWavePlayer {
public static void main(String[] args) {
-
- AudioContext ac;
-
- ac = new AudioContext();
+
+ /*
+ * As we are using the defaultcontext, there is no longer
+ * a need to create an AudioContext object. For simplicity's sake,
+ * we'll just give the defaultcontext a local name, and access it
+ * it using 'ac'.
+ */
+ AudioContext ac = AudioContext.getDefaultContext();
+
/*
* This is an Envelope. It can be used to modify
* the behaviour of other UGen object. We need to
* do this to get precise control of certain parameters
* at an audio rate.
+ *
+ * When using defaultcontexts, we no longer need to pass
+ * in an explicit AudioContext when constructing new UGens.
+ * Note that if you use a custom AudioContext, you will need
+ * pass it into the constructor of each UGen.
*/
- Envelope freqEnv = new Envelope(ac, 500);
+ Envelope freqEnv = new Envelope(500);
/*
* This is a WavePlayer. Here we've set it up using
* the above Envelope, and a SineBuffer. We'll use
* the Envelope to modify the freqency below.
*/
- WavePlayer wp = new WavePlayer(ac, freqEnv, Buffer.SINE);
+ WavePlayer wp = new WavePlayer(freqEnv, Buffer.SINE);
/*
* So now that the WavePlayer is set up with the
* frequency Envelope, do stuff with the frequency
@@ -40,8 +50,14 @@ public static void main(String[] args) {
/*
* Connect it all together as before.
*/
- Gain g = new Gain(ac, 1, 0.1f);
+ Gain g = new Gain(1, 0.1f);
g.addInput(wp);
+
+ /*
+ * We will still need to attach all the UGens to the output
+ * of the defaultcontext and make it start running in order
+ * for audio to play. We can do this the same way as before.
+ */
ac.out.addInput(g);
ac.start();
diff --git a/packages/Beads/beads_tutorial/Lesson03_FMSynthesis.java b/src/beads_tutorial/java/Lesson03_FMSynthesis.java
similarity index 86%
rename from packages/Beads/beads_tutorial/Lesson03_FMSynthesis.java
rename to src/beads_tutorial/java/Lesson03_FMSynthesis.java
index 5790c3b..22175b8 100644
--- a/packages/Beads/beads_tutorial/Lesson03_FMSynthesis.java
+++ b/src/beads_tutorial/java/Lesson03_FMSynthesis.java
@@ -10,9 +10,8 @@
public class Lesson03_FMSynthesis {
public static void main(String[] args) {
- AudioContext ac;
+ AudioContext ac = AudioContext.getDefaultContext();
- ac = new AudioContext();
/*
* In the last example, we used an Envelope to
* control the frequency of a WavePlayer.
@@ -23,7 +22,7 @@ public static void main(String[] args) {
* Here's the modulating WavePlayer. It has a low
* frequency.
*/
- WavePlayer freqModulator = new WavePlayer(ac, 50, Buffer.SINE);
+ WavePlayer freqModulator = new WavePlayer(50, Buffer.SINE);
/*
* The next line might look outrageous if you're not
* experienced in Java. Basically we're defining a
@@ -43,12 +42,13 @@ public float calculate() {
* Now we plug in the function. Compare this to the previous
* example, where we plugged in an envelope.
*/
- WavePlayer wp = new WavePlayer(ac, function, Buffer.SINE);
+ WavePlayer wp = new WavePlayer(function, Buffer.SINE);
/*
* Connect it all together as before.
*/
- Gain g = new Gain(ac, 1, 0.1f);
+ Gain g = new Gain(1, 0.1f);
g.addInput(wp);
+
ac.out.addInput(g);
ac.start();
diff --git a/packages/Beads/beads_tutorial/Lesson04_SamplePlayer.java b/src/beads_tutorial/java/Lesson04_SamplePlayer.java
similarity index 70%
rename from packages/Beads/beads_tutorial/Lesson04_SamplePlayer.java
rename to src/beads_tutorial/java/Lesson04_SamplePlayer.java
index 4c3ee31..cc8fb41 100644
--- a/packages/Beads/beads_tutorial/Lesson04_SamplePlayer.java
+++ b/src/beads_tutorial/java/Lesson04_SamplePlayer.java
@@ -1,18 +1,20 @@
+import org.jaudiolibs.beads.AudioServerIO;
+
import net.beadsproject.beads.core.AudioContext;
import net.beadsproject.beads.data.SampleManager;
import net.beadsproject.beads.ugens.Gain;
import net.beadsproject.beads.ugens.SamplePlayer;
+import net.beadsproject.beads.ugens.SamplePlayer.EnvelopeType;
+import net.beadsproject.beads.ugens.SamplePlayer.LoopType;
+import net.beadsproject.beads.ugens.Static;
public class Lesson04_SamplePlayer {
public static void main(String[] args) {
-
- AudioContext ac;
-
- ac = new AudioContext();
+ AudioContext ac = AudioContext.getDefaultContext();
/*
* Here's how to play back a sample.
*
@@ -23,18 +25,17 @@ public static void main(String[] args) {
* keeps track of loaded audio files according to their file names, so
* you don't have to load them again.
*/
- String audioFile = "audio/1234.aif";
+ String audioFile = "audio/kick_back.wav";
// SampleManager.setBufferingRegime(Sample.Regime.newStreamingRegime(1000));
- SamplePlayer player = new SamplePlayer(ac, SampleManager
+ SamplePlayer player = new SamplePlayer(SampleManager
.sample(audioFile));
+
/*
* And as before...
*/
- Gain g = new Gain(ac, 2, 0.2f);
+ Gain g = new Gain(2, 0.2f);
g.addInput(player);
ac.out.addInput(g);
ac.start();
-
-
}
}
diff --git a/packages/Beads/beads_tutorial/Lesson05_Clock.java b/src/beads_tutorial/java/Lesson05_Clock.java
similarity index 88%
rename from packages/Beads/beads_tutorial/Lesson05_Clock.java
rename to src/beads_tutorial/java/Lesson05_Clock.java
index 9ed066e..62febe7 100644
--- a/packages/Beads/beads_tutorial/Lesson05_Clock.java
+++ b/src/beads_tutorial/java/Lesson05_Clock.java
@@ -8,10 +8,8 @@
public class Lesson05_Clock {
public static void main(String[] args) {
+ AudioContext ac = AudioContext.getDefaultContext();
- AudioContext ac;
-
- ac = new AudioContext();
/*
* A Clock is an unusual UGen because it doesn't
* have any outputs and because objects can listen
@@ -23,7 +21,7 @@ public static void main(String[] args) {
*
* So we begin with the envelope as before.
*/
- Envelope intervalEnvelope = new Envelope(ac, 1000);
+ Envelope intervalEnvelope = new Envelope(1000);
intervalEnvelope.addSegment(600, 10000);
intervalEnvelope.addSegment(1000, 10000);
intervalEnvelope.addSegment(400, 10000);
@@ -32,7 +30,7 @@ public static void main(String[] args) {
* Then the clock, which gets initialised with the
* envelope.
*/
- Clock clock = new Clock(ac, intervalEnvelope);
+ Clock clock = new Clock(intervalEnvelope);
/*
* Tell the clock to tick (you probably don't want
* to do this except for debugging.
diff --git a/packages/Beads/beads_tutorial/Lesson06_Trigger.java b/src/beads_tutorial/java/Lesson06_Trigger.java
similarity index 87%
rename from packages/Beads/beads_tutorial/Lesson06_Trigger.java
rename to src/beads_tutorial/java/Lesson06_Trigger.java
index 639577e..f77351d 100644
--- a/packages/Beads/beads_tutorial/Lesson06_Trigger.java
+++ b/src/beads_tutorial/java/Lesson06_Trigger.java
@@ -11,10 +11,8 @@
public class Lesson06_Trigger {
public static void main(String[] args) {
+ AudioContext ac = AudioContext.getDefaultContext();
- AudioContext ac;
-
- ac = new AudioContext();
/*
* How do you trigger events to happen in the future?
*
@@ -26,22 +24,22 @@ public static void main(String[] args) {
/*
* Here is the master gain object.
*/
- Gain masterGain = new Gain(ac, 1, 1);
+ Gain masterGain = new Gain(1, 1);
/*
* Now two things. Firstly, a WavePlayer with an Envelope controlling
* its frequency, connected to a Gain.
*/
- Envelope freqEnv = new Envelope(ac, 250);
- WavePlayer wp = new WavePlayer(ac, freqEnv, Buffer.SINE);
- Gain g1 = new Gain(ac, 1, 0.3f);
+ Envelope freqEnv = new Envelope(250);
+ WavePlayer wp = new WavePlayer(freqEnv, Buffer.SINE);
+ Gain g1 = new Gain(1, 0.3f);
g1.addInput(wp);
/*
* Secondly, just another WavePlayer connected to a Gain (no Envelope).
*/
- WavePlayer wp2 = new WavePlayer(ac, 255, Buffer.SQUARE);
- Gain g2 = new Gain(ac, 1, 0.1f);
+ WavePlayer wp2 = new WavePlayer(255, Buffer.SQUARE);
+ Gain g2 = new Gain(1, 0.1f);
g2.addInput(wp2);
/*
diff --git a/packages/Beads/beads_tutorial/Lesson07_Music.java b/src/beads_tutorial/java/Lesson07_Music.java
similarity index 82%
rename from packages/Beads/beads_tutorial/Lesson07_Music.java
rename to src/beads_tutorial/java/Lesson07_Music.java
index 21b708f..b21500c 100644
--- a/packages/Beads/beads_tutorial/Lesson07_Music.java
+++ b/src/beads_tutorial/java/Lesson07_Music.java
@@ -15,10 +15,8 @@
public class Lesson07_Music {
public static void main(String[] args) {
+ AudioContext ac = AudioContext.getDefaultContext();
- final AudioContext ac;
-
- ac = new AudioContext();
/*
* In this example a Clock is used to trigger events. We do this by
* adding a listener to the Clock (which is of type Bead).
@@ -29,7 +27,7 @@ public static void main(String[] args) {
* This example is more sophisticated than the previous ones. It uses
* nested code.
*/
- Clock clock = new Clock(ac, 700);
+ Clock clock = new Clock(700);
clock.addMessageListener(
//this is the on-the-fly bead
new Bead() {
@@ -42,8 +40,8 @@ public void messageReceived(Bead message) {
if(random(1) < 0.5) return;
pitch = Pitch.forceToScale((int)random(12), Pitch.dorian);
float freq = Pitch.mtof(pitch + (int)random(5) * 12 + 32);
- WavePlayer wp = new WavePlayer(ac, freq, Buffer.SINE);
- Gain g = new Gain(ac, 1, new Envelope(ac, 0));
+ WavePlayer wp = new WavePlayer(freq, Buffer.SINE);
+ Gain g = new Gain(1, new Envelope(0));
g.addInput(wp);
ac.out.addInput(g);
((Envelope)g.getGainUGen()).addSegment(0.1f, random(200));
@@ -54,20 +52,20 @@ public void messageReceived(Bead message) {
int pitchAlt = pitch;
if(random(1) < 0.2) pitchAlt = Pitch.forceToScale((int)random(12), Pitch.dorian) + (int)random(2) * 12;
float freq = Pitch.mtof(pitchAlt + 32);
- WavePlayer wp = new WavePlayer(ac, freq, Buffer.SQUARE);
- Gain g = new Gain(ac, 1, new Envelope(ac, 0));
+ WavePlayer wp = new WavePlayer(freq, Buffer.SQUARE);
+ Gain g = new Gain(1, new Envelope(0));
g.addInput(wp);
- Panner p = new Panner(ac, random(1));
+ Panner p = new Panner(random(1));
p.addInput(g);
ac.out.addInput(p);
((Envelope)g.getGainUGen()).addSegment(random(0.1), random(50));
((Envelope)g.getGainUGen()).addSegment(0, random(400), new KillTrigger(p));
}
if(c.getCount() % 4 == 0) {
- Noise n = new Noise(ac);
- Gain g = new Gain(ac, 1, new Envelope(ac, 0.05f));
+ Noise n = new Noise();
+ Gain g = new Gain(1, new Envelope(0.05f));
g.addInput(n);
- Panner p = new Panner(ac, random(0.5) + 0.5f);
+ Panner p = new Panner(random(0.5) + 0.5f);
p.addInput(g);
ac.out.addInput(p);
((Envelope)g.getGainUGen()).addSegment(0, random(100), new KillTrigger(p));
diff --git a/packages/Beads/beads_tutorial/Lesson08_Granulation.java b/src/beads_tutorial/java/Lesson08_Granulation.java
similarity index 82%
rename from packages/Beads/beads_tutorial/Lesson08_Granulation.java
rename to src/beads_tutorial/java/Lesson08_Granulation.java
index 592597d..cd87030 100644
--- a/packages/Beads/beads_tutorial/Lesson08_Granulation.java
+++ b/src/beads_tutorial/java/Lesson08_Granulation.java
@@ -1,5 +1,3 @@
-
-
import net.beadsproject.beads.core.AudioContext;
import net.beadsproject.beads.data.SampleManager;
import net.beadsproject.beads.ugens.Envelope;
@@ -10,17 +8,15 @@
public class Lesson08_Granulation {
public static void main(String[] args) {
+ AudioContext ac = AudioContext.getDefaultContext();
- AudioContext ac;
-
- ac = new AudioContext();
/*
* In lesson 4 we played back samples. This example is almost the same
* but uses GranularSamplePlayer instead of SamplePlayer. See some of
* the controls below.
*/
- String audioFile = "audio/1234.aif";
- GranularSamplePlayer player = new GranularSamplePlayer(ac,
+ String audioFile = "audio/kick_back.wav";
+ GranularSamplePlayer player = new GranularSamplePlayer(
SampleManager.sample(audioFile));
/*
* Have some fun with the controls.
@@ -31,11 +27,11 @@ public static void main(String[] args) {
player.getLoopEndUGen().setValue(
(float)SampleManager.sample(audioFile).getLength());
// control the rate of grain firing
- Envelope grainIntervalEnvelope = new Envelope(ac, 100);
+ Envelope grainIntervalEnvelope = new Envelope(100);
grainIntervalEnvelope.addSegment(20, 10000);
player.setGrainInterval(grainIntervalEnvelope);
// control the playback rate
- Envelope rateEnvelope = new Envelope(ac, 1);
+ Envelope rateEnvelope = new Envelope(1);
rateEnvelope.addSegment(1, 5000);
rateEnvelope.addSegment(0, 5000);
rateEnvelope.addSegment(0, 2000);
@@ -43,14 +39,15 @@ public static void main(String[] args) {
player.setRate(rateEnvelope);
// a bit of noise can be nice
player.getRandomnessUGen().setValue(0.01f);
+
/*
* And as before...
*/
- Gain g = new Gain(ac, 2, 0.2f);
+ Gain g = new Gain(2, 0.2f);
g.addInput(player);
ac.out.addInput(g);
ac.start();
}
-}
+}
\ No newline at end of file
diff --git a/packages/Beads/beads_tutorial/Lesson09_RecordToSample.java b/src/beads_tutorial/java/Lesson09_RecordToSample.java
similarity index 95%
rename from packages/Beads/beads_tutorial/Lesson09_RecordToSample.java
rename to src/beads_tutorial/java/Lesson09_RecordToSample.java
index ab5f22c..918f0b4 100644
--- a/packages/Beads/beads_tutorial/Lesson09_RecordToSample.java
+++ b/src/beads_tutorial/java/Lesson09_RecordToSample.java
@@ -20,6 +20,8 @@
*/
public class Lesson09_RecordToSample {
public static void main(String[] args) {
+ AudioContext ac = AudioContext.getDefaultContext();
+
/*
* This example shows how to save the audio an AudioContext generates to
* a file. You need two additional objects:
@@ -34,12 +36,11 @@ public static void main(String[] args) {
* chain that redirects the audio going through the chain into a
* buffer to be saved to a file later.
*/
- final AudioContext ac = new AudioContext();
// Create the Sample we'll use for our recording buffer
final Sample outputSample = new Sample(5000D);
// Create the RecordToSample we'll use to take the audio generated by
// the AudioContect and send it to the Sample.
- final RecordToSample recordToSample = new RecordToSample(ac,
+ final RecordToSample recordToSample = new RecordToSample(
outputSample, RecordToSample.Mode.INFINITE);
/*
@@ -55,7 +56,7 @@ public static void main(String[] args) {
* up a lot of memory, so you don't want to record any more audio than
* you actually intend to use.
*/
- Clock clock = new Clock(ac, 700);
+ Clock clock = new Clock(700);
clock.addMessageListener(
// this is the on-the-fly bead
new Bead() {
@@ -63,8 +64,8 @@ public void messageReceived(Bead message) {
Clock c = (Clock) message;
if (c.isBeat()) {
// Play a tone about once a second
- WavePlayer wp = new WavePlayer(ac, 660, Buffer.SQUARE);
- Gain g = new Gain(ac, 1, new Envelope(ac, 0));
+ WavePlayer wp = new WavePlayer(660, Buffer.SQUARE);
+ Gain g = new Gain(1, new Envelope(0));
g.addInput(wp);
ac.out.addInput(g);
((Envelope) g.getGainUGen()).addSegment(0.1f, 200);