Comments (3)
I was bored and wrote a script for you. Here you go:
function getChordsForRootNote(rootNote, instrument, cb) {
const ukeNormalizeMap = { "Cb":"B", "C":"C", "C#":"Db", "Db":"Db", "D":"D", "D#":"Eb", "Eb":"Eb", "E":"E", "E#":"F", "Fb":"E", "F":"F", "F#":"Gb", "Gb":"Gb", "G":"G", "G#":"Ab", "Ab":"Ab", "A":"A", "A#":"Bb", "Bb":"Bb", "B":"B", "B#":"C"}
const guitarNormalizeMap = { "Cb":"B", "C":"C", "C#":"C#", "Db":"Db", "D":"D", "D#":"Eb", "Eb":"Eb", "E":"E", "E#":"F", "Fb":"E", "F":"F", "F#":"F#", "Gb":"Gb", "G":"G", "G#":"Ab", "Ab":"Ab", "A":"A", "A#":"Bb", "Bb":"Bb", "B":"B", "B#":"C"}
rootNote = (instrument==='ukelele') ? ukeNormalizeMap[rootNote] : guitarNormalizeMap[rootNote]
rootNote = rootNote.replace('#','sharp')
let ws = new WebSocket("wss://s-usc1c-nss-221.firebaseio.com/.ws?v=5&ns=chord-collection")
let query = '{"t":"d","d":{"r":1,"a":"q","b":{"p":"/'+instrument+'/chordsByKey/'+rootNote+'","h":""}}}'
let frameCount = 0
let response = ''
ws.onmessage = function (e) {
if (!isNaN(e.data)) {
frameCount = parseInt(e.data)
response = ''
return
} else {
if (frameCount>0) {
frameCount--
response+=e.data
} else
response=e.data
if (frameCount === 0) {
let data = JSON.parse(response)
if (data && data.d && data.d.b && data.d.b.p && data.d.b.p === instrument+'/chordsByKey/'+rootNote) {
cb(data.d.b.d)
ws.close()
}
}
}
}
ws.onopen = function(e) {
ws.send(query)
}
}
let rootNotes = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
let chordsObj={}
let retrievedCount=0
rootNotes.forEach(chordBase=>{
getChordsForRootNote(chordBase, 'ukelele', (chordData) => {
chordsObj[chordBase] = chordData
retrievedCount++
console.log("Retrieved all " + chordBase + " chords (" + retrievedCount + "/" + rootNotes.length + ")")
if (retrievedCount === rootNotes.length) {
console.log("Result:")
console.log(chordsObj)
}
})
})
You can just copy paste that into the developer console on the website.
from chord-collection.
I might extend the chord-collection to include ukulele chords at some point. So you might wanna set a watch on that.
If you know a thing or two about web development chord-collection.com has a websocket interface that provides all chords for a given root note in a json format. Scraping that by hand using Chrome's developer tools would probably be faster that writing a script. (Go to the site and select a chord, press F12 to open the dev tools, go to the network tab, filter by WS, select the only request in the list, click 'Frames' and check the really long entries. you'll see one of them has all the chords for the current root note)
from chord-collection.
Thank you very much! :D
from chord-collection.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chord-collection.