20 #define thisTTClass TTSoundfileLoader
21 #define thisTTClassName "soundfile.loader"
22 #define thisTTClassTags "dspSoundFileLib, audio, soundfile, buffer"
30 extern "C" void TTSoundfileLoader::registerClass()
32 TTClassRegister(thisTTClassName, thisTTClassTags, TTSoundfileLoader::instantiate);
36 TTSoundfileLoader::TTSoundfileLoader(
const TTValue& arguments) :
40 this->mTargetMatrixLengthInSamples = 0;
41 this->mTargetMatrixNumChannels = 0;
42 this->mTargetMatrixSampleRate = 0.;
43 this->mStartCopyAtSampleIndex = 0;
44 this->mEndCopyAtSampleIndex = 0;
45 this->mCopyFromChannelIndex = 0;
54 TTSoundfileLoader::~TTSoundfileLoader()
65 mTargetMatrixLengthInSamples = newTargetMatrix.
getRowCount();
67 newTargetMatrix.
get(
"sampleRate", mTargetMatrixSampleRate);
77 if (newTargetObjectPtr->
getName() !=
TT(
"samplematrix"))
93 if ((mEndCopyAtSampleIndex - mStartCopyAtSampleIndex) < mTargetMatrixLengthInSamples)
105 numChannelsToCopy = std::min(numChannelsToCopy, (this->
getNumChannels() - mCopyFromChannelIndex));
108 for (
TTRowID sample=0;sample<mTargetMatrixLengthInSamples;sample++)
110 for (
TTColumnID channel=0; channel<numChannelsToCopy; channel++)
113 this->
peek( (sample + mStartCopyAtSampleIndex),
114 (channel + mCopyFromChannelIndex),
118 mTargetMatrix->poke( sample,
137 if (((mEndCopyAtSampleIndex - mStartCopyAtSampleIndex) * sourceToTargetFactor) < mTargetMatrixLengthInSamples)
150 numChannelsToCopy = std::min(numChannelsToCopy, (this->
getNumChannels() - mCopyFromChannelIndex));
154 targetIndex<mTargetMatrixLengthInSamples;
158 sourceFloatIndex = mStartCopyAtSampleIndex +
159 (targetIndex * targetToSourceFactor);
161 for (
TTColumnID channel=0; channel<numChannelsToCopy; channel++)
164 this->
peeki( sourceFloatIndex,
165 (channel + mCopyFromChannelIndex),
169 mTargetMatrix->poke( targetIndex,
185 this->mStartCopyAtSampleIndex = 0;
190 this->mEndCopyAtSampleIndex = 0;
192 this->mCopyFromChannelIndex = 0;
202 TTMatrix newTargetMatrix = input[0];
217 if (input.
size() > 2) mCopyFromChannelIndex = input[2];
218 if (input.
size() > 3) mStartCopyAtSampleIndex = input[3];
219 if (input.
size() > 4) mEndCopyAtSampleIndex = input[4];
225 TTBoolean sameSampleRate = TTTestFloatEquivalence(mTargetMatrixSampleRate, this->
mSampleRate,
true, 0.0000001);
246 TTMatrix newTargetMatrix = input[0];
271 TTBoolean sameSampleRate = TTTestFloatEquivalence(mTargetMatrixSampleRate, this->
mSampleRate,
true, 0.0000001);
TTErr load(const TTValue &input, TTValue &unusedOutput)
Public method used to trigger the load process.
TTErr copyUntilFilledWithResampling()
Internal method that copies values from the source TTSoundfile to the targetted TTSampleMatrix with t...
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
An inappropriate value was specified for an attribute or variable.
Creates an interface to data in a soundfile from disk.
TTRowID getLengthInSamples()
Simple data accessor.
TTFloat64 mSampleRate
samples per second
TTSymbol getName() const
Return the name of this class.
size_type size() const noexcept
Return the number of elements.
TTInt32 TTColumnID
Datatype for any number used to indicate a column index within the matrix.
TTErr copyUntilFilled()
Internal method that copies values from the source TTSoundfile to the targetted TTSampleMatrix.
TTErr peek(const TTRowID frame, const TTColumnID channel, TTSampleValue &value)
Get the value stored at a specified frame and channel.
TTMatrixBase * instance() const
Get a pointer to the wrapped TTMatrixBase instance.
Base class for all first-class Jamoma objects.
TTInt32 TTRowID
Datatype for any number used to indicate a row index within a matrix.
TTErr setAttributeValue(const TTSymbol name, TTValue &value)
Set an attribute value for an object.
double TTFloat64
64 bit floating point number
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Container object that holds some audio in a chunk of memory.
TTRowID getRowCount() const
Number of rows in the matrix.
void * TTPtr
A generic pointer.
TTErr get(const TTSymbol aName, T &aReturnedValue) const
Get an attribute value for an object.
TTColumnID getColumnCount() const
Number of columns in the matrix.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
TTColumnID getNumChannels()
Simple data accessor.
#define addMessageWithArguments(name)
A convenience macro to be used by subclasses for registering messages.
TTErr setFilePath(const TTValue &newValue)
Atribute accessor.
Wrap TTMatrixBase instances.
Something went wrong, but what exactly is not known. Typically used for context-specific problems...
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
std::uint32_t TTUInt32
32 bit unsigned integer
TTFloat64 getLengthInSeconds()
Simple data accessor.
TTErr resizeThenLoad(const TTValue &input, TTValue &unusedOutput)
Public method similar to load(), except that it will resize the target matrix to match the source sou...
Creates an interface to data in a soundfile from disk.
TTErr setFilePath(const TTValue &newValue)
Atribute accessor.
TTErr peeki(const TTFloat64 frame, const TTColumnID channel, TTSampleValue &value)
Interpolate a value using a floating-point frame and integer channel.
TTErr setTargetMatrix(const TTMatrix newTargetMatrix)
Internal method that sets the class's pointer to the target sample matrix for loading sound file data...
TTFloat64 TTSampleValue
A value representing a single audio sample.
[doxygenAppendixC_copyExample]
Loads soundfile data into a sample matrix.