diff options
Diffstat (limited to 'src/com/jsyn/data')
-rw-r--r-- | src/com/jsyn/data/FloatSample.java | 10 | ||||
-rw-r--r-- | src/com/jsyn/data/SequentialData.java | 14 | ||||
-rw-r--r-- | src/com/jsyn/data/SequentialDataCommon.java | 37 |
3 files changed, 43 insertions, 18 deletions
diff --git a/src/com/jsyn/data/FloatSample.java b/src/com/jsyn/data/FloatSample.java index 0855786..2d8c973 100644 --- a/src/com/jsyn/data/FloatSample.java +++ b/src/com/jsyn/data/FloatSample.java @@ -57,7 +57,7 @@ public class FloatSample extends AudioSample implements Function { } /** - * Create an silent sample with enough memory to hold the audio data. The number of sample + * Create a silent sample with enough memory to hold the audio data. The number of sample * numbers in the array will be numFrames*channelsPerFrame. * * @param numFrames number of sample groups. A stereo frame contains 2 samples. @@ -133,7 +133,10 @@ public class FloatSample extends AudioSample implements Function { buffer[index] = (float) value; } - /* + /** + * Interpolate between two adjacent samples. + * Note that this will only work for mono, single channel samples. + * * @param fractionalIndex must be >=0 and < (size-1) */ public double interpolate(double fractionalIndex) { @@ -144,6 +147,9 @@ public class FloatSample extends AudioSample implements Function { return ((target - source) * phase) + source; } + /** + * Note that this will only work for mono, single channel samples. + */ @Override public double evaluate(double input) { // Input ranges from -1 to +1 diff --git a/src/com/jsyn/data/SequentialData.java b/src/com/jsyn/data/SequentialData.java index c5ce2f0..0deb5c9 100644 --- a/src/com/jsyn/data/SequentialData.java +++ b/src/com/jsyn/data/SequentialData.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import com.jsyn.unitgen.VariableRateStereoReader; /** * Interface for objects that can be read and/or written by index. The index is not stored * internally so they can be shared by multiple readers. - * + * * @author Phil Burk (C) 2010 Mobileer Inc * @see FixedRateMonoReader * @see FixedRateStereoReader @@ -38,7 +38,7 @@ import com.jsyn.unitgen.VariableRateStereoReader; public interface SequentialData { /** * Write a value at the given index. - * + * * @param index sample index is ((frameIndex * channelsPerFrame) + channelIndex) * @param value the value to be written */ @@ -46,7 +46,7 @@ public interface SequentialData { /** * Read a value from the sample independently from the internal storage format. - * + * * @param index sample index is ((frameIndex * channelsPerFrame) + channelIndex) */ @@ -60,7 +60,7 @@ public interface SequentialData { /** * SustainEnd value is the frame index of the frame just past the end of the loop. The number of * frames included in the loop is (SustainEnd - SustainBegin). - * + * * @return End of sustain loop or -1 if no loop. */ public int getSustainEnd(); @@ -78,7 +78,7 @@ public interface SequentialData { /** * Get rate to play the data. In an envelope this correspond to the inverse of the frame * duration and would vary frame to frame. For an audio sample it is 1.0. - * + * * @param index * @param synthesisRate * @return rate to scale the playback speed. diff --git a/src/com/jsyn/data/SequentialDataCommon.java b/src/com/jsyn/data/SequentialDataCommon.java index 190cd92..5cc51df 100644 --- a/src/com/jsyn/data/SequentialDataCommon.java +++ b/src/com/jsyn/data/SequentialDataCommon.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +18,7 @@ package com.jsyn.data; /** * Abstract base class for envelopes and samples that adds sustain and release loops. - * + * * @author Phil Burk (C) 2010 Mobileer Inc */ public abstract class SequentialDataCommon implements SequentialData { @@ -85,28 +85,47 @@ public abstract class SequentialDataCommon implements SequentialData { return this.releaseEnd; } + /** + * Set beginning of a sustain loop. When UnitDataQueuePort.queueOn() is called, + * if the loop is set then the attack portion will be queued followed by this sustain + * region using queueLoop(). + * The number of frames in the loop will be (SustainEnd - SustainBegin). + * <p> + * For a steady sustain level, like in an ADSR envelope, set SustainBegin and + * SustainEnd to the same frame. + * <p> + * For a sustain that is modulated, include two or more frames in the loop. + * + * @param sustainBegin + */ public void setSustainBegin(int sustainBegin) { this.sustainBegin = sustainBegin; } /** - * SustainEnd value is the frame index of the frame just past the end of the loop. The number of - * frames included in the loop is (SustainEnd - SustainBegin). - * + * SustainEnd value is the frame index of the frame just past the end of the loop. + * The number of frames included in the loop is (SustainEnd - SustainBegin). + * * @param sustainEnd */ public void setSustainEnd(int sustainEnd) { this.sustainEnd = sustainEnd; } + /** + * The release loop behaves like the sustain loop but it is triggered + * by UnitDataQueuePort.queueOff(). + * + * @param releaseBegin + */ public void setReleaseBegin(int releaseBegin) { this.releaseBegin = releaseBegin; } /** - * ReleaseEnd value is the frame index of the frame just past the end of the loop. The number of - * frames included in the loop is (ReleaseEnd - ReleaseBegin). - * + * ReleaseEnd value is the frame index of the frame just past the end of the loop. + * The number of frames included in the loop is (ReleaseEnd - ReleaseBegin). + * * @param releaseEnd */ |