<commit_before>/* 
 * Jamoma DataspaceLib Base Class
 * Copyright © 2007
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#ifndef __DATASPACELIB_H__
#define __DATASPACELIB_H__

#include "ext.h"
#include "ext_obex.h"
#include "JamomaTypes.h"

// Coeffs used for trigonometric cinvertions:

static const double RAD2DEG = 180.0 / 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068;
static const double DEG2RAD = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 / 180.0;

// 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
// Calculated as expr log(atodb(10))/log(127./100.)
static const double GAINMIDIPOWER = 4.816783;
// static const double GAINMIDIPOWERINV = 1./GAINMIDIPOWER;
static const double GAINMIDIPOWERINV = 0.2076074219;


/****************************************************************************************************/
// Class Specification


// Specification for the base class of each DataspaceUnit
// A DataspaceUnit converts from a specific unit to a neutral unit
// and is used by a DataspaceLib to do a conversion
class DataspaceUnit{
	public:
		t_symbol *name;				/// < name of this unit

		/** Constructor. Must be passed the name of this DataspaceUnit as a C-string. */
		DataspaceUnit(char *cName);
		
		/** Destructor */
		virtual ~DataspaceUnit();
		
		/** Converts from an actual unit to a 'neutral' unit that can be interpreted by other units within this dataspace.
			This must be defined by a sub-class.*/
		virtual void convertToNeutral(long inputNumArgs, t_atom *inputAtoms, long *outputNumArgs, double *output) = 0;<commit_msg>The constant GAINMIDIPOWER is now calculated. Should ensure maximum precision possible.<commit_after>/* 
 * Jamoma DataspaceLib Base Class
 * Copyright © 2007
 * 
 * License: This code is licensed under the terms of the GNU LGPL
 * http://www.gnu.org/licenses/lgpl.html 
 */

#ifndef __DATASPACELIB_H__
#define __DATASPACELIB_H__

#include "ext.h"
#include "ext_obex.h"
#include "JamomaTypes.h"

// Coeffs used for trigonometric cinvertions:

static const double RAD2DEG = 180.0 / 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068;
static const double DEG2RAD = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 / 180.0;

// 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 GAINMIDIPOWER = log(pow(10.,10./20.))/log(127./100.);
static const double GAINMIDIPOWERINV = 1./GAINMIDIPOWER;


/****************************************************************************************************/
// Class Specification


// Specification for the base class of each DataspaceUnit
// A DataspaceUnit converts from a specific unit to a neutral unit
// and is used by a DataspaceLib to do a conversion
class DataspaceUnit{
	public:
		t_symbol *name;				/// < name of this unit

		/** Constructor. Must be passed the name of this DataspaceUnit as a C-string. */
		DataspaceUnit(char *cName);
		
		/** Destructor */
		virtual ~DataspaceUnit();
		
		/** Converts from an actual unit to a 'neutral' unit that can be interpreted by other units within this dataspace.
			This must be defined by a sub-class.*/
		virtual void convertToNeutral(long inputNumArgs, t_atom *inputAtoms, long *outputNumArgs, double *output) = 0;
{'fraction_non_alphanumeric': 0.13111599780098956, 'fraction_numerical': 0.13413963716327654, 'mean_word_length': 4.6070878274268106, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5209616', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1151, 'n_words': 372}