<commit_before>#include "stft_filter.h"
#include "app_globals.h"
#include "app_config.h"
#include "audio_nodes.h"

#include <cinder/audio/Context.h>
#include <cinder/CinderMath.h>
#include <cinder/params/Params.h>

namespace cieq {

StftFilter::StftFilter(AppGlobals& g)
	: mViewableBins(256)
	, mLowPassFrequency(10000.0f) //10KHz
	, mHighPassFrequency(100.0f) //100Hz
	, mCalculatedFftSize(0)
	, mActualLowPassFrequency(0)
	, mActualHighPassFrequency(0)
	, mMagnitudeIndexEnd(0)
	, mMagnitudeIndexStart(0)
	, mGlobals(g)
{}

void StftFilter::calculate()
{
	// If not a valid bandpass
	if (mLowPassFrequency < mHighPassFrequency)
		mLowPassFrequency = mHighPassFrequency + 5000.0f;

	// just a sanity check
	if (mViewableBins < 0)
		mViewableBins = 256;

	mCalculatedFftSize = static_cast<int>(((mViewableBins + 1) * ci::audio::Context::master()->getSampleRate()) / (mLowPassFrequency - mHighPassFrequency));

	if (!ci::isPowerOf2(mCalculatedFftSize))
		mCalculatedFftSize = ci::nextPowerOf2(mCalculatedFftSize);

	if (mCalculatedFftSize <= static_cast<int>(mGlobals.getAppConfig().getAsNodeFromat().getWindowDurationInSamples()))
	{
		while (mCalculatedFftSize <= static_cast<int>(mGlobals.getAppConfig().getAsNodeFromat().getWindowDurationInSamples()))
		{
			mCalculatedFftSize = ci::nextPowerOf2(mCalculatedFftSize);
		}
	}

	// Less than 1024? get out of here.
	if (mCalculatedFftSize < 1024) mCalculatedFftSize = 1024;<commit_msg>This was supposed to be a minus!<commit_after>#include "stft_filter.h"
#include "app_globals.h"
#include "app_config.h"
#include "audio_nodes.h"

#include <cinder/audio/Context.h>
#include <cinder/CinderMath.h>
#include <cinder/params/Params.h>

namespace cieq {

StftFilter::StftFilter(AppGlobals& g)
	: mViewableBins(256)
	, mLowPassFrequency(10000.0f) //10KHz
	, mHighPassFrequency(100.0f) //100Hz
	, mCalculatedFftSize(0)
	, mActualLowPassFrequency(0)
	, mActualHighPassFrequency(0)
	, mMagnitudeIndexEnd(0)
	, mMagnitudeIndexStart(0)
	, mGlobals(g)
{}

void StftFilter::calculate()
{
	// If not a valid bandpass
	if (mLowPassFrequency < mHighPassFrequency)
		mLowPassFrequency = mHighPassFrequency + 5000.0f;

	// just a sanity check
	if (mViewableBins < 0)
		mViewableBins = 256;

	mCalculatedFftSize = static_cast<int>(((mViewableBins - 1) * ci::audio::Context::master()->getSampleRate()) / (mLowPassFrequency - mHighPassFrequency));

	if (!ci::isPowerOf2(mCalculatedFftSize))
		mCalculatedFftSize = ci::nextPowerOf2(mCalculatedFftSize);

	if (mCalculatedFftSize <= static_cast<int>(mGlobals.getAppConfig().getAsNodeFromat().getWindowDurationInSamples()))
	{
		while (mCalculatedFftSize <= static_cast<int>(mGlobals.getAppConfig().getAsNodeFromat().getWindowDurationInSamples()))
		{
			mCalculatedFftSize = ci::nextPowerOf2(mCalculatedFftSize);
		}
	}

	// Less than 1024? get out of here.
	if (mCalculatedFftSize < 1024) mCalculatedFftSize = 1024;
{'fraction_non_alphanumeric': 0.13307984790874525, 'fraction_numerical': 0.03318354649153128, 'mean_word_length': 6.308080808080808, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 17, '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': '4398056', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1092, 'n_words': 167}