GithubHelp home page GithubHelp logo

ni-c0de-mus / modularscale-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from modularscale/modularscale-js

0.0 1.0 0.0 15 KB

A JavaScript modular scale calculator

Home Page: http://modularscale.com

HTML 12.31% JavaScript 87.69%

modularscale-js's Introduction

Modularscale

This is a JavaScript modular scale calculator so you can create and use modular scales in your project. This calculator was built in tandem with the new modularscale.com website both as its calculation engine and as an external tool you can use in your own projects.

Installation

You can install modularscale-js as an NPM or Bower package to include in your project.

NPM:

$ npm install modularscale-js

Bower:

$ bower install modularscale-js

Alternatively you can download the latest release and add it to your project.

Using modularscale-js

First, you will want to set up your scale. You can go to modularscale.com and click on the js tab to generate a config, or define it yourself.

There is a configuration object that contains the settings for modular scale, inside it is an array of bases and the ratio value.

Call the function with either msFunction(n) or ms(n) where n is the point on your scale. You can pass settings in as a second variable.

$modularscale: {
  base: [1],
  ratio: 1.5
};

You can add multiple bases by adding values to the array

$modularscale: {
  base: [12,14,16],
  ratio: 1.5
};

Ratios

Modular scale includes functions for a number of classic design and musical scale ratios. You can add your own ratios as well.

By default, the variable msRatios is set to 1.618.

VariableDecimal value
minorSecond 1.067
majorSecond 1.125
minorThird 1.2
majorThird 1.25
perfectFourth 1.333
augFourth 1.414
perfectFifth 1.5
minorSixth 1.6
goldenSection 1.618
majorSixth 1.667
minorSeventh 1.778
majorSeventh 1.875
octave 2
majorTenth 2.5
majorEleventh 2.667
majorTwelfth 3
doubleOctave 4

Add your own ratio by setting a variable.

$modularscale: {
  ratio: 1.234
};

Multiple threads

You may notice you can have multiple scales at once on modularscale.com formatted like this:

$modularscale: {
  base: [1],
  ratio: 1.5,
  a: {
    base: [1],
    ratio: 1.2
  }
};

To use a scale with the $modularscale.a settings pass the settings in msFunction(n,$modularscale.a) where n is the point on the scale you wish to find a value for. You can break this variable down and pass it through via its own object but it is consolodated in the output of modularscale.com.

Licence

The MIT License (MIT)

Copyright © 2015 Scott Kellum

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

modularscale-js's People

Contributors

scottkellum avatar colbin8r avatar undistraction avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.