<commit_before>// setup.C -- Other Minc routines used to configure an LPCPLAY session

#include <ugens.h>
#include <stdio.h>
#include <string.h>
#include "setup.h"
#include "lp.h"
#include "DataSet.h"
#include <RTcmix.h>

static double lowthresh, highthresh;
static float maxdev;	// lpcplay, set from outside
static float perperiod = 1.0;	// lpcplay, set from outside
static float cutoff;	// amp cutoff level, lpcplay, set via lpcstuff
static float hnfactor = 1.0;	// harmonic count multiplier, set via lpcstuff
static float thresh, randamp, unvoiced_rate;
static float risetime, decaytime;	// enveloping; set externally
static bool  autoCorrect = false;	// whether to stabilize each frame as it runs

static const int maxDataSets = 16;

#define THRESH_UNSET (-1)

// For right now, datasets are created each time they are needed and are
//	not shared.

char	g_dataset_names[maxDataSets][80];	// open data set names
DataSet	*g_datasets[maxDataSets];			// open datasets
int		g_currentDataset = 0;

// The following three functions are called by LPCPLAY::init() to copy the
//	current set of parameters from the Minc environment into the LPCPLAY
//	instance.

int GetDataSet(DataSet **ppDataSet)
{
	*ppDataSet = g_datasets[g_currentDataset];
	return g_datasets[g_currentDataset] ? 1 : -1;
}

int 
GetLPCStuff(double *pHiThresh,
			double *pLowThresh,
			float *pThresh,
			float *pRandamp,
			bool *pUnvoiced_rate,
			float *pRisetime, float *pDecaytime,
			float *pAmpcutoff)
{
	// Set these here if not already set.
	if (highthresh == THRESH_UNSET)
		highthresh = thresh + 0.000001;
	if (lowthresh == THRESH_UNSET)
		lowthresh = thresh;
	*pHiThresh = highthresh;
	*pLowThresh = lowthresh;
	*pThresh = thresh;
	*pRandamp = randamp;
	*pUnvoiced_rate = unvoiced_rate;
	*pRisetime = risetime;
	*pDecaytime = decaytime;
	*pAmpcutoff = cutoff;
	return 1;
}
					   
int
GetConfiguration(float *pMaxdev,
				 float *pPerperiod,
				 float *pHnfactor,
				 bool  *pAutoCorrect)
{
	*pMaxdev = maxdev;
	*pPerperiod = perperiod;
	*pHnfactor = hnfactor;
	*pAutoCorrect = autoCorrect;
	return 1;
}

//	These functions are all Minc utilities

double dataset(float *p, int n_args, double *pp)
/* p1=dataset name, p2=npoles */
{
	char *name;
	int i, set;
	i=(int)pp[0];
	name=(char *)i;

	if (name == NULL) {
		rterror("dataset", "NULL file name");
		return -1;
	}

	// Search all open dataset slots for matching name
	for (set = 0; set < maxDataSets && strlen(g_dataset_names[set]); ++set) {
		if (strcmp(name, g_dataset_names[set]) == 0) {
			g_currentDataset = set;
			::advise("dataset", "Using already open dataset at slot %d", set);
			return g_datasets[g_currentDataset]->getFrameCount();
		}
	}
	if (set >= maxDataSets) {
		::rterror("dataset", "Maximum number of datasets exceeded");
		return -1;
	}

	// OK, this is a new set that we will put in a new slot

	g_currentDataset = set;

	strcpy(g_dataset_names[g_currentDataset],name);
<commit_msg>Changed all locations in code where a string is coerced into a double or vice versa, and substituted new macros (in ugens.h) which support 64-bit compiles (for which string pointers are the size of a long long).  These macros will switch automatically based on gcc's built-in macros.  No 64-bit support for non-Gnu builds yet.<commit_after>// setup.C -- Other Minc routines used to configure an LPCPLAY session

#include <ugens.h>
#include <stdio.h>
#include <string.h>
#include "setup.h"
#include "lp.h"
#include "DataSet.h"
#include <RTcmix.h>

static double lowthresh, highthresh;
static float maxdev;	// lpcplay, set from outside
static float perperiod = 1.0;	// lpcplay, set from outside
static float cutoff;	// amp cutoff level, lpcplay, set via lpcstuff
static float hnfactor = 1.0;	// harmonic count multiplier, set via lpcstuff
static float thresh, randamp, unvoiced_rate;
static float risetime, decaytime;	// enveloping; set externally
static bool  autoCorrect = false;	// whether to stabilize each frame as it runs

static const int maxDataSets = 16;

#define THRESH_UNSET (-1)

// For right now, datasets are created each time they are needed and are
//	not shared.

char	g_dataset_names[maxDataSets][80];	// open data set names
DataSet	*g_datasets[maxDataSets];			// open datasets
int		g_currentDataset = 0;

// The following three functions are called by LPCPLAY::init() to copy the
//	current set of parameters from the Minc environment into the LPCPLAY
//	instance.

int GetDataSet(DataSet **ppDataSet)
{
	*ppDataSet = g_datasets[g_currentDataset];
	return g_datasets[g_currentDataset] ? 1 : -1;
}

int 
GetLPCStuff(double *pHiThresh,
			double *pLowThresh,
			float *pThresh,
			float *pRandamp,
			bool *pUnvoiced_rate,
			float *pRisetime, float *pDecaytime,
			float *pAmpcutoff)
{
	// Set these here if not already set.
	if (highthresh == THRESH_UNSET)
		highthresh = thresh + 0.000001;
	if (lowthresh == THRESH_UNSET)
		lowthresh = thresh;
	*pHiThresh = highthresh;
	*pLowThresh = lowthresh;
	*pThresh = thresh;
	*pRandamp = randamp;
	*pUnvoiced_rate = unvoiced_rate;
	*pRisetime = risetime;
	*pDecaytime = decaytime;
	*pAmpcutoff = cutoff;
	return 1;
}
					   
int
GetConfiguration(float *pMaxdev,
				 float *pPerperiod,
				 float *pHnfactor,
				 bool  *pAutoCorrect)
{
	*pMaxdev = maxdev;
	*pPerperiod = perperiod;
	*pHnfactor = hnfactor;
	*pAutoCorrect = autoCorrect;
	return 1;
}

//	These functions are all Minc utilities

double dataset(float *p, int n_args, double *pp)
/* p1=dataset name, p2=npoles */
{
	int i, set;
	char *name=DOUBLE_TO_STRING(pp[0]);

	if (name == NULL) {
		rterror("dataset", "NULL file name");
		return -1;
	}

	// Search all open dataset slots for matching name
	for (set = 0; set < maxDataSets && strlen(g_dataset_names[set]); ++set) {
		if (strcmp(name, g_dataset_names[set]) == 0) {
			g_currentDataset = set;
			::advise("dataset", "Using already open dataset at slot %d", set);
			return g_datasets[g_currentDataset]->getFrameCount();
		}
	}
	if (set >= maxDataSets) {
		::rterror("dataset", "Maximum number of datasets exceeded");
		return -1;
	}

	// OK, this is a new set that we will put in a new slot

	g_currentDataset = set;

	strcpy(g_dataset_names[g_currentDataset],name);

{'fraction_non_alphanumeric': 0.11030244218017143, 'fraction_numerical': 0.009704027171276079, 'mean_word_length': 4.1576313594662215, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '4709862', 'n_tokens_mistral': 2350, 'n_tokens_neox': 2188, 'n_words': 692}