Skip to content

Commit

Permalink
first draft of the SampleBundle.at() function. issue #70
Browse files Browse the repository at this point in the history
  • Loading branch information
nwolek committed Jan 2, 2016
1 parent f4ca9f8 commit d9f2022
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/core/JamomaSample.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,25 @@ namespace Jamoma {
{
return const_cast<SampleBundle*>(this)->mChannels[index];
}


/** Interpolate a value between known Samples.
*/
Sample at(size_t channel, double interpolatedFrameIndex) {
Sample output = 0.0;
Jamoma::Interpolator::Linear<Sample> my_interp;

int frameIndexBefore = (int)interpolatedFrameIndex;
double delta = interpolatedFrameIndex - frameIndexBefore;
int frameIndexAfter = frameIndexBefore + 1;

Sample sampleAtIndexBefore = mChannels[channel][frameIndexBefore];
Sample sampleAtIndexAfter = mChannels[channel][frameIndexAfter];

output = my_interp(sampleAtIndexBefore,sampleAtIndexAfter,delta);

return output;
}


/** Change the channel count of the bundle.
Expand Down

0 comments on commit d9f2022

Please sign in to comment.