Giter Site home page Giter Site logo

bpm-delay's Introduction

Calculation of the delay timet for a note at given tempo in BPM

This mini project starts as an exercise for closure that is in file "quarternote.js".

Used Function:

const delayCounter = () => {
    let ms = 6e4;
    let calcDelay = (bpm) => {
        return Math.round(ms / bpm * 100) / 100;
    };
    return calcDelay;
};

// variable "quarternote" contain function calcDelay with access to variable "ms"
const quarternote = delayCounter();

Then I have decided to calculate values for multiple note lenghts and result is in "multicalc.js". I have created object "notes" where property name is note lenght and value is function with calculation formula

Example:

let notes = {
    noteQuarter : (bpm) => Math.round( 6e4 / bpm * 1000 ) / 1000
}

Function calculateBpm take "usersBpm" as input, then loop thru object "notes". Each loop store function ( property value ) in variable "values", then stored function is envoked and its result is stored in array "delayTime".

const calculateBpm = (usersBpm) => {
    // loop thru object "notes"
    for(let delay in notes){
        // store property value (inthis case function in variable "values")
        const values = notes[delay];
        // run each function and push results into array "delayTime"
        delayTime.push(values(usersBpm));
    }
};

To show results on front end is used function "print()"

Example:

let print = () =>{
    noteQuarter.innerHTML = delayTime[3];
}

Because this exercise is focused for javaScript, HTML and CSS is just very basic.

Feel free to use and customized this exercise code to your needs.# bpm-delay

bpm-delay

bpm-delay's People

Contributors

stanskrivanek avatar

Watchers

 avatar

Forkers

tanurkova

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.