Skip to content

๐ŸŽน๐ŸŽต Client web application to find chords through keyboard UI

Notifications You must be signed in to change notification settings

ManuelVargas1251/Chord-Finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Programming language Version Build Status - enhancement/coverage Coverage Status Jest Unit Tests

Chord Finder ๐ŸŽน

This is a js web application that tells you what chord you are playing on the piano in any inversion. Click or keypress the notes to build your chord! If you select two notes it will tell you what the interval is between those two notes.

I started by rewriting my previous C++ chord finder console application in javascript and added the web interface as I went.

[View Web Application]

Event Handlers

Code is triggered by clicking or keypressing on the keyboard UI. Also using Automatic Semicolon Insertion.

// mouse click on piano key event
$(".key").click(function () {
	//pass note id to add to chord
	let noteCode = $(this).attr('id')
	$(this).toggleClass("pressed")	//toggle key color key when pressed
	processDOMChord(noteCode, userChordIds)
})

// keyboard keypress event
$("html").keypress(function (element) {
	let noteCode = keyMapping[element.which]
	$("#" + noteCode).toggleClass("pressed")
	processDOMChord(noteCode, userChordIds)
})

// reset button event
$(".reset").click(function (){
	userChordIds.forEach((v)=>$("#" + v).toggleClass("pressed"))
	userChordIds = []
	processDOMChord(undefined, userChordIds)
})

Unit Testing & Coverage

Using Facebook's Jest for unit testing. Configured Travis-CI for continuos integration on every commit and pull request as well as coverage reporting from Coveralls

# download node modules locally
npm install

# run js tests
npm test

Test Configuration in package.json

{
	"build": "node env",
	"test": "jest --coverage --coverageReporters=text-lcov | coveralls",
	"jest-watch": "jest --watchAll --coverage",
	"jest": "jest --coverage --coverageReporters=text-lcov | coveralls"
}

For local testing, remove the coveralls flag, else err response 422

{
	"build": "node env",
	"test": "jest --coverage --coverageReporters=text-lcov",
	"jest-watch": "jest --watchAll --coverage",
	"jest": "jest --coverage --coverageReporters=text-lcov"
}

Development Setup

# download the repo locally from github and cd into the folder
gh repo clone ManuelVargas1251/Chord-Finder
cd Chord-Finder

# install dev node modules (includes browserify)
npm install

# build new bundle to view your changes
node_modules/.bin/browserify src/js/index.js > src/js/bundle.js

Design Development

image

Sound Development

When testing sound locally I get CORS errors which prevent the sound from playing for security reasons. As a work around, run a local server from root:

npm install --global http-server
http-server ./

Environments

By using https://raw.githack.com/ I created a working lower environments to test code in any committed branch. I was also able to provide test statuses for every branch through Travis CI and Coveralls.

Production

Build Status - Master Coverage Status - Master

Development

Build Status - Development Coverage Status - Development

Reference

Musical Chord Wiki

Musical Interval Wiki