Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:jamoma/JamomaCore into dev
- Loading branch information
Showing
23 changed files
with
2,626 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env ruby -wKU | ||
# encoding: utf-8 | ||
|
||
require 'Jamoma' | ||
|
||
environment = TTObject.new "environment" | ||
environment.set "benchmarking", 1 | ||
|
||
o = TTAudio.new "soundfile", 1 | ||
o.send "test" | ||
|
||
err, cpu = o.send "getProcessingBenchmark", 1 | ||
|
||
puts | ||
puts "time spent calculating audio process method: #{cpu} µs" | ||
puts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env ruby -wKU | ||
# encoding: utf-8 | ||
|
||
require 'Jamoma' | ||
|
||
environment = TTObject.new "environment" | ||
environment.set "benchmarking", 1 | ||
|
||
o = TTAudio.new "soundfile.loader", 1 | ||
o.send "test" | ||
|
||
err, cpu = o.send "getProcessingBenchmark", 1 | ||
|
||
puts | ||
puts "time spent calculating audio process method: #{cpu} µs" | ||
puts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,073 changes: 1,073 additions & 0 deletions
1,073
DSP/extensions/SoundfileLib/SoundfileLibIOS.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/** @file | ||
* | ||
* @ingroup dspSoundFileLib | ||
* | ||
* @brief Provides a common interface to soundfile data | ||
* | ||
* @details This object provides a common set of attributes and methods for working with soundfiles at a specific filepath. | ||
* This allows us to access metadata and copy values in a common way without duplicating code. As with the rest of the | ||
* SoundfileLib, it relies on the third-party <a href="http://www.mega-nerd.com/libsndfile/">libsndfile library</a>.@n | ||
* Be aware that attributes and metadata are cached when the setFilePath method is called in order to provide efficiency, but this may lead to problems if the file somehow changes after the method call. | ||
* | ||
* @authors Nathan Wolek | ||
* | ||
* @copyright Copyright © 2013 by Nathan Wolek @n | ||
* This code is licensed under the terms of the "New BSD License" @n | ||
* http://creativecommons.org/licenses/BSD/ | ||
*/ | ||
|
||
#ifndef __TT_SOUNDFILE_H__ | ||
#define __TT_SOUNDFILE_H__ | ||
|
||
#include "TTDSP.h" | ||
|
||
#ifdef uint | ||
#undef uint | ||
#endif | ||
#include "../libsndfile/sndfile.h" | ||
|
||
/** Creates an interface to data in a soundfile from disk */ | ||
class TTSoundfile : public TTAudioObjectBase { | ||
TTCLASS_SETUP(TTSoundfile) | ||
|
||
protected: | ||
TTSymbol mFilePath; ///< full POSIX path to the file, including file name | ||
TTColumnID mNumChannels; ///< channels in the file | ||
TTFloat64 mSampleRate; ///< samples per second | ||
TTRowID mLengthInSamples; ///< length in samples | ||
TTFloat64 mLengthInSeconds; ///< length in seconds | ||
TTSymbol mTitle; ///< title if metadata is present in the file | ||
TTSymbol mArtist; ///< artist if metadata is present in the file | ||
TTSymbol mDate; ///< date if metadata is present in the file | ||
TTSymbol mAnnotation; ///< comments if metadata is present in the file | ||
|
||
private: | ||
SNDFILE* mSoundFile; ///< libsndfile handle for the actual file we open | ||
SF_INFO mSoundFileInfo; ///< libsndfile metadata for the file we open | ||
|
||
public: | ||
/** Atribute accessor. Send a filepath to the object and attempt to interface with the file. | ||
@param newValue full POSIX path to the file, including file name | ||
@return TTErr kTTErrInvalidValue is the filepath is invalid, otherwise kTTErrNone | ||
*/ | ||
TTErr setFilePath(const TTValue& newValue); | ||
|
||
/** Simple data accessor. | ||
@return TTColumnID the number of channels in mSoundFile at mFilePath */ | ||
TTColumnID getNumChannels() | ||
{ | ||
return mNumChannels; | ||
}; | ||
|
||
/** Simple data accessor. | ||
@return TTFloat64 samples per second of mSoundFile at mFilePath */ | ||
TTFloat64 getSampleRate() | ||
{ | ||
return mSampleRate; | ||
}; | ||
|
||
/** Simple data accessor. | ||
@return TTRowID the number of frames in mSoundFile at mFilePath */ | ||
TTRowID getLengthInSamples() | ||
{ | ||
return mLengthInSamples; | ||
}; | ||
|
||
/** Simple data accessor. | ||
@return TTFloat64 duration in second of mSoundFile at mFilePath */ | ||
TTFloat64 getLengthInSeconds() | ||
{ | ||
return mLengthInSeconds; | ||
}; | ||
|
||
/** Simple data accessor. | ||
@return TTSymbol title pulled from the mSoundFile's metadata */ | ||
TTSymbol getTitle() | ||
{ | ||
return mTitle; | ||
}; | ||
|
||
/** Simple data accessor. | ||
@return TTSymbol artist pulled from the mSoundFile's metadata */ | ||
TTSymbol getArtist() | ||
{ | ||
return mArtist; | ||
}; | ||
|
||
/** Simple data accessor. | ||
@return TTSymbol date pulled from the mSoundFile's metadata */ | ||
TTSymbol getDate() | ||
{ | ||
return mDate; | ||
}; | ||
|
||
/** Simple data accessor. | ||
@return TTSymbol comments pulled from the mSoundFile's metadata */ | ||
TTSymbol getAnnotation() | ||
{ | ||
return mAnnotation; | ||
}; | ||
|
||
/** Get the value stored at a specified frame and channel. Modelled after the method found in #TTSampleMatrix. Note that both channels and samples use zero indexing. There is currently no boundary checking implemented. | ||
@param[in] frame index of sample as count from the beginning of file. first sample = 0. | ||
@param[in] channel channel within multichannel file. | ||
@param[out] value used to return the value pulled from sound file. | ||
@return TTErr returns kTTErrNone until futher notice | ||
*/ | ||
TTErr peek(const TTRowID frame, const TTColumnID channel, TTSampleValue& value); | ||
|
||
/** Interpolate a value using a floating-point frame and integer channel. Modelled after the method found in #TTSampleMatrix. Note that both channels and samples use zero indexing. There is currently no boundary checking implemented. | ||
@param[in] frame index of sample as count from the beginning of file. first sample = 0. | ||
@param[in] channel channel within multichannel file. | ||
@param[out] value used to return the value pulled from sound file. | ||
@return TTErr returns kTTErrNone until futher notice | ||
*/ | ||
TTErr peeki(const TTFloat64 frame, const TTColumnID channel, TTSampleValue& value); | ||
|
||
/** Unit test for this object. | ||
@param[out] returnedTestInfo The outcome from the performed unit test. | ||
@return #TTErr error code if the method fails to execute, else #kTTErrNone. | ||
*/ | ||
virtual TTErr test(TTValue& returnedTestInfo); | ||
|
||
}; | ||
|
||
typedef TTSoundfile* TTSoundfilePtr; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** @file | ||
* | ||
* @ingroup dspSoundFileLib | ||
* | ||
* @brief Loads soundfile data into a sample matrix | ||
* | ||
* @details This object collaborates with #TTSampleMatrix to load values from a sound file into the sample matrix. An extension of the #TTSoundfile object. | ||
* | ||
* @see TTSampleMatrix | ||
* | ||
* @authors Nathan Wolek | ||
* | ||
* @copyright Copyright © 2013 by Nathan Wolek @n | ||
* This code is licensed under the terms of the "New BSD License" @n | ||
* http://creativecommons.org/licenses/BSD/ | ||
*/ | ||
|
||
#ifndef __TT_SOUNDFILELOADER_H__ | ||
#define __TT_SOUNDFILELOADER_H__ | ||
|
||
#include "TTDSP.h" | ||
#include "TTSoundfile.h" | ||
#include "TTSampleMatrix.h" | ||
|
||
/** Creates an interface to data in a soundfile from disk */ | ||
class TTSoundfileLoader : public TTSoundfile { | ||
TTCLASS_SETUP(TTSoundfileLoader) | ||
|
||
protected: | ||
TTSampleMatrixPtr mTargetMatrix; | ||
TTRowID mTargetMatrixLengthInSamples; | ||
TTColumnID mTargetMatrixNumChannels; | ||
TTFloat64 mTargetMatrixSampleRate; | ||
TTRowID mStartCopyAtSampleIndex; | ||
TTRowID mEndCopyAtSampleIndex; | ||
TTColumnID mCopyFromChannelIndex; | ||
|
||
/** Internal method that sets the class's pointer to the target sample matrix for loading sound file data. | ||
@param newTargetMatrix pointer to the new matrix | ||
@return TTErr kTTErrNone if the pointer was updated. | ||
*/ | ||
TTErr setTargetMatrix(const TTSampleMatrixPtr newTargetMatrix); | ||
|
||
/** 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. | ||
@param newTargetMatrix pointer to the new matrix | ||
@return TTErr kTTErrNone if the pointer was updated. kTTErrInvalidValue if the pointer was not to a TTSampleMatrix. | ||
*/ | ||
TTErr setTargetMatrix(const TTObjectBase* newTargetObjectPtr); | ||
|
||
/** 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. | ||
@return TTErr kTTErrNone if copy is successful. kTTErrGeneric if the source soundfile was too short to fill samplematrix. | ||
*/ | ||
TTErr copyUntilFilled(); | ||
|
||
/** 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. | ||
@return TTErr kTTErrNone if copy is successful. kTTErrGeneric if the source soundfile was too short to fill samplematrix. | ||
*/ | ||
TTErr copyUntilFilledWithResampling(); | ||
|
||
public: | ||
/** 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. | ||
@param newValue full POSIX path to the file, including file name | ||
@return TTErr kTTErrInvalidValue is the filepath is invalid, otherwise kTTErrNone | ||
*/ | ||
TTErr setFilePath(const TTValue& newValue); | ||
|
||
/** Public method used to trigger the load process. Copies samples from a sound file on the hard drive into a TTSampleMatrix. | ||
@param[in] input Multi-item TTValue used to set the copy parameters: | ||
-# TTObjectBasePtr to the target matrix | ||
-# TTSymbol containing the filepath | ||
-# (optional) channel to copy from source, default is 0 | ||
-# (optional) frame to start copy from source, default is 0 | ||
-# (optional) frame to stop copy from source, default is last | ||
@param[out] unusedOutput not used | ||
@return TTErr kTTErrNone load was successful. kTTErrInvalidFilepath if the filepath was invalid. kTTErrInvalidValue if the pointer to TTSampleMatrix was invalid. | ||
*/ | ||
TTErr load(const TTValueRef input, TTValueRef unusedOutput); | ||
|
||
/** Unit test for this object. | ||
@param[out] returnedTestInfo The outcome from the performed unit test. | ||
@return #TTErr error code if the method fails to execute, else #kTTErrNone. | ||
*/ | ||
virtual TTErr test(TTValue& returnedTestInfo); | ||
|
||
}; | ||
|
||
typedef TTSoundfileLoader* TTSoundfileLoaderPtr; | ||
|
||
#endif /* defined(__TT_SOUNDFILELOADER_H__) */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.