I have already begun work on this. Creating a new issue for tracking and so that I can cleanly turn this into a separate pull request. These functions would help resolve some of the specific concerns that are related to interpolation in a periodic wavetable (raised as part of issue #5 and pull https://github.com/jamoma/jamoma2/pull/81).
By adding samples as padding to the beginning and ended of the wavetable, we can better interpolate between the first and last sample without having to introduce branching to stay within the bounds of the SampleBundle. Since the implementations are likely to be so similar, resolving this issue should introduce and test two type of padding:
copying samples from beginning to end, as well as end to beginning
adding samples with a value of zero (which was called for in issue #44)
A few notes on the features needed:
Since this is happening at the SampleBundle level, the unit of measuring padding is technically a frame.
We will need to introduce a private member to track the number of frames added (for now mPaddingAmount).
It should be the responsibility of the object accessing the SampleBundle to use this info or ignore it. Typically it would be the same object that added the padding, so it would be logical for the object to maintain the chain of responsibility.
The same amount of frames should always be added to the beginning and ending of the SampleBundle.
mPaddingAmount should represent the number of frames at one end, not the total from both ends.
This is likely a situation where the ImmutableSampleBundle will be useful. The Oscillator object should prep the SampleBundle by generating the waveshape, adding the padding and whatever else needs to be done, then make the thing immutable/const.
Happy to receive feedback from others, including calls for clarification in the above notes.
I have already begun work on this. Creating a new issue for tracking and so that I can cleanly turn this into a separate pull request. These functions would help resolve some of the specific concerns that are related to interpolation in a periodic wavetable (raised as part of issue #5 and pull https://github.com/jamoma/jamoma2/pull/81).
By adding samples as padding to the beginning and ended of the wavetable, we can better interpolate between the first and last sample without having to introduce branching to stay within the bounds of the
SampleBundle
. Since the implementations are likely to be so similar, resolving this issue should introduce and test two type of padding:A few notes on the features needed:
SampleBundle
level, the unit of measuring padding is technically a frame.mPaddingAmount
).SampleBundle
to use this info or ignore it. Typically it would be the same object that added the padding, so it would be logical for the object to maintain the chain of responsibility.SampleBundle
.mPaddingAmount
should represent the number of frames at one end, not the total from both ends.ImmutableSampleBundle
will be useful. TheOscillator
object should prep theSampleBundle
by generating the waveshape, adding the padding and whatever else needs to be done, then make the thing immutable/const.Happy to receive feedback from others, including calls for clarification in the above notes.