npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cxchord

v1.1.3

Published

Midi Chord Recognizer

Downloads

9

Readme

CxChord

Midi chord recognizer

Recognizes Chords from an array of midi notes and uses a Bayes probalistic method to find the most likely matches.

An explaination of Midi Note Numbers can be seen here.

This examples/sample.html file will generate the following web-page:

Sample Output

Installation:

npm install cxchord

Usage JavaScript (sample.js):

Go into the example directory:

cd examples
//
// Lookup Chords for midi notes
// 
var CxChord = require('../lib/CxChord');

console.log("-------------------");
var midiChord = [64, 67, 71, 72, 74, 78, 81 ];
var cm =  new CxChord.ChordMatcher()
cm.match(midiChord)
var mached = cm.getMatch();
console.log( JSON.stringify(mached, null, " ") );

console.log("-------------------");
console.log("First match a normal Major Chord:");
var midiChord = [ 63, 67, 69, 74];
var cm =  new CxChord.ChordMatcher();
cm.match(midiChord);
mached = cm.getMatch();
console.log( JSON.stringify(mached, null, " ") );

console.log("-------------------");
console.log("Then the same notes, but this time favor a Jazz block chord interpretation:");
cm.favorJazz(true);
cm.match(midiChord);
mached = cm.getMatch();
console.log( JSON.stringify(mached, null, " ") );

Execute the script at the command prompt:

$ node sample.js

Usage TypeScript (tsSample.ts):

import * as CxChord from "../lib/CxChord"

console.log("-------------------");
var midiChord = [64, 67, 71, 72, 74, 78, 81 ];
var cm =  new CxChord.ChordMatcher()
cm.match(midiChord)
var mached = cm.getMatch();
console.log( JSON.stringify(mached, null, " ") )

Compile and execute the script at the command prompt:

$ tsc tsSample.ts
$ node tsSample.js

Usage HTML (examples/sample.html):

<!doctype html>
<html>
  <head>
    <title>CxChord HTML Example</title>
    <meta http-equiv="content-type" content="text/html; image/svg; charset=utf-8 ;">
    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src 'self' blob: data:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'">
  </head>
  <body>
    <h2> Match midi notes 64, 67, 71, 72, 74, 78, 81  ( E, G, B, C, D, F#, A ) </h2>
    <blockquote>
        Identifies a Cmaj type chord in first inversion (here displaying the first 15 chord-posibilities ranked): 
        <table>
            <tr>
                <td >
                    <canvas id="visualization"  height="400"  width="1300" ></canvas>
                </td>
                <td>
                    <div id="legend"></div>
                </td>
             </tr>
         </table>
    </blockquote>
    <script type="text/javascript"  src="./sample.html.bundle.js"></script>
   </body>
</html>

Open the html file in your browser, e.g. in vscode right and choose Open In Default Browser. Note that the examples/sample.html.bundle.js is a browseryfied and bablified version of examples\sample.html.js in order to work in the browser. Have a look at BrowserifyBuild.js to see how that works.

You can have a look at the test specification src/CxChordSpec.ts for more details.