Conversions.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef CONVERSIONS_H
00023 #define CONVERSIONS_H
00024
00025 #include "Platform.hpp"
00026 #ifdef SWIG
00027 %module CsoundAC
00028 %{
00029 #include <cmath>
00030 #include <string>
00031 #include <cstdio>
00032 #include <map>
00033 #include <vector>
00034 %}
00035 %include "std_string.i"
00036 %include "std_vector.i"
00037 %template(DoubleVector) std::vector<double>;
00038 #else
00039 #include <cmath>
00040 #include <string>
00041 #include <cstdio>
00042 #include <map>
00043 #include <vector>
00044 #endif
00045
00046 namespace csound
00047 {
00060 class Conversions
00061 {
00062 static bool initialized_;
00063 static std::map<std::string, double> pitchClassSetsForNames;
00064 static std::map<double, std::string> namesForPitchClassSets;
00065 static void subfill(std::string root, char *cname, double pcs);
00066 static void fill(char *cname, char *cpitches);
00067 static std::string listPitchClassSets();
00068 #if !defined(SWIG)
00069 static const double PI_;
00070 static const double TWO_PI_;
00071 static const double middleCHz;
00072 static const double log10d20;
00073 static const double log10scale;
00074 static const double NORM_7_;
00075 static const double floatMaximumAmplitude;
00076 static int sampleSize;
00077 #endif
00078 public:
00079 static double getPI(void);
00080 static double get2PI(void);
00081 static double getMiddleCHz(void);
00082 static double getNORM_7(void);
00083 static bool initialize();
00087 static int getSampleSize(void);
00092 static double getMaximumAmplitude(int size);
00093 static double getMaximumDynamicRange();
00094 static double amplitudeToDecibels(double amplitude);
00095 static double amplitudeToGain(double Amplitude);
00096 static double decibelsToAmplitude(double decibels);
00097 static double decibelsToMidi(double decibels);
00098 static double gainToAmplitude(double Gain);
00099 static double midiToDecibels(double Midi);
00100 static double midiToAmplitude(double Midi);
00101 static double amplitudeToMidi(double Amplitude);
00102 static double midiToGain(double Midi);
00103 static double leftPan(double x);
00104 static const double round(double value);
00105 static double temper(double octave, double tonesPerOctave);
00106 static double phaseToTableLengths(double Phase, double TableSampleCount);
00107 static double hzToMidi(double Hz, bool rounded);
00108 static double hzToOctave(double Hz);
00109 static double hzToSamplingIncrement(double Hz, double SR, double SamplesPerCycle);
00110 static double midiToHz(double Midi);
00111 static double midiToOctave(double Midi);
00112 static double midiToSamplingIncrement(double Midi, double SR, double SamplesPerCycle);
00113 static double octaveToHz(double Octave);
00114 static double octaveToMidi(double Octave, bool rounded);
00115 static double octaveToSamplingIncrement(double Octave, double SR, double SamplesPerCycle);
00116 static double rightPan(double x);
00117 static int swapInt(int Source);
00118 static short swapShort(short Source);
00119 static bool stringToBool(std::string value);
00120 static std::string boolToString(bool value);
00121 static int stringToInt(std::string value);
00122 static std::string intToString(int value);
00123 static double stringToDouble(std::string value);
00124 static std::string doubleToString(double value);
00125 static double midiToPitchClass(double midiKey);
00126 static double pitchClassSetToMidi(double pitchClassSet);
00127 static double midiToPitchClassSet(double midiKey);
00128 static double pitchClassToMidi(double pitchClass);
00133 static double findClosestPitchClass(double M, double pitchClass, double tones = 12.0);
00134 static double midiToRoundedOctave(double midiKey);
00135 static std::string &trim(std::string &value);
00136 static std::string &trimQuotes(std::string &value);
00140 static double modulus(double a, double b);
00144 static std::vector<double> nameToPitches(std::string name);
00150 static double nameToM(std::string name);
00157 static std::string mToName(double pitchClassSet);
00162 static char *dupstr(const char *string);
00170 static double gainToDb(double inputDb, double gain, bool odbfs = false);
00171 };
00172 }
00173
00174 #endif