<commit_before>/* 
 * TTBlue Audio Object Base Class
 * Copyright © 2008, <NAME>
 * 
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#include "TTDSP.h"
#include "TTAudioObject.h"
#include "TTEnvironment.h"
#include "TTUnitTest.h"


// This coeff is used in GainDataspace mapping MIDI to and from linear gain 
// so that MIDI=100 equals 0 dB and MIDI = 127 equals +10 dB
//static const double kGainMidiPower = log(pow(10.,10./20.))/log(127./100.);
//static const double kGainMidiPowerInv = 1./kGainMidiPower;


/****************************************************************************************************/

TTAudioObject::TTAudioObject(TTValue& arguments) : 
	TTObject(arguments), 
	maxNumChannels(0),
	attrMute(0), 
	inputArray(NULL),
	outputArray(NULL),
	startProcessingTime(0.0),
	accumulatedProcessingTime(0.0),
	accumulatedProcessingCalls(0.0)
{
	// Convention: 'Public' attribute names begin with a capital letter, 'Private' attribute names begin with a lower case letter
	registerAttribute(TT("maxNumChannels"), kTypeUInt8,		&maxNumChannels,	(TTSetterMethod)&TTAudioObject::setMaxNumChannels);
	registerAttribute(kTTSym_sampleRate,	kTypeUInt32,	&sr,				(TTSetterMethod)&TTAudioObject::setSr);
	registerAttribute(TT("bypass"),			kTypeBoolean,	&attrBypass,		(TTSetterMethod)&TTAudioObject::setBypass);
	registerAttribute(TT("mute"),			kTypeBoolean,	&attrMute,			(TTSetterMethod)&TTAudioObject::setMute);
	
	registerMessage(TT("calculate"), (TTMethod)&TTAudioObject::calculateMessage);
	registerMessage(TT("test"), TTMethod(&TTObject::test));
	registerMessage(TT("resetBenchmarking"), (TTMethod)&TTAudioObject::resetBenchmarking, kTTMessagePassNone);
	registerMessage(TT("getProcessingBenchmark"), (TTMethod)&TTAudioObject::getProcessingBenchmark);
	
	TTObjectInstantiate(kTTSym_audiosignalarray, (TTObjectPtr*)&inputArray, 2);
	TTObjectInstantiate(kTTSym_audiosignalarray, (TTObjectPtr*)&outputArray, 2);

	// Set Defaults...
		
	setAttributeValue(kTTSym_sampleRate,	(uint)ttEnvironment->mSampleRate);
	setProcess(&TTAudioObject::bypassProcess);
    setCalculate(&TTAudioObject::defaultCalculateMethod);
	setAttributeValue(TT("bypass"),			kTTBoolNo);
	setAttributeValue(TT("processInPlace"), kTTBoolNo);	
}


TTAudioObject::~TTAudioObject()
{
	TTObjectRelease((TTObjectPtr*)&inputArray);
	TTObjectRelease((TTObjectPtr*)&outputArray);
}


TTErr TTAudioObject::setMaxNumChannels(const TTValue& newValue)
{
	if (TTUInt16(newValue) != maxNumChannels) {
		TTValue	oldMaxNumChannels = maxNumChannels;
		
		maxNumChannels = newValue;
		sendMessage(TT("updateMaxNumChannels"), oldMaxNumChannels, kTTValNONE);
	}
	return kTTErrNone;
}


TTErr TTAudioObject::setSr(const TTValue& newValue)
{
	TTValue oldSampleRate(sr);<commit_msg>removing unused Attribute from initialization<commit_after>/* 
 * TTBlue Audio Object Base Class
 * Copyright © 2008, <NAME>
 * 
 * License: This code is licensed under the terms of the "New BSD License"
 * http://creativecommons.org/licenses/BSD/
 */

#include "TTDSP.h"
#include "TTAudioObject.h"
#include "TTEnvironment.h"
#include "TTUnitTest.h"


// This coeff is used in GainDataspace mapping MIDI to and from linear gain 
// so that MIDI=100 equals 0 dB and MIDI = 127 equals +10 dB
//static const double kGainMidiPower = log(pow(10.,10./20.))/log(127./100.);
//static const double kGainMidiPowerInv = 1./kGainMidiPower;


/****************************************************************************************************/

TTAudioObject::TTAudioObject(TTValue& arguments) : 
	TTObject(arguments), 
	maxNumChannels(0),
	attrMute(0), 
	inputArray(NULL),
	outputArray(NULL),
	startProcessingTime(0.0),
	accumulatedProcessingTime(0.0),
	accumulatedProcessingCalls(0.0)
{
	// Convention: 'Public' attribute names begin with a capital letter, 'Private' attribute names begin with a lower case letter
	registerAttribute(TT("maxNumChannels"), kTypeUInt8,		&maxNumChannels,	(TTSetterMethod)&TTAudioObject::setMaxNumChannels);
	registerAttribute(kTTSym_sampleRate,	kTypeUInt32,	&sr,				(TTSetterMethod)&TTAudioObject::setSr);
	registerAttribute(TT("bypass"),			kTypeBoolean,	&attrBypass,		(TTSetterMethod)&TTAudioObject::setBypass);
	registerAttribute(TT("mute"),			kTypeBoolean,	&attrMute,			(TTSetterMethod)&TTAudioObject::setMute);
	
	registerMessage(TT("calculate"), (TTMethod)&TTAudioObject::calculateMessage);
	registerMessage(TT("test"), TTMethod(&TTObject::test));
	registerMessage(TT("resetBenchmarking"), (TTMethod)&TTAudioObject::resetBenchmarking, kTTMessagePassNone);
	registerMessage(TT("getProcessingBenchmark"), (TTMethod)&TTAudioObject::getProcessingBenchmark);
	
	TTObjectInstantiate(kTTSym_audiosignalarray, (TTObjectPtr*)&inputArray, 2);
	TTObjectInstantiate(kTTSym_audiosignalarray, (TTObjectPtr*)&outputArray, 2);

	// Set Defaults...
		
	setAttributeValue(kTTSym_sampleRate,	(uint)ttEnvironment->mSampleRate);
	setProcess(&TTAudioObject::bypassProcess);
    setCalculate(&TTAudioObject::defaultCalculateMethod);
	setAttributeValue(TT("bypass"),			kTTBoolNo);	
}


TTAudioObject::~TTAudioObject()
{
	TTObjectRelease((TTObjectPtr*)&inputArray);
	TTObjectRelease((TTObjectPtr*)&outputArray);
}


TTErr TTAudioObject::setMaxNumChannels(const TTValue& newValue)
{
	if (TTUInt16(newValue) != maxNumChannels) {
		TTValue	oldMaxNumChannels = maxNumChannels;
		
		maxNumChannels = newValue;
		sendMessage(TT("updateMaxNumChannels"), oldMaxNumChannels, kTTValNONE);
	}
	return kTTErrNone;
}


TTErr TTAudioObject::setSr(const TTValue& newValue)
{
	TTValue oldSampleRate(sr);
{'fraction_non_alphanumeric': 0.15901375737001966, 'fraction_numerical': 0.014650705735215293, 'mean_word_length': 7.719626168224299, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4490548', 'n_tokens_mistral': 1980, 'n_tokens_neox': 1800, 'n_words': 325}