Csound and CsoundAC API  5.17
Static Public Member Functions | Static Private Member Functions | Static Private Attributes
csound::Conversions Class Reference

Conversions to and from various music and signal processing units. More...

#include <Conversions.hpp>

Static Public Member Functions

static double amplitudeToDecibels (double amplitude)
static double amplitudeToGain (double Amplitude)
static double amplitudeToMidi (double Amplitude)
static std::string boolToString (bool value)
static double decibelsToAmplitude (double decibels)
static double decibelsToMidi (double decibels)
static std::string doubleToString (double value)
static char * dupstr (const char *string)
 Return a new copy of a "C" string allocated on the heap.
static double EPSILON ()
static double & epsilonFactor ()
static bool eq_epsilon (double a, double b)
static double findClosestPitchClass (double M, double pitchClass, double tones=12.0)
 Given the pitch-class set number M = sum over pitch-classes of (2 ^ pitch-class), return the pitch-class in the set that is closest to the argumen pitch-class.
static double gainToAmplitude (double Gain)
static double gainToDb (double inputDb, double gain, bool odbfs=false)
 Return a new value in dB that represents the input value in dB adjusted by the specified gain.
static bool ge_epsilon (double a, double b)
static double get2PI (void)
static double getMaximumAmplitude (int size)
 Returns the maximum soundfile amplitude for the sample size, assuming either float or twos' complement integer samples.
static double getMaximumDynamicRange ()
static double getMiddleCHz (void)
static double getNORM_7 (void)
static double getPI (void)
static int getSampleSize (void)
 Returns the maximum soundfile amplitude for the sample size.
static bool gt_epsilon (double a, double b)
static double hzToMidi (double Hz, bool rounded)
static double hzToOctave (double Hz)
static double hzToSamplingIncrement (double Hz, double SR, double SamplesPerCycle)
static bool initialize ()
static std::string intToString (int value)
static bool le_epsilon (double a, double b)
static double leftPan (double x)
static bool lt_epsilon (double a, double b)
static double midiToAmplitude (double Midi)
static double midiToDecibels (double Midi)
static double midiToGain (double Midi)
static double midiToHz (double Midi)
static double midiToOctave (double Midi)
static double midiToPitchClass (double midiKey)
static double midiToPitchClassSet (double midiKey)
static double midiToRoundedOctave (double midiKey)
static double midiToSamplingIncrement (double Midi, double SR, double SamplesPerCycle)
static double modulus (double a, double b)
 True modulus accounting for sign.
static std::string mToName (double pitchClassSet)
 Return the jazz-style scale or chord name for the pitch-class set number M = sum over pitch-classes of (2 ^ pitch-class) These numbers form a multiplicative monoid for all pitch-class sets in a system of equal temperament.
static double nameToM (std::string name)
 Return the pitch-class set number M = sum over pitch-classes of (2 ^ pitch-class) for the jazz-style scale or chord name.
static std::vector< double > nameToPitches (std::string name)
 Return the pitches for a chord name.
static double octaveToHz (double Octave)
static double octaveToMidi (double Octave, bool rounded)
static double octaveToSamplingIncrement (double Octave, double SR, double SamplesPerCycle)
static double phaseToTableLengths (double Phase, double TableSampleCount)
static double pitchClassSetToMidi (double pitchClassSet)
static double pitchClassToMidi (double pitchClass)
static double rightPan (double x)
static double round (double value)
static bool stringToBool (std::string value, bool default_=false)
 Translate the string value to a boolean value, returning the default if the string value is empty.
static double stringToDouble (std::string value, double default_=0.0)
 Translate the string value to a double-precision value, returning the default if the string value is empty.
static int stringToInt (std::string value, int default_=0)
 Translate the string value to an integer value, returning the default if the string value is empty.
static void stringToVector (const std::string &text, std::vector< double > &vector)
 Parses text in the format "n,..,n" to a vector of doubles.
static int swapInt (int Source)
static short swapShort (short Source)
static double temper (double octave, double tonesPerOctave)
static std::string & trim (std::string &value)
static std::string & trimQuotes (std::string &value)

Static Private Member Functions

static void fill (const char *cname, const char *cpitches)
static std::string listPitchClassSets ()
static void subfill (std::string root, const char *cname, double pcs)

Static Private Attributes

static const double floatMaximumAmplitude
static bool initialized_
static const double log10d20
static const double log10scale
static const double middleCHz
static std::map< double,
std::string > 
namesForPitchClassSets
static const double NORM_7_
static const double PI_
static std::map< std::string,
double > 
pitchClassSetsForNames
static int sampleSize
static const double TWO_PI_

Detailed Description

Conversions to and from various music and signal processing units.

Note that: silence::Event represents loudness in MIDI units (0 to 127). silence::Orchestra represents loudness in gain (0 to 1). silence::WaveSoundfileOut represents loudness in amplitude (0 to 1 for float samples, 0 to 32767 for short samples). Loudness can also be represented in positive decibels (0 to 84 for short samples, 0 to whatever for float samples). For float samples, decibels are assumed to be equivalent to MIDI velocity; otherwise, MIDI velocity is rescaled according to the maximum dynamic range supported by the sample size. All loudness conversions are driven by sample word size, which must be set before use; the default is 4 (float samples).

Member Function Documentation

static double csound::Conversions::amplitudeToDecibels ( double  amplitude)
static
static double csound::Conversions::amplitudeToGain ( double  Amplitude)
static
static double csound::Conversions::amplitudeToMidi ( double  Amplitude)
static
static std::string csound::Conversions::boolToString ( bool  value)
static
static double csound::Conversions::decibelsToAmplitude ( double  decibels)
static
static double csound::Conversions::decibelsToMidi ( double  decibels)
static
static std::string csound::Conversions::doubleToString ( double  value)
static
static char* csound::Conversions::dupstr ( const char *  string)
static

Return a new copy of a "C" string allocated on the heap.

The user is responsible for freeing the copy.

static double csound::Conversions::EPSILON ( )
static
static double& csound::Conversions::epsilonFactor ( )
static
static bool csound::Conversions::eq_epsilon ( double  a,
double  b 
)
static
static void csound::Conversions::fill ( const char *  cname,
const char *  cpitches 
)
staticprivate
static double csound::Conversions::findClosestPitchClass ( double  M,
double  pitchClass,
double  tones = 12.0 
)
static

Given the pitch-class set number M = sum over pitch-classes of (2 ^ pitch-class), return the pitch-class in the set that is closest to the argumen pitch-class.

static double csound::Conversions::gainToAmplitude ( double  Gain)
static
static double csound::Conversions::gainToDb ( double  inputDb,
double  gain,
bool  odbfs = false 
)
static

Return a new value in dB that represents the input value in dB adjusted by the specified gain.

If odbfs is false (the default), then 0 dB is the threshold of hearing; otherwise, 0 dB is full scale.

static bool csound::Conversions::ge_epsilon ( double  a,
double  b 
)
static
static double csound::Conversions::get2PI ( void  )
static
static double csound::Conversions::getMaximumAmplitude ( int  size)
static

Returns the maximum soundfile amplitude for the sample size, assuming either float or twos' complement integer samples.

static double csound::Conversions::getMaximumDynamicRange ( )
static
static double csound::Conversions::getMiddleCHz ( void  )
static
static double csound::Conversions::getNORM_7 ( void  )
static
static double csound::Conversions::getPI ( void  )
static
static int csound::Conversions::getSampleSize ( void  )
static

Returns the maximum soundfile amplitude for the sample size.

static bool csound::Conversions::gt_epsilon ( double  a,
double  b 
)
static
static double csound::Conversions::hzToMidi ( double  Hz,
bool  rounded 
)
static
static double csound::Conversions::hzToOctave ( double  Hz)
static
static double csound::Conversions::hzToSamplingIncrement ( double  Hz,
double  SR,
double  SamplesPerCycle 
)
static
static bool csound::Conversions::initialize ( )
static
static std::string csound::Conversions::intToString ( int  value)
static
static bool csound::Conversions::le_epsilon ( double  a,
double  b 
)
static
static double csound::Conversions::leftPan ( double  x)
static
static std::string csound::Conversions::listPitchClassSets ( )
staticprivate
static bool csound::Conversions::lt_epsilon ( double  a,
double  b 
)
static
static double csound::Conversions::midiToAmplitude ( double  Midi)
static
static double csound::Conversions::midiToDecibels ( double  Midi)
static
static double csound::Conversions::midiToGain ( double  Midi)
static
static double csound::Conversions::midiToHz ( double  Midi)
static
static double csound::Conversions::midiToOctave ( double  Midi)
static
static double csound::Conversions::midiToPitchClass ( double  midiKey)
static
static double csound::Conversions::midiToPitchClassSet ( double  midiKey)
static
static double csound::Conversions::midiToRoundedOctave ( double  midiKey)
static
static double csound::Conversions::midiToSamplingIncrement ( double  Midi,
double  SR,
double  SamplesPerCycle 
)
static
static double csound::Conversions::modulus ( double  a,
double  b 
)
static

True modulus accounting for sign.

static std::string csound::Conversions::mToName ( double  pitchClassSet)
static

Return the jazz-style scale or chord name for the pitch-class set number M = sum over pitch-classes of (2 ^ pitch-class) These numbers form a multiplicative monoid for all pitch-class sets in a system of equal temperament.

static double csound::Conversions::nameToM ( std::string  name)
static

Return the pitch-class set number M = sum over pitch-classes of (2 ^ pitch-class) for the jazz-style scale or chord name.

These numbers form a multiplicative monoid for all pitch-class sets in a system of equal temperament.

static std::vector<double> csound::Conversions::nameToPitches ( std::string  name)
static

Return the pitches for a chord name.

static double csound::Conversions::octaveToHz ( double  Octave)
static
static double csound::Conversions::octaveToMidi ( double  Octave,
bool  rounded 
)
static
static double csound::Conversions::octaveToSamplingIncrement ( double  Octave,
double  SR,
double  SamplesPerCycle 
)
static
static double csound::Conversions::phaseToTableLengths ( double  Phase,
double  TableSampleCount 
)
static
static double csound::Conversions::pitchClassSetToMidi ( double  pitchClassSet)
static
static double csound::Conversions::pitchClassToMidi ( double  pitchClass)
static
static double csound::Conversions::rightPan ( double  x)
static
static double csound::Conversions::round ( double  value)
static
static bool csound::Conversions::stringToBool ( std::string  value,
bool  default_ = false 
)
static

Translate the string value to a boolean value, returning the default if the string value is empty.

static double csound::Conversions::stringToDouble ( std::string  value,
double  default_ = 0.0 
)
static

Translate the string value to a double-precision value, returning the default if the string value is empty.

static int csound::Conversions::stringToInt ( std::string  value,
int  default_ = 0 
)
static

Translate the string value to an integer value, returning the default if the string value is empty.

static void csound::Conversions::stringToVector ( const std::string &  text,
std::vector< double > &  vector 
)
static

Parses text in the format "n,..,n" to a vector of doubles.

static void csound::Conversions::subfill ( std::string  root,
const char *  cname,
double  pcs 
)
staticprivate
static int csound::Conversions::swapInt ( int  Source)
static
static short csound::Conversions::swapShort ( short  Source)
static
static double csound::Conversions::temper ( double  octave,
double  tonesPerOctave 
)
static
static std::string& csound::Conversions::trim ( std::string &  value)
static
static std::string& csound::Conversions::trimQuotes ( std::string &  value)
static

Field Documentation

const double csound::Conversions::floatMaximumAmplitude
staticprivate
bool csound::Conversions::initialized_
staticprivate
const double csound::Conversions::log10d20
staticprivate
const double csound::Conversions::log10scale
staticprivate
const double csound::Conversions::middleCHz
staticprivate
std::map<double, std::string> csound::Conversions::namesForPitchClassSets
staticprivate
const double csound::Conversions::NORM_7_
staticprivate
const double csound::Conversions::PI_
staticprivate
std::map<std::string, double> csound::Conversions::pitchClassSetsForNames
staticprivate
int csound::Conversions::sampleSize
staticprivate
const double csound::Conversions::TWO_PI_
staticprivate