MCPcopy Create free account
hub / github.com/amsynth/amsynth / parseScalaLine

Function parseScalaLine

src/core/synth/TuningMap.cpp:106–131  ·  view source on GitHub ↗

Convert a single line of a Scala scale file to a frequency relative to 1/1.

Source from the content-addressed store, hash-verified

104
105// Convert a single line of a Scala scale file to a frequency relative to 1/1.
106static double
107parseScalaLine(const std::string & line)
108{
109 std::istringstream iss(line);
110 if (line.find('.') == std::string::npos)
111 { // treat as ratio
112 long n, d;
113 char slash;
114 iss >> n >> slash >> d;
115 if (iss.fail() || slash != '/' || n <= 0 || d <= 0)
116 {
117 return -1;
118 }
119 return (double) n / d;
120 }
121 else
122 { // treat as cents
123 double cents;
124 iss >> cents;
125 if (iss.fail())
126 {
127 return -1;
128 }
129 return pow(2., cents/1200.);
130 }
131}
132
133int
134TuningMap::loadScale (const std::string & filename)

Callers 1

loadScaleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected