polymerchm / chordcalc Goto Github PK
View Code? Open in Web Editor NEWTurning Gek S. Low's chordcalc python script into a full-featured chord calculator/player
Turning Gek S. Low's chordcalc python script into a full-featured chord calculator/player
I was playing around to see if javascript midi.js could be used to do midi within pythonista (answer yes... It's slow)... But came across "soundfonts" which are sampled sounds, or at least generated samples.
https://github.com/gleitz/midi-js-soundfonts/tree/master/FluidR3_GM
Here's a dirty script to download a few sounds and create a slew of mp3s. I was lazy and downloaded the single .js which contains all sounds, rather than downloading individual mp3s which might be faster since they don't need to be base64 encoded... Maybe. A better option might be to zip them up for distribution.
import json, base64, urllib,ui
instruments=['banjo','acoustic_guitar_steel','slap_bass_1']
def download_soundfont(instrument):
print 'downloading'+instrument
p=ui.Label()
p.present('popover')
def report(count,size,total):
p.text= '{:0.0f} % complete'.format(round(100*count*size/(1.0*total)))
p.size_to_fit()
if not p.on_screen:
p.present('popover')
p.set_needs_display()
filename=instrument+'-mp3.js'
urllib.urlretrieve('https://raw.githubusercontent.com/gleitz/midi-js-soundfonts/master/FluidR3_GM/'+filename
,filename
,report)
p.close()
with open(instrument+'-mp3.js') as f:
s=f.read()
#extract the dict
s=s[s.find('{\n'):s.find(',\n\n}')-1]+'"}'
d=json.loads(s)
for note,data in d.items():
start=data.find('//')
with open(instrument+'_'+note+'.mp3','wb') as f:
f.write(base64.decodestring(data[start:]))
for inst in instruments:
download_soundfont(inst)
Standard 5 string banjo tuning is g'DGbd.
Also. Something is strange about adding a new tuning... For 5 string banjo, the tuning shows g'DGbg', but the spinners come up as g' D G c g'. The second to last spinner shows s different value than the tuning, until that spinner is touched.
This is in devel-capo branch (is that the latest? You might want to push to master)
Thus overriding builtin max
and min
functions. Consider putting that code into a function, then call the function, to avoid polluting global namespace.
Not sure how the mechanics would work, maybe choose which chords to drill, or scales, or have to identify all scale notes in some range of frets...
Consider zipping up sound fonts, then just grabbing data over the wire once (per instrument maybe), then unzipping locally.. Opening url's is expensive, at least on a slow/lossy connection..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.