mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
globally remove all trailing whitespace from .cpp and .hpp files missed by previous commit
This commit is contained in:
parent
4dc63966f0
commit
4178db5f63
56 changed files with 50764 additions and 50764 deletions
|
|
@ -55,7 +55,7 @@ struct AudioBuffer
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
AUOutputBL::AUOutputBL (const CAStreamBasicDescription &inDesc, UInt32 inDefaultNumFrames)
|
AUOutputBL::AUOutputBL (const CAStreamBasicDescription &inDesc, UInt32 inDefaultNumFrames)
|
||||||
: mFormat (inDesc),
|
: mFormat (inDesc),
|
||||||
mBufferMemory(NULL),
|
mBufferMemory(NULL),
|
||||||
mBufferList (NULL),
|
mBufferList (NULL),
|
||||||
|
|
@ -76,7 +76,7 @@ AUOutputBL::~AUOutputBL()
|
||||||
delete [] mBufferList;
|
delete [] mBufferList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUOutputBL::Prepare (UInt32 inNumFrames, bool inWantNullBufferIfAllocated)
|
void AUOutputBL::Prepare (UInt32 inNumFrames, bool inWantNullBufferIfAllocated)
|
||||||
{
|
{
|
||||||
UInt32 channelsPerBuffer = mFormat.IsInterleaved() ? mFormat.NumberChannels() : 1;
|
UInt32 channelsPerBuffer = mFormat.IsInterleaved() ? mFormat.NumberChannels() : 1;
|
||||||
|
|
||||||
|
|
@ -111,11 +111,11 @@ void AUOutputBL::Prepare (UInt32 inNumFrames, bool inWantNullBufferIfAllocated)
|
||||||
|
|
||||||
void AUOutputBL::Allocate (UInt32 inNumFrames)
|
void AUOutputBL::Allocate (UInt32 inNumFrames)
|
||||||
{
|
{
|
||||||
if (inNumFrames)
|
if (inNumFrames)
|
||||||
{
|
{
|
||||||
UInt32 nBytes = mFormat.FramesToBytes (inNumFrames);
|
UInt32 nBytes = mFormat.FramesToBytes (inNumFrames);
|
||||||
|
|
||||||
if (nBytes <= AllocatedBytes())
|
if (nBytes <= AllocatedBytes())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// align successive buffers for Altivec and to take alternating
|
// align successive buffers for Altivec and to take alternating
|
||||||
|
|
@ -134,8 +134,8 @@ void AUOutputBL::Allocate (UInt32 inNumFrames)
|
||||||
delete[] oldMemory;
|
delete[] oldMemory;
|
||||||
|
|
||||||
mFrames = inNumFrames;
|
mFrames = inNumFrames;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mBufferMemory) {
|
if (mBufferMemory) {
|
||||||
delete [] mBufferMemory;
|
delete [] mBufferMemory;
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@
|
||||||
#include "AUParamInfo.h"
|
#include "AUParamInfo.h"
|
||||||
#include "CAXException.h"
|
#include "CAXException.h"
|
||||||
|
|
||||||
AUParamInfo::AUParamInfo (AudioUnit inAU,
|
AUParamInfo::AUParamInfo (AudioUnit inAU,
|
||||||
bool inIncludeExpert,
|
bool inIncludeExpert,
|
||||||
bool inIncludeReadOnly,
|
bool inIncludeReadOnly,
|
||||||
AudioUnitScope inScope,
|
AudioUnitScope inScope,
|
||||||
AudioUnitElement inElement)
|
AudioUnitElement inElement)
|
||||||
|
|
@ -73,13 +73,13 @@ AUParamInfo::AUParamInfo (AudioUnit inAU,
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterMap params;
|
ParameterMap params;
|
||||||
for (int i = 0; i < nparams; ++i)
|
for (int i = 0; i < nparams; ++i)
|
||||||
{
|
{
|
||||||
CAAUParameter auvp (mAU, paramList[i], mScope, mElement); // took out only using global scope in CAAUParameter creation
|
CAAUParameter auvp (mAU, paramList[i], mScope, mElement); // took out only using global scope in CAAUParameter creation
|
||||||
const AudioUnitParameterInfo ¶mInfo = auvp.ParamInfo();
|
const AudioUnitParameterInfo ¶mInfo = auvp.ParamInfo();
|
||||||
|
|
||||||
// don't include if parameter can't be read or written
|
// don't include if parameter can't be read or written
|
||||||
if (!(paramInfo.flags & kAudioUnitParameterFlag_IsWritable)
|
if (!(paramInfo.flags & kAudioUnitParameterFlag_IsWritable)
|
||||||
&& !(paramInfo.flags & kAudioUnitParameterFlag_IsReadable))
|
&& !(paramInfo.flags & kAudioUnitParameterFlag_IsReadable))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -88,7 +88,7 @@ AUParamInfo::AUParamInfo (AudioUnit inAU,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// only include if read only params are wanted
|
// only include if read only params are wanted
|
||||||
if (!(paramInfo.flags & kAudioUnitParameterFlag_IsWritable)
|
if (!(paramInfo.flags & kAudioUnitParameterFlag_IsWritable)
|
||||||
&& (paramInfo.flags & kAudioUnitParameterFlag_IsReadable))
|
&& (paramInfo.flags & kAudioUnitParameterFlag_IsReadable))
|
||||||
{
|
{
|
||||||
if (!inIncludeReadOnly)
|
if (!inIncludeReadOnly)
|
||||||
|
|
@ -113,9 +113,9 @@ AUParamInfo::~AUParamInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 AUParamInfo::NumParamsForClump (UInt32 inClump) const
|
UInt32 AUParamInfo::NumParamsForClump (UInt32 inClump) const
|
||||||
{
|
{
|
||||||
ParameterMap::const_iterator it = mParams.find(inClump);
|
ParameterMap::const_iterator it = mParams.find(inClump);
|
||||||
if (it != mParams.end())
|
if (it != mParams.end())
|
||||||
return (*it).second.size();
|
return (*it).second.size();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
#include "CAAUParameter.h"
|
#include "CAAUParameter.h"
|
||||||
|
|
||||||
CAAUParameter::CAAUParameter()
|
CAAUParameter::CAAUParameter()
|
||||||
{
|
{
|
||||||
memset(this, 0, sizeof(CAAUParameter));
|
memset(this, 0, sizeof(CAAUParameter));
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +59,7 @@ CAAUParameter::CAAUParameter (AudioUnitParameter &inParam)
|
||||||
Init (inParam.mAudioUnit, inParam.mParameterID, inParam.mScope, inParam.mElement);
|
Init (inParam.mAudioUnit, inParam.mParameterID, inParam.mScope, inParam.mElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAAUParameter::CAAUParameter(const CAAUParameter &a)
|
CAAUParameter::CAAUParameter(const CAAUParameter &a)
|
||||||
{
|
{
|
||||||
memset(this, 0, sizeof(CAAUParameter));
|
memset(this, 0, sizeof(CAAUParameter));
|
||||||
*this = a;
|
*this = a;
|
||||||
|
|
@ -101,7 +101,7 @@ void CAAUParameter::Init (AudioUnit au, AudioUnitParameterID param, AudioUnitSc
|
||||||
memset(&mParamInfo, 0, sizeof(mParamInfo));
|
memset(&mParamInfo, 0, sizeof(mParamInfo));
|
||||||
if (mParamInfo.flags & kAudioUnitParameterFlag_HasCFNameString) {
|
if (mParamInfo.flags & kAudioUnitParameterFlag_HasCFNameString) {
|
||||||
mParamName = mParamInfo.cfNameString;
|
mParamName = mParamInfo.cfNameString;
|
||||||
if (!(mParamInfo.flags & kAudioUnitParameterFlag_CFNameRelease))
|
if (!(mParamInfo.flags & kAudioUnitParameterFlag_CFNameRelease))
|
||||||
CFRetain (mParamName);
|
CFRetain (mParamName);
|
||||||
} else
|
} else
|
||||||
mParamName = CFStringCreateWithCString(NULL, mParamInfo.name, kCFStringEncodingUTF8);
|
mParamName = CFStringCreateWithCString(NULL, mParamInfo.name, kCFStringEncodingUTF8);
|
||||||
|
|
@ -173,11 +173,11 @@ void CAAUParameter::Init (AudioUnit au, AudioUnitParameterID param, AudioUnitSc
|
||||||
case kAudioUnitParameterUnit_Indexed:
|
case kAudioUnitParameterUnit_Indexed:
|
||||||
{
|
{
|
||||||
propertySize = sizeof(mNamedParams);
|
propertySize = sizeof(mNamedParams);
|
||||||
err = AudioUnitGetProperty (au,
|
err = AudioUnitGetProperty (au,
|
||||||
kAudioUnitProperty_ParameterValueStrings,
|
kAudioUnitProperty_ParameterValueStrings,
|
||||||
scope,
|
scope,
|
||||||
param,
|
param,
|
||||||
&mNamedParams,
|
&mNamedParams,
|
||||||
&propertySize);
|
&propertySize);
|
||||||
if (!err && mNamedParams) {
|
if (!err && mNamedParams) {
|
||||||
mNumIndexedParams = CFArrayGetCount(mNamedParams);
|
mNumIndexedParams = CFArrayGetCount(mNamedParams);
|
||||||
|
|
@ -215,7 +215,7 @@ void CAAUParameter::Init (AudioUnit au, AudioUnitParameterID param, AudioUnitSc
|
||||||
Float32 CAAUParameter::GetValue() const
|
Float32 CAAUParameter::GetValue() const
|
||||||
{
|
{
|
||||||
Float32 value = 0.;
|
Float32 value = 0.;
|
||||||
//OSStatus err =
|
//OSStatus err =
|
||||||
AudioUnitGetParameter(mAudioUnit, mParameterID, mScope, mElement, &value);
|
AudioUnitGetParameter(mAudioUnit, mParameterID, mScope, mElement, &value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
@ -232,7 +232,7 @@ CFStringRef CAAUParameter::GetStringFromValueCopy(const Float32 *value) const
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ValuesHaveStrings())
|
else if (ValuesHaveStrings())
|
||||||
{
|
{
|
||||||
AudioUnitParameterStringFromValue stringValue;
|
AudioUnitParameterStringFromValue stringValue;
|
||||||
stringValue.inParamID = mParameterID;
|
stringValue.inParamID = mParameterID;
|
||||||
|
|
@ -240,11 +240,11 @@ CFStringRef CAAUParameter::GetStringFromValueCopy(const Float32 *value) const
|
||||||
stringValue.outString = NULL;
|
stringValue.outString = NULL;
|
||||||
UInt32 propertySize = sizeof(stringValue);
|
UInt32 propertySize = sizeof(stringValue);
|
||||||
|
|
||||||
OSStatus err = AudioUnitGetProperty (mAudioUnit,
|
OSStatus err = AudioUnitGetProperty (mAudioUnit,
|
||||||
kAudioUnitProperty_ParameterStringFromValue,
|
kAudioUnitProperty_ParameterStringFromValue,
|
||||||
mScope,
|
mScope,
|
||||||
mParameterID,
|
mParameterID,
|
||||||
&stringValue,
|
&stringValue,
|
||||||
&propertySize);
|
&propertySize);
|
||||||
|
|
||||||
if (err == noErr && stringValue.outString != NULL)
|
if (err == noErr && stringValue.outString != NULL)
|
||||||
|
|
@ -259,18 +259,18 @@ CFStringRef CAAUParameter::GetStringFromValueCopy(const Float32 *value) const
|
||||||
|
|
||||||
Float32 CAAUParameter::GetValueFromString(CFStringRef str) const
|
Float32 CAAUParameter::GetValueFromString(CFStringRef str) const
|
||||||
{
|
{
|
||||||
if (ValuesHaveStrings())
|
if (ValuesHaveStrings())
|
||||||
{
|
{
|
||||||
AudioUnitParameterValueFromString valueString;
|
AudioUnitParameterValueFromString valueString;
|
||||||
valueString.inParamID = mParameterID;
|
valueString.inParamID = mParameterID;
|
||||||
valueString.inString = str;
|
valueString.inString = str;
|
||||||
UInt32 propertySize = sizeof(valueString);
|
UInt32 propertySize = sizeof(valueString);
|
||||||
|
|
||||||
OSStatus err = AudioUnitGetProperty (mAudioUnit,
|
OSStatus err = AudioUnitGetProperty (mAudioUnit,
|
||||||
kAudioUnitProperty_ParameterValueFromString,
|
kAudioUnitProperty_ParameterValueFromString,
|
||||||
mScope,
|
mScope,
|
||||||
mParameterID,
|
mParameterID,
|
||||||
&valueString,
|
&valueString,
|
||||||
&propertySize);
|
&propertySize);
|
||||||
|
|
||||||
if (err == noErr) {
|
if (err == noErr) {
|
||||||
|
|
@ -285,7 +285,7 @@ Float32 CAAUParameter::GetValueFromString(CFStringRef str) const
|
||||||
return paramValue;
|
return paramValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAAUParameter::SetValue( AUParameterListenerRef inListener,
|
void CAAUParameter::SetValue( AUParameterListenerRef inListener,
|
||||||
void * inObject,
|
void * inObject,
|
||||||
Float32 inValue) const
|
Float32 inValue) const
|
||||||
{
|
{
|
||||||
|
|
@ -295,7 +295,7 @@ void CAAUParameter::SetValue( AUParameterListenerRef inListener,
|
||||||
valueToSet = mParamInfo.maxValue;
|
valueToSet = mParamInfo.maxValue;
|
||||||
if (valueToSet < mParamInfo.minValue)
|
if (valueToSet < mParamInfo.minValue)
|
||||||
valueToSet = mParamInfo.minValue;
|
valueToSet = mParamInfo.minValue;
|
||||||
|
|
||||||
AUParameterSet(inListener, inObject, this, valueToSet, 0);
|
AUParameterSet(inListener, inObject, this, valueToSet, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
CAAudioChannelLayoutObject.cpp
|
CAAudioChannelLayoutObject.cpp
|
||||||
|
|
||||||
=============================================================================*/
|
=============================================================================*/
|
||||||
|
|
||||||
#include "CAAudioChannelLayout.h"
|
#include "CAAudioChannelLayout.h"
|
||||||
|
|
@ -69,7 +69,7 @@ CAAudioChannelLayout::CAAudioChannelLayout (UInt32 inNumberChannels, bool inChoo
|
||||||
|
|
||||||
layout->mNumberChannelDescriptions = inNumberChannels;
|
layout->mNumberChannelDescriptions = inNumberChannels;
|
||||||
|
|
||||||
switch (inNumberChannels)
|
switch (inNumberChannels)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
layout->mChannelLayoutTag = kAudioChannelLayoutTag_Mono;
|
layout->mChannelLayoutTag = kAudioChannelLayoutTag_Mono;
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ void CAAudioFile::CreateNew(const FSRef &parentDir, CFStringRef filename, AudioF
|
||||||
|
|
||||||
// _______________________________________________________________________________________
|
// _______________________________________________________________________________________
|
||||||
//
|
//
|
||||||
// called to create the file -- or update its format/channel layout/properties based on an encoder
|
// called to create the file -- or update its format/channel layout/properties based on an encoder
|
||||||
// setting change
|
// setting change
|
||||||
void CAAudioFile::FileFormatChanged(const FSRef *parentDir, CFStringRef filename, AudioFileTypeID filetype)
|
void CAAudioFile::FileFormatChanged(const FSRef *parentDir, CFStringRef filename, AudioFileTypeID filetype)
|
||||||
{
|
{
|
||||||
|
|
@ -356,7 +356,7 @@ void CAAudioFile::FileFormatChanged(const FSRef *parentDir, CFStringRef filename
|
||||||
#if VERBOSE_CHANNELMAP
|
#if VERBOSE_CHANNELMAP
|
||||||
printf("writing file's channel layout: %s\n", CAChannelLayouts::ConstantToString(mFileChannelLayout.Tag()));
|
printf("writing file's channel layout: %s\n", CAChannelLayouts::ConstantToString(mFileChannelLayout.Tag()));
|
||||||
#endif
|
#endif
|
||||||
err = AudioFileSetProperty(mAudioFile, kAudioFilePropertyChannelLayout,
|
err = AudioFileSetProperty(mAudioFile, kAudioFilePropertyChannelLayout,
|
||||||
mFileChannelLayout.Size(), &mFileChannelLayout.Layout());
|
mFileChannelLayout.Size(), &mFileChannelLayout.Layout());
|
||||||
if (err)
|
if (err)
|
||||||
CAXException::Warning("could not set the file's channel layout", err);
|
CAXException::Warning("could not set the file's channel layout", err);
|
||||||
|
|
@ -378,7 +378,7 @@ void CAAudioFile::InitFileMaxPacketSize()
|
||||||
{
|
{
|
||||||
LOG_FUNCTION("CAAudioFile::InitFileMaxPacketSize", "%p", this);
|
LOG_FUNCTION("CAAudioFile::InitFileMaxPacketSize", "%p", this);
|
||||||
UInt32 propertySize = sizeof(UInt32);
|
UInt32 propertySize = sizeof(UInt32);
|
||||||
OSStatus err = AudioFileGetProperty(mAudioFile, kAudioFilePropertyMaximumPacketSize,
|
OSStatus err = AudioFileGetProperty(mAudioFile, kAudioFilePropertyMaximumPacketSize,
|
||||||
&propertySize, &mFileMaxPacketSize);
|
&propertySize, &mFileMaxPacketSize);
|
||||||
if (err) {
|
if (err) {
|
||||||
// workaround for 3361377: not all file formats' maximum packet sizes are supported
|
// workaround for 3361377: not all file formats' maximum packet sizes are supported
|
||||||
|
|
@ -657,7 +657,7 @@ void CAAudioFile::UpdateClientMaxPacketSize()
|
||||||
LOG_FUNCTION("CAAudioFile::UpdateClientMaxPacketSize", "%p", this);
|
LOG_FUNCTION("CAAudioFile::UpdateClientMaxPacketSize", "%p", this);
|
||||||
mFrame0Offset = 0;
|
mFrame0Offset = 0;
|
||||||
if (mConverter != NULL) {
|
if (mConverter != NULL) {
|
||||||
AudioConverterPropertyID property = (mMode == kReading) ?
|
AudioConverterPropertyID property = (mMode == kReading) ?
|
||||||
kAudioConverterPropertyMaximumOutputPacketSize :
|
kAudioConverterPropertyMaximumOutputPacketSize :
|
||||||
kAudioConverterPropertyMaximumInputPacketSize;
|
kAudioConverterPropertyMaximumInputPacketSize;
|
||||||
|
|
||||||
|
|
@ -1078,14 +1078,14 @@ void CAAudioFile::Write(UInt32 numPackets, const AudioBufferList *data)
|
||||||
WritePacketsFromCallback(WriteInputProc, this);
|
WritePacketsFromCallback(WriteInputProc, this);
|
||||||
} else {
|
} else {
|
||||||
StartTiming(this, write);
|
StartTiming(this, write);
|
||||||
XThrowIfError(AudioFileWritePackets(mAudioFile, mUseCache, data->mBuffers[0].mDataByteSize,
|
XThrowIfError(AudioFileWritePackets(mAudioFile, mUseCache, data->mBuffers[0].mDataByteSize,
|
||||||
NULL, mPacketMark, &numPackets, data->mBuffers[0].mData),
|
NULL, mPacketMark, &numPackets, data->mBuffers[0].mData),
|
||||||
"write audio file");
|
"write audio file");
|
||||||
ElapsedTime(this, write, mTicksInIO);
|
ElapsedTime(this, write, mTicksInIO);
|
||||||
#if VERBOSE_IO
|
#if VERBOSE_IO
|
||||||
printf("CAAudioFile::WritePackets: wrote %ld packets at %qd, %ld bytes\n", numPackets, mPacketMark, data->mBuffers[0].mDataByteSize);
|
printf("CAAudioFile::WritePackets: wrote %ld packets at %qd, %ld bytes\n", numPackets, mPacketMark, data->mBuffers[0].mDataByteSize);
|
||||||
#endif
|
#endif
|
||||||
//mNumberPackets =
|
//mNumberPackets =
|
||||||
mPacketMark += numPackets;
|
mPacketMark += numPackets;
|
||||||
if (mFileDataFormat.mFramesPerPacket > 0)
|
if (mFileDataFormat.mFramesPerPacket > 0)
|
||||||
mFrameMark += numPackets * mFileDataFormat.mFramesPerPacket;
|
mFrameMark += numPackets * mFileDataFormat.mFramesPerPacket;
|
||||||
|
|
@ -1201,7 +1201,7 @@ void CAAudioFile::WritePacketsFromCallback(
|
||||||
mInConverter = true;
|
mInConverter = true;
|
||||||
#endif
|
#endif
|
||||||
StartTiming(this, fill);
|
StartTiming(this, fill);
|
||||||
OSStatus err = AudioConverterFillComplexBuffer(mConverter, inInputDataProc, inInputDataProcUserData,
|
OSStatus err = AudioConverterFillComplexBuffer(mConverter, inInputDataProc, inInputDataProcUserData,
|
||||||
&numEncodedPackets, &mIOBufferList, mPacketDescs);
|
&numEncodedPackets, &mIOBufferList, mPacketDescs);
|
||||||
ElapsedTime(this, fill, mTicksInConverter);
|
ElapsedTime(this, fill, mTicksInConverter);
|
||||||
#if CAAUDIOFILE_PROFILE
|
#if CAAUDIOFILE_PROFILE
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
CAAudioUnit.cpp
|
CAAudioUnit.cpp
|
||||||
|
|
||||||
=============================================================================*/
|
=============================================================================*/
|
||||||
|
|
||||||
#include "CAAudioUnit.h"
|
#include "CAAudioUnit.h"
|
||||||
|
|
@ -65,15 +65,15 @@ class CAAudioUnit::AUState : public CAReferenceCounted {
|
||||||
public:
|
public:
|
||||||
AUState (Component inComp)
|
AUState (Component inComp)
|
||||||
: mUnit(0), mNode (0)
|
: mUnit(0), mNode (0)
|
||||||
{
|
{
|
||||||
OSStatus result = ::OpenAComponent (inComp, &mUnit);
|
OSStatus result = ::OpenAComponent (inComp, &mUnit);
|
||||||
if (result)
|
if (result)
|
||||||
throw result;
|
throw result;
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
AUState (const AUNode &inNode, const AudioUnit& inUnit)
|
AUState (const AUNode &inNode, const AudioUnit& inUnit)
|
||||||
: mUnit (inUnit), mNode (inNode)
|
: mUnit (inUnit), mNode (inNode)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
@ -87,7 +87,7 @@ public:
|
||||||
Float32 &outValue) const
|
Float32 &outValue) const
|
||||||
{
|
{
|
||||||
if (mGetParamProc != NULL) {
|
if (mGetParamProc != NULL) {
|
||||||
return reinterpret_cast<AudioUnitGetParameterProc>(mGetParamProc) (mConnInstanceStorage,
|
return reinterpret_cast<AudioUnitGetParameterProc>(mGetParamProc) (mConnInstanceStorage,
|
||||||
inID, scope, element, &outValue);
|
inID, scope, element, &outValue);
|
||||||
}
|
}
|
||||||
return AudioUnitGetParameter(mUnit, inID, scope, element, &outValue);
|
return AudioUnitGetParameter(mUnit, inID, scope, element, &outValue);
|
||||||
|
|
@ -97,7 +97,7 @@ public:
|
||||||
Float32 value, UInt32 bufferOffsetFrames)
|
Float32 value, UInt32 bufferOffsetFrames)
|
||||||
{
|
{
|
||||||
if (mSetParamProc != NULL) {
|
if (mSetParamProc != NULL) {
|
||||||
return reinterpret_cast<AudioUnitSetParameterProc>(mSetParamProc) (mConnInstanceStorage,
|
return reinterpret_cast<AudioUnitSetParameterProc>(mSetParamProc) (mConnInstanceStorage,
|
||||||
inID, scope, element, value, bufferOffsetFrames);
|
inID, scope, element, value, bufferOffsetFrames);
|
||||||
}
|
}
|
||||||
return AudioUnitSetParameter(mUnit, inID, scope, element, value, bufferOffsetFrames);
|
return AudioUnitSetParameter(mUnit, inID, scope, element, value, bufferOffsetFrames);
|
||||||
|
|
@ -110,7 +110,7 @@ public:
|
||||||
AudioBufferList * ioData)
|
AudioBufferList * ioData)
|
||||||
{
|
{
|
||||||
if (mRenderProc != NULL) {
|
if (mRenderProc != NULL) {
|
||||||
return reinterpret_cast<AudioUnitRenderProc>(mRenderProc) (mConnInstanceStorage,
|
return reinterpret_cast<AudioUnitRenderProc>(mRenderProc) (mConnInstanceStorage,
|
||||||
ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData);
|
ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData);
|
||||||
}
|
}
|
||||||
return AudioUnitRender(mUnit, ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData);
|
return AudioUnitRender(mUnit, ioActionFlags, inTimeStamp, inOutputBusNumber, inNumberFrames, ioData);
|
||||||
|
|
@ -123,7 +123,7 @@ public:
|
||||||
{
|
{
|
||||||
#if !TARGET_OS_WIN32
|
#if !TARGET_OS_WIN32
|
||||||
if (mMIDIEventProc != NULL) {
|
if (mMIDIEventProc != NULL) {
|
||||||
return reinterpret_cast<MusicDeviceMIDIEventProc>(mMIDIEventProc) (mConnInstanceStorage,
|
return reinterpret_cast<MusicDeviceMIDIEventProc>(mMIDIEventProc) (mConnInstanceStorage,
|
||||||
inStatus, inData1, inData2, inOffsetSampleFrame);
|
inStatus, inData1, inData2, inOffsetSampleFrame);
|
||||||
}
|
}
|
||||||
return MusicDeviceMIDIEvent (mUnit, inStatus, inData1, inData2, inOffsetSampleFrame);
|
return MusicDeviceMIDIEvent (mUnit, inStatus, inData1, inData2, inOffsetSampleFrame);
|
||||||
|
|
@ -157,7 +157,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// get the fast dispatch pointers
|
// get the fast dispatch pointers
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
UInt32 size = sizeof(AudioUnitRenderProc);
|
UInt32 size = sizeof(AudioUnitRenderProc);
|
||||||
if (AudioUnitGetProperty(mUnit, kAudioUnitProperty_FastDispatch,
|
if (AudioUnitGetProperty(mUnit, kAudioUnitProperty_FastDispatch,
|
||||||
|
|
@ -192,7 +192,7 @@ private:
|
||||||
// get the compiler to tell us when we do a bad thing!!!
|
// get the compiler to tell us when we do a bad thing!!!
|
||||||
AUState () {}
|
AUState () {}
|
||||||
AUState (const AUState& other) : CAReferenceCounted (other) {}
|
AUState (const AUState& other) : CAReferenceCounted (other) {}
|
||||||
AUState& operator= (const AUState&) { return *this; }
|
AUState& operator= (const AUState&) { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -208,7 +208,7 @@ CAAudioUnit::AUState::~AUState ()
|
||||||
OSStatus CAAudioUnit::Open (const CAComponent& inComp, CAAudioUnit &outUnit)
|
OSStatus CAAudioUnit::Open (const CAComponent& inComp, CAAudioUnit &outUnit)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
outUnit = inComp;
|
outUnit = inComp;
|
||||||
return noErr;
|
return noErr;
|
||||||
} catch (OSStatus res) {
|
} catch (OSStatus res) {
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -229,7 +229,7 @@ CAAudioUnit::CAAudioUnit (const CAComponent& inComp)
|
||||||
}
|
}
|
||||||
|
|
||||||
CAAudioUnit::CAAudioUnit (const AUNode &inNode, const AudioUnit& inUnit)
|
CAAudioUnit::CAAudioUnit (const AUNode &inNode, const AudioUnit& inUnit)
|
||||||
: mComp (inUnit), mDataPtr(new AUState (inNode, inUnit))
|
: mComp (inUnit), mDataPtr(new AUState (inNode, inUnit))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -272,24 +272,24 @@ bool CAAudioUnit::operator== (const AudioUnit& y) const
|
||||||
|
|
||||||
#pragma mark __State Management
|
#pragma mark __State Management
|
||||||
|
|
||||||
bool CAAudioUnit::IsValid () const
|
bool CAAudioUnit::IsValid () const
|
||||||
{
|
{
|
||||||
return mDataPtr ? mDataPtr->mUnit != 0 : false;
|
return mDataPtr ? mDataPtr->mUnit != 0 : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioUnit CAAudioUnit::AU() const
|
AudioUnit CAAudioUnit::AU() const
|
||||||
{
|
{
|
||||||
return mDataPtr ? mDataPtr->mUnit : 0;
|
return mDataPtr ? mDataPtr->mUnit : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AUNode CAAudioUnit::GetAUNode () const
|
AUNode CAAudioUnit::GetAUNode () const
|
||||||
{
|
{
|
||||||
return mDataPtr ? mDataPtr->mNode : 0;
|
return mDataPtr ? mDataPtr->mNode : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark __Format Handling
|
#pragma mark __Format Handling
|
||||||
|
|
||||||
bool CAAudioUnit::CanDo ( int inChannelsIn,
|
bool CAAudioUnit::CanDo ( int inChannelsIn,
|
||||||
int inChannelsOut) const
|
int inChannelsOut) const
|
||||||
{
|
{
|
||||||
// this is the default assumption of an audio effect unit
|
// this is the default assumption of an audio effect unit
|
||||||
|
|
@ -303,14 +303,14 @@ bool CAAudioUnit::CanDo ( int inChannelsIn,
|
||||||
|
|
||||||
// if this property is NOT implemented an FX unit
|
// if this property is NOT implemented an FX unit
|
||||||
// is expected to deal with same channel valance in and out
|
// is expected to deal with same channel valance in and out
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
if ((Comp().Desc().IsEffect() && (inChannelsIn == inChannelsOut))
|
if ((Comp().Desc().IsEffect() && (inChannelsIn == inChannelsOut))
|
||||||
|| (Comp().Desc().IsOffline() && (inChannelsIn == inChannelsOut)))
|
|| (Comp().Desc().IsOffline() && (inChannelsIn == inChannelsOut)))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// the au should either really tell us about this
|
// the au should either really tell us about this
|
||||||
// or we will assume the worst
|
// or we will assume the worst
|
||||||
|
|
@ -342,9 +342,9 @@ int CAAudioUnit::GetChannelInfo (AUChannelInfo** chaninfo, UInt32& cnt)
|
||||||
// if this property is NOT implemented an FX unit
|
// if this property is NOT implemented an FX unit
|
||||||
// is expected to deal with same channel valance in and out
|
// is expected to deal with same channel valance in and out
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
if (Comp().Desc().IsEffect())
|
if (Comp().Desc().IsEffect())
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -383,7 +383,7 @@ int CAAudioUnit::GetChannelInfo (AUChannelInfo** chaninfo, UInt32& cnt)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// the au should either really tell us about this
|
// the au should either really tell us about this
|
||||||
// or we will assume the worst
|
// or we will assume the worst
|
||||||
|
|
@ -403,7 +403,7 @@ int CAAudioUnit::GetChannelInfo (AUChannelInfo** chaninfo, UInt32& cnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CAAudioUnit::ValidateChannelPair (int inChannelsIn,
|
bool CAAudioUnit::ValidateChannelPair (int inChannelsIn,
|
||||||
int inChannelsOut,
|
int inChannelsOut,
|
||||||
const AUChannelInfo * info,
|
const AUChannelInfo * info,
|
||||||
UInt32 numChanInfo) const
|
UInt32 numChanInfo) const
|
||||||
|
|
@ -415,8 +415,8 @@ bool CAAudioUnit::ValidateChannelPair (int inChannelsIn,
|
||||||
-1 wild card:
|
-1 wild card:
|
||||||
-1,-1 any num channels as long as same channels on in and out
|
-1,-1 any num channels as long as same channels on in and out
|
||||||
-1,-2 any num channels channels on in and out - special meaning
|
-1,-2 any num channels channels on in and out - special meaning
|
||||||
-2+ indicates total num channs AU can handle
|
-2+ indicates total num channs AU can handle
|
||||||
- elements configurable to any num channels,
|
- elements configurable to any num channels,
|
||||||
- element count in scope must be writable
|
- element count in scope must be writable
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -433,7 +433,7 @@ bool CAAudioUnit::ValidateChannelPair (int inChannelsIn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((info[i].inChannels == -1 && info[i].outChannels == -2)
|
else if ((info[i].inChannels == -1 && info[i].outChannels == -2)
|
||||||
|| (info[i].inChannels == -2 && info[i].outChannels == -1))
|
|| (info[i].inChannels == -2 && info[i].outChannels == -1))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -445,7 +445,7 @@ bool CAAudioUnit::ValidateChannelPair (int inChannelsIn,
|
||||||
IsElementCountWritable (kAudioUnitScope_Input, inWrite);
|
IsElementCountWritable (kAudioUnitScope_Input, inWrite);
|
||||||
if (inWrite && outWrite) {
|
if (inWrite && outWrite) {
|
||||||
if ((inChannelsOut <= abs(info[i].outChannels))
|
if ((inChannelsOut <= abs(info[i].outChannels))
|
||||||
&& (inChannelsIn <= abs(info[i].inChannels)))
|
&& (inChannelsIn <= abs(info[i].inChannels)))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -455,12 +455,12 @@ bool CAAudioUnit::ValidateChannelPair (int inChannelsIn,
|
||||||
|
|
||||||
// special meaning on input, specific num on output
|
// special meaning on input, specific num on output
|
||||||
else if (info[i].inChannels < 0) {
|
else if (info[i].inChannels < 0) {
|
||||||
if (info[i].outChannels == inChannelsOut)
|
if (info[i].outChannels == inChannelsOut)
|
||||||
{
|
{
|
||||||
// can do any in channels
|
// can do any in channels
|
||||||
if (info[i].inChannels == -1) {
|
if (info[i].inChannels == -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// total chans on input
|
// total chans on input
|
||||||
else {
|
else {
|
||||||
bool inWrite = false;
|
bool inWrite = false;
|
||||||
|
|
@ -474,12 +474,12 @@ bool CAAudioUnit::ValidateChannelPair (int inChannelsIn,
|
||||||
|
|
||||||
// special meaning on output, specific num on input
|
// special meaning on output, specific num on input
|
||||||
else if (info[i].outChannels < 0) {
|
else if (info[i].outChannels < 0) {
|
||||||
if (info[i].inChannels == inChannelsIn)
|
if (info[i].inChannels == inChannelsIn)
|
||||||
{
|
{
|
||||||
// can do any out channels
|
// can do any out channels
|
||||||
if (info[i].outChannels == -1) {
|
if (info[i].outChannels == -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// total chans on output
|
// total chans on output
|
||||||
else {
|
else {
|
||||||
bool outWrite = false;
|
bool outWrite = false;
|
||||||
|
|
@ -494,9 +494,9 @@ bool CAAudioUnit::ValidateChannelPair (int inChannelsIn,
|
||||||
// both chans in struct >= 0 - thus has to explicitly match
|
// both chans in struct >= 0 - thus has to explicitly match
|
||||||
else if ((info[i].inChannels == inChannelsIn) && (info[i].outChannels == inChannelsOut)) {
|
else if ((info[i].inChannels == inChannelsIn) && (info[i].outChannels == inChannelsOut)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now check to see if a wild card on the args (inChannelsIn or inChannelsOut chans is zero) is found
|
// now check to see if a wild card on the args (inChannelsIn or inChannelsOut chans is zero) is found
|
||||||
// tells us to match just one side of the scopes
|
// tells us to match just one side of the scopes
|
||||||
else if (inChannelsIn == 0) {
|
else if (inChannelsIn == 0) {
|
||||||
if (info[i].outChannels == inChannelsOut) {
|
if (info[i].outChannels == inChannelsOut) {
|
||||||
|
|
@ -521,9 +521,9 @@ bool CheckDynCount (SInt32 inTotalChans, const CAAUChanHelper &inHelper)
|
||||||
return (totalChans <= inTotalChans);
|
return (totalChans <= inTotalChans);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAAudioUnit::CheckOneSide (const CAAUChanHelper &inHelper,
|
bool CAAudioUnit::CheckOneSide (const CAAUChanHelper &inHelper,
|
||||||
bool checkOutput,
|
bool checkOutput,
|
||||||
const AUChannelInfo *info,
|
const AUChannelInfo *info,
|
||||||
UInt32 numInfo) const
|
UInt32 numInfo) const
|
||||||
{
|
{
|
||||||
// now we can use the wildcard option (see above impl) to see if this matches
|
// now we can use the wildcard option (see above impl) to see if this matches
|
||||||
|
|
@ -546,7 +546,7 @@ bool CAAudioUnit::CheckOneSide (const CAAUChanHelper &inHelper,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAAudioUnit::CanDo (const CAAUChanHelper &inputs,
|
bool CAAudioUnit::CanDo (const CAAUChanHelper &inputs,
|
||||||
const CAAUChanHelper &outputs) const
|
const CAAUChanHelper &outputs) const
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -564,7 +564,7 @@ bool CAAudioUnit::CanDo (const CAAUChanHelper &inputs,
|
||||||
// (1) special cases (effects and sources (generators and instruments) only)
|
// (1) special cases (effects and sources (generators and instruments) only)
|
||||||
UInt32 dataSize = 0;
|
UInt32 dataSize = 0;
|
||||||
if (GetPropertyInfo (kAudioUnitProperty_SupportedNumChannels,
|
if (GetPropertyInfo (kAudioUnitProperty_SupportedNumChannels,
|
||||||
kAudioUnitScope_Global, 0, &dataSize, NULL) != noErr)
|
kAudioUnitScope_Global, 0, &dataSize, NULL) != noErr)
|
||||||
{
|
{
|
||||||
if (Comp().Desc().IsEffect() || Comp().Desc().IsOffline()) {
|
if (Comp().Desc().IsEffect() || Comp().Desc().IsOffline()) {
|
||||||
UInt32 numChan = outputs.mNumEls > 0 ? outputs.mChans[0] : inputs.mChans[0];
|
UInt32 numChan = outputs.mNumEls > 0 ? outputs.mChans[0] : inputs.mChans[0];
|
||||||
|
|
@ -599,8 +599,8 @@ bool CAAudioUnit::CanDo (const CAAUChanHelper &inputs,
|
||||||
if (GetProperty (kAudioUnitProperty_SupportedNumChannels,
|
if (GetProperty (kAudioUnitProperty_SupportedNumChannels,
|
||||||
kAudioUnitScope_Global, 0,
|
kAudioUnitScope_Global, 0,
|
||||||
info.mChanInfo, &dataSize) != noErr)
|
info.mChanInfo, &dataSize) != noErr)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numInfo = dataSize / sizeof(AUChannelInfo);
|
int numInfo = dataSize / sizeof(AUChannelInfo);
|
||||||
|
|
@ -628,7 +628,7 @@ bool CAAudioUnit::CanDo (const CAAUChanHelper &inputs,
|
||||||
}
|
}
|
||||||
|
|
||||||
// (4) - not a dynamic AU, has ins and outs, and has channel constraints so we test every possible pairing
|
// (4) - not a dynamic AU, has ins and outs, and has channel constraints so we test every possible pairing
|
||||||
for (unsigned int in = 0; in < inputs.mNumEls; ++in)
|
for (unsigned int in = 0; in < inputs.mNumEls; ++in)
|
||||||
{
|
{
|
||||||
bool testInAlready = false;
|
bool testInAlready = false;
|
||||||
for (unsigned int i = 0; i < in; ++i) {
|
for (unsigned int i = 0; i < in; ++i) {
|
||||||
|
|
@ -683,7 +683,7 @@ bool CAAudioUnit::GetChannelLayouts (AudioUnitScope inScope,
|
||||||
AudioUnitElement inEl,
|
AudioUnitElement inEl,
|
||||||
ChannelTagVector &outChannelVector) const
|
ChannelTagVector &outChannelVector) const
|
||||||
{
|
{
|
||||||
if (HasChannelLayouts (inScope, inEl) == false) return false;
|
if (HasChannelLayouts (inScope, inEl) == false) return false;
|
||||||
|
|
||||||
UInt32 dataSize;
|
UInt32 dataSize;
|
||||||
OSStatus result = AudioUnitGetPropertyInfo (AU(),
|
OSStatus result = AudioUnitGetPropertyInfo (AU(),
|
||||||
|
|
@ -721,7 +721,7 @@ home:
|
||||||
return canDo;
|
return canDo;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAAudioUnit::HasChannelLayouts (AudioUnitScope inScope,
|
bool CAAudioUnit::HasChannelLayouts (AudioUnitScope inScope,
|
||||||
AudioUnitElement inEl) const
|
AudioUnitElement inEl) const
|
||||||
{
|
{
|
||||||
OSStatus result = AudioUnitGetPropertyInfo (AU(),
|
OSStatus result = AudioUnitGetPropertyInfo (AU(),
|
||||||
|
|
@ -763,7 +763,7 @@ OSStatus CAAudioUnit::SetChannelLayout (AudioUnitScope inScope,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus CAAudioUnit::SetChannelLayout (AudioUnitScope inScope,
|
OSStatus CAAudioUnit::SetChannelLayout (AudioUnitScope inScope,
|
||||||
AudioUnitElement inEl,
|
AudioUnitElement inEl,
|
||||||
AudioChannelLayout &inLayout,
|
AudioChannelLayout &inLayout,
|
||||||
UInt32 inSize)
|
UInt32 inSize)
|
||||||
|
|
@ -789,7 +789,7 @@ OSStatus CAAudioUnit::GetFormat (AudioUnitScope inScope,
|
||||||
{
|
{
|
||||||
UInt32 dataSize = sizeof (AudioStreamBasicDescription);
|
UInt32 dataSize = sizeof (AudioStreamBasicDescription);
|
||||||
return AudioUnitGetProperty (AU(), kAudioUnitProperty_StreamFormat,
|
return AudioUnitGetProperty (AU(), kAudioUnitProperty_StreamFormat,
|
||||||
inScope, inEl,
|
inScope, inEl,
|
||||||
&outFormat, &dataSize);
|
&outFormat, &dataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -799,7 +799,7 @@ OSStatus CAAudioUnit::SetFormat (AudioUnitScope inScope,
|
||||||
{
|
{
|
||||||
return AudioUnitSetProperty (AU(), kAudioUnitProperty_StreamFormat,
|
return AudioUnitSetProperty (AU(), kAudioUnitProperty_StreamFormat,
|
||||||
inScope, inEl,
|
inScope, inEl,
|
||||||
const_cast<AudioStreamBasicDescription*>(&inFormat),
|
const_cast<AudioStreamBasicDescription*>(&inFormat),
|
||||||
sizeof (AudioStreamBasicDescription));
|
sizeof (AudioStreamBasicDescription));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -809,7 +809,7 @@ OSStatus CAAudioUnit::GetSampleRate (AudioUnitScope inScope,
|
||||||
{
|
{
|
||||||
UInt32 dataSize = sizeof (Float64);
|
UInt32 dataSize = sizeof (Float64);
|
||||||
return AudioUnitGetProperty (AU(), kAudioUnitProperty_SampleRate,
|
return AudioUnitGetProperty (AU(), kAudioUnitProperty_SampleRate,
|
||||||
inScope, inEl,
|
inScope, inEl,
|
||||||
&outRate, &dataSize);
|
&outRate, &dataSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -924,9 +924,9 @@ bool CAAudioUnit::HasDynamicScope (AudioUnitScope inScope, SInt32 &outTotalNum
|
||||||
|
|
||||||
-N (where N is less than -2), signifies the total channel count on the scope side (in or out)
|
-N (where N is less than -2), signifies the total channel count on the scope side (in or out)
|
||||||
*/
|
*/
|
||||||
bool CAAudioUnit::ValidateDynamicScope (AudioUnitScope inScope,
|
bool CAAudioUnit::ValidateDynamicScope (AudioUnitScope inScope,
|
||||||
SInt32 &outTotalNumChannels,
|
SInt32 &outTotalNumChannels,
|
||||||
const AUChannelInfo *info,
|
const AUChannelInfo *info,
|
||||||
UInt32 numInfo) const
|
UInt32 numInfo) const
|
||||||
{
|
{
|
||||||
bool writable = false;
|
bool writable = false;
|
||||||
|
|
@ -956,7 +956,7 @@ bool CAAudioUnit::ValidateDynamicScope (AudioUnitScope inScope,
|
||||||
outTotalNumChannels = abs (info[i].inChannels);
|
outTotalNumChannels = abs (info[i].inChannels);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (inScope == kAudioUnitScope_Output) {
|
else if (inScope == kAudioUnitScope_Output) {
|
||||||
// isn't dynamic on this side at least
|
// isn't dynamic on this side at least
|
||||||
|
|
@ -967,7 +967,7 @@ bool CAAudioUnit::ValidateDynamicScope (AudioUnitScope inScope,
|
||||||
outTotalNumChannels = abs (info[i].outChannels);
|
outTotalNumChannels = abs (info[i].outChannels);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
break; // wrong scope was specified
|
break; // wrong scope was specified
|
||||||
|
|
@ -977,9 +977,9 @@ bool CAAudioUnit::ValidateDynamicScope (AudioUnitScope inScope,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSStatus CAAudioUnit::ConfigureDynamicScope (AudioUnitScope inScope,
|
OSStatus CAAudioUnit::ConfigureDynamicScope (AudioUnitScope inScope,
|
||||||
UInt32 inNumElements,
|
UInt32 inNumElements,
|
||||||
UInt32 *inChannelsPerElement,
|
UInt32 *inChannelsPerElement,
|
||||||
Float64 inSampleRate)
|
Float64 inSampleRate)
|
||||||
{
|
{
|
||||||
SInt32 numChannels = 0;
|
SInt32 numChannels = 0;
|
||||||
|
|
@ -1142,7 +1142,7 @@ OSStatus CAAudioUnit::StartNote (MusicDeviceInstrumentID inInstrument,
|
||||||
UInt32 inOffsetSampleFrame,
|
UInt32 inOffsetSampleFrame,
|
||||||
const MusicDeviceNoteParams * inParams)
|
const MusicDeviceNoteParams * inParams)
|
||||||
{
|
{
|
||||||
return mDataPtr ? (OSStatus) mDataPtr->StartNote (inInstrument, inGroupID, outNoteInstanceID, inOffsetSampleFrame, inParams)
|
return mDataPtr ? (OSStatus) mDataPtr->StartNote (inInstrument, inGroupID, outNoteInstanceID, inOffsetSampleFrame, inParams)
|
||||||
: paramErr;
|
: paramErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1165,11 +1165,11 @@ OSStatus CAAudioUnit::Render (AudioUnitRenderActionFlags * ioActionFlags,
|
||||||
}
|
}
|
||||||
|
|
||||||
static AURenderCallbackStruct sRenderCallback;
|
static AURenderCallbackStruct sRenderCallback;
|
||||||
static OSStatus PrerollRenderProc ( void * /*inRefCon*/,
|
static OSStatus PrerollRenderProc ( void * /*inRefCon*/,
|
||||||
AudioUnitRenderActionFlags * /*inActionFlags*/,
|
AudioUnitRenderActionFlags * /*inActionFlags*/,
|
||||||
const AudioTimeStamp * /*inTimeStamp*/,
|
const AudioTimeStamp * /*inTimeStamp*/,
|
||||||
UInt32 /*inBusNumber*/,
|
UInt32 /*inBusNumber*/,
|
||||||
UInt32 /*inNumFrames*/,
|
UInt32 /*inNumFrames*/,
|
||||||
AudioBufferList *ioData)
|
AudioBufferList *ioData)
|
||||||
{
|
{
|
||||||
AudioBuffer *buf = ioData->mBuffers;
|
AudioBuffer *buf = ioData->mBuffers;
|
||||||
|
|
@ -1185,12 +1185,12 @@ OSStatus CAAudioUnit::Preroll (UInt32 inFrameSize)
|
||||||
OSStatus result = GetFormat (kAudioUnitScope_Input, 0, desc);
|
OSStatus result = GetFormat (kAudioUnitScope_Input, 0, desc);
|
||||||
bool hasInput = false;
|
bool hasInput = false;
|
||||||
//we have input
|
//we have input
|
||||||
if (result == noErr)
|
if (result == noErr)
|
||||||
{
|
{
|
||||||
sRenderCallback.inputProc = PrerollRenderProc;
|
sRenderCallback.inputProc = PrerollRenderProc;
|
||||||
sRenderCallback.inputProcRefCon = 0;
|
sRenderCallback.inputProcRefCon = 0;
|
||||||
|
|
||||||
result = SetProperty (kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input,
|
result = SetProperty (kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input,
|
||||||
0, &sRenderCallback, sizeof(sRenderCallback));
|
0, &sRenderCallback, sizeof(sRenderCallback));
|
||||||
if (result) return result;
|
if (result) return result;
|
||||||
hasInput = true;
|
hasInput = true;
|
||||||
|
|
@ -1217,7 +1217,7 @@ home:
|
||||||
sRenderCallback.inputProc = 0;
|
sRenderCallback.inputProc = 0;
|
||||||
sRenderCallback.inputProcRefCon = 0;
|
sRenderCallback.inputProcRefCon = 0;
|
||||||
|
|
||||||
SetProperty (kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input,
|
SetProperty (kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input,
|
||||||
0, &sRenderCallback, sizeof(sRenderCallback));
|
0, &sRenderCallback, sizeof(sRenderCallback));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1251,8 +1251,8 @@ CAAUChanHelper::~CAAUChanHelper()
|
||||||
if (mDidAllocate) delete [] mChans;
|
if (mDidAllocate) delete [] mChans;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAAUChanHelper& CAAUChanHelper::operator= (const CAAUChanHelper &c)
|
CAAUChanHelper& CAAUChanHelper::operator= (const CAAUChanHelper &c)
|
||||||
{
|
{
|
||||||
if (mDidAllocate) delete [] mChans;
|
if (mDidAllocate) delete [] mChans;
|
||||||
if (c.mDidAllocate) {
|
if (c.mDidAllocate) {
|
||||||
mChans = new UInt32[c.mNumEls];
|
mChans = new UInt32[c.mNumEls];
|
||||||
|
|
@ -1263,7 +1263,7 @@ CAAUChanHelper& CAAUChanHelper::operator= (const CAAUChanHelper &c)
|
||||||
}
|
}
|
||||||
memcpy (mChans, c.mChans, c.mNumEls * sizeof(int));
|
memcpy (mChans, c.mChans, c.mNumEls * sizeof(int));
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark __Print Utilities
|
#pragma mark __Print Utilities
|
||||||
|
|
@ -1271,7 +1271,7 @@ CAAUChanHelper& CAAUChanHelper::operator= (const CAAUChanHelper &c)
|
||||||
void CAAudioUnit::Print (FILE* file) const
|
void CAAudioUnit::Print (FILE* file) const
|
||||||
{
|
{
|
||||||
fprintf (file, "AudioUnit:%p\n", AU());
|
fprintf (file, "AudioUnit:%p\n", AU());
|
||||||
if (IsValid()) {
|
if (IsValid()) {
|
||||||
fprintf (file, "\tnode=%ld\t", (long)GetAUNode()); Comp().Print (file);
|
fprintf (file, "\tnode=%ld\t", (long)GetAUNode()); Comp().Print (file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ void CABufferList::DeallocateBuffers()
|
||||||
delete[] mBufferMemory;
|
delete[] mBufferMemory;
|
||||||
mBufferMemory = NULL;
|
mBufferMemory = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void CAShowAudioBufferList(const AudioBufferList *abl, int framesToPrint, int wordSize)
|
extern "C" void CAShowAudioBufferList(const AudioBufferList *abl, int framesToPrint, int wordSize)
|
||||||
|
|
@ -131,7 +131,7 @@ extern "C" void CAShowAudioBufferList(const AudioBufferList *abl, int framesToPr
|
||||||
printf("AudioBufferList @ %p:\n", abl);
|
printf("AudioBufferList @ %p:\n", abl);
|
||||||
const AudioBuffer *buf = abl->mBuffers;
|
const AudioBuffer *buf = abl->mBuffers;
|
||||||
for (UInt32 i = 0; i < abl->mNumberBuffers; ++i, ++buf) {
|
for (UInt32 i = 0; i < abl->mNumberBuffers; ++i, ++buf) {
|
||||||
printf(" [%2ld]: %2ldch, %5ld bytes @ %8p",
|
printf(" [%2ld]: %2ldch, %5ld bytes @ %8p",
|
||||||
i, buf->mNumberChannels, buf->mDataByteSize, buf->mData);
|
i, buf->mNumberChannels, buf->mDataByteSize, buf->mData);
|
||||||
if (framesToPrint) {
|
if (framesToPrint) {
|
||||||
printf(":");
|
printf(":");
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
CAComponent.cpp
|
CAComponent.cpp
|
||||||
|
|
||||||
=============================================================================*/
|
=============================================================================*/
|
||||||
|
|
||||||
#include "CAComponent.h"
|
#include "CAComponent.h"
|
||||||
|
|
@ -55,23 +55,23 @@ CAComponent::CAComponent (const ComponentDescription& inDesc, CAComponent* next)
|
||||||
memcpy (&mDesc, &inDesc, sizeof(ComponentDescription));
|
memcpy (&mDesc, &inDesc, sizeof(ComponentDescription));
|
||||||
}
|
}
|
||||||
|
|
||||||
CAComponent::CAComponent (const Component& comp)
|
CAComponent::CAComponent (const Component& comp)
|
||||||
: mComp (comp),
|
: mComp (comp),
|
||||||
mManuName(0),
|
mManuName(0),
|
||||||
mAUName(0),
|
mAUName(0),
|
||||||
mCompName(0),
|
mCompName(0),
|
||||||
mCompInfo (0)
|
mCompInfo (0)
|
||||||
{
|
{
|
||||||
GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL);
|
GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAComponent::CAComponent (const ComponentInstance& compInst)
|
CAComponent::CAComponent (const ComponentInstance& compInst)
|
||||||
: mComp (Component(compInst)),
|
: mComp (Component(compInst)),
|
||||||
mManuName(0),
|
mManuName(0),
|
||||||
mAUName(0),
|
mAUName(0),
|
||||||
mCompName(0),
|
mCompName(0),
|
||||||
mCompInfo (0)
|
mCompInfo (0)
|
||||||
{
|
{
|
||||||
GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL);
|
GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,7 +107,7 @@ OSStatus CAComponent::GetResourceVersion (UInt32 &outVersion) const
|
||||||
// only go on if we successfully found at least 1 thng resource
|
// only go on if we successfully found at least 1 thng resource
|
||||||
require_noerr (thngResourceCount <= 0 ? -1 : 0, home);
|
require_noerr (thngResourceCount <= 0 ? -1 : 0, home);
|
||||||
|
|
||||||
// loop through all of the Component thng resources trying to
|
// loop through all of the Component thng resources trying to
|
||||||
// find one that matches this Component description
|
// find one that matches this Component description
|
||||||
for (short i = 0; i < thngResourceCount && (!versionFound); i++)
|
for (short i = 0; i < thngResourceCount && (!versionFound); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -121,8 +121,8 @@ OSStatus CAComponent::GetResourceVersion (UInt32 &outVersion) const
|
||||||
|
|
||||||
// check to see if this is the thng resource for the particular Component that we are looking at
|
// check to see if this is the thng resource for the particular Component that we are looking at
|
||||||
// (there often is more than one Component described in the resource)
|
// (there often is more than one Component described in the resource)
|
||||||
if ((componentThng->cd.componentType == mDesc.Type())
|
if ((componentThng->cd.componentType == mDesc.Type())
|
||||||
&& (componentThng->cd.componentSubType == mDesc.SubType())
|
&& (componentThng->cd.componentSubType == mDesc.SubType())
|
||||||
&& (componentThng->cd.componentManufacturer == mDesc.Manu()))
|
&& (componentThng->cd.componentManufacturer == mDesc.Manu()))
|
||||||
{
|
{
|
||||||
outVersion = componentThng->componentVersion;
|
outVersion = componentThng->componentVersion;
|
||||||
|
|
@ -162,7 +162,7 @@ CAComponent& CAComponent::operator= (const CAComponent& y)
|
||||||
|
|
||||||
if (y.mManuName) { mManuName = y.mManuName; CFRetain (mManuName); }
|
if (y.mManuName) { mManuName = y.mManuName; CFRetain (mManuName); }
|
||||||
if (y.mAUName) { mAUName = y.mAUName; CFRetain (mAUName); }
|
if (y.mAUName) { mAUName = y.mAUName; CFRetain (mAUName); }
|
||||||
if (y.mCompName) { mCompName = y.mCompName; CFRetain (mCompName); }
|
if (y.mCompName) { mCompName = y.mCompName; CFRetain (mCompName); }
|
||||||
if (y.mCompInfo) { mCompInfo = y.mCompInfo; CFRetain (mCompInfo); }
|
if (y.mCompInfo) { mCompInfo = y.mCompInfo; CFRetain (mCompInfo); }
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
|
|
@ -208,7 +208,7 @@ void CAComponent::SetCompNames () const
|
||||||
displayStr[j] = 0;
|
displayStr[j] = 0;
|
||||||
|
|
||||||
const_cast<CAComponent*>(this)->mAUName = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingMacRoman);
|
const_cast<CAComponent*>(this)->mAUName = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingMacRoman);
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposeHandle (h1);
|
DisposeHandle (h1);
|
||||||
}
|
}
|
||||||
|
|
@ -252,6 +252,6 @@ void CAComponent::Print(FILE* file) const
|
||||||
fprintf (file, ", Manu:"); _ShowCF (file, mManuName);
|
fprintf (file, ", Manu:"); _ShowCF (file, mManuName);
|
||||||
if (mAUName) fprintf (file, ", Name:"); _ShowCF (file, mAUName);
|
if (mAUName) fprintf (file, ", Name:"); _ShowCF (file, mAUName);
|
||||||
}
|
}
|
||||||
fprintf (file, ", ");
|
fprintf (file, ", ");
|
||||||
Desc ().Print(file);
|
Desc ().Print(file);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
CAComponentDescription.cpp
|
CAComponentDescription.cpp
|
||||||
|
|
||||||
=============================================================================*/
|
=============================================================================*/
|
||||||
|
|
||||||
#include "CAComponentDescription.h"
|
#include "CAComponentDescription.h"
|
||||||
|
|
@ -87,8 +87,8 @@ CAComponentDescription::CAComponentDescription (OSType inType, OSType inSubtype,
|
||||||
componentFlagsMask = 0;
|
componentFlagsMask = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAComponentDescription::IsAU () const
|
bool CAComponentDescription::IsAU () const
|
||||||
{
|
{
|
||||||
bool flag = IsEffect() || IsMusicDevice() || IsOffline();
|
bool flag = IsEffect() || IsMusicDevice() || IsOffline();
|
||||||
if (flag) return true;
|
if (flag) return true;
|
||||||
|
|
||||||
|
|
@ -103,7 +103,7 @@ bool CAComponentDescription::IsAU () const
|
||||||
|
|
||||||
inline bool _MatchTest (const OSType &inTypeA, const OSType &inTypeB)
|
inline bool _MatchTest (const OSType &inTypeA, const OSType &inTypeB)
|
||||||
{
|
{
|
||||||
return ((inTypeA == inTypeB) || (!inTypeA && !inTypeB) || (inTypeA && !inTypeB) || (!inTypeA && inTypeB));
|
return ((inTypeA == inTypeB) || (!inTypeA && !inTypeB) || (inTypeA && !inTypeB) || (!inTypeA && inTypeB));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAComponentDescription::Matches (const ComponentDescription &desc) const
|
bool CAComponentDescription::Matches (const ComponentDescription &desc) const
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
CAStreamBasicDescription.cpp
|
CAStreamBasicDescription.cpp
|
||||||
|
|
||||||
=============================================================================*/
|
=============================================================================*/
|
||||||
|
|
||||||
#include "CAConditionalMacros.h"
|
#include "CAConditionalMacros.h"
|
||||||
|
|
@ -82,9 +82,9 @@ void CAStreamBasicDescription::PrintFormat(FILE *f, const char *indent, const ch
|
||||||
if (mFormatID == kAudioFormatLinearPCM) {
|
if (mFormatID == kAudioFormatLinearPCM) {
|
||||||
bool isInt = !(mFormatFlags & kLinearPCMFormatFlagIsFloat);
|
bool isInt = !(mFormatFlags & kLinearPCMFormatFlagIsFloat);
|
||||||
int wordSize = SampleWordSize();
|
int wordSize = SampleWordSize();
|
||||||
const char *endian = (wordSize > 1) ?
|
const char *endian = (wordSize > 1) ?
|
||||||
((mFormatFlags & kLinearPCMFormatFlagIsBigEndian) ? " big-endian" : " little-endian" ) : "";
|
((mFormatFlags & kLinearPCMFormatFlagIsBigEndian) ? " big-endian" : " little-endian" ) : "";
|
||||||
const char *sign = isInt ?
|
const char *sign = isInt ?
|
||||||
((mFormatFlags & kLinearPCMFormatFlagIsSignedInteger) ? " signed" : " unsigned") : "";
|
((mFormatFlags & kLinearPCMFormatFlagIsSignedInteger) ? " signed" : " unsigned") : "";
|
||||||
const char *floatInt = isInt ? "integer" : "float";
|
const char *floatInt = isInt ? "integer" : "float";
|
||||||
char packed[32];
|
char packed[32];
|
||||||
|
|
@ -101,7 +101,7 @@ void CAStreamBasicDescription::PrintFormat(FILE *f, const char *indent, const ch
|
||||||
const char *commaSpace = (packed[0]!='\0') || (align[0]!='\0') ? ", " : "";
|
const char *commaSpace = (packed[0]!='\0') || (align[0]!='\0') ? ", " : "";
|
||||||
|
|
||||||
fprintf(f, "%ld-bit%s%s %s%s%s%s%s\n",
|
fprintf(f, "%ld-bit%s%s %s%s%s%s%s\n",
|
||||||
mBitsPerChannel, endian, sign, floatInt,
|
mBitsPerChannel, endian, sign, floatInt,
|
||||||
commaSpace, packed, align, deinter);
|
commaSpace, packed, align, deinter);
|
||||||
} else if (mFormatID == 'alac') { // kAudioFormatAppleLossless
|
} else if (mFormatID == 'alac') { // kAudioFormatAppleLossless
|
||||||
int sourceBits = 0;
|
int sourceBits = 0;
|
||||||
|
|
@ -128,7 +128,7 @@ void CAStreamBasicDescription::PrintFormat(FILE *f, const char *indent, const ch
|
||||||
fprintf(f, "%ld frames/packet\n", mFramesPerPacket);
|
fprintf(f, "%ld frames/packet\n", mFramesPerPacket);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(f, "%ld bits/channel, %ld bytes/packet, %ld frames/packet, %ld bytes/frame\n",
|
fprintf(f, "%ld bits/channel, %ld bytes/packet, %ld frames/packet, %ld bytes/frame\n",
|
||||||
mBitsPerChannel, mBytesPerPacket, mFramesPerPacket, mBytesPerFrame);
|
mBitsPerChannel, mBytesPerPacket, mFramesPerPacket, mBytesPerFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -440,7 +440,7 @@ static bool MatchFormatFlags(const AudioStreamBasicDescription& x, const AudioSt
|
||||||
UInt32 yFlags = y.mFormatFlags;
|
UInt32 yFlags = y.mFormatFlags;
|
||||||
|
|
||||||
// match wildcards
|
// match wildcards
|
||||||
if (x.mFormatID == 0 || y.mFormatID == 0 || xFlags == 0 || yFlags == 0)
|
if (x.mFormatID == 0 || y.mFormatID == 0 || xFlags == 0 || yFlags == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (x.mFormatID == kAudioFormatLinearPCM)
|
if (x.mFormatID == kAudioFormatLinearPCM)
|
||||||
|
|
@ -488,7 +488,7 @@ bool operator==(const AudioStreamBasicDescription& x, const AudioStreamBasicDesc
|
||||||
|
|
||||||
#define MATCH(name) ((x.name) == 0 || (y.name) == 0 || (x.name) == (y.name))
|
#define MATCH(name) ((x.name) == 0 || (y.name) == 0 || (x.name) == (y.name))
|
||||||
|
|
||||||
return
|
return
|
||||||
// check the sample rate
|
// check the sample rate
|
||||||
(fiszero(x.mSampleRate) || fiszero(y.mSampleRate) || fequal(x.mSampleRate, y.mSampleRate))
|
(fiszero(x.mSampleRate) || fiszero(y.mSampleRate) || fequal(x.mSampleRate, y.mSampleRate))
|
||||||
|
|
||||||
|
|
@ -496,19 +496,19 @@ bool operator==(const AudioStreamBasicDescription& x, const AudioStreamBasicDesc
|
||||||
&& MATCH(mFormatID)
|
&& MATCH(mFormatID)
|
||||||
|
|
||||||
// check the format flags
|
// check the format flags
|
||||||
&& MatchFormatFlags(x, y)
|
&& MatchFormatFlags(x, y)
|
||||||
|
|
||||||
// check the bytes per packet
|
// check the bytes per packet
|
||||||
&& MATCH(mBytesPerPacket)
|
&& MATCH(mBytesPerPacket)
|
||||||
|
|
||||||
// check the frames per packet
|
// check the frames per packet
|
||||||
&& MATCH(mFramesPerPacket)
|
&& MATCH(mFramesPerPacket)
|
||||||
|
|
||||||
// check the bytes per frame
|
// check the bytes per frame
|
||||||
&& MATCH(mBytesPerFrame)
|
&& MATCH(mBytesPerFrame)
|
||||||
|
|
||||||
// check the channels per frame
|
// check the channels per frame
|
||||||
&& MATCH(mChannelsPerFrame)
|
&& MATCH(mChannelsPerFrame)
|
||||||
|
|
||||||
// check the channels per frame
|
// check the channels per frame
|
||||||
&& MATCH(mBitsPerChannel) ;
|
&& MATCH(mBitsPerChannel) ;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "UMicroseconds.h"
|
#include "UMicroseconds.h"
|
||||||
|
|
||||||
namespace wvNS {
|
namespace wvNS {
|
||||||
UMicroseconds& UMicroseconds::ReadTime()
|
UMicroseconds& UMicroseconds::ReadTime()
|
||||||
{
|
{
|
||||||
// Note: g_get_monotonic_time() may be a viable alternative
|
// Note: g_get_monotonic_time() may be a viable alternative
|
||||||
|
|
@ -39,7 +39,7 @@ UMicroseconds& UMicroseconds::ReadTime()
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Removed in favor of the posix implementation.
|
Removed in favor of the posix implementation.
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
uint32_t UMicroseconds::hi() {return reinterpret_cast<UnsignedWide*>(&theTime)->hi;}
|
uint32_t UMicroseconds::hi() {return reinterpret_cast<UnsignedWide*>(&theTime)->hi;}
|
||||||
uint32_t UMicroseconds::lo() {return reinterpret_cast<UnsignedWide*>(&theTime)->lo;}
|
uint32_t UMicroseconds::lo() {return reinterpret_cast<UnsignedWide*>(&theTime)->lo;}
|
||||||
|
|
@ -74,4 +74,4 @@ UMicrosecondsAccumulator& UMicrosecondsAccumulator::operator+=(const UMicrosecon
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace wvNS {
|
} // namespace wvNS {
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ namespace wvThread
|
||||||
//--------------------- begin measurement code
|
//--------------------- begin measurement code
|
||||||
// poll to align to a tick of gettimeofday
|
// poll to align to a tick of gettimeofday
|
||||||
::gettimeofday(&tvtmp,0);
|
::gettimeofday(&tvtmp,0);
|
||||||
do {
|
do {
|
||||||
::gettimeofday(&tvstart,0);
|
::gettimeofday(&tvstart,0);
|
||||||
__asm__ __volatile__ (".byte 0x0f, 0x31" : "=A" (Tstart)); // RDTSC
|
__asm__ __volatile__ (".byte 0x0f, 0x31" : "=A" (Tstart)); // RDTSC
|
||||||
} while (tvtmp.tv_usec!=tvstart.tv_usec);
|
} while (tvtmp.tv_usec!=tvstart.tv_usec);
|
||||||
|
|
@ -74,7 +74,7 @@ namespace wvThread
|
||||||
::usleep(sktd_TSC_MeasurementPeriod);
|
::usleep(sktd_TSC_MeasurementPeriod);
|
||||||
//
|
//
|
||||||
::gettimeofday(&tvtmp,0);
|
::gettimeofday(&tvtmp,0);
|
||||||
do {
|
do {
|
||||||
::gettimeofday(&tvend,0);
|
::gettimeofday(&tvend,0);
|
||||||
__asm__ __volatile__ (".byte 0x0f, 0x31" : "=A" (Tend)); // RDTSC
|
__asm__ __volatile__ (".byte 0x0f, 0x31" : "=A" (Tend)); // RDTSC
|
||||||
} while (tvtmp.tv_usec!=tvend.tv_usec);
|
} while (tvtmp.tv_usec!=tvend.tv_usec);
|
||||||
|
|
@ -86,10 +86,10 @@ namespace wvThread
|
||||||
#endif
|
#endif
|
||||||
return nTicksPerMicrosecond;
|
return nTicksPerMicrosecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__) //&& !defined(__MACH__)
|
#if defined(__APPLE__) //&& !defined(__MACH__)
|
||||||
|
|
||||||
|
|
||||||
bool FindNetInterfaceByIPAddress(const char *sIP, char *sInterface) // sIP and sInterface are both char[16]
|
bool FindNetInterfaceByIPAddress(const char *sIP, char *sInterface) // sIP and sInterface are both char[16]
|
||||||
{
|
{
|
||||||
FILE *fProcess , *pSubcall;
|
FILE *fProcess , *pSubcall;
|
||||||
|
|
@ -106,7 +106,7 @@ namespace wvThread
|
||||||
while (pToken)
|
while (pToken)
|
||||||
{
|
{
|
||||||
sprintf(sCommand, "ifconfig %s | grep \"inet %s \"", pToken, sIP);
|
sprintf(sCommand, "ifconfig %s | grep \"inet %s \"", pToken, sIP);
|
||||||
|
|
||||||
pSubcall = popen(sCommand, "r");
|
pSubcall = popen(sCommand, "r");
|
||||||
if (pSubcall)
|
if (pSubcall)
|
||||||
{
|
{
|
||||||
|
|
@ -121,12 +121,12 @@ namespace wvThread
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pclose(pSubcall);
|
pclose(pSubcall);
|
||||||
pToken = strtok(NULL, " ");
|
pToken = strtok(NULL, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
pclose(fProcess);
|
pclose(fProcess);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif // MACOS
|
#endif // MACOS
|
||||||
|
|
@ -198,7 +198,7 @@ namespace wvThread
|
||||||
#elif XPLATFORMTHREADS_POSIX
|
#elif XPLATFORMTHREADS_POSIX
|
||||||
void yield() { ::sched_yield(); }
|
void yield() { ::sched_yield(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -214,14 +214,14 @@ namespace wvThread
|
||||||
inline void obtain() { EnsureThreadingInitialized(); ::EnterCriticalSection (&m_critsec); }
|
inline void obtain() { EnsureThreadingInitialized(); ::EnterCriticalSection (&m_critsec); }
|
||||||
inline void release() { EnsureThreadingInitialized(); ::LeaveCriticalSection (&m_critsec); }
|
inline void release() { EnsureThreadingInitialized(); ::LeaveCriticalSection (&m_critsec); }
|
||||||
inline bool tryobtain() { EnsureThreadingInitialized(); return TryEnterCriticalSection(&m_critsec)!=FALSE; }
|
inline bool tryobtain() { EnsureThreadingInitialized(); return TryEnterCriticalSection(&m_critsec)!=FALSE; }
|
||||||
|
|
||||||
#elif defined (XPLATFORMTHREADS_POSIX)
|
#elif defined (XPLATFORMTHREADS_POSIX)
|
||||||
protected:
|
protected:
|
||||||
pthread_mutex_t m_ptmutex;
|
pthread_mutex_t m_ptmutex;
|
||||||
public:
|
public:
|
||||||
inline OSDependentMutex()
|
inline OSDependentMutex()
|
||||||
{
|
{
|
||||||
EnsureThreadingInitialized();
|
EnsureThreadingInitialized();
|
||||||
pthread_mutexattr_t attr;
|
pthread_mutexattr_t attr;
|
||||||
pthread_mutexattr_init(&attr);
|
pthread_mutexattr_init(&attr);
|
||||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
|
@ -237,7 +237,7 @@ namespace wvThread
|
||||||
|
|
||||||
ThreadMutexInited::ThreadMutexInited() :
|
ThreadMutexInited::ThreadMutexInited() :
|
||||||
m_osdmutex(0) {}
|
m_osdmutex(0) {}
|
||||||
|
|
||||||
void ThreadMutexInited::init()
|
void ThreadMutexInited::init()
|
||||||
{
|
{
|
||||||
if (! is_init())
|
if (! is_init())
|
||||||
|
|
@ -245,7 +245,7 @@ namespace wvThread
|
||||||
m_osdmutex = new OSDependentMutex;
|
m_osdmutex = new OSDependentMutex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadMutexInited::uninit()
|
void ThreadMutexInited::uninit()
|
||||||
{
|
{
|
||||||
if (is_init())
|
if (is_init())
|
||||||
|
|
@ -254,38 +254,38 @@ namespace wvThread
|
||||||
m_osdmutex = 0;
|
m_osdmutex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadMutexInited::~ThreadMutexInited()
|
ThreadMutexInited::~ThreadMutexInited()
|
||||||
{
|
{
|
||||||
uninit();
|
uninit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadMutexInited::obtain()
|
void ThreadMutexInited::obtain()
|
||||||
{
|
{
|
||||||
if (is_init())
|
if (is_init())
|
||||||
{
|
{
|
||||||
m_osdmutex->obtain();
|
m_osdmutex->obtain();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadMutexInited::release()
|
void ThreadMutexInited::release()
|
||||||
{
|
{
|
||||||
if (is_init())
|
if (is_init())
|
||||||
{
|
{
|
||||||
m_osdmutex->release();
|
m_osdmutex->release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ThreadMutexInited::tryobtain()
|
bool ThreadMutexInited::tryobtain()
|
||||||
{
|
{
|
||||||
bool retVal = true;
|
bool retVal = true;
|
||||||
if (is_init())
|
if (is_init())
|
||||||
{
|
{
|
||||||
retVal = m_osdmutex->tryobtain();
|
retVal = m_osdmutex->tryobtain();
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ThreadConditionSignal::OSDependentObject : public noncopyableobject
|
class ThreadConditionSignal::OSDependentObject : public noncopyableobject
|
||||||
{
|
{
|
||||||
#if defined (XPLATFORMTHREADS_POSIX)
|
#if defined (XPLATFORMTHREADS_POSIX)
|
||||||
|
|
@ -294,17 +294,17 @@ namespace wvThread
|
||||||
pthread_cond_t m_ptcond;
|
pthread_cond_t m_ptcond;
|
||||||
pthread_mutex_t m_ptmutex;
|
pthread_mutex_t m_ptmutex;
|
||||||
public:
|
public:
|
||||||
inline OSDependentObject()
|
inline OSDependentObject()
|
||||||
{
|
{
|
||||||
EnsureThreadingInitialized();
|
EnsureThreadingInitialized();
|
||||||
::pthread_mutex_init(&m_ptmutex,0);
|
::pthread_mutex_init(&m_ptmutex,0);
|
||||||
::pthread_cond_init(&m_ptcond, 0);
|
::pthread_cond_init(&m_ptcond, 0);
|
||||||
}
|
}
|
||||||
inline ~OSDependentObject() { ::pthread_cond_destroy(&m_ptcond), ::pthread_mutex_destroy(&m_ptmutex); }
|
inline ~OSDependentObject() { ::pthread_cond_destroy(&m_ptcond), ::pthread_mutex_destroy(&m_ptmutex); }
|
||||||
inline void signal_unicast() { ::pthread_cond_signal(&m_ptcond); }
|
inline void signal_unicast() { ::pthread_cond_signal(&m_ptcond); }
|
||||||
inline void signal_broadcast() { ::pthread_cond_broadcast(&m_ptcond); }
|
inline void signal_broadcast() { ::pthread_cond_broadcast(&m_ptcond); }
|
||||||
inline void await_signal() { ::pthread_cond_wait(&m_ptcond, &m_ptmutex); }
|
inline void await_signal() { ::pthread_cond_wait(&m_ptcond, &m_ptmutex); }
|
||||||
inline bool await_signal(timediff td)
|
inline bool await_signal(timediff td)
|
||||||
{
|
{
|
||||||
timespec tspecDeadline;
|
timespec tspecDeadline;
|
||||||
timeval tvNow;
|
timeval tvNow;
|
||||||
|
|
@ -423,14 +423,14 @@ namespace wvThread
|
||||||
#endif // OS switch
|
#endif // OS switch
|
||||||
};
|
};
|
||||||
|
|
||||||
void ThreadConditionSignal::obtain_mutex()
|
void ThreadConditionSignal::obtain_mutex()
|
||||||
{
|
{
|
||||||
m_osdepobj.obtain_mutex();
|
m_osdepobj.obtain_mutex();
|
||||||
}
|
}
|
||||||
bool ThreadConditionSignal::tryobtain_mutex() { return m_osdepobj.tryobtain_mutex(); }
|
bool ThreadConditionSignal::tryobtain_mutex() { return m_osdepobj.tryobtain_mutex(); }
|
||||||
void ThreadConditionSignal::release_mutex()
|
void ThreadConditionSignal::release_mutex()
|
||||||
{
|
{
|
||||||
m_osdepobj.release_mutex();
|
m_osdepobj.release_mutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadConditionSignal::await_condition() { m_osdepobj.await_signal(); }
|
void ThreadConditionSignal::await_condition() { m_osdepobj.await_signal(); }
|
||||||
|
|
@ -587,7 +587,7 @@ namespace wvThread
|
||||||
0 // where to store thread ID
|
0 // where to store thread ID
|
||||||
);
|
);
|
||||||
|
|
||||||
if (h)
|
if (h)
|
||||||
{
|
{
|
||||||
th.m_oshandle = h;
|
th.m_oshandle = h;
|
||||||
if (pri!=ThreadPriority::Normal)
|
if (pri!=ThreadPriority::Normal)
|
||||||
|
|
@ -620,8 +620,8 @@ namespace wvThread
|
||||||
ThunkedThreadWrapper,
|
ThunkedThreadWrapper,
|
||||||
ptwdata
|
ptwdata
|
||||||
);
|
);
|
||||||
|
|
||||||
if (anyerr)
|
if (anyerr)
|
||||||
th=Invalid;
|
th=Invalid;
|
||||||
else
|
else
|
||||||
th.m_oshandle = OSDependent::from_oshandle(pt);
|
th.m_oshandle = OSDependent::from_oshandle(pt);
|
||||||
|
|
@ -676,7 +676,7 @@ namespace wvThread
|
||||||
class WCThreadRef::OSDependent
|
class WCThreadRef::OSDependent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void GetCurrentThreadRef(WCThreadRef& tid);
|
static void GetCurrentThreadRef(WCThreadRef& tid);
|
||||||
#if XPLATFORMTHREADS_WINDOWS
|
#if XPLATFORMTHREADS_WINDOWS
|
||||||
static inline uintptr_t from_os(DWORD thread_id) { return (uintptr_t)(thread_id); }
|
static inline uintptr_t from_os(DWORD thread_id) { return (uintptr_t)(thread_id); }
|
||||||
static inline DWORD to_os(uintptr_t thread_id) { return (DWORD)(thread_id); }
|
static inline DWORD to_os(uintptr_t thread_id) { return (DWORD)(thread_id); }
|
||||||
|
|
@ -735,7 +735,7 @@ namespace wvThread
|
||||||
|
|
||||||
WCThreadRef GetCurrentThreadRef()
|
WCThreadRef GetCurrentThreadRef()
|
||||||
{
|
{
|
||||||
EnsureThreadingInitialized(); // Is it necessary?
|
EnsureThreadingInitialized(); // Is it necessary?
|
||||||
WCThreadRef tRefToReturn;
|
WCThreadRef tRefToReturn;
|
||||||
WCThreadRef::OSDependent::GetCurrentThreadRef(tRefToReturn);
|
WCThreadRef::OSDependent::GetCurrentThreadRef(tRefToReturn);
|
||||||
return tRefToReturn;
|
return tRefToReturn;
|
||||||
|
|
@ -794,7 +794,7 @@ namespace wvThread
|
||||||
bool WCAtomicLock::obtain(const uint32_t in_num_trys)
|
bool WCAtomicLock::obtain(const uint32_t in_num_trys)
|
||||||
{
|
{
|
||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
|
|
||||||
uint32_t timeOut = in_num_trys;
|
uint32_t timeOut = in_num_trys;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
@ -812,7 +812,7 @@ namespace wvThread
|
||||||
sleep_milliseconds(1000);
|
sleep_milliseconds(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Akupara
|
||||||
{
|
{
|
||||||
// The ultimate nothingness
|
// The ultimate nothingness
|
||||||
// This is useful for writing constructors that nullify their object, and for testing nullness
|
// This is useful for writing constructors that nullify their object, and for testing nullness
|
||||||
struct null_type
|
struct null_type
|
||||||
{
|
{
|
||||||
null_type() {}
|
null_type() {}
|
||||||
null_type(const null_type *) {} // this allows 0 to be implicitly converted to null_type
|
null_type(const null_type *) {} // this allows 0 to be implicitly converted to null_type
|
||||||
|
|
|
||||||
|
|
@ -18,22 +18,22 @@ namespace Akupara
|
||||||
|
|
||||||
// Integer log2 functions
|
// Integer log2 functions
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
template<unsigned int n>
|
template<unsigned int n>
|
||||||
struct compiletime_bit_count_to_represent { static const unsigned int value = 1+compiletime_bit_count_to_represent<(n>>1)>::value; };
|
struct compiletime_bit_count_to_represent { static const unsigned int value = 1+compiletime_bit_count_to_represent<(n>>1)>::value; };
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct compiletime_bit_count_to_represent<0> { static const unsigned int value = 0; };
|
struct compiletime_bit_count_to_represent<0> { static const unsigned int value = 0; };
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
template<unsigned int n>
|
template<unsigned int n>
|
||||||
struct compiletime_log2_ceiling { static const unsigned int value=compiletime_bit_count_to_represent<n-1>::value; };
|
struct compiletime_log2_ceiling { static const unsigned int value=compiletime_bit_count_to_represent<n-1>::value; };
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct compiletime_log2_ceiling<0> {}; // no value for 0 argument
|
struct compiletime_log2_ceiling<0> {}; // no value for 0 argument
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
template<unsigned int n>
|
template<unsigned int n>
|
||||||
struct compiletime_log2_floor { static const unsigned int value=compiletime_bit_count_to_represent<n>::value-1; };
|
struct compiletime_log2_floor { static const unsigned int value=compiletime_bit_count_to_represent<n>::value-1; };
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct compiletime_log2_floor<0> {}; // no value for 0 argument
|
struct compiletime_log2_floor<0> {}; // no value for 0 argument
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -41,13 +41,13 @@ namespace Akupara
|
||||||
|
|
||||||
// Assertion - accessing 'value' will generate a compile-time error if the argument evaluates to false
|
// Assertion - accessing 'value' will generate a compile-time error if the argument evaluates to false
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
template<bool>
|
template<bool>
|
||||||
struct compiletime_assert;
|
struct compiletime_assert;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct compiletime_assert<true> { static const bool value=true; };
|
struct compiletime_assert<true> { static const bool value=true; };
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct compiletime_assert<false> {}; // no value member for false assertion -> compile time error
|
struct compiletime_assert<false> {}; // no value member for false assertion -> compile time error
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -60,7 +60,7 @@ namespace Akupara
|
||||||
template<typename _true_type, typename _false_type>
|
template<typename _true_type, typename _false_type>
|
||||||
struct compiletime_select_type<true, _true_type, _false_type> { typedef _true_type type; };
|
struct compiletime_select_type<true, _true_type, _false_type> { typedef _true_type type; };
|
||||||
|
|
||||||
template<typename _true_type, typename _false_type>
|
template<typename _true_type, typename _false_type>
|
||||||
struct compiletime_select_type<false, _true_type, _false_type> { typedef _false_type type; };
|
struct compiletime_select_type<false, _true_type, _false_type> { typedef _false_type type; };
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Akupara
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template<unsigned int _size, bool _signed>
|
template<unsigned int _size, bool _signed>
|
||||||
struct integer_with_byte_count_base;
|
struct integer_with_byte_count_base;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
@ -149,15 +149,15 @@ namespace Akupara
|
||||||
AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(3, int )
|
AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(3, int )
|
||||||
|
|
||||||
//AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(4, int32_t )// 64BitConversion
|
//AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(4, int32_t )// 64BitConversion
|
||||||
template<>
|
template<>
|
||||||
struct
|
struct
|
||||||
signed_unsigned_pair<4>
|
signed_unsigned_pair<4>
|
||||||
{
|
{
|
||||||
typedef int32_t signed_type;
|
typedef int32_t signed_type;
|
||||||
typedef uint32_t unsigned_type;
|
typedef uint32_t unsigned_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(5, long long)
|
AKUPARA_SIGNED_UNSIGNED_INTEGER_PAIR(5, long long)
|
||||||
AKUPARA_SIGNED_UNSIGNED_FLOAT_PAIR (6, float )
|
AKUPARA_SIGNED_UNSIGNED_FLOAT_PAIR (6, float )
|
||||||
AKUPARA_SIGNED_UNSIGNED_FLOAT_PAIR (7, double )
|
AKUPARA_SIGNED_UNSIGNED_FLOAT_PAIR (7, double )
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Akupara/threading/atomic_ops.hpp
|
* Akupara/threading/atomic_ops.hpp
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Created by Udi Barzilai on 06/06.
|
* Created by Udi Barzilai on 06/06.
|
||||||
* Copyright 2006 __MyCompanyName__. All rights reserved.
|
* Copyright 2006 __MyCompanyName__. All rights reserved.
|
||||||
|
|
@ -91,16 +91,16 @@ namespace Akupara
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template<unsigned int _byte_count>
|
template<unsigned int _byte_count>
|
||||||
struct largest_atomic_byte_count_upto
|
struct largest_atomic_byte_count_upto
|
||||||
{
|
{
|
||||||
static const unsigned int value =
|
static const unsigned int value =
|
||||||
machine::implements_load<_byte_count>::value && machine::implements_store<_byte_count>::value ?
|
machine::implements_load<_byte_count>::value && machine::implements_store<_byte_count>::value ?
|
||||||
_byte_count :
|
_byte_count :
|
||||||
largest_atomic_byte_count_upto<_byte_count/2>::value;
|
largest_atomic_byte_count_upto<_byte_count/2>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct largest_atomic_byte_count_upto<0> { static const unsigned int value = 0; };
|
struct largest_atomic_byte_count_upto<0> { static const unsigned int value = 0; };
|
||||||
|
|
||||||
const unsigned int k_byte_count_best_atomic = largest_atomic_byte_count_upto<sizeof(int)>::value;
|
const unsigned int k_byte_count_best_atomic = largest_atomic_byte_count_upto<sizeof(int)>::value;
|
||||||
|
|
@ -129,7 +129,7 @@ _byte_count :
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template<
|
template<
|
||||||
typename _integer_type,
|
typename _integer_type,
|
||||||
bool _implements_CAS = machine::implements_CAS <sizeof(_integer_type)>::value,
|
bool _implements_CAS = machine::implements_CAS <sizeof(_integer_type)>::value,
|
||||||
bool _implements_LL_SC = machine::implements_LL_SC<sizeof(_integer_type)>::value>
|
bool _implements_LL_SC = machine::implements_LL_SC<sizeof(_integer_type)>::value>
|
||||||
struct implementation_CAS
|
struct implementation_CAS
|
||||||
|
|
@ -138,7 +138,7 @@ _byte_count :
|
||||||
};
|
};
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// specialization for native CAS support
|
// specialization for native CAS support
|
||||||
template<typename _integer_type, bool _implements_LL_SC>
|
template<typename _integer_type, bool _implements_LL_SC>
|
||||||
struct implementation_CAS<_integer_type, true, _implements_LL_SC>
|
struct implementation_CAS<_integer_type, true, _implements_LL_SC>
|
||||||
{
|
{
|
||||||
static const bool s_exists = true;
|
static const bool s_exists = true;
|
||||||
|
|
@ -164,7 +164,7 @@ _byte_count :
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
template<typename _integer_type>
|
template<typename _integer_type>
|
||||||
inline bool compare_and_store(volatile _integer_type * operand_address, const _integer_type & expected_value, const _integer_type & value_to_store)
|
inline bool compare_and_store(volatile _integer_type * operand_address, const _integer_type & expected_value, const _integer_type & value_to_store)
|
||||||
{
|
{
|
||||||
// if your compiler can't find the function to call here then there is no implementation available for your machine
|
// if your compiler can't find the function to call here then there is no implementation available for your machine
|
||||||
|
|
@ -181,7 +181,7 @@ _byte_count :
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template<
|
template<
|
||||||
typename _integer_type,
|
typename _integer_type,
|
||||||
bool _0 = machine::implements_fetch_and_add<sizeof(_integer_type)>::value,
|
bool _0 = machine::implements_fetch_and_add<sizeof(_integer_type)>::value,
|
||||||
bool _1 = machine::implements_add_and_fetch<sizeof(_integer_type)>::value,
|
bool _1 = machine::implements_add_and_fetch<sizeof(_integer_type)>::value,
|
||||||
bool _2 = machine::implements_LL_SC <sizeof(_integer_type)>::value,
|
bool _2 = machine::implements_LL_SC <sizeof(_integer_type)>::value,
|
||||||
|
|
@ -244,7 +244,7 @@ _byte_count :
|
||||||
};
|
};
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
template<typename _integer_type>
|
template<typename _integer_type>
|
||||||
inline _integer_type fetch_and_add(volatile _integer_type * operand_address, const _integer_type & addend)
|
inline _integer_type fetch_and_add(volatile _integer_type * operand_address, const _integer_type & addend)
|
||||||
{
|
{
|
||||||
// if your compiler can't find the function to call here then there is no implementation available for your machine
|
// if your compiler can't find the function to call here then there is no implementation available for your machine
|
||||||
|
|
@ -260,7 +260,7 @@ _byte_count :
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
template<
|
template<
|
||||||
typename _integer_type,
|
typename _integer_type,
|
||||||
bool _0 = machine::implements_add_and_fetch<sizeof(_integer_type)>::value,
|
bool _0 = machine::implements_add_and_fetch<sizeof(_integer_type)>::value,
|
||||||
bool _1 = machine::implements_fetch_and_add<sizeof(_integer_type)>::value,
|
bool _1 = machine::implements_fetch_and_add<sizeof(_integer_type)>::value,
|
||||||
bool _2 = machine::implements_LL_SC <sizeof(_integer_type)>::value,
|
bool _2 = machine::implements_LL_SC <sizeof(_integer_type)>::value,
|
||||||
|
|
@ -323,7 +323,7 @@ _byte_count :
|
||||||
};
|
};
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
template<typename _integer_type>
|
template<typename _integer_type>
|
||||||
inline _integer_type add_and_fetch(volatile _integer_type * operand_address, const _integer_type & addend)
|
inline _integer_type add_and_fetch(volatile _integer_type * operand_address, const _integer_type & addend)
|
||||||
{
|
{
|
||||||
// if your compiler can't find the function to call here then there is no implementation available for your machine
|
// if your compiler can't find the function to call here then there is no implementation available for your machine
|
||||||
|
|
@ -335,7 +335,7 @@ _byte_count :
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------
|
||||||
// add
|
// add
|
||||||
template<typename _integer_type>
|
template<typename _integer_type>
|
||||||
inline void add(volatile _integer_type * operand_address, const _integer_type & addend)
|
inline void add(volatile _integer_type * operand_address, const _integer_type & addend)
|
||||||
{
|
{
|
||||||
if (machine::implements_add<sizeof(_integer_type)>::value)
|
if (machine::implements_add<sizeof(_integer_type)>::value)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Akupara/threading/atomic_ops_gcc_x86.hpp
|
* Akupara/threading/atomic_ops_gcc_x86.hpp
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Created by Udi Barzilai on 06/06.
|
* Created by Udi Barzilai on 06/06.
|
||||||
* Copyright 2006 __MyCompanyName__. All rights reserved.
|
* Copyright 2006 __MyCompanyName__. All rights reserved.
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::WCMRAudioDevice
|
// WCMRAudioDevice::WCMRAudioDevice
|
||||||
//
|
//
|
||||||
//! Constructor for the audio device. The derived classes will need to do more actual work, such
|
//! Constructor for the audio device. The derived classes will need to do more actual work, such
|
||||||
//! as determining supported sampling rates, buffer sizes, and channel counts. Connection
|
//! as determining supported sampling rates, buffer sizes, and channel counts. Connection
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
//!
|
//!
|
||||||
//! \param *pManager : The audio device manager that's managing this device.
|
//! \param *pManager : The audio device manager that's managing this device.
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRAudioDevice::WCMRAudioDevice (WCMRAudioDeviceManager *pManager) :
|
WCMRAudioDevice::WCMRAudioDevice (WCMRAudioDeviceManager *pManager) :
|
||||||
m_pMyManager (pManager)
|
m_pMyManager (pManager)
|
||||||
|
|
@ -39,19 +39,19 @@ WCMRAudioDevice::WCMRAudioDevice (WCMRAudioDeviceManager *pManager) :
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::~WCMRAudioDevice
|
// WCMRAudioDevice::~WCMRAudioDevice
|
||||||
//
|
//
|
||||||
//! Destructor for the audio device. It release all the connections that were created.
|
//! Destructor for the audio device. It release all the connections that were created.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRAudioDevice::~WCMRAudioDevice ()
|
WCMRAudioDevice::~WCMRAudioDevice ()
|
||||||
{
|
{
|
||||||
AUTO_FUNC_DEBUG;
|
AUTO_FUNC_DEBUG;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
|
|
@ -65,14 +65,14 @@ WCMRAudioDevice::~WCMRAudioDevice ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::DeviceName
|
// WCMRAudioDevice::DeviceName
|
||||||
//
|
//
|
||||||
//! Retrieves Device's name.
|
//! Retrieves Device's name.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return The device name.
|
//! \return The device name.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
const std::string& WCMRAudioDevice::DeviceName () const
|
const std::string& WCMRAudioDevice::DeviceName () const
|
||||||
{
|
{
|
||||||
|
|
@ -83,14 +83,14 @@ const std::string& WCMRAudioDevice::DeviceName () const
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::InputChannels
|
// WCMRAudioDevice::InputChannels
|
||||||
//
|
//
|
||||||
//! Retrieves Input Channel information. Note that the list may be changed at run-time.
|
//! Retrieves Input Channel information. Note that the list may be changed at run-time.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return A vector with Input Channel Names.
|
//! \return A vector with Input Channel Names.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
const std::vector<std::string>& WCMRAudioDevice::InputChannels ()
|
const std::vector<std::string>& WCMRAudioDevice::InputChannels ()
|
||||||
{
|
{
|
||||||
|
|
@ -101,14 +101,14 @@ const std::vector<std::string>& WCMRAudioDevice::InputChannels ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::OutputChannels
|
// WCMRAudioDevice::OutputChannels
|
||||||
//
|
//
|
||||||
//! Retrieves Output Channel Information. Note that the list may be changed at run-time.
|
//! Retrieves Output Channel Information. Note that the list may be changed at run-time.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return A vector with Output Channel Names.
|
//! \return A vector with Output Channel Names.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
const std::vector<std::string>& WCMRAudioDevice::OutputChannels ()
|
const std::vector<std::string>& WCMRAudioDevice::OutputChannels ()
|
||||||
{
|
{
|
||||||
|
|
@ -119,14 +119,14 @@ const std::vector<std::string>& WCMRAudioDevice::OutputChannels ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::SamplingRates
|
// WCMRAudioDevice::SamplingRates
|
||||||
//
|
//
|
||||||
//! Retrieves supported sampling rate information.
|
//! Retrieves supported sampling rate information.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return A vector with supported sampling rates.
|
//! \return A vector with supported sampling rates.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
const std::vector<int>& WCMRAudioDevice::SamplingRates ()
|
const std::vector<int>& WCMRAudioDevice::SamplingRates ()
|
||||||
{
|
{
|
||||||
|
|
@ -136,15 +136,15 @@ const std::vector<int>& WCMRAudioDevice::SamplingRates ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::CurrentSamplingRate
|
// WCMRAudioDevice::CurrentSamplingRate
|
||||||
//
|
//
|
||||||
//! The device's current sampling rate. This may be overridden, if the device needs to
|
//! The device's current sampling rate. This may be overridden, if the device needs to
|
||||||
//! query the driver for the current rate.
|
//! query the driver for the current rate.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return The device's current sampling rate. -1 on error.
|
//! \return The device's current sampling rate. -1 on error.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
int WCMRAudioDevice::CurrentSamplingRate ()
|
int WCMRAudioDevice::CurrentSamplingRate ()
|
||||||
{
|
{
|
||||||
|
|
@ -155,15 +155,15 @@ int WCMRAudioDevice::CurrentSamplingRate ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::SetCurrentSamplingRate
|
// WCMRAudioDevice::SetCurrentSamplingRate
|
||||||
//
|
//
|
||||||
//! Change the sampling rate to be used by the device. This will most likely be overridden,
|
//! Change the sampling rate to be used by the device. This will most likely be overridden,
|
||||||
//! the base class simply updates the member variable.
|
//! the base class simply updates the member variable.
|
||||||
//!
|
//!
|
||||||
//! \param newRate : The rate to use (samples per sec).
|
//! \param newRate : The rate to use (samples per sec).
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always. The derived classes may return error codes.
|
//! \return eNoErr always. The derived classes may return error codes.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRAudioDevice::SetCurrentSamplingRate (int newRate)
|
WTErr WCMRAudioDevice::SetCurrentSamplingRate (int newRate)
|
||||||
{
|
{
|
||||||
|
|
@ -176,14 +176,14 @@ WTErr WCMRAudioDevice::SetCurrentSamplingRate (int newRate)
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::BufferSizes
|
// WCMRAudioDevice::BufferSizes
|
||||||
//
|
//
|
||||||
//! Retrieves supported buffer size information.
|
//! Retrieves supported buffer size information.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return A vector with supported buffer sizes.
|
//! \return A vector with supported buffer sizes.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
const std::vector<int>& WCMRAudioDevice::BufferSizes ()
|
const std::vector<int>& WCMRAudioDevice::BufferSizes ()
|
||||||
{
|
{
|
||||||
|
|
@ -195,13 +195,13 @@ const std::vector<int>& WCMRAudioDevice::BufferSizes ()
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::CurrentBufferSize
|
// WCMRAudioDevice::CurrentBufferSize
|
||||||
//
|
//
|
||||||
//! The device's current buffer size in use. This may be overridden, if the device needs to
|
//! The device's current buffer size in use. This may be overridden, if the device needs to
|
||||||
//! query the driver for the current size.
|
//! query the driver for the current size.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return The device's current buffer size. 0 on error.
|
//! \return The device's current buffer size. 0 on error.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
int WCMRAudioDevice::CurrentBufferSize ()
|
int WCMRAudioDevice::CurrentBufferSize ()
|
||||||
{
|
{
|
||||||
|
|
@ -216,9 +216,9 @@ int WCMRAudioDevice::CurrentBufferSize ()
|
||||||
//! data other then the audio buffers, like frames info in SG, so it can be overridden
|
//! data other then the audio buffers, like frames info in SG, so it can be overridden
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return The device's current block size. 0 on error.
|
//! \return The device's current block size. 0 on error.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
int WCMRAudioDevice::CurrentBlockSize()
|
int WCMRAudioDevice::CurrentBlockSize()
|
||||||
{
|
{
|
||||||
|
|
@ -230,13 +230,13 @@ int WCMRAudioDevice::CurrentBlockSize()
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::SetCurrentBufferSize
|
// WCMRAudioDevice::SetCurrentBufferSize
|
||||||
//
|
//
|
||||||
//! Change the buffer size to be used by the device. This will most likely be overridden,
|
//! Change the buffer size to be used by the device. This will most likely be overridden,
|
||||||
//! the base class simply updates the member variable.
|
//! the base class simply updates the member variable.
|
||||||
//!
|
//!
|
||||||
//! \param newSize : The buffer size to use (in sample-frames)
|
//! \param newSize : The buffer size to use (in sample-frames)
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always. The derived classes may return error codes.
|
//! \return eNoErr always. The derived classes may return error codes.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRAudioDevice::SetCurrentBufferSize (int newSize)
|
WTErr WCMRAudioDevice::SetCurrentBufferSize (int newSize)
|
||||||
{
|
{
|
||||||
|
|
@ -250,15 +250,15 @@ WTErr WCMRAudioDevice::SetCurrentBufferSize (int newSize)
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::ConnectionStatus
|
// WCMRAudioDevice::ConnectionStatus
|
||||||
//
|
//
|
||||||
//! Retrieves the device's current connection status. This will most likely be overridden,
|
//! Retrieves the device's current connection status. This will most likely be overridden,
|
||||||
//! in case some driver communication is required to query the status.
|
//! in case some driver communication is required to query the status.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return A ConnectionStates value.
|
//! \return A ConnectionStates value.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRAudioDevice::ConnectionStates WCMRAudioDevice::ConnectionStatus ()
|
WCMRAudioDevice::ConnectionStates WCMRAudioDevice::ConnectionStatus ()
|
||||||
{
|
{
|
||||||
|
|
@ -270,14 +270,14 @@ WCMRAudioDevice::ConnectionStates WCMRAudioDevice::ConnectionStatus ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::Active
|
// WCMRAudioDevice::Active
|
||||||
//
|
//
|
||||||
//! Retrieves Device activation status.
|
//! Retrieves Device activation status.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return true if device is active, false otherwise.
|
//! \return true if device is active, false otherwise.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
bool WCMRAudioDevice::Active ()
|
bool WCMRAudioDevice::Active ()
|
||||||
{
|
{
|
||||||
|
|
@ -288,15 +288,15 @@ bool WCMRAudioDevice::Active ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::SetActive
|
// WCMRAudioDevice::SetActive
|
||||||
//
|
//
|
||||||
//! Sets the device's activation status.
|
//! Sets the device's activation status.
|
||||||
//!
|
//!
|
||||||
//! \param newState : Should be true to activate, false to deactivate. This roughly corresponds
|
//! \param newState : Should be true to activate, false to deactivate. This roughly corresponds
|
||||||
//! to opening and closing the device handle/stream/audio unit.
|
//! to opening and closing the device handle/stream/audio unit.
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always, the derived classes may return appropriate error code.
|
//! \return eNoErr always, the derived classes may return appropriate error code.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRAudioDevice::SetActive (bool newState)
|
WTErr WCMRAudioDevice::SetActive (bool newState)
|
||||||
{
|
{
|
||||||
|
|
@ -310,14 +310,14 @@ WTErr WCMRAudioDevice::SetActive (bool newState)
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::Streaming
|
// WCMRAudioDevice::Streaming
|
||||||
//
|
//
|
||||||
//! Retrieves Device streaming status.
|
//! Retrieves Device streaming status.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return true if device is streaming, false otherwise.
|
//! \return true if device is streaming, false otherwise.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
bool WCMRAudioDevice::Streaming ()
|
bool WCMRAudioDevice::Streaming ()
|
||||||
{
|
{
|
||||||
|
|
@ -333,9 +333,9 @@ bool WCMRAudioDevice::Streaming ()
|
||||||
//!
|
//!
|
||||||
//! \param newState : Should be true to start streaming, false to stop streaming. This roughly
|
//! \param newState : Should be true to start streaming, false to stop streaming. This roughly
|
||||||
//! corresponds to calling Start/Stop on the lower level interface.
|
//! corresponds to calling Start/Stop on the lower level interface.
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always, the derived classes may return appropriate error code.
|
//! \return eNoErr always, the derived classes may return appropriate error code.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRAudioDevice::SetStreaming (bool newState)
|
WTErr WCMRAudioDevice::SetStreaming (bool newState)
|
||||||
{
|
{
|
||||||
|
|
@ -387,15 +387,15 @@ bool WCMRAudioDevice::IsProcessActive()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::DoIdle
|
// WCMRAudioDevice::DoIdle
|
||||||
//
|
//
|
||||||
//! A place for doing idle time processing. The derived classes will probably do something
|
//! A place for doing idle time processing. The derived classes will probably do something
|
||||||
//! meaningful.
|
//! meaningful.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always.
|
//! \return eNoErr always.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRAudioDevice::DoIdle ()
|
WTErr WCMRAudioDevice::DoIdle ()
|
||||||
{
|
{
|
||||||
|
|
@ -408,14 +408,14 @@ WTErr WCMRAudioDevice::DoIdle ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::InputLevels
|
// WCMRAudioDevice::InputLevels
|
||||||
//
|
//
|
||||||
//! Retrieve current input levels.
|
//! Retrieve current input levels.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return A vector (the same size as input channels list) that contains current input levels.
|
//! \return A vector (the same size as input channels list) that contains current input levels.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
const std::vector<float>& WCMRAudioDevice::InputLevels ()
|
const std::vector<float>& WCMRAudioDevice::InputLevels ()
|
||||||
{
|
{
|
||||||
|
|
@ -427,14 +427,14 @@ const std::vector<float>& WCMRAudioDevice::InputLevels ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::OutputLevels
|
// WCMRAudioDevice::OutputLevels
|
||||||
//
|
//
|
||||||
//! Retrieve current output levels.
|
//! Retrieve current output levels.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return A vector (the same size as output channels list) that contains current output levels.
|
//! \return A vector (the same size as output channels list) that contains current output levels.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
const std::vector<float>& WCMRAudioDevice::OutputLevels ()
|
const std::vector<float>& WCMRAudioDevice::OutputLevels ()
|
||||||
{
|
{
|
||||||
|
|
@ -446,16 +446,16 @@ const std::vector<float>& WCMRAudioDevice::OutputLevels ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::GetMonitorInfo
|
// WCMRAudioDevice::GetMonitorInfo
|
||||||
//
|
//
|
||||||
//! Retrieves current monitoring information.
|
//! Retrieves current monitoring information.
|
||||||
//!
|
//!
|
||||||
//! \param *pLeftChannel : Pointer to receive left monitor channel index.
|
//! \param *pLeftChannel : Pointer to receive left monitor channel index.
|
||||||
//! \param *pRightChannel : Pointer to receive right monitor channel index.
|
//! \param *pRightChannel : Pointer to receive right monitor channel index.
|
||||||
//! \param *pGain : Pointer to receive the gain (linear) to be applied.
|
//! \param *pGain : Pointer to receive the gain (linear) to be applied.
|
||||||
//!
|
//!
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
void WCMRAudioDevice::GetMonitorInfo (int *pLeftChannel, int *pRightChannel, float *pGain)
|
void WCMRAudioDevice::GetMonitorInfo (int *pLeftChannel, int *pRightChannel, float *pGain)
|
||||||
{
|
{
|
||||||
|
|
@ -471,15 +471,15 @@ void WCMRAudioDevice::GetMonitorInfo (int *pLeftChannel, int *pRightChannel, flo
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::SetMonitorChannels
|
// WCMRAudioDevice::SetMonitorChannels
|
||||||
//
|
//
|
||||||
//! Used to set the channels to be used for monitoring.
|
//! Used to set the channels to be used for monitoring.
|
||||||
//!
|
//!
|
||||||
//! \param leftChannel : Left monitor channel index.
|
//! \param leftChannel : Left monitor channel index.
|
||||||
//! \param rightChannel : Right monitor channel index.
|
//! \param rightChannel : Right monitor channel index.
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always, the derived classes may return appropriate errors.
|
//! \return eNoErr always, the derived classes may return appropriate errors.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel)
|
WTErr WCMRAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel)
|
||||||
{
|
{
|
||||||
|
|
@ -493,14 +493,14 @@ WTErr WCMRAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel)
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::SetMonitorGain
|
// WCMRAudioDevice::SetMonitorGain
|
||||||
//
|
//
|
||||||
//! Used to set monitor gain (or atten).
|
//! Used to set monitor gain (or atten).
|
||||||
//!
|
//!
|
||||||
//! \param newGain : The new gain or atten. value to use. Specified as a linear multiplier (not dB)
|
//! \param newGain : The new gain or atten. value to use. Specified as a linear multiplier (not dB)
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always, the derived classes may return appropriate errors.
|
//! \return eNoErr always, the derived classes may return appropriate errors.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRAudioDevice::SetMonitorGain (float newGain)
|
WTErr WCMRAudioDevice::SetMonitorGain (float newGain)
|
||||||
{
|
{
|
||||||
|
|
@ -514,15 +514,15 @@ WTErr WCMRAudioDevice::SetMonitorGain (float newGain)
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::ShowConfigPanel
|
// WCMRAudioDevice::ShowConfigPanel
|
||||||
//
|
//
|
||||||
//! Used to show device specific config/control panel. Some interfaces may not support it.
|
//! Used to show device specific config/control panel. Some interfaces may not support it.
|
||||||
//! Some interfaces may require the device to be active before it can display a panel.
|
//! Some interfaces may require the device to be active before it can display a panel.
|
||||||
//!
|
//!
|
||||||
//! \param pParam : A device/interface specific parameter - optional.
|
//! \param pParam : A device/interface specific parameter - optional.
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always, the derived classes may return errors.
|
//! \return eNoErr always, the derived classes may return errors.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRAudioDevice::ShowConfigPanel (void *WCUNUSEDPARAM(pParam))
|
WTErr WCMRAudioDevice::ShowConfigPanel (void *WCUNUSEDPARAM(pParam))
|
||||||
{
|
{
|
||||||
|
|
@ -532,16 +532,16 @@ WTErr WCMRAudioDevice::ShowConfigPanel (void *WCUNUSEDPARAM(pParam))
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDevice::SendCustomCommand
|
// WCMRAudioDevice::SendCustomCommand
|
||||||
//
|
//
|
||||||
//! Used to Send a custom command to the audiodevice. Some interfaces may require the device
|
//! Used to Send a custom command to the audiodevice. Some interfaces may require the device
|
||||||
//! to be active before it can do anything in this.
|
//! to be active before it can do anything in this.
|
||||||
//!
|
//!
|
||||||
//! \param customCommand : A device/interface specific command.
|
//! \param customCommand : A device/interface specific command.
|
||||||
//! \param pCommandParam : A device/interface/command specific parameter - optional.
|
//! \param pCommandParam : A device/interface/command specific parameter - optional.
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always, the derived classes may return errors.
|
//! \return eNoErr always, the derived classes may return errors.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRAudioDevice::SendCustomCommand (int WCUNUSEDPARAM(customCommand), void *WCUNUSEDPARAM(pCommandParam))
|
WTErr WCMRAudioDevice::SendCustomCommand (int WCUNUSEDPARAM(customCommand), void *WCUNUSEDPARAM(pCommandParam))
|
||||||
{
|
{
|
||||||
|
|
@ -573,10 +573,10 @@ uint32_t WCMRAudioDevice::GetLatency (bool isInput)
|
||||||
//
|
//
|
||||||
//! The constructuor, most of the work will be done in the derived class' constructor.
|
//! The constructuor, most of the work will be done in the derived class' constructor.
|
||||||
//!
|
//!
|
||||||
//! \param *pTheClient :
|
//! \param *pTheClient :
|
||||||
//!
|
//!
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRAudioDeviceManager::WCMRAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter)
|
WCMRAudioDeviceManager::WCMRAudioDeviceManager(WCMRAudioDeviceManagerClient *pTheClient, eAudioDeviceFilter eCurAudioDeviceFilter)
|
||||||
: m_eAudioDeviceFilter(eCurAudioDeviceFilter)
|
: m_eAudioDeviceFilter(eCurAudioDeviceFilter)
|
||||||
|
|
@ -592,9 +592,9 @@ WCMRAudioDeviceManager::WCMRAudioDeviceManager(WCMRAudioDeviceManagerClient *pTh
|
||||||
//! It clears the device list, releasing each of the device.
|
//! It clears the device list, releasing each of the device.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRAudioDeviceManager::~WCMRAudioDeviceManager()
|
WCMRAudioDeviceManager::~WCMRAudioDeviceManager()
|
||||||
{
|
{
|
||||||
|
|
@ -674,15 +674,15 @@ WTErr WCMRAudioDeviceManager::GetDeviceBufferSizes(const std::string & nameToMat
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRAudioDeviceManager::NotifyClient
|
// WCMRAudioDeviceManager::NotifyClient
|
||||||
//
|
//
|
||||||
//! A helper routine used to call the client for notification.
|
//! A helper routine used to call the client for notification.
|
||||||
//!
|
//!
|
||||||
//! \param forReason : The reason for notification.
|
//! \param forReason : The reason for notification.
|
||||||
//! \param *pParam : A parameter (if required) for notification.
|
//! \param *pParam : A parameter (if required) for notification.
|
||||||
//!
|
//!
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
void WCMRAudioDeviceManager::NotifyClient (WCMRAudioDeviceManagerClient::NotificationReason forReason, void *pParam)
|
void WCMRAudioDeviceManager::NotifyClient (WCMRAudioDeviceManagerClient::NotificationReason forReason, void *pParam)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -30,8 +30,8 @@
|
||||||
//! the applications.
|
//! the applications.
|
||||||
//!
|
//!
|
||||||
//! \param pManager : The managing device manager - simply passed on to the base class.
|
//! \param pManager : The managing device manager - simply passed on to the base class.
|
||||||
//!
|
//!
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRNativeAudioNoneDevice::WCMRNativeAudioNoneDevice (WCMRAudioDeviceManager *pManager)
|
WCMRNativeAudioNoneDevice::WCMRNativeAudioNoneDevice (WCMRAudioDeviceManager *pManager)
|
||||||
: WCMRNativeAudioDevice (pManager, false /*useMultiThreading*/)
|
: WCMRNativeAudioDevice (pManager, false /*useMultiThreading*/)
|
||||||
|
|
@ -155,7 +155,7 @@ WTErr WCMRNativeAudioNoneDevice::SetStreaming (bool newState)
|
||||||
std::cerr << "WCMRNativeAudioNoneDevice::SetStreaming (): pthread_attr_init () failed!" << std::endl;
|
std::cerr << "WCMRNativeAudioNoneDevice::SetStreaming (): pthread_attr_init () failed!" << std::endl;
|
||||||
return eGenericErr;
|
return eGenericErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_attr_setstacksize (&attributes, stack_size)) {
|
if (pthread_attr_setstacksize (&attributes, stack_size)) {
|
||||||
std::cerr << "WCMRNativeAudioNoneDevice::SetStreaming (): pthread_attr_setstacksize () failed!" << std::endl;
|
std::cerr << "WCMRNativeAudioNoneDevice::SetStreaming (): pthread_attr_setstacksize () failed!" << std::endl;
|
||||||
return eGenericErr;
|
return eGenericErr;
|
||||||
|
|
@ -203,13 +203,13 @@ void WCMRNativeAudioNoneDevice::_SilenceThread()
|
||||||
(const float*)theInpBuffers,
|
(const float*)theInpBuffers,
|
||||||
_m_outputBuffer,
|
_m_outputBuffer,
|
||||||
buffer_size,
|
buffer_size,
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
audioCallbackData.acdCycleStartTimeNanos =__get_time_nanos();
|
audioCallbackData.acdCycleStartTimeNanos =__get_time_nanos();
|
||||||
|
|
||||||
// VERY ROUGH IMPLEMENTATION:
|
// VERY ROUGH IMPLEMENTATION:
|
||||||
while(Streaming()) {
|
while(Streaming()) {
|
||||||
|
|
||||||
uint64_t cycleEndTimeNanos = audioCallbackData.acdCycleStartTimeNanos + cyclePeriodNanos;
|
uint64_t cycleEndTimeNanos = audioCallbackData.acdCycleStartTimeNanos + cyclePeriodNanos;
|
||||||
|
|
@ -236,13 +236,13 @@ void* WCMRNativeAudioNoneDevice::__SilenceThread(void *This)
|
||||||
|
|
||||||
#if defined(PLATFORM_WINDOWS)
|
#if defined(PLATFORM_WINDOWS)
|
||||||
void WCMRNativeAudioNoneDevice::_usleep(uint64_t duration_usec)
|
void WCMRNativeAudioNoneDevice::_usleep(uint64_t duration_usec)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER ft;
|
LARGE_INTEGER ft;
|
||||||
|
|
||||||
ft.QuadPart = -(10*duration_usec); // Convert to 100 nanosecond interval, negative value indicates relative time
|
ft.QuadPart = -(10*duration_usec); // Convert to 100 nanosecond interval, negative value indicates relative time
|
||||||
|
|
||||||
SetWaitableTimer(_waitableTimerForUsleep, &ft, 0, NULL, NULL, 0);
|
SetWaitableTimer(_waitableTimerForUsleep, &ft, 0, NULL, NULL, 0);
|
||||||
WaitForSingleObject(_waitableTimerForUsleep, INFINITE);
|
WaitForSingleObject(_waitableTimerForUsleep, INFINITE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -254,9 +254,9 @@ WCMRNativeAudioNoneDevice::__get_time_nanos ()
|
||||||
// the API should be a part of WCMRCoreAudioDeviceManager to give a chance of being tied to the
|
// the API should be a part of WCMRCoreAudioDeviceManager to give a chance of being tied to the
|
||||||
// audio device transport timeß.
|
// audio device transport timeß.
|
||||||
return AudioConvertHostTimeToNanos (AudioGetCurrentHostTime ());
|
return AudioConvertHostTimeToNanos (AudioGetCurrentHostTime ());
|
||||||
|
|
||||||
#elif PLATFORM_WINDOWS
|
#elif PLATFORM_WINDOWS
|
||||||
|
|
||||||
LARGE_INTEGER Frequency, Count ;
|
LARGE_INTEGER Frequency, Count ;
|
||||||
|
|
||||||
QueryPerformanceFrequency (&Frequency) ;
|
QueryPerformanceFrequency (&Frequency) ;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ using namespace wvNS;
|
||||||
#define PROPERTY_CHANGE_TIMEOUT_SECONDS 2
|
#define PROPERTY_CHANGE_TIMEOUT_SECONDS 2
|
||||||
#define PROPERTY_CHANGE_RETRIES 3
|
#define PROPERTY_CHANGE_RETRIES 3
|
||||||
|
|
||||||
///< Supported Sample rates
|
///< Supported Sample rates
|
||||||
static const double gAllSampleRates[] =
|
static const double gAllSampleRates[] =
|
||||||
{
|
{
|
||||||
44100.0, 48000.0, 88200.0, 96000.0, 176400.0, 192000.0, -1 /* negative terminated list */
|
44100.0, 48000.0, 88200.0, 96000.0, 176400.0, 192000.0, -1 /* negative terminated list */
|
||||||
|
|
@ -64,7 +64,7 @@ DWORD WINAPI WCMRPortAudioDevice::__DoIdle__(LPVOID lpThreadParameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::WCMRPortAudioDevice
|
// WCMRPortAudioDevice::WCMRPortAudioDevice
|
||||||
//
|
//
|
||||||
//! Constructor for the audio device. Opens the PA device
|
//! Constructor for the audio device. Opens the PA device
|
||||||
//! and gets information about the device.
|
//! and gets information about the device.
|
||||||
|
|
@ -74,9 +74,9 @@ DWORD WINAPI WCMRPortAudioDevice::__DoIdle__(LPVOID lpThreadParameter)
|
||||||
//! \param *pManager : The audio device manager that's managing this device.
|
//! \param *pManager : The audio device manager that's managing this device.
|
||||||
//! \param deviceID : The port audio device ID.
|
//! \param deviceID : The port audio device ID.
|
||||||
//! \param useMultithreading : Whether to use multi-threading for audio processing. Default is true.
|
//! \param useMultithreading : Whether to use multi-threading for audio processing. Default is true.
|
||||||
//!
|
//!
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRPortAudioDevice::WCMRPortAudioDevice (WCMRPortAudioDeviceManager *pManager, unsigned int deviceID, bool useMultithreading, bool bNoCopy) :
|
WCMRPortAudioDevice::WCMRPortAudioDevice (WCMRPortAudioDeviceManager *pManager, unsigned int deviceID, bool useMultithreading, bool bNoCopy) :
|
||||||
WCMRNativeAudioDevice (pManager, useMultithreading, bNoCopy)
|
WCMRNativeAudioDevice (pManager, useMultithreading, bNoCopy)
|
||||||
|
|
@ -230,16 +230,16 @@ void WCMRPortAudioDevice::terminateDevice()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::~WCMRPortAudioDevice
|
// WCMRPortAudioDevice::~WCMRPortAudioDevice
|
||||||
//
|
//
|
||||||
//! Destructor for the audio device. The base release all the connections that were created, if
|
//! Destructor for the audio device. The base release all the connections that were created, if
|
||||||
//! they have not been already destroyed! Here we simply stop streaming, and close device
|
//! they have not been already destroyed! Here we simply stop streaming, and close device
|
||||||
//! handles if necessary.
|
//! handles if necessary.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRPortAudioDevice::~WCMRPortAudioDevice ()
|
WCMRPortAudioDevice::~WCMRPortAudioDevice ()
|
||||||
{
|
{
|
||||||
|
|
@ -293,13 +293,13 @@ WTErr WCMRPortAudioDevice::UpdateDeviceInfo ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::updateDeviceInfo
|
// WCMRPortAudioDevice::updateDeviceInfo
|
||||||
//
|
//
|
||||||
//! Must be called be device processing thread
|
//! Must be called be device processing thread
|
||||||
//! Updates Device Information about channels, sampling rates, buffer sizes.
|
//! Updates Device Information about channels, sampling rates, buffer sizes.
|
||||||
//!
|
//!
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
void WCMRPortAudioDevice::updateDeviceInfo (bool callerIsWaiting/*=false*/)
|
void WCMRPortAudioDevice::updateDeviceInfo (bool callerIsWaiting/*=false*/)
|
||||||
{
|
{
|
||||||
|
|
@ -353,7 +353,7 @@ void WCMRPortAudioDevice::updateDeviceInfo (bool callerIsWaiting/*=false*/)
|
||||||
m_BufferSizes.clear();
|
m_BufferSizes.clear();
|
||||||
bool useDefaultBuffers = true;
|
bool useDefaultBuffers = true;
|
||||||
|
|
||||||
// In ASIO Windows, the buffer size is set from the sound device manufacturer's control panel
|
// In ASIO Windows, the buffer size is set from the sound device manufacturer's control panel
|
||||||
long minSize, maxSize, preferredSize, granularity;
|
long minSize, maxSize, preferredSize, granularity;
|
||||||
PaError err = PaAsio_GetAvailableBufferSizes(m_DeviceID, &minSize, &maxSize, &preferredSize, &granularity);
|
PaError err = PaAsio_GetAvailableBufferSizes(m_DeviceID, &minSize, &maxSize, &preferredSize, &granularity);
|
||||||
|
|
||||||
|
|
@ -486,15 +486,15 @@ PaError WCMRPortAudioDevice::testStateValidness(int sampleRate, int bufferSize)
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::CurrentSamplingRate
|
// WCMRPortAudioDevice::CurrentSamplingRate
|
||||||
//
|
//
|
||||||
//! The device's current sampling rate. This may be overridden, if the device needs to
|
//! The device's current sampling rate. This may be overridden, if the device needs to
|
||||||
//! query the driver for the current rate.
|
//! query the driver for the current rate.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return The device's current sampling rate. -1 on error.
|
//! \return The device's current sampling rate. -1 on error.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
int WCMRPortAudioDevice::CurrentSamplingRate ()
|
int WCMRPortAudioDevice::CurrentSamplingRate ()
|
||||||
{
|
{
|
||||||
|
|
@ -561,14 +561,14 @@ WTErr WCMRPortAudioDevice::ResetDevice()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::SetCurrentSamplingRate
|
// WCMRPortAudioDevice::SetCurrentSamplingRate
|
||||||
//
|
//
|
||||||
//! Change the sampling rate to be used by the device.
|
//! Change the sampling rate to be used by the device.
|
||||||
//!
|
//!
|
||||||
//! \param newRate : The rate to use (samples per sec).
|
//! \param newRate : The rate to use (samples per sec).
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always. The derived classes may return error codes.
|
//! \return eNoErr always. The derived classes may return error codes.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRPortAudioDevice::SetCurrentSamplingRate (int newRate)
|
WTErr WCMRPortAudioDevice::SetCurrentSamplingRate (int newRate)
|
||||||
{
|
{
|
||||||
|
|
@ -622,13 +622,13 @@ WTErr WCMRPortAudioDevice::SetCurrentSamplingRate (int newRate)
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::CurrentBufferSize
|
// WCMRPortAudioDevice::CurrentBufferSize
|
||||||
//
|
//
|
||||||
//! The device's current buffer size in use. This may be overridden, if the device needs to
|
//! The device's current buffer size in use. This may be overridden, if the device needs to
|
||||||
//! query the driver for the current size.
|
//! query the driver for the current size.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return The device's current buffer size. 0 on error.
|
//! \return The device's current buffer size. 0 on error.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
int WCMRPortAudioDevice::CurrentBufferSize ()
|
int WCMRPortAudioDevice::CurrentBufferSize ()
|
||||||
{
|
{
|
||||||
|
|
@ -639,13 +639,13 @@ int WCMRPortAudioDevice::CurrentBufferSize ()
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::SetCurrentBufferSize
|
// WCMRPortAudioDevice::SetCurrentBufferSize
|
||||||
//
|
//
|
||||||
//! Change the buffer size to be used by the device. This will most likely be overridden,
|
//! Change the buffer size to be used by the device. This will most likely be overridden,
|
||||||
//! the base class simply updates the member variable.
|
//! the base class simply updates the member variable.
|
||||||
//!
|
//!
|
||||||
//! \param newSize : The buffer size to use (in sample-frames)
|
//! \param newSize : The buffer size to use (in sample-frames)
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always. The derived classes may return error codes.
|
//! \return eNoErr always. The derived classes may return error codes.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRPortAudioDevice::SetCurrentBufferSize (int newSize)
|
WTErr WCMRPortAudioDevice::SetCurrentBufferSize (int newSize)
|
||||||
{
|
{
|
||||||
|
|
@ -678,15 +678,15 @@ WTErr WCMRPortAudioDevice::SetCurrentBufferSize (int newSize)
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::ConnectionStatus
|
// WCMRPortAudioDevice::ConnectionStatus
|
||||||
//
|
//
|
||||||
//! Retrieves the device's current connection status. This will most likely be overridden,
|
//! Retrieves the device's current connection status. This will most likely be overridden,
|
||||||
//! in case some driver communication is required to query the status.
|
//! in case some driver communication is required to query the status.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return A ConnectionStates value.
|
//! \return A ConnectionStates value.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRPortAudioDevice::ConnectionStates WCMRPortAudioDevice::ConnectionStatus ()
|
WCMRPortAudioDevice::ConnectionStates WCMRPortAudioDevice::ConnectionStatus ()
|
||||||
{
|
{
|
||||||
|
|
@ -701,7 +701,7 @@ WCMRPortAudioDevice::ConnectionStates WCMRPortAudioDevice::ConnectionStatus ()
|
||||||
// WCMRPortAudioDevice::activateDevice
|
// WCMRPortAudioDevice::activateDevice
|
||||||
//
|
//
|
||||||
//! IS CALLED BY PROCESS THREAD
|
//! IS CALLED BY PROCESS THREAD
|
||||||
//! Sets the device into "active" state. Essentially, opens the PA device.
|
//! Sets the device into "active" state. Essentially, opens the PA device.
|
||||||
//! If it's an ASIO device it may result in buffer size change in some cases.
|
//! If it's an ASIO device it may result in buffer size change in some cases.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
|
|
@ -740,7 +740,7 @@ void WCMRPortAudioDevice::activateDevice (bool callerIsWaiting/*=false*/)
|
||||||
|
|
||||||
std::cout << "API::Device " << m_DeviceName << " Opening device stream " << std::endl;
|
std::cout << "API::Device " << m_DeviceName << " Opening device stream " << std::endl;
|
||||||
std::cout << "Sample rate: " << m_CurrentSamplingRate << " buffer size: " << m_CurrentBufferSize << std::endl;
|
std::cout << "Sample rate: " << m_CurrentSamplingRate << " buffer size: " << m_CurrentBufferSize << std::endl;
|
||||||
paErr = Pa_OpenStream(&m_PortAudioStream,
|
paErr = Pa_OpenStream(&m_PortAudioStream,
|
||||||
pInS,
|
pInS,
|
||||||
pOutS,
|
pOutS,
|
||||||
m_CurrentSamplingRate,
|
m_CurrentSamplingRate,
|
||||||
|
|
@ -817,7 +817,7 @@ void WCMRPortAudioDevice::activateDevice (bool callerIsWaiting/*=false*/)
|
||||||
// WCMRPortAudioDevice::deactivateDevice
|
// WCMRPortAudioDevice::deactivateDevice
|
||||||
//
|
//
|
||||||
//! IS CALLED BY PROCESS THREAD
|
//! IS CALLED BY PROCESS THREAD
|
||||||
//! Sets the device into "inactive" state. Essentially, closes the PA device.
|
//! Sets the device into "inactive" state. Essentially, closes the PA device.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
void WCMRPortAudioDevice::deactivateDevice (bool callerIsWaiting/*=false*/)
|
void WCMRPortAudioDevice::deactivateDevice (bool callerIsWaiting/*=false*/)
|
||||||
|
|
@ -878,7 +878,7 @@ void WCMRPortAudioDevice::deactivateDevice (bool callerIsWaiting/*=false*/)
|
||||||
//
|
//
|
||||||
//! Sets the devices into "streaming" state. Calls PA's Start stream routines.
|
//! Sets the devices into "streaming" state. Calls PA's Start stream routines.
|
||||||
//! This roughly corresponds to calling Start on the lower level interface.
|
//! This roughly corresponds to calling Start on the lower level interface.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
void WCMRPortAudioDevice::startStreaming (bool callerIsWaiting/*=false*/)
|
void WCMRPortAudioDevice::startStreaming (bool callerIsWaiting/*=false*/)
|
||||||
{
|
{
|
||||||
|
|
@ -928,7 +928,7 @@ void WCMRPortAudioDevice::startStreaming (bool callerIsWaiting/*=false*/)
|
||||||
//
|
//
|
||||||
//! Sets the devices into "not streaming" state. Calls PA's Stop stream routines.
|
//! Sets the devices into "not streaming" state. Calls PA's Stop stream routines.
|
||||||
//! This roughly corresponds to calling Stop on the lower level interface.
|
//! This roughly corresponds to calling Stop on the lower level interface.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
void WCMRPortAudioDevice::stopStreaming (bool callerIsWaiting/*=false*/)
|
void WCMRPortAudioDevice::stopStreaming (bool callerIsWaiting/*=false*/)
|
||||||
{
|
{
|
||||||
|
|
@ -963,15 +963,15 @@ void WCMRPortAudioDevice::stopStreaming (bool callerIsWaiting/*=false*/)
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::resetDevice
|
// WCMRPortAudioDevice::resetDevice
|
||||||
//
|
//
|
||||||
//! Resets the device, updates device info. Importnat: does PA reinitialization calling
|
//! Resets the device, updates device info. Importnat: does PA reinitialization calling
|
||||||
//! Pa_terminate/Pa_initialize functions.
|
//! Pa_terminate/Pa_initialize functions.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return nothing
|
//! \return nothing
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
void WCMRPortAudioDevice::resetDevice (bool callerIsWaiting /*=false*/ )
|
void WCMRPortAudioDevice::resetDevice (bool callerIsWaiting /*=false*/ )
|
||||||
{
|
{
|
||||||
|
|
@ -1007,7 +1007,7 @@ void WCMRPortAudioDevice::resetDevice (bool callerIsWaiting /*=false*/ )
|
||||||
if (paErr != paNoError)
|
if (paErr != paNoError)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_CurrentBufferSize = preferredSize;
|
m_CurrentBufferSize = preferredSize;
|
||||||
|
|
||||||
paErr = testStateValidness(m_CurrentSamplingRate, m_CurrentBufferSize);
|
paErr = testStateValidness(m_CurrentSamplingRate, m_CurrentBufferSize);
|
||||||
|
|
@ -1115,22 +1115,22 @@ long WCMRPortAudioDevice::ASIOMessageHook (long selector, long WCUNUSEDPARAM(val
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::DoIdle
|
// WCMRPortAudioDevice::DoIdle
|
||||||
//
|
//
|
||||||
//! A place for doing idle time processing. The other derived classes will probably do something
|
//! A place for doing idle time processing. The other derived classes will probably do something
|
||||||
//! meaningful.
|
//! meaningful.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always.
|
//! \return eNoErr always.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRPortAudioDevice::DoIdle ()
|
WTErr WCMRPortAudioDevice::DoIdle ()
|
||||||
{
|
{
|
||||||
WTErr retVal = eNoErr;
|
WTErr retVal = eNoErr;
|
||||||
|
|
||||||
std::cout << "WCMRPortAudioDevice::DoIdle ()" << std::endl;
|
std::cout << "WCMRPortAudioDevice::DoIdle ()" << std::endl;
|
||||||
HANDLE hEvents[] =
|
HANDLE hEvents[] =
|
||||||
{
|
{
|
||||||
m_hUpdateDeviceInfoRequestedEvent,
|
m_hUpdateDeviceInfoRequestedEvent,
|
||||||
m_hActivateRequestedEvent,
|
m_hActivateRequestedEvent,
|
||||||
|
|
@ -1218,15 +1218,15 @@ WTErr WCMRPortAudioDevice::DoIdle ()
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::SetMonitorChannels
|
// WCMRPortAudioDevice::SetMonitorChannels
|
||||||
//
|
//
|
||||||
//! Used to set the channels to be used for monitoring.
|
//! Used to set the channels to be used for monitoring.
|
||||||
//!
|
//!
|
||||||
//! \param leftChannel : Left monitor channel index.
|
//! \param leftChannel : Left monitor channel index.
|
||||||
//! \param rightChannel : Right monitor channel index.
|
//! \param rightChannel : Right monitor channel index.
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always, the derived classes may return appropriate errors.
|
//! \return eNoErr always, the derived classes may return appropriate errors.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRPortAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel)
|
WTErr WCMRPortAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel)
|
||||||
{
|
{
|
||||||
|
|
@ -1241,14 +1241,14 @@ WTErr WCMRPortAudioDevice::SetMonitorChannels (int leftChannel, int rightChannel
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::SetMonitorGain
|
// WCMRPortAudioDevice::SetMonitorGain
|
||||||
//
|
//
|
||||||
//! Used to set monitor gain (or atten).
|
//! Used to set monitor gain (or atten).
|
||||||
//!
|
//!
|
||||||
//! \param newGain : The new gain or atten. value to use. Specified as a linear multiplier (not dB)
|
//! \param newGain : The new gain or atten. value to use. Specified as a linear multiplier (not dB)
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always, the derived classes may return appropriate errors.
|
//! \return eNoErr always, the derived classes may return appropriate errors.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRPortAudioDevice::SetMonitorGain (float newGain)
|
WTErr WCMRPortAudioDevice::SetMonitorGain (float newGain)
|
||||||
{
|
{
|
||||||
|
|
@ -1264,15 +1264,15 @@ WTErr WCMRPortAudioDevice::SetMonitorGain (float newGain)
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::ShowConfigPanel
|
// WCMRPortAudioDevice::ShowConfigPanel
|
||||||
//
|
//
|
||||||
//! Used to show device specific config/control panel. Some interfaces may not support it.
|
//! Used to show device specific config/control panel. Some interfaces may not support it.
|
||||||
//! Some interfaces may require the device to be active before it can display a panel.
|
//! Some interfaces may require the device to be active before it can display a panel.
|
||||||
//!
|
//!
|
||||||
//! \param pParam : A device/interface specific parameter, should be the app window handle for ASIO.
|
//! \param pParam : A device/interface specific parameter, should be the app window handle for ASIO.
|
||||||
//!
|
//!
|
||||||
//! \return eNoErr always, the derived classes may return errors.
|
//! \return eNoErr always, the derived classes may return errors.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WTErr WCMRPortAudioDevice::ShowConfigPanel (void *pParam)
|
WTErr WCMRPortAudioDevice::ShowConfigPanel (void *pParam)
|
||||||
{
|
{
|
||||||
|
|
@ -1315,7 +1315,7 @@ WTErr WCMRPortAudioDevice::ShowConfigPanel (void *pParam)
|
||||||
//*****************************************************************************************************
|
//*****************************************************************************************************
|
||||||
// WCMRPortAudioDevice::TheCallback
|
// WCMRPortAudioDevice::TheCallback
|
||||||
//
|
//
|
||||||
//! The (static) Port Audio Callback function. This is a static member. It calls on the AudioCallback in the
|
//! The (static) Port Audio Callback function. This is a static member. It calls on the AudioCallback in the
|
||||||
//! WCMRPortAudioDevice to do the real work.
|
//! WCMRPortAudioDevice to do the real work.
|
||||||
//!
|
//!
|
||||||
//! \param pInputBuffer: pointer to input buffer.
|
//! \param pInputBuffer: pointer to input buffer.
|
||||||
|
|
@ -1324,10 +1324,10 @@ WTErr WCMRPortAudioDevice::ShowConfigPanel (void *pParam)
|
||||||
//! \param pTimeInfo: time info for PaStream callback.
|
//! \param pTimeInfo: time info for PaStream callback.
|
||||||
//! \param statusFlags:
|
//! \param statusFlags:
|
||||||
//! \param pUserData: pointer to user data, in our case the WCMRPortAudioDevice object.
|
//! \param pUserData: pointer to user data, in our case the WCMRPortAudioDevice object.
|
||||||
//!
|
//!
|
||||||
//! \return true to stop streaming else returns false.
|
//! \return true to stop streaming else returns false.
|
||||||
//******************************************************************************************************
|
//******************************************************************************************************
|
||||||
int WCMRPortAudioDevice::TheCallback (const void *pInputBuffer, void *pOutputBuffer, unsigned long framesPerBuffer,
|
int WCMRPortAudioDevice::TheCallback (const void *pInputBuffer, void *pOutputBuffer, unsigned long framesPerBuffer,
|
||||||
const PaStreamCallbackTimeInfo* /*pTimeInfo*/, PaStreamCallbackFlags statusFlags, void *pUserData )
|
const PaStreamCallbackTimeInfo* /*pTimeInfo*/, PaStreamCallbackFlags statusFlags, void *pUserData )
|
||||||
{
|
{
|
||||||
WCMRPortAudioDevice *pMyDevice = (WCMRPortAudioDevice *)pUserData;
|
WCMRPortAudioDevice *pMyDevice = (WCMRPortAudioDevice *)pUserData;
|
||||||
|
|
@ -1342,10 +1342,10 @@ int WCMRPortAudioDevice::TheCallback (const void *pInputBuffer, void *pOutputBuf
|
||||||
|
|
||||||
|
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
// WCMRPortAudioDevice::AudoiCallback
|
// WCMRPortAudioDevice::AudoiCallback
|
||||||
//
|
//
|
||||||
//! Here's where the actual audio processing happens. We call upon all the active connections'
|
//! Here's where the actual audio processing happens. We call upon all the active connections'
|
||||||
//! sinks to provide data to us which can be put/mixed in the output buffer! Also, we make the
|
//! sinks to provide data to us which can be put/mixed in the output buffer! Also, we make the
|
||||||
//! input data available to any sources that may call upon us during this time!
|
//! input data available to any sources that may call upon us during this time!
|
||||||
//!
|
//!
|
||||||
//! \param *pInputBuffer : Points to a buffer with recorded data.
|
//! \param *pInputBuffer : Points to a buffer with recorded data.
|
||||||
|
|
@ -1354,9 +1354,9 @@ int WCMRPortAudioDevice::TheCallback (const void *pInputBuffer, void *pOutputBuf
|
||||||
//! which are interleaved, is fixed at Device Open (Active) time. In this implementation,
|
//! which are interleaved, is fixed at Device Open (Active) time. In this implementation,
|
||||||
//! the number of channels are fixed to use the maximum available.
|
//! the number of channels are fixed to use the maximum available.
|
||||||
//! \param dropsDetected : True if dropouts were detected in input or output. Can be used to signal the GUI.
|
//! \param dropsDetected : True if dropouts were detected in input or output. Can be used to signal the GUI.
|
||||||
//!
|
//!
|
||||||
//! \return true
|
//! \return true
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
int WCMRPortAudioDevice::AudioCallback( const float *pInputBuffer, float *pOutputBuffer, unsigned long framesPerBuffer, bool dropsDetected )
|
int WCMRPortAudioDevice::AudioCallback( const float *pInputBuffer, float *pOutputBuffer, unsigned long framesPerBuffer, bool dropsDetected )
|
||||||
{
|
{
|
||||||
|
|
@ -1382,7 +1382,7 @@ int WCMRPortAudioDevice::AudioCallback( const float *pInputBuffer, float *pOutpu
|
||||||
m_SampleCounter,
|
m_SampleCounter,
|
||||||
theStartTime.MicroSeconds()*1000
|
theStartTime.MicroSeconds()*1000
|
||||||
};
|
};
|
||||||
|
|
||||||
m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::AudioCallback, (void *)&audioCallbackData );
|
m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::AudioCallback, (void *)&audioCallbackData );
|
||||||
|
|
||||||
//Don't try to access after this call returns!
|
//Don't try to access after this call returns!
|
||||||
|
|
@ -1404,11 +1404,11 @@ int WCMRPortAudioDevice::AudioCallback( const float *pInputBuffer, float *pOutpu
|
||||||
//! \param *pTheClient : The manager's client object (which receives notifications).
|
//! \param *pTheClient : The manager's client object (which receives notifications).
|
||||||
//! \param interfaceType : The PortAudio interface type to use for this manager - acts as a filter.
|
//! \param interfaceType : The PortAudio interface type to use for this manager - acts as a filter.
|
||||||
//! \param useMultithreading : Whether to use multi-threading for audio processing. Default is true.
|
//! \param useMultithreading : Whether to use multi-threading for audio processing. Default is true.
|
||||||
//!
|
//!
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRPortAudioDeviceManager::WCMRPortAudioDeviceManager (WCMRAudioDeviceManagerClient *pTheClient,
|
WCMRPortAudioDeviceManager::WCMRPortAudioDeviceManager (WCMRAudioDeviceManagerClient *pTheClient,
|
||||||
eAudioDeviceFilter eCurAudioDeviceFilter, bool useMultithreading, bool bNocopy)
|
eAudioDeviceFilter eCurAudioDeviceFilter, bool useMultithreading, bool bNocopy)
|
||||||
: WCMRAudioDeviceManager (pTheClient, eCurAudioDeviceFilter)
|
: WCMRAudioDeviceManager (pTheClient, eCurAudioDeviceFilter)
|
||||||
, m_NoneDevice(0)
|
, m_NoneDevice(0)
|
||||||
|
|
@ -1436,9 +1436,9 @@ WCMRPortAudioDeviceManager::WCMRPortAudioDeviceManager (WCMRAudioDeviceManagerCl
|
||||||
//! It clears the device list, releasing each of the device.
|
//! It clears the device list, releasing each of the device.
|
||||||
//!
|
//!
|
||||||
//! \param none
|
//! \param none
|
||||||
//!
|
//!
|
||||||
//! \return Nothing.
|
//! \return Nothing.
|
||||||
//!
|
//!
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
WCMRPortAudioDeviceManager::~WCMRPortAudioDeviceManager()
|
WCMRPortAudioDeviceManager::~WCMRPortAudioDeviceManager()
|
||||||
{
|
{
|
||||||
|
|
@ -1463,7 +1463,7 @@ WCMRPortAudioDeviceManager::~WCMRPortAudioDeviceManager()
|
||||||
WCMRAudioDevice* WCMRPortAudioDeviceManager::initNewCurrentDeviceImpl(const std::string & deviceName)
|
WCMRAudioDevice* WCMRPortAudioDeviceManager::initNewCurrentDeviceImpl(const std::string & deviceName)
|
||||||
{
|
{
|
||||||
destroyCurrentDeviceImpl();
|
destroyCurrentDeviceImpl();
|
||||||
|
|
||||||
std::cout << "API::PortAudioDeviceManager::initNewCurrentDevice " << deviceName << std::endl;
|
std::cout << "API::PortAudioDeviceManager::initNewCurrentDevice " << deviceName << std::endl;
|
||||||
if (deviceName == m_NoneDevice->DeviceName() )
|
if (deviceName == m_NoneDevice->DeviceName() )
|
||||||
{
|
{
|
||||||
|
|
@ -1687,7 +1687,7 @@ WTErr WCMRPortAudioDeviceManager::generateDeviceListImpl()
|
||||||
m_DeviceInfoVec.push_back(pDevInfo);
|
m_DeviceInfoVec.push_back(pDevInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bRejectDevice)
|
if(bRejectDevice)
|
||||||
{
|
{
|
||||||
TRACE_MSG ("API::PortAudioDeviceManager::Device " << pDevInfo->m_DeviceName << "Rejected. \
|
TRACE_MSG ("API::PortAudioDeviceManager::Device " << pDevInfo->m_DeviceName << "Rejected. \
|
||||||
|
|
@ -1721,9 +1721,9 @@ WTErr WCMRPortAudioDeviceManager::generateDeviceListImpl()
|
||||||
WTErr WCMRPortAudioDeviceManager::getDeviceSampleRatesImpl(const std::string & deviceName, std::vector<int>& sampleRates) const
|
WTErr WCMRPortAudioDeviceManager::getDeviceSampleRatesImpl(const std::string & deviceName, std::vector<int>& sampleRates) const
|
||||||
{
|
{
|
||||||
sampleRates.clear ();
|
sampleRates.clear ();
|
||||||
|
|
||||||
WTErr retVal = eNoErr;
|
WTErr retVal = eNoErr;
|
||||||
|
|
||||||
if (m_CurrentDevice && deviceName == m_CurrentDevice->DeviceName() )
|
if (m_CurrentDevice && deviceName == m_CurrentDevice->DeviceName() )
|
||||||
{
|
{
|
||||||
sampleRates=m_CurrentDevice->SamplingRates();
|
sampleRates=m_CurrentDevice->SamplingRates();
|
||||||
|
|
@ -1732,7 +1732,7 @@ WTErr WCMRPortAudioDeviceManager::getDeviceSampleRatesImpl(const std::string & d
|
||||||
|
|
||||||
DeviceInfo devInfo;
|
DeviceInfo devInfo;
|
||||||
retVal = GetDeviceInfoByName(deviceName, devInfo);
|
retVal = GetDeviceInfoByName(deviceName, devInfo);
|
||||||
|
|
||||||
if (eNoErr == retVal)
|
if (eNoErr == retVal)
|
||||||
{
|
{
|
||||||
sampleRates=devInfo.m_AvailableSampleRates;
|
sampleRates=devInfo.m_AvailableSampleRates;
|
||||||
|
|
@ -1765,7 +1765,7 @@ WTErr WCMRPortAudioDeviceManager::getDeviceBufferSizesImpl(const std::string & d
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceInfo devInfo;
|
DeviceInfo devInfo;
|
||||||
retVal = GetDeviceInfoByName(deviceName, devInfo);
|
retVal = GetDeviceInfoByName(deviceName, devInfo);
|
||||||
|
|
||||||
if (eNoErr == retVal)
|
if (eNoErr == retVal)
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ public:
|
||||||
inline bool is_spp() const { return this->_buf[0] == 0xF2 && this->size() == 1; }
|
inline bool is_spp() const { return this->_buf[0] == 0xF2 && this->size() == 1; }
|
||||||
inline bool is_mtc_quarter() const { return this->_buf[0] == 0xF1 && this->size() == 1; }
|
inline bool is_mtc_quarter() const { return this->_buf[0] == 0xF1 && this->size() == 1; }
|
||||||
inline bool is_mtc_full() const {
|
inline bool is_mtc_full() const {
|
||||||
return this->size() == 10 && this->_buf[0] == 0xf0 && this->_buf[1] == 0x7f &&
|
return this->size() == 10 && this->_buf[0] == 0xf0 && this->_buf[1] == 0x7f &&
|
||||||
this->_buf[3] == 0x01 && this->_buf[4] == 0x01;
|
this->_buf[3] == 0x01 && this->_buf[4] == 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -288,8 +288,8 @@ ControlList::thin (double thinning_factor)
|
||||||
/* compute the area of the triangle formed by 3 points
|
/* compute the area of the triangle formed by 3 points
|
||||||
*/
|
*/
|
||||||
|
|
||||||
double area = fabs ((prevprev->when * (prev->value - cur->value)) +
|
double area = fabs ((prevprev->when * (prev->value - cur->value)) +
|
||||||
(prev->when * (cur->value - prevprev->value)) +
|
(prev->when * (cur->value - prevprev->value)) +
|
||||||
(cur->when * (prevprev->value - prev->value)));
|
(cur->when * (prevprev->value - prev->value)));
|
||||||
|
|
||||||
if (area < thinning_factor) {
|
if (area < thinning_factor) {
|
||||||
|
|
@ -413,11 +413,11 @@ ControlList::add_guard_point (double when)
|
||||||
/* most_recent_insert_iterator points to a control event
|
/* most_recent_insert_iterator points to a control event
|
||||||
already at the insert position, so there is
|
already at the insert position, so there is
|
||||||
nothing to do.
|
nothing to do.
|
||||||
|
|
||||||
... except ...
|
... except ...
|
||||||
|
|
||||||
advance most_recent_insert_iterator so that the "real"
|
advance most_recent_insert_iterator so that the "real"
|
||||||
insert occurs in the right place, since it
|
insert occurs in the right place, since it
|
||||||
points to the control event just inserted.
|
points to the control event just inserted.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -427,13 +427,13 @@ ControlList::add_guard_point (double when)
|
||||||
/* insert a new control event at the right spot
|
/* insert a new control event at the right spot
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 insert eval-value %2 just before iterator @ %3\n",
|
DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 insert eval-value %2 just before iterator @ %3\n",
|
||||||
this, eval_value, (*most_recent_insert_iterator)->when));
|
this, eval_value, (*most_recent_insert_iterator)->when));
|
||||||
|
|
||||||
most_recent_insert_iterator = _events.insert (most_recent_insert_iterator, new ControlEvent (when, eval_value));
|
most_recent_insert_iterator = _events.insert (most_recent_insert_iterator, new ControlEvent (when, eval_value));
|
||||||
|
|
||||||
/* advance most_recent_insert_iterator so that the "real"
|
/* advance most_recent_insert_iterator so that the "real"
|
||||||
* insert occurs in the right place, since it
|
* insert occurs in the right place, since it
|
||||||
* points to the control event just inserted.
|
* points to the control event just inserted.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,13 @@ static event_id_t _event_id_counter = 0;
|
||||||
event_id_t
|
event_id_t
|
||||||
event_id_counter()
|
event_id_counter()
|
||||||
{
|
{
|
||||||
return g_atomic_int_get (&_event_id_counter);
|
return g_atomic_int_get (&_event_id_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
init_event_id_counter(event_id_t n)
|
init_event_id_counter(event_id_t n)
|
||||||
{
|
{
|
||||||
g_atomic_int_set (&_event_id_counter, n);
|
g_atomic_int_set (&_event_id_counter, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
event_id_t
|
event_id_t
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@ CurveTest::constrainedCubic ()
|
||||||
f"2(x2) = 2*(2*f'2(x2) + f'2(x1))/(x2 – x1) - 6*(y2 – y1)/ (x2 – x1)^2
|
f"2(x2) = 2*(2*f'2(x2) + f'2(x1))/(x2 – x1) - 6*(y2 – y1)/ (x2 – x1)^2
|
||||||
= 2*(2*0 + 1.8181)/(30 – 10) – 6*(150 – 130)/(30 – 10)^2
|
= 2*(2*0 + 1.8181)/(30 – 10) – 6*(150 – 130)/(30 – 10)^2
|
||||||
= -0.11818
|
= -0.11818
|
||||||
|
|
||||||
d2 = 1/6 * (f"2(x2) - f"2(x1))/(x2 – x1)
|
d2 = 1/6 * (f"2(x2) - f"2(x1))/(x2 – x1)
|
||||||
= 1/6 * (-0.11818 + 0.063636)/(30 – 10)
|
= 1/6 * (-0.11818 + 0.063636)/(30 – 10)
|
||||||
= -0.0004545
|
= -0.0004545
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ MidnamTest::yamaha_PSRS900_patchfile_test()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MidnamTest::load_all_midnams_test ()
|
MidnamTest::load_all_midnams_test ()
|
||||||
{
|
{
|
||||||
vector<std::string> result;
|
vector<std::string> result;
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ public:
|
||||||
BOOST_ASSERT(px != 0);
|
BOOST_ASSERT(px != 0);
|
||||||
return px;
|
return px;
|
||||||
}
|
}
|
||||||
|
|
||||||
T * get() const // never throws
|
T * get() const // never throws
|
||||||
{
|
{
|
||||||
return px;
|
return px;
|
||||||
|
|
@ -284,13 +284,13 @@ public:
|
||||||
( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) )
|
( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) )
|
||||||
|
|
||||||
typedef T * (this_type::*unspecified_bool_type)() const;
|
typedef T * (this_type::*unspecified_bool_type)() const;
|
||||||
|
|
||||||
operator unspecified_bool_type() const // never throws
|
operator unspecified_bool_type() const // never throws
|
||||||
{
|
{
|
||||||
return px == 0? 0: &this_type::get;
|
return px == 0? 0: &this_type::get;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
typedef T * this_type::*unspecified_bool_type;
|
typedef T * this_type::*unspecified_bool_type;
|
||||||
|
|
||||||
|
|
@ -446,7 +446,7 @@ using std::basic_ostream;
|
||||||
template<class E, class T, class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os, shared_ptr<Y> const & p)
|
template<class E, class T, class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os, shared_ptr<Y> const & p)
|
||||||
# else
|
# else
|
||||||
template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, shared_ptr<Y> const & p)
|
template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, shared_ptr<Y> const & p)
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
os << p.get();
|
os << p.get();
|
||||||
return os;
|
return os;
|
||||||
|
|
@ -482,7 +482,7 @@ template<class D, class T> D * get_deleter(shared_ptr<T> const & p)
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
|
#endif // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ Pitch::getPitchForFrequency(float frequency,
|
||||||
midiPitch = midiPitch + 1;
|
midiPitch = midiPitch + 1;
|
||||||
centsOffset = -(100.0 - centsOffset);
|
centsOffset = -(100.0 - centsOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (centsOffsetReturn) *centsOffsetReturn = centsOffset;
|
if (centsOffsetReturn) *centsOffsetReturn = centsOffset;
|
||||||
return midiPitch;
|
return midiPitch;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -124,7 +124,7 @@ void Chromagram::unityNormalise(double *src)
|
||||||
double* Chromagram::process( const double *data )
|
double* Chromagram::process( const double *data )
|
||||||
{
|
{
|
||||||
if (!m_skGenerated) {
|
if (!m_skGenerated) {
|
||||||
// Generate CQ Kernel
|
// Generate CQ Kernel
|
||||||
m_ConstantQ->sparsekernel();
|
m_ConstantQ->sparsekernel();
|
||||||
m_skGenerated = true;
|
m_skGenerated = true;
|
||||||
}
|
}
|
||||||
|
|
@ -148,7 +148,7 @@ double* Chromagram::process( const double *data )
|
||||||
double* Chromagram::process( const double *real, const double *imag )
|
double* Chromagram::process( const double *real, const double *imag )
|
||||||
{
|
{
|
||||||
if (!m_skGenerated) {
|
if (!m_skGenerated) {
|
||||||
// Generate CQ Kernel
|
// Generate CQ Kernel
|
||||||
m_ConstantQ->sparsekernel();
|
m_ConstantQ->sparsekernel();
|
||||||
m_skGenerated = true;
|
m_skGenerated = true;
|
||||||
}
|
}
|
||||||
|
|
@ -164,10 +164,10 @@ double* Chromagram::process( const double *real, const double *imag )
|
||||||
|
|
||||||
// add each octave of cq data into Chromagram
|
// add each octave of cq data into Chromagram
|
||||||
const unsigned octaves = (int)floor(double( m_uK/m_BPO))-1;
|
const unsigned octaves = (int)floor(double( m_uK/m_BPO))-1;
|
||||||
for (unsigned octave = 0; octave <= octaves; octave++)
|
for (unsigned octave = 0; octave <= octaves; octave++)
|
||||||
{
|
{
|
||||||
unsigned firstBin = octave*m_BPO;
|
unsigned firstBin = octave*m_BPO;
|
||||||
for (unsigned i = 0; i < m_BPO; i++)
|
for (unsigned i = 0; i < m_BPO; i++)
|
||||||
{
|
{
|
||||||
m_chromadata[i] += kabs( m_CQRe[ firstBin + i ], m_CQIm[ firstBin + i ]);
|
m_chromadata[i] += kabs( m_CQRe[ firstBin + i ], m_CQIm[ firstBin + i ]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ void ConstantQ::sparsekernel()
|
||||||
double* transfHammingWindowRe = new double [ m_FFTLength ];
|
double* transfHammingWindowRe = new double [ m_FFTLength ];
|
||||||
double* transfHammingWindowIm = new double [ m_FFTLength ];
|
double* transfHammingWindowIm = new double [ m_FFTLength ];
|
||||||
|
|
||||||
for (unsigned u=0; u < m_FFTLength; u++)
|
for (unsigned u=0; u < m_FFTLength; u++)
|
||||||
{
|
{
|
||||||
hammingWindowRe[u] = 0;
|
hammingWindowRe[u] = 0;
|
||||||
hammingWindowIm[u] = 0;
|
hammingWindowIm[u] = 0;
|
||||||
|
|
@ -111,26 +111,26 @@ void ConstantQ::sparsekernel()
|
||||||
sk->imag.reserve( m_FFTLength*2 );
|
sk->imag.reserve( m_FFTLength*2 );
|
||||||
|
|
||||||
// for each bin value K, calculate temporal kernel, take its fft to
|
// for each bin value K, calculate temporal kernel, take its fft to
|
||||||
//calculate the spectral kernel then threshold it to make it sparse and
|
//calculate the spectral kernel then threshold it to make it sparse and
|
||||||
//add it to the sparse kernels matrix
|
//add it to the sparse kernels matrix
|
||||||
double squareThreshold = m_CQThresh * m_CQThresh;
|
double squareThreshold = m_CQThresh * m_CQThresh;
|
||||||
|
|
||||||
FFT m_FFT(m_FFTLength);
|
FFT m_FFT(m_FFTLength);
|
||||||
|
|
||||||
for (unsigned k = m_uK; k--; )
|
for (unsigned k = m_uK; k--; )
|
||||||
{
|
{
|
||||||
for (unsigned u=0; u < m_FFTLength; u++)
|
for (unsigned u=0; u < m_FFTLength; u++)
|
||||||
{
|
{
|
||||||
hammingWindowRe[u] = 0;
|
hammingWindowRe[u] = 0;
|
||||||
hammingWindowIm[u] = 0;
|
hammingWindowIm[u] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Computing a hamming window
|
// Computing a hamming window
|
||||||
const unsigned hammingLength = (int) ceil( m_dQ * m_FS / ( m_FMin * pow(2,((double)(k))/(double)m_BPO)));
|
const unsigned hammingLength = (int) ceil( m_dQ * m_FS / ( m_FMin * pow(2,((double)(k))/(double)m_BPO)));
|
||||||
|
|
||||||
unsigned origin = m_FFTLength/2 - hammingLength/2;
|
unsigned origin = m_FFTLength/2 - hammingLength/2;
|
||||||
|
|
||||||
for (unsigned i=0; i<hammingLength; i++)
|
for (unsigned i=0; i<hammingLength; i++)
|
||||||
{
|
{
|
||||||
const double angle = 2*PI*m_dQ*i/hammingLength;
|
const double angle = 2*PI*m_dQ*i/hammingLength;
|
||||||
const double real = cos(angle);
|
const double real = cos(angle);
|
||||||
|
|
@ -148,12 +148,12 @@ void ConstantQ::sparsekernel()
|
||||||
hammingWindowIm[i] = hammingWindowIm[i + m_FFTLength/2];
|
hammingWindowIm[i] = hammingWindowIm[i + m_FFTLength/2];
|
||||||
hammingWindowIm[i + m_FFTLength/2] = temp;
|
hammingWindowIm[i + m_FFTLength/2] = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
//do fft of hammingWindow
|
//do fft of hammingWindow
|
||||||
m_FFT.process( 0, hammingWindowRe, hammingWindowIm, transfHammingWindowRe, transfHammingWindowIm );
|
m_FFT.process( 0, hammingWindowRe, hammingWindowIm, transfHammingWindowRe, transfHammingWindowIm );
|
||||||
|
|
||||||
|
|
||||||
for (unsigned j=0; j<( m_FFTLength ); j++)
|
for (unsigned j=0; j<( m_FFTLength ); j++)
|
||||||
{
|
{
|
||||||
// perform thresholding
|
// perform thresholding
|
||||||
const double squaredBin = squaredModule( transfHammingWindowRe[ j ], transfHammingWindowIm[ j ]);
|
const double squaredBin = squaredModule( transfHammingWindowRe[ j ], transfHammingWindowIm[ j ]);
|
||||||
|
|
@ -241,7 +241,7 @@ void ConstantQ::sparsekernel()
|
||||||
cout << "}" << endl;
|
cout << "}" << endl;
|
||||||
*/
|
*/
|
||||||
// std::cerr << "done\n -> is: " << sk->is.size() << ", js: " << sk->js.size() << ", reals: " << sk->real.size() << ", imags: " << sk->imag.size() << std::endl;
|
// std::cerr << "done\n -> is: " << sk->is.size() << ", js: " << sk->js.size() << ", reals: " << sk->real.size() << ", imags: " << sk->imag.size() << std::endl;
|
||||||
|
|
||||||
m_sparseKernel = sk;
|
m_sparseKernel = sk;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -256,7 +256,7 @@ double* ConstantQ::process( const double* fftdata )
|
||||||
|
|
||||||
SparseKernel *sk = m_sparseKernel;
|
SparseKernel *sk = m_sparseKernel;
|
||||||
|
|
||||||
for (unsigned row=0; row<2*m_uK; row++)
|
for (unsigned row=0; row<2*m_uK; row++)
|
||||||
{
|
{
|
||||||
m_CQdata[ row ] = 0;
|
m_CQdata[ row ] = 0;
|
||||||
m_CQdata[ row+1 ] = 0;
|
m_CQdata[ row+1 ] = 0;
|
||||||
|
|
@ -324,7 +324,7 @@ void ConstantQ::process(const double *FFTRe, const double* FFTIm,
|
||||||
|
|
||||||
SparseKernel *sk = m_sparseKernel;
|
SparseKernel *sk = m_sparseKernel;
|
||||||
|
|
||||||
for (unsigned row=0; row<m_uK; row++)
|
for (unsigned row=0; row<m_uK; row++)
|
||||||
{
|
{
|
||||||
CQRe[ row ] = 0;
|
CQRe[ row ] = 0;
|
||||||
CQIm[ row ] = 0;
|
CQIm[ row ] = 0;
|
||||||
|
|
|
||||||
|
|
@ -27,75 +27,75 @@ MFCC::MFCC(MFCCConfig config)
|
||||||
|
|
||||||
/* Calculate at startup */
|
/* Calculate at startup */
|
||||||
double *freqs, *lower, *center, *upper, *triangleHeight, *fftFreqs;
|
double *freqs, *lower, *center, *upper, *triangleHeight, *fftFreqs;
|
||||||
|
|
||||||
lowestFrequency = 66.6666666;
|
lowestFrequency = 66.6666666;
|
||||||
linearFilters = 13;
|
linearFilters = 13;
|
||||||
linearSpacing = 66.66666666;
|
linearSpacing = 66.66666666;
|
||||||
logFilters = 27;
|
logFilters = 27;
|
||||||
logSpacing = 1.0711703;
|
logSpacing = 1.0711703;
|
||||||
|
|
||||||
/* FFT and analysis window sizes */
|
/* FFT and analysis window sizes */
|
||||||
fftSize = config.fftsize;
|
fftSize = config.fftsize;
|
||||||
fft = new FFTReal(fftSize);
|
fft = new FFTReal(fftSize);
|
||||||
|
|
||||||
totalFilters = linearFilters + logFilters;
|
totalFilters = linearFilters + logFilters;
|
||||||
logPower = config.logpower;
|
logPower = config.logpower;
|
||||||
|
|
||||||
samplingRate = config.FS;
|
samplingRate = config.FS;
|
||||||
|
|
||||||
/* The number of cepstral componenents */
|
/* The number of cepstral componenents */
|
||||||
nceps = config.nceps;
|
nceps = config.nceps;
|
||||||
|
|
||||||
/* Set if user want C0 */
|
/* Set if user want C0 */
|
||||||
WANT_C0 = (config.want_c0 ? 1 : 0);
|
WANT_C0 = (config.want_c0 ? 1 : 0);
|
||||||
|
|
||||||
/* Allocate space for feature vector */
|
/* Allocate space for feature vector */
|
||||||
if (WANT_C0 == 1) {
|
if (WANT_C0 == 1) {
|
||||||
ceps = (double*)calloc(nceps+1, sizeof(double));
|
ceps = (double*)calloc(nceps+1, sizeof(double));
|
||||||
} else {
|
} else {
|
||||||
ceps = (double*)calloc(nceps, sizeof(double));
|
ceps = (double*)calloc(nceps, sizeof(double));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate space for local vectors */
|
/* Allocate space for local vectors */
|
||||||
mfccDCTMatrix = (double**)calloc(nceps+1, sizeof(double*));
|
mfccDCTMatrix = (double**)calloc(nceps+1, sizeof(double*));
|
||||||
for (i = 0; i < nceps+1; i++) {
|
for (i = 0; i < nceps+1; i++) {
|
||||||
mfccDCTMatrix[i]= (double*)calloc(totalFilters, sizeof(double));
|
mfccDCTMatrix[i]= (double*)calloc(totalFilters, sizeof(double));
|
||||||
}
|
}
|
||||||
|
|
||||||
mfccFilterWeights = (double**)calloc(totalFilters, sizeof(double*));
|
mfccFilterWeights = (double**)calloc(totalFilters, sizeof(double*));
|
||||||
for (i = 0; i < totalFilters; i++) {
|
for (i = 0; i < totalFilters; i++) {
|
||||||
mfccFilterWeights[i] = (double*)calloc(fftSize, sizeof(double));
|
mfccFilterWeights[i] = (double*)calloc(fftSize, sizeof(double));
|
||||||
}
|
}
|
||||||
|
|
||||||
freqs = (double*)calloc(totalFilters+2,sizeof(double));
|
freqs = (double*)calloc(totalFilters+2,sizeof(double));
|
||||||
|
|
||||||
lower = (double*)calloc(totalFilters,sizeof(double));
|
lower = (double*)calloc(totalFilters,sizeof(double));
|
||||||
center = (double*)calloc(totalFilters,sizeof(double));
|
center = (double*)calloc(totalFilters,sizeof(double));
|
||||||
upper = (double*)calloc(totalFilters,sizeof(double));
|
upper = (double*)calloc(totalFilters,sizeof(double));
|
||||||
|
|
||||||
triangleHeight = (double*)calloc(totalFilters,sizeof(double));
|
triangleHeight = (double*)calloc(totalFilters,sizeof(double));
|
||||||
fftFreqs = (double*)calloc(fftSize,sizeof(double));
|
fftFreqs = (double*)calloc(fftSize,sizeof(double));
|
||||||
|
|
||||||
for (i = 0; i < linearFilters; i++) {
|
for (i = 0; i < linearFilters; i++) {
|
||||||
freqs[i] = lowestFrequency + ((double)i) * linearSpacing;
|
freqs[i] = lowestFrequency + ((double)i) * linearSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = linearFilters; i < totalFilters+2; i++) {
|
for (i = linearFilters; i < totalFilters+2; i++) {
|
||||||
freqs[i] = freqs[linearFilters-1] *
|
freqs[i] = freqs[linearFilters-1] *
|
||||||
pow(logSpacing, (double)(i-linearFilters+1));
|
pow(logSpacing, (double)(i-linearFilters+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Define lower, center and upper */
|
/* Define lower, center and upper */
|
||||||
memcpy(lower, freqs,totalFilters*sizeof(double));
|
memcpy(lower, freqs,totalFilters*sizeof(double));
|
||||||
memcpy(center, &freqs[1],totalFilters*sizeof(double));
|
memcpy(center, &freqs[1],totalFilters*sizeof(double));
|
||||||
memcpy(upper, &freqs[2],totalFilters*sizeof(double));
|
memcpy(upper, &freqs[2],totalFilters*sizeof(double));
|
||||||
|
|
||||||
for (i=0;i<totalFilters;i++){
|
for (i=0;i<totalFilters;i++){
|
||||||
triangleHeight[i] = 2./(upper[i]-lower[i]);
|
triangleHeight[i] = 2./(upper[i]-lower[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i<fftSize;i++){
|
for (i=0;i<fftSize;i++){
|
||||||
fftFreqs[i] = ((double) i / ((double) fftSize ) *
|
fftFreqs[i] = ((double) i / ((double) fftSize ) *
|
||||||
(double) samplingRate);
|
(double) samplingRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,12 +103,12 @@ MFCC::MFCC(MFCCConfig config)
|
||||||
for (i=0;i<totalFilters;i++){
|
for (i=0;i<totalFilters;i++){
|
||||||
|
|
||||||
for (j=0;j<fftSize;j++) {
|
for (j=0;j<fftSize;j++) {
|
||||||
|
|
||||||
if ((fftFreqs[j] > lower[i]) && (fftFreqs[j] <= center[i])) {
|
if ((fftFreqs[j] > lower[i]) && (fftFreqs[j] <= center[i])) {
|
||||||
|
|
||||||
mfccFilterWeights[i][j] = triangleHeight[i] *
|
mfccFilterWeights[i][j] = triangleHeight[i] *
|
||||||
(fftFreqs[j]-lower[i]) / (center[i]-lower[i]);
|
(fftFreqs[j]-lower[i]) / (center[i]-lower[i]);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -118,7 +118,7 @@ MFCC::MFCC(MFCCConfig config)
|
||||||
if ((fftFreqs[j]>center[i]) && (fftFreqs[j]<upper[i])) {
|
if ((fftFreqs[j]>center[i]) && (fftFreqs[j]<upper[i])) {
|
||||||
|
|
||||||
mfccFilterWeights[i][j] = mfccFilterWeights[i][j]
|
mfccFilterWeights[i][j] = mfccFilterWeights[i][j]
|
||||||
+ triangleHeight[i] * (upper[i]-fftFreqs[j])
|
+ triangleHeight[i] * (upper[i]-fftFreqs[j])
|
||||||
/ (upper[i]-center[i]);
|
/ (upper[i]-center[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -130,15 +130,15 @@ MFCC::MFCC(MFCCConfig config)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We calculate now mfccDCT matrix
|
* We calculate now mfccDCT matrix
|
||||||
* NB: +1 because of the DC component
|
* NB: +1 because of the DC component
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const double pi = 3.14159265358979323846264338327950288;
|
const double pi = 3.14159265358979323846264338327950288;
|
||||||
|
|
||||||
for (i = 0; i < nceps+1; i++) {
|
for (i = 0; i < nceps+1; i++) {
|
||||||
for (j = 0; j < totalFilters; j++) {
|
for (j = 0; j < totalFilters; j++) {
|
||||||
mfccDCTMatrix[i][j] = (1./sqrt((double) totalFilters / 2.))
|
mfccDCTMatrix[i][j] = (1./sqrt((double) totalFilters / 2.))
|
||||||
* cos((double) i * ((double) j + 0.5) / (double) totalFilters * pi);
|
* cos((double) i * ((double) j + 0.5) / (double) totalFilters * pi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +146,7 @@ MFCC::MFCC(MFCCConfig config)
|
||||||
for (j = 0; j < totalFilters; j++){
|
for (j = 0; j < totalFilters; j++){
|
||||||
mfccDCTMatrix[0][j] = (sqrt(2.)/2.) * mfccDCTMatrix[0][j];
|
mfccDCTMatrix[0][j] = (sqrt(2.)/2.) * mfccDCTMatrix[0][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The analysis window */
|
/* The analysis window */
|
||||||
window = new Window<double>(config.window, fftSize);
|
window = new Window<double>(config.window, fftSize);
|
||||||
|
|
||||||
|
|
@ -156,7 +156,7 @@ MFCC::MFCC(MFCCConfig config)
|
||||||
|
|
||||||
earMag = (double*)calloc(totalFilters, sizeof(double));
|
earMag = (double*)calloc(totalFilters, sizeof(double));
|
||||||
fftMag = (double*)calloc(fftSize/2, sizeof(double));
|
fftMag = (double*)calloc(fftSize/2, sizeof(double));
|
||||||
|
|
||||||
free(freqs);
|
free(freqs);
|
||||||
free(lower);
|
free(lower);
|
||||||
free(center);
|
free(center);
|
||||||
|
|
@ -168,27 +168,27 @@ MFCC::MFCC(MFCCConfig config)
|
||||||
MFCC::~MFCC()
|
MFCC::~MFCC()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Free the structure */
|
/* Free the structure */
|
||||||
for (i = 0; i < nceps+1; i++) {
|
for (i = 0; i < nceps+1; i++) {
|
||||||
free(mfccDCTMatrix[i]);
|
free(mfccDCTMatrix[i]);
|
||||||
}
|
}
|
||||||
free(mfccDCTMatrix);
|
free(mfccDCTMatrix);
|
||||||
|
|
||||||
for (i = 0; i < totalFilters; i++) {
|
for (i = 0; i < totalFilters; i++) {
|
||||||
free(mfccFilterWeights[i]);
|
free(mfccFilterWeights[i]);
|
||||||
}
|
}
|
||||||
free(mfccFilterWeights);
|
free(mfccFilterWeights);
|
||||||
|
|
||||||
/* Free the feature vector */
|
/* Free the feature vector */
|
||||||
free(ceps);
|
free(ceps);
|
||||||
|
|
||||||
/* The analysis window */
|
/* The analysis window */
|
||||||
delete window;
|
delete window;
|
||||||
|
|
||||||
free(earMag);
|
free(earMag);
|
||||||
free(fftMag);
|
free(fftMag);
|
||||||
|
|
||||||
/* Free the FFT */
|
/* Free the FFT */
|
||||||
free(realOut);
|
free(realOut);
|
||||||
free(imagOut);
|
free(imagOut);
|
||||||
|
|
@ -198,17 +198,17 @@ MFCC::~MFCC()
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Extract the MFCC on the input frame
|
* Extract the MFCC on the input frame
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int MFCC::process(const double *inframe, double *outceps)
|
int MFCC::process(const double *inframe, double *outceps)
|
||||||
{
|
{
|
||||||
double *inputData = (double *)malloc(fftSize * sizeof(double));
|
double *inputData = (double *)malloc(fftSize * sizeof(double));
|
||||||
for (int i = 0; i < fftSize; ++i) inputData[i] = inframe[i];
|
for (int i = 0; i < fftSize; ++i) inputData[i] = inframe[i];
|
||||||
|
|
||||||
window->cut(inputData);
|
window->cut(inputData);
|
||||||
|
|
||||||
/* Calculate the fft on the input frame */
|
/* Calculate the fft on the input frame */
|
||||||
fft->process(0, inputData, realOut, imagOut);
|
fft->process(0, inputData, realOut, imagOut);
|
||||||
|
|
||||||
|
|
@ -244,14 +244,14 @@ int MFCC::process(const double *real, const double *imag, double *outceps)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Calculate now the cepstral coefficients
|
* Calculate now the cepstral coefficients
|
||||||
* with or without the DC component
|
* with or without the DC component
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (WANT_C0 == 1) {
|
if (WANT_C0 == 1) {
|
||||||
|
|
||||||
for (i = 0; i < nceps+1; i++) {
|
for (i = 0; i < nceps+1; i++) {
|
||||||
double tmp = 0.;
|
double tmp = 0.;
|
||||||
for (j = 0; j < totalFilters; j++){
|
for (j = 0; j < totalFilters; j++){
|
||||||
|
|
@ -260,8 +260,8 @@ int MFCC::process(const double *real, const double *imag, double *outceps)
|
||||||
outceps[i] = tmp;
|
outceps[i] = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 1; i < nceps+1; i++) {
|
for (i = 1; i < nceps+1; i++) {
|
||||||
double tmp = 0.;
|
double tmp = 0.;
|
||||||
for (j = 0; j < totalFilters; j++){
|
for (j = 0; j < totalFilters; j++){
|
||||||
|
|
@ -270,7 +270,7 @@ int MFCC::process(const double *real, const double *imag, double *outceps)
|
||||||
outceps[i-1] = tmp;
|
outceps[i-1] = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nceps;
|
return nceps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ double DetectionFunction::complexSD(unsigned int length, double *srcMagnitude, d
|
||||||
double tmpPhase = 0;
|
double tmpPhase = 0;
|
||||||
double tmpReal = 0;
|
double tmpReal = 0;
|
||||||
double tmpImag = 0;
|
double tmpImag = 0;
|
||||||
|
|
||||||
double dev = 0;
|
double dev = 0;
|
||||||
ComplexData meas = ComplexData( 0, 0 );
|
ComplexData meas = ComplexData( 0, 0 );
|
||||||
ComplexData j = ComplexData( 0, 1 );
|
ComplexData j = ComplexData( 0, 1 );
|
||||||
|
|
@ -287,7 +287,7 @@ double DetectionFunction::broadband(unsigned int length, double *src)
|
||||||
m_magHistory[i] = sqrmag;
|
m_magHistory[i] = sqrmag;
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
double* DetectionFunction::getSpectrumMagnitude()
|
double* DetectionFunction::getSpectrumMagnitude()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,12 @@ void PeakPicking::initialise( PPickParams Config )
|
||||||
Qfiltb = Config.QuadThresh.b ;
|
Qfiltb = Config.QuadThresh.b ;
|
||||||
Qfiltc = Config.QuadThresh.c ;
|
Qfiltc = Config.QuadThresh.c ;
|
||||||
|
|
||||||
m_DFProcessingParams.length = m_DFLength;
|
m_DFProcessingParams.length = m_DFLength;
|
||||||
m_DFProcessingParams.LPOrd = Config.LPOrd;
|
m_DFProcessingParams.LPOrd = Config.LPOrd;
|
||||||
m_DFProcessingParams.LPACoeffs = Config.LPACoeffs;
|
m_DFProcessingParams.LPACoeffs = Config.LPACoeffs;
|
||||||
m_DFProcessingParams.LPBCoeffs = Config.LPBCoeffs;
|
m_DFProcessingParams.LPBCoeffs = Config.LPBCoeffs;
|
||||||
m_DFProcessingParams.winPre = Config.WinT.pre;
|
m_DFProcessingParams.winPre = Config.WinT.pre;
|
||||||
m_DFProcessingParams.winPost = Config.WinT.post;
|
m_DFProcessingParams.winPost = Config.WinT.post;
|
||||||
m_DFProcessingParams.AlphaNormParam = Config.alpha;
|
m_DFProcessingParams.AlphaNormParam = Config.alpha;
|
||||||
m_DFProcessingParams.isMedianPositive = false;
|
m_DFProcessingParams.isMedianPositive = false;
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ void PeakPicking::process( double* src, unsigned int len, vector<int> &onsets )
|
||||||
|
|
||||||
vector <double> m_maxima;
|
vector <double> m_maxima;
|
||||||
|
|
||||||
// Signal conditioning
|
// Signal conditioning
|
||||||
m_DFSmoothing->process( src, m_workBuffer );
|
m_DFSmoothing->process( src, m_workBuffer );
|
||||||
|
|
||||||
for( unsigned int u = 0; u < len; u++)
|
for( unsigned int u = 0; u < len; u++)
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ void PhaseVocoder::getPhase(unsigned int size, double *theta, double *real, doub
|
||||||
{
|
{
|
||||||
unsigned int k;
|
unsigned int k;
|
||||||
|
|
||||||
// Phase Angle "matlab" style
|
// Phase Angle "matlab" style
|
||||||
//Watch out for quadrant mapping !!!
|
//Watch out for quadrant mapping !!!
|
||||||
for( k = 0; k < size; k++)
|
for( k = 0; k < size; k++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ void ClusterMeltSegmenter::initialise(int fs)
|
||||||
|
|
||||||
if (featureType == FEATURE_TYPE_CONSTQ ||
|
if (featureType == FEATURE_TYPE_CONSTQ ||
|
||||||
featureType == FEATURE_TYPE_CHROMA) {
|
featureType == FEATURE_TYPE_CHROMA) {
|
||||||
|
|
||||||
// run internal processing at 11025 or thereabouts
|
// run internal processing at 11025 or thereabouts
|
||||||
int internalRate = 11025;
|
int internalRate = 11025;
|
||||||
int decimationFactor = samplerate / internalRate;
|
int decimationFactor = samplerate / internalRate;
|
||||||
|
|
@ -77,11 +77,11 @@ void ClusterMeltSegmenter::initialise(int fs)
|
||||||
|
|
||||||
constq = new ConstantQ(config);
|
constq = new ConstantQ(config);
|
||||||
constq->sparsekernel();
|
constq->sparsekernel();
|
||||||
|
|
||||||
ncoeff = constq->getK();
|
ncoeff = constq->getK();
|
||||||
|
|
||||||
fft = new FFTReal(constq->getfftlength());
|
fft = new FFTReal(constq->getfftlength());
|
||||||
|
|
||||||
} else if (featureType == FEATURE_TYPE_MFCC) {
|
} else if (featureType == FEATURE_TYPE_MFCC) {
|
||||||
|
|
||||||
// run internal processing at 22050 or thereabouts
|
// run internal processing at 22050 or thereabouts
|
||||||
|
|
@ -110,7 +110,7 @@ void ClusterMeltSegmenter::initialise(int fs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterMeltSegmenter::~ClusterMeltSegmenter()
|
ClusterMeltSegmenter::~ClusterMeltSegmenter()
|
||||||
{
|
{
|
||||||
delete window;
|
delete window;
|
||||||
delete constq;
|
delete constq;
|
||||||
|
|
@ -164,7 +164,7 @@ void ClusterMeltSegmenter::extractFeaturesConstQ(const double* samples, int nsam
|
||||||
vector<double> cq(ncoeff);
|
vector<double> cq(ncoeff);
|
||||||
|
|
||||||
for (int i = 0; i < ncoeff; ++i) cq[i] = 0.0;
|
for (int i = 0; i < ncoeff; ++i) cq[i] = 0.0;
|
||||||
|
|
||||||
const double *psource = samples;
|
const double *psource = samples;
|
||||||
int pcount = nsamples;
|
int pcount = nsamples;
|
||||||
|
|
||||||
|
|
@ -174,9 +174,9 @@ void ClusterMeltSegmenter::extractFeaturesConstQ(const double* samples, int nsam
|
||||||
decimator->process(samples, decout);
|
decimator->process(samples, decout);
|
||||||
psource = decout;
|
psource = decout;
|
||||||
}
|
}
|
||||||
|
|
||||||
int origin = 0;
|
int origin = 0;
|
||||||
|
|
||||||
// std::cerr << "nsamples = " << nsamples << ", pcount = " << pcount << std::endl;
|
// std::cerr << "nsamples = " << nsamples << ", pcount = " << pcount << std::endl;
|
||||||
|
|
||||||
int frames = 0;
|
int frames = 0;
|
||||||
|
|
@ -208,9 +208,9 @@ void ClusterMeltSegmenter::extractFeaturesConstQ(const double* samples, int nsam
|
||||||
}
|
}
|
||||||
|
|
||||||
window->cut(frame);
|
window->cut(frame);
|
||||||
|
|
||||||
fft->process(false, frame, real, imag);
|
fft->process(false, frame, real, imag);
|
||||||
|
|
||||||
constq->process(real, imag, cqre, cqim);
|
constq->process(real, imag, cqre, cqim);
|
||||||
|
|
||||||
for (int i = 0; i < ncoeff; ++i) {
|
for (int i = 0; i < ncoeff; ++i) {
|
||||||
|
|
@ -255,7 +255,7 @@ void ClusterMeltSegmenter::extractFeaturesMFCC(const double* samples, int nsampl
|
||||||
vector<double> cc(ncoeff);
|
vector<double> cc(ncoeff);
|
||||||
|
|
||||||
for (int i = 0; i < ncoeff; ++i) cc[i] = 0.0;
|
for (int i = 0; i < ncoeff; ++i) cc[i] = 0.0;
|
||||||
|
|
||||||
const double *psource = samples;
|
const double *psource = samples;
|
||||||
int pcount = nsamples;
|
int pcount = nsamples;
|
||||||
|
|
||||||
|
|
@ -330,7 +330,7 @@ void ClusterMeltSegmenter::segment()
|
||||||
decimator = 0;
|
decimator = 0;
|
||||||
|
|
||||||
if (features.size() < histogramLength) return;
|
if (features.size() < histogramLength) return;
|
||||||
/*
|
/*
|
||||||
std::cerr << "ClusterMeltSegmenter::segment: have " << features.size()
|
std::cerr << "ClusterMeltSegmenter::segment: have " << features.size()
|
||||||
<< " features with " << features[0].size() << " coefficients (ncoeff = " << ncoeff << ", ncomponents = " << ncomponents << ")" << std::endl;
|
<< " features with " << features[0].size() << " coefficients (ncoeff = " << ncoeff << ", ncomponents = " << ncomponents << ")" << std::endl;
|
||||||
*/
|
*/
|
||||||
|
|
@ -353,10 +353,10 @@ void ClusterMeltSegmenter::segment()
|
||||||
|
|
||||||
if (featureType == FEATURE_TYPE_UNKNOWN ||
|
if (featureType == FEATURE_TYPE_UNKNOWN ||
|
||||||
featureType == FEATURE_TYPE_MFCC)
|
featureType == FEATURE_TYPE_MFCC)
|
||||||
cluster_segment(q, arrFeatures, features.size(), features[0].size(), nHMMStates, histogramLength,
|
cluster_segment(q, arrFeatures, features.size(), features[0].size(), nHMMStates, histogramLength,
|
||||||
nclusters, neighbourhoodLimit);
|
nclusters, neighbourhoodLimit);
|
||||||
else
|
else
|
||||||
constq_segment(q, arrFeatures, features.size(), nbins, ncoeff, featureType,
|
constq_segment(q, arrFeatures, features.size(), nbins, ncoeff, featureType,
|
||||||
nHMMStates, histogramLength, nclusters, neighbourhoodLimit);
|
nHMMStates, histogramLength, nclusters, neighbourhoodLimit);
|
||||||
|
|
||||||
// convert the cluster assignment sequence to a segmentation
|
// convert the cluster assignment sequence to a segmentation
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ ostream& operator<<(ostream& os, const Segmentation& s)
|
||||||
for (int i = 0; i < s.segments.size(); i++)
|
for (int i = 0; i < s.segments.size(); i++)
|
||||||
{
|
{
|
||||||
Segment seg = s.segments[i];
|
Segment seg = s.segments[i];
|
||||||
os << std::fixed << seg.type << ':' << '\t' << std::setprecision(6) << seg.start / static_cast<double>(s.samplerate)
|
os << std::fixed << seg.type << ':' << '\t' << std::setprecision(6) << seg.start / static_cast<double>(s.samplerate)
|
||||||
<< '\t' << std::setprecision(6) << seg.end / static_cast<double>(s.samplerate) << "\n";
|
<< '\t' << std::setprecision(6) << seg.end / static_cast<double>(s.samplerate) << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ void DFProcess::medianFilter(double *src, double *dst)
|
||||||
{
|
{
|
||||||
if (index >= m_length) break;
|
if (index >= m_length) break;
|
||||||
|
|
||||||
|
|
||||||
l = 0;
|
l = 0;
|
||||||
for( j = i; j < ( i + m_winPost + m_winPre + 1); j++)
|
for( j = i; j < ( i + m_winPost + m_winPre + 1); j++)
|
||||||
{
|
{
|
||||||
|
|
@ -140,7 +140,7 @@ void DFProcess::medianFilter(double *src, double *dst)
|
||||||
l++;
|
l++;
|
||||||
}
|
}
|
||||||
|
|
||||||
scratch[ index++ ] = MathUtilities::median( y, l);
|
scratch[ index++ ] = MathUtilities::median( y, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -182,6 +182,6 @@ void DFProcess::removeDCNormalize( double *src, double*dst )
|
||||||
|
|
||||||
for(int i = 0; i< m_length; i++)
|
for(int i = 0; i< m_length; i++)
|
||||||
{
|
{
|
||||||
dst[ i ] = ( src[ i ] - DFMin ) / DFAlphaNorm;
|
dst[ i ] = ( src[ i ] - DFMin ) / DFAlphaNorm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ void FiltFilt::process(double *src, double *dst, unsigned int length)
|
||||||
m_filtScratchOut = new double[ nExt ];
|
m_filtScratchOut = new double[ nExt ];
|
||||||
|
|
||||||
|
|
||||||
for( i = 0; i< nExt; i++ )
|
for( i = 0; i< nExt; i++ )
|
||||||
{
|
{
|
||||||
m_filtScratchIn[ i ] = 0.0;
|
m_filtScratchIn[ i ] = 0.0;
|
||||||
m_filtScratchOut[ i ] = 0.0;
|
m_filtScratchOut[ i ] = 0.0;
|
||||||
|
|
@ -94,16 +94,16 @@ void FiltFilt::process(double *src, double *dst, unsigned int length)
|
||||||
// Do 0Ph filtering
|
// Do 0Ph filtering
|
||||||
m_filter->process( m_filtScratchIn, m_filtScratchOut, nExt);
|
m_filter->process( m_filtScratchIn, m_filtScratchOut, nExt);
|
||||||
|
|
||||||
// reverse the series for FILTFILT
|
// reverse the series for FILTFILT
|
||||||
for ( i = 0; i < nExt; i++)
|
for ( i = 0; i < nExt; i++)
|
||||||
{
|
{
|
||||||
m_filtScratchIn[ i ] = m_filtScratchOut[ nExt - i - 1];
|
m_filtScratchIn[ i ] = m_filtScratchOut[ nExt - i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// do FILTER again
|
// do FILTER again
|
||||||
m_filter->process( m_filtScratchIn, m_filtScratchOut, nExt);
|
m_filter->process( m_filtScratchIn, m_filtScratchOut, nExt);
|
||||||
|
|
||||||
// reverse the series back
|
// reverse the series back
|
||||||
for ( i = 0; i < nExt; i++)
|
for ( i = 0; i < nExt; i++)
|
||||||
{
|
{
|
||||||
m_filtScratchIn[ i ] = m_filtScratchOut[ nExt - i - 1 ];
|
m_filtScratchIn[ i ] = m_filtScratchOut[ nExt - i - 1 ];
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ void Framer::getFrame(double *dst)
|
||||||
{
|
{
|
||||||
for( unsigned int u = 0; u < m_frameLength; u++)
|
for( unsigned int u = 0; u < m_frameLength; u++)
|
||||||
{
|
{
|
||||||
dst[ u ] = m_srcBuffer[ m_ulSrcIndex++ ];
|
dst[ u ] = m_srcBuffer[ m_ulSrcIndex++ ];
|
||||||
}
|
}
|
||||||
m_ulSrcIndex -= ( m_frameLength - m_stepSize );
|
m_ulSrcIndex -= ( m_frameLength - m_stepSize );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ DownBeat::pushAudioBlock(const float *audio)
|
||||||
// std::cerr << "pushAudioBlock: rms in " << sqrt(rmsin) << ", out " << sqrt(rmsout) << std::endl;
|
// std::cerr << "pushAudioBlock: rms in " << sqrt(rmsin) << ", out " << sqrt(rmsout) << std::endl;
|
||||||
m_buffill += m_increment / m_factor;
|
m_buffill += m_increment / m_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float *
|
const float *
|
||||||
DownBeat::getBufferedAudio(size_t &length) const
|
DownBeat::getBufferedAudio(size_t &length) const
|
||||||
{
|
{
|
||||||
|
|
@ -192,9 +192,9 @@ DownBeat::findDownBeats(const float *audio,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now FFT beat frame
|
// Now FFT beat frame
|
||||||
|
|
||||||
m_fft->process(false, m_beatframe, m_fftRealOut, m_fftImagOut);
|
m_fft->process(false, m_beatframe, m_fftRealOut, m_fftImagOut);
|
||||||
|
|
||||||
// Calculate magnitudes
|
// Calculate magnitudes
|
||||||
|
|
||||||
for (size_t j = 0; j < m_beatframesize/2; ++j) {
|
for (size_t j = 0; j < m_beatframesize/2; ++j) {
|
||||||
|
|
@ -257,7 +257,7 @@ DownBeat::measureSpecDiff(d_vec_t oldspec, d_vec_t newspec)
|
||||||
{
|
{
|
||||||
// JENSEN-SHANNON DIVERGENCE BETWEEN SPECTRAL FRAMES
|
// JENSEN-SHANNON DIVERGENCE BETWEEN SPECTRAL FRAMES
|
||||||
|
|
||||||
unsigned int SPECSIZE = 512; // ONLY LOOK AT FIRST 512 SAMPLES OF SPECTRUM.
|
unsigned int SPECSIZE = 512; // ONLY LOOK AT FIRST 512 SAMPLES OF SPECTRUM.
|
||||||
if (SPECSIZE > oldspec.size()/4) {
|
if (SPECSIZE > oldspec.size()/4) {
|
||||||
SPECSIZE = oldspec.size()/4;
|
SPECSIZE = oldspec.size()/4;
|
||||||
}
|
}
|
||||||
|
|
@ -266,37 +266,37 @@ DownBeat::measureSpecDiff(d_vec_t oldspec, d_vec_t newspec)
|
||||||
|
|
||||||
double sumnew = 0.;
|
double sumnew = 0.;
|
||||||
double sumold = 0.;
|
double sumold = 0.;
|
||||||
|
|
||||||
for (unsigned int i = 0;i < SPECSIZE;i++)
|
for (unsigned int i = 0;i < SPECSIZE;i++)
|
||||||
{
|
{
|
||||||
newspec[i] +=EPS;
|
newspec[i] +=EPS;
|
||||||
oldspec[i] +=EPS;
|
oldspec[i] +=EPS;
|
||||||
|
|
||||||
sumnew+=newspec[i];
|
sumnew+=newspec[i];
|
||||||
sumold+=oldspec[i];
|
sumold+=oldspec[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0;i < SPECSIZE;i++)
|
for (unsigned int i = 0;i < SPECSIZE;i++)
|
||||||
{
|
{
|
||||||
newspec[i] /= (sumnew);
|
newspec[i] /= (sumnew);
|
||||||
oldspec[i] /= (sumold);
|
oldspec[i] /= (sumold);
|
||||||
|
|
||||||
// IF ANY SPECTRAL VALUES ARE 0 (SHOULDN'T BE ANY!) SET THEM TO 1
|
// IF ANY SPECTRAL VALUES ARE 0 (SHOULDN'T BE ANY!) SET THEM TO 1
|
||||||
if (newspec[i] == 0)
|
if (newspec[i] == 0)
|
||||||
{
|
{
|
||||||
newspec[i] = 1.;
|
newspec[i] = 1.;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldspec[i] == 0)
|
if (oldspec[i] == 0)
|
||||||
{
|
{
|
||||||
oldspec[i] = 1.;
|
oldspec[i] = 1.;
|
||||||
}
|
}
|
||||||
|
|
||||||
// JENSEN-SHANNON CALCULATION
|
// JENSEN-SHANNON CALCULATION
|
||||||
sd1 = 0.5*oldspec[i] + 0.5*newspec[i];
|
sd1 = 0.5*oldspec[i] + 0.5*newspec[i];
|
||||||
SD = SD + (-sd1*log(sd1)) + (0.5*(oldspec[i]*log(oldspec[i]))) + (0.5*(newspec[i]*log(newspec[i])));
|
SD = SD + (-sd1*log(sd1)) + (0.5*(oldspec[i]*log(oldspec[i]))) + (0.5*(newspec[i]*log(newspec[i])));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SD;
|
return SD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ TempoTrackV2::filter_df(d_vec_t &df)
|
||||||
b[0] = 0.2066;
|
b[0] = 0.2066;
|
||||||
b[1] = 0.4131;
|
b[1] = 0.4131;
|
||||||
b[2] = 0.2066;
|
b[2] = 0.2066;
|
||||||
|
|
||||||
double inp1 = 0.;
|
double inp1 = 0.;
|
||||||
double inp2 = 0.;
|
double inp2 = 0.;
|
||||||
double out1 = 0.;
|
double out1 = 0.;
|
||||||
|
|
@ -67,7 +67,7 @@ TempoTrackV2::filter_df(d_vec_t &df)
|
||||||
|
|
||||||
for (unsigned int i = 0;i < df.size();i++)
|
for (unsigned int i = 0;i < df.size();i++)
|
||||||
{
|
{
|
||||||
lp_df[i] = 0.;
|
lp_df[i] = 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
inp1 = 0.; inp2 = 0.;
|
inp1 = 0.; inp2 = 0.;
|
||||||
|
|
@ -130,9 +130,9 @@ TempoTrackV2::calculateBeatPeriod(const vector<double> &df,
|
||||||
dfframe[k] = df[i+k];
|
dfframe[k] = df[i+k];
|
||||||
}
|
}
|
||||||
// get rcf vector for current frame
|
// get rcf vector for current frame
|
||||||
d_vec_t rcf(wv_len);
|
d_vec_t rcf(wv_len);
|
||||||
get_rcf(dfframe,wv,rcf);
|
get_rcf(dfframe,wv,rcf);
|
||||||
|
|
||||||
rcfmat.push_back( d_vec_t() ); // adds a new column
|
rcfmat.push_back( d_vec_t() ); // adds a new column
|
||||||
col_counter++;
|
col_counter++;
|
||||||
for (unsigned int j=0; j<rcf.size(); j++)
|
for (unsigned int j=0; j<rcf.size(); j++)
|
||||||
|
|
@ -140,7 +140,7 @@ TempoTrackV2::calculateBeatPeriod(const vector<double> &df,
|
||||||
rcfmat[col_counter].push_back( rcf[j] );
|
rcfmat[col_counter].push_back( rcf[j] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now call viterbi decoding function
|
// now call viterbi decoding function
|
||||||
viterbi_decode(rcfmat,wv,beat_period,tempi);
|
viterbi_decode(rcfmat,wv,beat_period,tempi);
|
||||||
}
|
}
|
||||||
|
|
@ -161,7 +161,7 @@ TempoTrackV2::get_rcf(const d_vec_t &dfframe_in, const d_vec_t &wv, d_vec_t &rcf
|
||||||
|
|
||||||
d_vec_t acf(dfframe.size());
|
d_vec_t acf(dfframe.size());
|
||||||
|
|
||||||
|
|
||||||
for (unsigned int lag=0; lag<dfframe.size(); lag++)
|
for (unsigned int lag=0; lag<dfframe.size(); lag++)
|
||||||
{
|
{
|
||||||
double sum = 0.;
|
double sum = 0.;
|
||||||
|
|
@ -169,7 +169,7 @@ TempoTrackV2::get_rcf(const d_vec_t &dfframe_in, const d_vec_t &wv, d_vec_t &rcf
|
||||||
|
|
||||||
for (unsigned int n=0; n<(dfframe.size()-lag); n++)
|
for (unsigned int n=0; n<(dfframe.size()-lag); n++)
|
||||||
{
|
{
|
||||||
tmp = dfframe[n] * dfframe[n+lag];
|
tmp = dfframe[n] * dfframe[n+lag];
|
||||||
sum += tmp;
|
sum += tmp;
|
||||||
}
|
}
|
||||||
acf[lag] = static_cast<double> (sum/ (dfframe.size()-lag));
|
acf[lag] = static_cast<double> (sum/ (dfframe.size()-lag));
|
||||||
|
|
@ -188,10 +188,10 @@ TempoTrackV2::get_rcf(const d_vec_t &dfframe_in, const d_vec_t &wv, d_vec_t &rcf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply adaptive threshold to rcf
|
// apply adaptive threshold to rcf
|
||||||
MathUtilities::adaptiveThreshold(rcf);
|
MathUtilities::adaptiveThreshold(rcf);
|
||||||
|
|
||||||
double rcfsum =0.;
|
double rcfsum =0.;
|
||||||
for (unsigned int i=0; i<rcf.size(); i++)
|
for (unsigned int i=0; i<rcf.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -222,7 +222,7 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
|
||||||
tmat[i].push_back(0.); // fill with zeros initially
|
tmat[i].push_back(0.); // fill with zeros initially
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// variance of Gaussians in transition matrix
|
// variance of Gaussians in transition matrix
|
||||||
// formed of Gaussians on diagonal - implies slow tempo change
|
// formed of Gaussians on diagonal - implies slow tempo change
|
||||||
double sigma = 8.;
|
double sigma = 8.;
|
||||||
|
|
@ -265,16 +265,16 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
|
||||||
delta[0][j] = wv[j] * rcfmat[0][j];
|
delta[0][j] = wv[j] * rcfmat[0][j];
|
||||||
psi[0][j] = 0;
|
psi[0][j] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double deltasum = 0.;
|
double deltasum = 0.;
|
||||||
for (unsigned int i=0; i<Q; i++)
|
for (unsigned int i=0; i<Q; i++)
|
||||||
{
|
{
|
||||||
deltasum += delta[0][i];
|
deltasum += delta[0][i];
|
||||||
}
|
}
|
||||||
for (unsigned int i=0; i<Q; i++)
|
for (unsigned int i=0; i<Q; i++)
|
||||||
{
|
{
|
||||||
delta[0][i] /= (deltasum + EPS);
|
delta[0][i] /= (deltasum + EPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (unsigned int t=1; t<T; t++)
|
for (unsigned int t=1; t<T; t++)
|
||||||
|
|
@ -286,12 +286,12 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
|
||||||
for (unsigned int i=0; i<Q; i++)
|
for (unsigned int i=0; i<Q; i++)
|
||||||
{
|
{
|
||||||
tmp_vec[i] = delta[t-1][i] * tmat[j][i];
|
tmp_vec[i] = delta[t-1][i] * tmat[j][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
delta[t][j] = get_max_val(tmp_vec);
|
delta[t][j] = get_max_val(tmp_vec);
|
||||||
|
|
||||||
psi[t][j] = get_max_ind(tmp_vec);
|
psi[t][j] = get_max_ind(tmp_vec);
|
||||||
|
|
||||||
delta[t][j] *= rcfmat[t][j];
|
delta[t][j] *= rcfmat[t][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -300,23 +300,23 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
|
||||||
for (unsigned int i=0; i<Q; i++)
|
for (unsigned int i=0; i<Q; i++)
|
||||||
{
|
{
|
||||||
deltasum += delta[t][i];
|
deltasum += delta[t][i];
|
||||||
}
|
}
|
||||||
for (unsigned int i=0; i<Q; i++)
|
for (unsigned int i=0; i<Q; i++)
|
||||||
{
|
{
|
||||||
delta[t][i] /= (deltasum + EPS);
|
delta[t][i] /= (deltasum + EPS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i_vec_t bestpath(T);
|
i_vec_t bestpath(T);
|
||||||
d_vec_t tmp_vec(Q);
|
d_vec_t tmp_vec(Q);
|
||||||
for (unsigned int i=0; i<Q; i++)
|
for (unsigned int i=0; i<Q; i++)
|
||||||
{
|
{
|
||||||
tmp_vec[i] = delta[T-1][i];
|
tmp_vec[i] = delta[T-1][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// find starting point - best beat period for "last" frame
|
// find starting point - best beat period for "last" frame
|
||||||
bestpath[T-1] = get_max_ind(tmp_vec);
|
bestpath[T-1] = get_max_ind(tmp_vec);
|
||||||
|
|
||||||
// backtrace through index of maximum values in psi
|
// backtrace through index of maximum values in psi
|
||||||
for (unsigned int t=T-2; t>0 ;t--)
|
for (unsigned int t=T-2; t>0 ;t--)
|
||||||
{
|
{
|
||||||
|
|
@ -328,7 +328,7 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
|
||||||
|
|
||||||
unsigned int lastind = 0;
|
unsigned int lastind = 0;
|
||||||
for (unsigned int i=0; i<T; i++)
|
for (unsigned int i=0; i<T; i++)
|
||||||
{
|
{
|
||||||
unsigned int step = 128;
|
unsigned int step = 128;
|
||||||
for (unsigned int j=0; j<step; j++)
|
for (unsigned int j=0; j<step; j++)
|
||||||
{
|
{
|
||||||
|
|
@ -361,7 +361,7 @@ TempoTrackV2::get_max_val(const d_vec_t &df)
|
||||||
maxval = df[i];
|
maxval = df[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return maxval;
|
return maxval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -378,7 +378,7 @@ TempoTrackV2::get_max_ind(const d_vec_t &df)
|
||||||
ind = i;
|
ind = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ind;
|
return ind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -390,7 +390,7 @@ TempoTrackV2::normalise_vec(d_vec_t &df)
|
||||||
{
|
{
|
||||||
sum += df[i];
|
sum += df[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i=0; i<df.size(); i++)
|
for (unsigned int i=0; i<df.size(); i++)
|
||||||
{
|
{
|
||||||
df[i]/= (sum + EPS);
|
df[i]/= (sum + EPS);
|
||||||
|
|
@ -436,7 +436,7 @@ TempoTrackV2::calculateBeats(const vector<double> &df,
|
||||||
// ELSE LEAVE AT DEFAULT VALUE FROM INITIALISATION: D_VEC_T SCORECANDS (TXWT.SIZE());
|
// ELSE LEAVE AT DEFAULT VALUE FROM INITIALISATION: D_VEC_T SCORECANDS (TXWT.SIZE());
|
||||||
|
|
||||||
int cscore_ind = i+prange_min+j;
|
int cscore_ind = i+prange_min+j;
|
||||||
if (cscore_ind >= 0)
|
if (cscore_ind >= 0)
|
||||||
{
|
{
|
||||||
scorecands[j] = txwt[j] * cumscore[cscore_ind];
|
scorecands[j] = txwt[j] * cumscore[cscore_ind];
|
||||||
}
|
}
|
||||||
|
|
@ -457,7 +457,7 @@ TempoTrackV2::calculateBeats(const vector<double> &df,
|
||||||
for (unsigned int i=cumscore.size() - beat_period[beat_period.size()-1] ; i<cumscore.size(); i++)
|
for (unsigned int i=cumscore.size() - beat_period[beat_period.size()-1] ; i<cumscore.size(); i++)
|
||||||
{
|
{
|
||||||
tmp_vec.push_back(cumscore[i]);
|
tmp_vec.push_back(cumscore[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int startpoint = get_max_ind(tmp_vec) + cumscore.size() - beat_period[beat_period.size()-1] ;
|
int startpoint = get_max_ind(tmp_vec) + cumscore.size() - beat_period[beat_period.size()-1] ;
|
||||||
|
|
||||||
|
|
@ -476,10 +476,10 @@ TempoTrackV2::calculateBeats(const vector<double> &df,
|
||||||
if (backlink[b] == b) break; // shouldn't happen... haha
|
if (backlink[b] == b) break; // shouldn't happen... haha
|
||||||
ibeats.push_back(backlink[b]);
|
ibeats.push_back(backlink[b]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// REVERSE SEQUENCE OF IBEATS AND STORE AS BEATS
|
// REVERSE SEQUENCE OF IBEATS AND STORE AS BEATS
|
||||||
for (unsigned int i=0; i<ibeats.size(); i++)
|
for (unsigned int i=0; i<ibeats.size(); i++)
|
||||||
{
|
{
|
||||||
beats.push_back( static_cast<double>(ibeats[ibeats.size()-i-1]) );
|
beats.push_back( static_cast<double>(ibeats[ibeats.size()-i-1]) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ TCSGram::~TCSGram()
|
||||||
|
|
||||||
void TCSGram::getTCSVector(int iPosition, TCSVector& rTCSVector) const
|
void TCSGram::getTCSVector(int iPosition, TCSVector& rTCSVector) const
|
||||||
{
|
{
|
||||||
if (iPosition < 0)
|
if (iPosition < 0)
|
||||||
rTCSVector = TCSVector();
|
rTCSVector = TCSVector();
|
||||||
else if (iPosition >= m_VectorList.size())
|
else if (iPosition >= m_VectorList.size())
|
||||||
rTCSVector = TCSVector();
|
rTCSVector = TCSVector();
|
||||||
|
|
@ -52,7 +52,7 @@ void TCSGram::addTCSVector(const TCSVector& rTCSVector)
|
||||||
{
|
{
|
||||||
size_t uSize = m_VectorList.size();
|
size_t uSize = m_VectorList.size();
|
||||||
long lMilliSeconds = static_cast<long>(uSize*m_dFrameDurationMS);
|
long lMilliSeconds = static_cast<long>(uSize*m_dFrameDurationMS);
|
||||||
std::pair<long, TCSVector> p;
|
std::pair<long, TCSVector> p;
|
||||||
p.first = lMilliSeconds;
|
p.first = lMilliSeconds;
|
||||||
p.second = rTCSVector;
|
p.second = rTCSVector;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ Wavelet::createDecompositionFilters(Type wavelet,
|
||||||
|
|
||||||
switch (wavelet) {
|
switch (wavelet) {
|
||||||
|
|
||||||
case Haar:
|
case Haar:
|
||||||
lpd.push_back(0.70710678118655);
|
lpd.push_back(0.70710678118655);
|
||||||
lpd.push_back(0.70710678118655);
|
lpd.push_back(0.70710678118655);
|
||||||
hpd.push_back(-0.70710678118655);
|
hpd.push_back(-0.70710678118655);
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ void Correlation::doAutoUnBiased(double *src, double *dst, unsigned int length)
|
||||||
{
|
{
|
||||||
for( j = i; j < length; j++)
|
for( j = i; j < length; j++)
|
||||||
{
|
{
|
||||||
tmp += src[ j-i ] * src[ j ];
|
tmp += src[ j-i ] * src[ j ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ double KLDivergence::distanceDistribution(const vector<double> &d1,
|
||||||
|
|
||||||
double d = 0;
|
double d = 0;
|
||||||
double small = 1e-20;
|
double small = 1e-20;
|
||||||
|
|
||||||
for (int i = 0; i < sz; ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
d += d1[i] * log10((d1[i] + small) / (d2[i] + small));
|
d += d1[i] * log10((d1[i] + small) / (d2[i] + small));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ double MathUtilities::getAlphaNorm( const std::vector <double> &data, unsigned i
|
||||||
double MathUtilities::round(double x)
|
double MathUtilities::round(double x)
|
||||||
{
|
{
|
||||||
double val = (double)floor(x + 0.5);
|
double val = (double)floor(x + 0.5);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ double MathUtilities::median(const double *src, unsigned int len)
|
||||||
double tmp = 0.0;
|
double tmp = 0.0;
|
||||||
double tempMedian;
|
double tempMedian;
|
||||||
double medianVal;
|
double medianVal;
|
||||||
|
|
||||||
double* scratch = new double[ len ];//Vector < double > sortedX = Vector < double > ( size );
|
double* scratch = new double[ len ];//Vector < double > sortedX = Vector < double > ( size );
|
||||||
|
|
||||||
for ( i = 0; i < len; i++ )
|
for ( i = 0; i < len; i++ )
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,9 @@ Thread::start()
|
||||||
#endif
|
#endif
|
||||||
m_extant = true;
|
m_extant = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Thread::wait()
|
Thread::wait()
|
||||||
{
|
{
|
||||||
if (m_extant) {
|
if (m_extant) {
|
||||||
|
|
@ -233,7 +233,7 @@ Condition::unlock()
|
||||||
ReleaseMutex(m_mutex);
|
ReleaseMutex(m_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Condition::wait(int us)
|
Condition::wait(int us)
|
||||||
{
|
{
|
||||||
if (us == 0) {
|
if (us == 0) {
|
||||||
|
|
@ -248,7 +248,7 @@ Condition::wait(int us)
|
||||||
|
|
||||||
DWORD ms = us / 1000;
|
DWORD ms = us / 1000;
|
||||||
if (us > 0 && ms == 0) ms = 1;
|
if (us > 0 && ms == 0) ms = 1;
|
||||||
|
|
||||||
#ifdef DEBUG_CONDITION
|
#ifdef DEBUG_CONDITION
|
||||||
cerr << "CONDITION DEBUG: " << (void *)GetCurrentThreadId() << ": Timed waiting on " << &m_condition << " \"" << m_name << "\"" << endl;
|
cerr << "CONDITION DEBUG: " << (void *)GetCurrentThreadId() << ": Timed waiting on " << &m_condition << " \"" << m_name << "\"" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -310,9 +310,9 @@ Thread::start()
|
||||||
#endif
|
#endif
|
||||||
m_extant = true;
|
m_extant = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Thread::wait()
|
Thread::wait()
|
||||||
{
|
{
|
||||||
if (m_extant) {
|
if (m_extant) {
|
||||||
|
|
@ -490,7 +490,7 @@ Condition::unlock()
|
||||||
pthread_mutex_unlock(&m_mutex);
|
pthread_mutex_unlock(&m_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Condition::wait(int us)
|
Condition::wait(int us)
|
||||||
{
|
{
|
||||||
if (us == 0) {
|
if (us == 0) {
|
||||||
|
|
@ -514,7 +514,7 @@ Condition::wait(int us)
|
||||||
struct timespec timeout;
|
struct timespec timeout;
|
||||||
timeout.tv_sec = now.tv_sec;
|
timeout.tv_sec = now.tv_sec;
|
||||||
timeout.tv_nsec = now.tv_usec * 1000;
|
timeout.tv_nsec = now.tv_usec * 1000;
|
||||||
|
|
||||||
#ifdef DEBUG_CONDITION
|
#ifdef DEBUG_CONDITION
|
||||||
cerr << "CONDITION DEBUG: " << (void *)pthread_self() << ": Timed waiting on " << &m_condition << " \"" << m_name << "\"" << endl;
|
cerr << "CONDITION DEBUG: " << (void *)pthread_self() << ": Timed waiting on " << &m_condition << " \"" << m_name << "\"" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -551,9 +551,9 @@ void
|
||||||
Thread::start()
|
Thread::start()
|
||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Thread::wait()
|
Thread::wait()
|
||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
|
|
@ -611,7 +611,7 @@ Condition::lock()
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Condition::wait(int us)
|
Condition::wait(int us)
|
||||||
{
|
{
|
||||||
abort();
|
abort();
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
Centre for Digital Music, Queen Mary, University of London.
|
Centre for Digital Music, Queen Mary, University of London.
|
||||||
This file copyright 2006 Dan Stowell.
|
This file copyright 2006 Dan Stowell.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
files (the "Software"), to deal in the Software without
|
files (the "Software"), to deal in the Software without
|
||||||
|
|
@ -109,7 +109,7 @@ AmplitudeFollower::initialise(size_t channels, size_t stepSize, size_t blockSize
|
||||||
|
|
||||||
m_stepSize = std::min(stepSize, blockSize);
|
m_stepSize = std::min(stepSize, blockSize);
|
||||||
|
|
||||||
// Translate the coefficients
|
// Translate the coefficients
|
||||||
// from their "convenient" 60dB convergence-time values
|
// from their "convenient" 60dB convergence-time values
|
||||||
// to real coefficients
|
// to real coefficients
|
||||||
m_clampcoef = m_clampcoef==0.0 ? 0.0 : exp(log(0.1)/(m_clampcoef * m_inputSampleRate));
|
m_clampcoef = m_clampcoef==0.0 ? 0.0 : exp(log(0.1)/(m_clampcoef * m_inputSampleRate));
|
||||||
|
|
@ -158,9 +158,9 @@ AmplitudeFollower::getParameterDescriptors() const
|
||||||
att.maxValue = 1.f;
|
att.maxValue = 1.f;
|
||||||
att.defaultValue = 0.01f;
|
att.defaultValue = 0.01f;
|
||||||
att.isQuantized = false;
|
att.isQuantized = false;
|
||||||
|
|
||||||
list.push_back(att);
|
list.push_back(att);
|
||||||
|
|
||||||
ParameterDescriptor dec;
|
ParameterDescriptor dec;
|
||||||
dec.identifier = "release";
|
dec.identifier = "release";
|
||||||
dec.name = "Release time";
|
dec.name = "Release time";
|
||||||
|
|
@ -170,9 +170,9 @@ AmplitudeFollower::getParameterDescriptors() const
|
||||||
dec.maxValue = 1.f;
|
dec.maxValue = 1.f;
|
||||||
dec.defaultValue = 0.01f;
|
dec.defaultValue = 0.01f;
|
||||||
dec.isQuantized = false;
|
dec.isQuantized = false;
|
||||||
|
|
||||||
list.push_back(dec);
|
list.push_back(dec);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
Centre for Digital Music, Queen Mary, University of London.
|
Centre for Digital Music, Queen Mary, University of London.
|
||||||
This file copyright 2006 Chris Cannam.
|
This file copyright 2006 Chris Cannam.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
modify it under the terms of the GNU General Public License as
|
||||||
published by the Free Software Foundation; either version 2 of the
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
|
@ -136,7 +136,7 @@ Onset::initialise(size_t channels, size_t stepSize, size_t blockSize)
|
||||||
m_peakpick = new_aubio_peakpicker(m_threshold);
|
m_peakpick = new_aubio_peakpicker(m_threshold);
|
||||||
|
|
||||||
m_onsetdet = new_aubio_onsetdetection(m_onsettype, blockSize, channels);
|
m_onsetdet = new_aubio_onsetdetection(m_onsettype, blockSize, channels);
|
||||||
|
|
||||||
m_delay = Vamp::RealTime::frame2RealTime(4 * stepSize,
|
m_delay = Vamp::RealTime::frame2RealTime(4 * stepSize,
|
||||||
lrintf(m_inputSampleRate));
|
lrintf(m_inputSampleRate));
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ Onset::reset()
|
||||||
m_blockSize,
|
m_blockSize,
|
||||||
m_stepSize,
|
m_stepSize,
|
||||||
lrintf(m_inputSampleRate));
|
lrintf(m_inputSampleRate));
|
||||||
|
|
||||||
aubio_onset_set_threshold(m_onsetdet, m_threshold);
|
aubio_onset_set_threshold(m_onsetdet, m_threshold);
|
||||||
aubio_onset_set_silence(m_onsetdet, m_silence);
|
aubio_onset_set_silence(m_onsetdet, m_silence);
|
||||||
aubio_onset_set_minioi(m_onsetdet, m_minioi);
|
aubio_onset_set_minioi(m_onsetdet, m_minioi);
|
||||||
|
|
@ -185,7 +185,7 @@ Onset::ParameterList
|
||||||
Onset::getParameterDescriptors() const
|
Onset::getParameterDescriptors() const
|
||||||
{
|
{
|
||||||
ParameterList list;
|
ParameterList list;
|
||||||
|
|
||||||
ParameterDescriptor desc;
|
ParameterDescriptor desc;
|
||||||
desc.identifier = "onsettype";
|
desc.identifier = "onsettype";
|
||||||
desc.name = "Onset Detection Function Type";
|
desc.name = "Onset Detection Function Type";
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public:
|
||||||
vector<double> dfOutput;
|
vector<double> dfOutput;
|
||||||
Vamp::RealTime origin;
|
Vamp::RealTime origin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
OnsetDetector::OnsetDetector(float inputSampleRate) :
|
OnsetDetector::OnsetDetector(float inputSampleRate) :
|
||||||
Vamp::Plugin(inputSampleRate),
|
Vamp::Plugin(inputSampleRate),
|
||||||
|
|
@ -162,7 +162,7 @@ OnsetDetector::getParameter(std::string name) const
|
||||||
} else if (name == "sensitivity") {
|
} else if (name == "sensitivity") {
|
||||||
return m_sensitivity;
|
return m_sensitivity;
|
||||||
} else if (name == "whiten") {
|
} else if (name == "whiten") {
|
||||||
return m_whiten ? 1.0 : 0.0;
|
return m_whiten ? 1.0 : 0.0;
|
||||||
}
|
}
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +265,7 @@ OnsetDetector::initialise(size_t channels, size_t stepSize, size_t blockSize)
|
||||||
dfConfig.adaptiveWhitening = m_whiten;
|
dfConfig.adaptiveWhitening = m_whiten;
|
||||||
dfConfig.whiteningRelaxCoeff = -1;
|
dfConfig.whiteningRelaxCoeff = -1;
|
||||||
dfConfig.whiteningFloor = -1;
|
dfConfig.whiteningFloor = -1;
|
||||||
|
|
||||||
m_d = new OnsetDetectorData(dfConfig);
|
m_d = new OnsetDetectorData(dfConfig);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -480,7 +480,7 @@ OnsetDetector::getRemainingFeatures()
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ppParams.length; ++i) {
|
for (unsigned int i = 0; i < ppParams.length; ++i) {
|
||||||
|
|
||||||
Feature feature;
|
Feature feature;
|
||||||
// feature.hasTimestamp = false;
|
// feature.hasTimestamp = false;
|
||||||
feature.hasTimestamp = true;
|
feature.hasTimestamp = true;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
Centre for Digital Music, Queen Mary, University of London.
|
Centre for Digital Music, Queen Mary, University of London.
|
||||||
Copyright 2006 Chris Cannam.
|
Copyright 2006 Chris Cannam.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
files (the "Software"), to deal in the Software without
|
files (the "Software"), to deal in the Software without
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
Centre for Digital Music, Queen Mary, University of London.
|
Centre for Digital Music, Queen Mary, University of London.
|
||||||
Copyright 2006 Chris Cannam.
|
Copyright 2006 Chris Cannam.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
files (the "Software"), to deal in the Software without
|
files (the "Software"), to deal in the Software without
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
Centre for Digital Music, Queen Mary, University of London.
|
Centre for Digital Music, Queen Mary, University of London.
|
||||||
Copyright 2006 Chris Cannam.
|
Copyright 2006 Chris Cannam.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
files (the "Software"), to deal in the Software without
|
files (the "Software"), to deal in the Software without
|
||||||
|
|
@ -165,7 +165,7 @@ ZeroCrossing::process(const float *const *inputBuffers,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crossing) {
|
if (crossing) {
|
||||||
++count;
|
++count;
|
||||||
Feature feature;
|
Feature feature;
|
||||||
feature.hasTimestamp = true;
|
feature.hasTimestamp = true;
|
||||||
feature.timestamp = timestamp +
|
feature.timestamp = timestamp +
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
Centre for Digital Music, Queen Mary, University of London.
|
Centre for Digital Music, Queen Mary, University of London.
|
||||||
Copyright 2006 Chris Cannam.
|
Copyright 2006 Chris Cannam.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
files (the "Software"), to deal in the Software without
|
files (the "Software"), to deal in the Software without
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* program: sanityCheck
|
* program: sanityCheck
|
||||||
* file: main.c
|
* file: main.c
|
||||||
* author: Todd Naugle
|
* author: Todd Naugle
|
||||||
* date: 11/17/2010
|
* date: 11/17/2010
|
||||||
*
|
*
|
||||||
* Desc: Command line version of the sanity check functions found in jack
|
* Desc: Command line version of the sanity check functions found in jack
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -262,7 +262,7 @@ ParseSwitches(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OK) {
|
if (OK) {
|
||||||
// All switches are at least valid, now check to make sure they are all valid to
|
// All switches are at least valid, now check to make sure they are all valid to
|
||||||
// be used together.
|
// be used together.
|
||||||
|
|
||||||
if (gSwitchesReceived.size() > 1) {
|
if (gSwitchesReceived.size() > 1) {
|
||||||
|
|
@ -291,7 +291,7 @@ ParseSwitches(
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
fprintf(stderr, "ERROR - Invalid Option: %s\n", (const char *) argv[--i]);
|
fprintf(stderr, "ERROR - Invalid Option: %s\n", (const char *) argv[--i]);
|
||||||
fprintf(stderr, "Check syntax\n");
|
fprintf(stderr, "Check syntax\n");
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*
|
*
|
||||||
* Set of functions to gather system information for the jack setup wizard.
|
* Set of functions to gather system information for the jack setup wizard.
|
||||||
*
|
*
|
||||||
* TODO: Test for rt prio availability
|
* TODO: Test for rt prio availability
|
||||||
*
|
*
|
||||||
* @author Florian Faber, faber@faberman.de
|
* @author Florian Faber, faber@faberman.de
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
#include "systemtest.h"
|
#include "systemtest.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function checks for the existence of known frequency scaling mechanisms
|
* This function checks for the existence of known frequency scaling mechanisms
|
||||||
* in this system by testing for the availability of scaling governors/
|
* in this system by testing for the availability of scaling governors/
|
||||||
*
|
*
|
||||||
* @returns 0 if the system has no frequency scaling capabilities non-0 otherwise.
|
* @returns 0 if the system has no frequency scaling capabilities non-0 otherwise.
|
||||||
|
|
@ -73,13 +73,13 @@ static int read_string(char* filename, char* buf, size_t buflen) {
|
||||||
if (-1<fd) {
|
if (-1<fd) {
|
||||||
r = read (fd, buf, buflen-1);
|
r = read (fd, buf, buflen-1);
|
||||||
(void) close(fd);
|
(void) close(fd);
|
||||||
|
|
||||||
if (-1==r) {
|
if (-1==r) {
|
||||||
fprintf(stderr, "Error while reading \"%s\": %s\n", filename, strerror(errno));
|
fprintf(stderr, "Error while reading \"%s\": %s\n", filename, strerror(errno));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) r;
|
return (int) r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,7 +96,7 @@ static int read_int(char* filename, int* value) {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function determines wether any CPU core uses a variable clock speed if frequency
|
* This function determines wether any CPU core uses a variable clock speed if frequency
|
||||||
* scaling is available. If the governor for all cores is either "powersave" or
|
* scaling is available. If the governor for all cores is either "powersave" or
|
||||||
* "performance", the CPU frequency can be assumed to be static. This is also the case
|
* "performance", the CPU frequency can be assumed to be static. This is also the case
|
||||||
* if scaling_min_freq and scaling_max_freq are set to the same value.
|
* if scaling_min_freq and scaling_max_freq are set to the same value.
|
||||||
|
|
@ -110,7 +110,7 @@ int system_uses_frequencyscaling() {
|
||||||
while (!done) {
|
while (!done) {
|
||||||
(void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", cpu);
|
(void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor", cpu);
|
||||||
if (0<read_string(filename, buf, 256)) {
|
if (0<read_string(filename, buf, 256)) {
|
||||||
if ((0!=strncmp("performance", buf, 11)) &&
|
if ((0!=strncmp("performance", buf, 11)) &&
|
||||||
(0!=strncmp("powersafe", buf, 9))) {
|
(0!=strncmp("powersafe", buf, 9))) {
|
||||||
// So it's neither the "performance" nor the "powersafe" governor
|
// So it's neither the "performance" nor the "powersafe" governor
|
||||||
(void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq", cpu);
|
(void) snprintf(filename, 256, "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_min_freq", cpu);
|
||||||
|
|
@ -121,7 +121,7 @@ int system_uses_frequencyscaling() {
|
||||||
// wrong governor AND different frequency limits -> scaling
|
// wrong governor AND different frequency limits -> scaling
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -130,7 +130,7 @@ int system_uses_frequencyscaling() {
|
||||||
}
|
}
|
||||||
cpu++;
|
cpu++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// couldn't find anything that points to scaling
|
// couldn't find anything that points to scaling
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -172,18 +172,18 @@ int system_user_in_group(const char *name) {
|
||||||
free(list);
|
free(list);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_groups = getgroups(MAX_GROUPS, list);
|
num_groups = getgroups(MAX_GROUPS, list);
|
||||||
|
|
||||||
while (i<num_groups) {
|
while (i<num_groups) {
|
||||||
if (list[i]==gid) {
|
if (list[i]==gid) {
|
||||||
found = 1;
|
found = 1;
|
||||||
i = num_groups;
|
i = num_groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(list);
|
free(list);
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
|
|
@ -254,7 +254,7 @@ int system_user_can_rtprio() {
|
||||||
perror("sched_get_priority");
|
perror("sched_get_priority");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
schparam.sched_priority = min_prio;
|
schparam.sched_priority = min_prio;
|
||||||
|
|
||||||
if (0 == sched_setscheduler(0, SCHED_FIFO, &schparam)) {
|
if (0 == sched_setscheduler(0, SCHED_FIFO, &schparam)) {
|
||||||
// TODO: restore previous state
|
// TODO: restore previous state
|
||||||
|
|
@ -264,7 +264,7 @@ int system_user_can_rtprio() {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -300,7 +300,7 @@ long long unsigned int system_available_physical_mem() {
|
||||||
if (strncmp (buf, "MemTotal:", 9) == 0) {
|
if (strncmp (buf, "MemTotal:", 9) == 0) {
|
||||||
if (sscanf (buf, "%*s %llu", &res) != 1) {
|
if (sscanf (buf, "%*s %llu", &res) != 1) {
|
||||||
perror ("parse error in /proc/meminfo");
|
perror ("parse error in /proc/meminfo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
perror("read from /proc/meminfo");
|
perror("read from /proc/meminfo");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue