All Projects → maxwellpollack → scalemap

maxwellpollack / scalemap

Licence: other
a string format and API for musical scales in C, C++, and JavaScript

Programming Languages

C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to scalemap

Modulo7
A semantic and technical analysis of musical scores based on Information Retrieval Principles
Stars: ✭ 15 (-6.25%)
Mutual labels:  music-theory
MusicTheory
Music Theory Library for Java and Android apps
Stars: ✭ 24 (+50%)
Mutual labels:  music-theory
Prelude
A web app for practicing musical sight reading skills
Stars: ✭ 24 (+50%)
Mutual labels:  music-theory
octave-compass
A tool for exploring musical scales and chords
Stars: ✭ 21 (+31.25%)
Mutual labels:  music-theory
AIBud
An experimental CreateML project for predicting playing musical key and scale in realtime
Stars: ✭ 18 (+12.5%)
Mutual labels:  music-theory
LabMidi
Midi IN and OUT. Standard midi file parser and player. Midi Softsynth implementation.
Stars: ✭ 38 (+137.5%)
Mutual labels:  music-theory
chords
Text-based chord progression editor
Stars: ✭ 25 (+56.25%)
Mutual labels:  music-theory
scale-workshop
Design microtonal scales and play them in your web browser. Export your scales for use with VST instruments. Convert Scala files to various tuning formats.
Stars: ✭ 132 (+725%)
Mutual labels:  microtonal
fretonator
The ultimate interactive free guitar theory tool.
Stars: ✭ 42 (+162.5%)
Mutual labels:  music-theory
chord-master
A web application for building chord progression
Stars: ✭ 34 (+112.5%)
Mutual labels:  music-theory
react-orchestra
A declarative toolbox to build interactive musical instruments on web and mobile.
Stars: ✭ 72 (+350%)
Mutual labels:  music-theory
pytheory
Music Theory for Humans.
Stars: ✭ 1,358 (+8387.5%)
Mutual labels:  music-theory
NegativeHarmonizer
A python tool to invert the tonality (a.k.a negative harmony) of midi notation
Stars: ✭ 23 (+43.75%)
Mutual labels:  music-theory
ziffers
Numbered musical notation for composing algorithmic and generative melodies
Stars: ✭ 53 (+231.25%)
Mutual labels:  music-theory
fretboarder
🎸 A web app to visualize scales, chords and arpeggios on all kinds of fretboards.
Stars: ✭ 34 (+112.5%)
Mutual labels:  music-theory
musyn
Write music together, in real time.
Stars: ✭ 20 (+25%)
Mutual labels:  music-theory
mahler.c
Western music theory library in C99
Stars: ✭ 13 (-18.75%)
Mutual labels:  music-theory
arpeggio
A chord naming app for guitar written in React.
Stars: ✭ 49 (+206.25%)
Mutual labels:  music-theory
Tonal
A functional music theory library for Javascript
Stars: ✭ 2,156 (+13375%)
Mutual labels:  music-theory
pitchplots
Plotting library for note distributions in different representations of tonal space
Stars: ✭ 17 (+6.25%)
Mutual labels:  music-theory

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

  • int baseNote, the note number of the tonic.
  • double baseFreq, the frequency of the tonic.
  • size_t scaleSize, the number of degrees in scale (at least 1).
  • double* scale, an array containing the frequency ratio of each scale degree, ending with the octave.

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

  • Returns a tuning specified by:
    • baseNoteExpr, a math expression for baseNote (rounded to nearest integer).
    • baseFreqExpr, a math expression for baseFreq.
    • scaleExpr, math expressions for each scale degree, separated by \n.
  • Math expressions are parsed by TinyExpr.
  • Be sure to call free(tuning.scale) when you're done with it to prevent a memory leak.

double noteToFreq(int note, tuning tuning)

  • Returns the frequency of a note according to a 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

  • Tuning(std::string baseNoteExpr, std::string baseFreqExpr, std::string scaleExpr)
  • int baseNote
  • double baseFreq
  • std::vector<double> scale
  • noteToFreq(int note)
#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)

  • Returns the Number result of parsing the String mathExpr using TinyExpr
  • If the math expression is invalid, returns 0

class Tuning

  • Tuning(baseNoteExpr, baseFreqExpr, scaleExpr) (Object)
  • baseNote (Number)
  • baseFreq (Number)
  • scale (Array of Numbers)
  • noteToFreq(note) (Number)
<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>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].