Jamoma API  0.6.0.a19
TTSoundfileLoader.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspSoundFileLib
4  *
5  * @brief Loads soundfile data into a sample matrix
6  *
7  * @details This object collaborates with #TTSampleMatrix to load values from a sound file into the sample matrix. An extension of the #TTSoundfile object.
8  *
9  * @see TTSampleMatrix
10  *
11  * @authors Nathan Wolek
12  *
13  * @copyright Copyright © 2013 by Nathan Wolek @n
14  * This code is licensed under the terms of the "New BSD License" @n
15  * http://creativecommons.org/licenses/BSD/
16  */
17 
18 #ifndef __TT_SOUNDFILELOADER_H__
19 #define __TT_SOUNDFILELOADER_H__
20 
21 #include "TTDSP.h"
22 #include "TTSoundfile.h"
23 #include "TTSampleMatrix.h"
24 
25 /** Creates an interface to data in a soundfile from disk */
28 
29 protected:
30  TTSampleMatrixPtr mTargetMatrix;
31  TTRowID mTargetMatrixLengthInSamples;
32  TTColumnID mTargetMatrixNumChannels;
33  TTFloat64 mTargetMatrixSampleRate;
34  TTRowID mStartCopyAtSampleIndex;
35  TTRowID mEndCopyAtSampleIndex;
36  TTColumnID mCopyFromChannelIndex;
37 
38  /** Internal method that sets the class's pointer to the target sample matrix for loading sound file data.
39  @param newTargetMatrix pointer to the new matrix
40  @return TTErr kTTErrNone if the pointer was updated.
41  */
42  TTErr setTargetMatrix(const TTMatrix newTargetMatrix);
43 
44  /** Internal method that sets the class's pointer to the target sample matrix for loading sound file data. This version is a function overload so that setTargetMatrix() can accept a TTObjectBase* as an input parameter and test whether it points to an actual instance of TTSampleMatrix.
45  @param newTargetMatrix pointer to the new matrix
46  @return TTErr kTTErrNone if the pointer was updated. kTTErrInvalidValue if the pointer was not to a TTSampleMatrix.
47  */
48  TTErr setTargetMatrix(const TTObjectBase* newTargetObjectPtr);
49 
50  /** Internal method that copies values from the source TTSoundfile to the targetted TTSampleMatrix. Beware that the setFilePath() and setTargetMatrix() must be successfully executed before this method is called.
51  @return TTErr kTTErrNone if copy is successful. kTTErrGeneric if the source soundfile was too short to fill samplematrix.
52  */
54 
55  /** Internal method that copies values from the source TTSoundfile to the targetted TTSampleMatrix with the necessary interpolation to acheive the target's sample rate. Beware that the setFilePath() and setTargetMatrix() must be successfully executed before this method is called.
56  @return TTErr kTTErrNone if copy is successful. kTTErrGeneric if the source soundfile was too short to fill samplematrix.
57  */
59 
60 public:
61  /** Atribute accessor. Send a filepath to the object and attempt to interface with the file. Overriding so that additional variable will be set when setting the filepath.
62  @param newValue full POSIX path to the file, including file name
63  @return TTErr kTTErrInvalidValue is the filepath is invalid, otherwise kTTErrNone
64  */
65  TTErr setFilePath(const TTValue& newValue);
66 
67  /** Public method used to trigger the load process. Copies samples from a sound file on the hard drive into a TTSampleMatrix.
68  @param[in] input Multi-item TTValue used to set the copy parameters:
69  -# TTObjectBasePtr to the target matrix
70  -# TTSymbol containing the filepath
71  -# (optional) channel to copy from source, default is 0
72  -# (optional) frame to start copy from source, default is 0
73  -# (optional) frame to stop copy from source, default is last
74  @param[out] unusedOutput not used
75  @return TTErr kTTErrNone load was successful. kTTErrInvalidFilepath if the filepath was invalid. kTTErrInvalidValue if the pointer to TTSampleMatrix was invalid.
76  */
77  TTErr load(const TTValue& input, TTValue& unusedOutput);
78 
79  /** Public method similar to load(), except that it will resize the target matrix to match the source soundfile before copying values.
80  @param[in] input Multi-item TTValue used to set the copy parameters:
81  -# TTObjectBasePtr to the target matrix
82  -# TTSymbol containing the filepath
83  @param[out] unusedOutput not used
84  @return TTErr kTTErrNone load was successful. kTTErrInvalidFilepath if the filepath was invalid. kTTErrInvalidValue if the pointer to TTSampleMatrix was invalid.
85  */
86  TTErr resizeThenLoad(const TTValue& input, TTValue& unusedOutput);
87 
88  /** Unit test for this object.
89  @param[out] returnedTestInfo The outcome from the performed unit test.
90  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
91  */
92  virtual TTErr test(TTValue& returnedTestInfo);
93 
94 };
95 
97 
98 #endif /* defined(__TT_SOUNDFILELOADER_H__) */
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...
Creates an interface to data in a soundfile from disk.
TTInt32 TTColumnID
Datatype for any number used to indicate a column index within the matrix.
Definition: TTBase.h:216
TTErr copyUntilFilled()
Internal method that copies values from the source TTSoundfile to the targetted TTSampleMatrix.
TTSampleMatrix holds some audio in a chunk of memory.
Base class for all first-class Jamoma objects.
Definition: TTObjectBase.h:109
TTInt32 TTRowID
Datatype for any number used to indicate a row index within a matrix.
Definition: TTBase.h:207
Jamoma DSP Library.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
Container object that holds some audio in a chunk of memory.
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
TTErr setFilePath(const TTValue &newValue)
Atribute accessor.
Wrap TTMatrixBase instances.
Definition: TTMatrix.h:27
virtual TTErr test(TTValue &returnedTestInfo)
Unit test for this object.
Provides a common interface to soundfile data.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
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.
Definition: TTSoundfile.h:30
TTErr setTargetMatrix(const TTMatrix newTargetMatrix)
Internal method that sets the class's pointer to the target sample matrix for loading sound file data...
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34