Home

Awesome

scalemap

a string format for musical scales, consisting of a sequence of newline-separated math expressions corresponding to the frequency interval of each scale degree (ending with the octave).

Try it out in Frequency Explorer.

Examples:

12-tone equal temperament:

2^(1/12)

5-limit JI:

9/8
5/4
4/3
3/2
5/3
15/8
2

C API

typedef struct tuning

tuning newTuning(const char* baseNoteExpr, const char* baseFreqExpr, const char* scaleExpr)

double noteToFreq(int note, tuning tuning)

#include "scalemap.h"

int main() {
  tuning t = newTuning("69","440","2^(1/12)");
  noteToFreq(60, t); // returns 261.626
  free(t.scale);
}

C++ API

Defines all the same functions and types as in C, plus the Tuning convenience class:

class Tuning

#include "scalemap.h"

int main() {
  Tuning t ("69","440","2^(1/12)");
  t.noteToFreq(60); // returns 261.626
}

JavaScript API

Ported to WebAssembly with Emscripten

parseExpr(mathExpr)

class Tuning

<script src="scalemap.js"></script>
<script>
  Module.onRuntimeInitialized = function() { // wait for WebAssembly to initialize
    var t  = new Tuning("69","440","2^(1/12)");
    t.noteToFreq(60); // returns 261.626
  }
</script>