Library for playing back Chord
Aduffy opened this issue · 3 comments
Not really related to this project at all, but are you aware of any good packages for playing back a simple chord, either strummed or arpeggiated ? Preferably something that can play back a soundfont or other actual guitar sample and not just a oscillating tone.
No unfortunately I'm not aware of such a package. If you find a good one please let me know because I've been thinking about implementing a svguitar plugin to actually playing back the chords :)
OK well insomnia does has some advantages.. Found this last night..
https://github.com/danigb/soundfont-player
var ac = new AudioContext();
var soundfont = new Soundfont(ac);
var guitar = soundfont.instrument('/assets/soundfonts/MusyngKite/acoustic_guitar_steel-mp3.js');
function playChord(){
guitar.play('G2', ac.currentTime , { duration: 2});
guitar.play('F3', ac.currentTime +.001, { duration: 2});
guitar.play('B3', ac.currentTime +.002, { duration: 2});
guitar.play('D4', ac.currentTime +.003, { duration: 2});
}
I have it loading local soundfont files but by default it loads them from https://github.com/gleitz/midi-js-soundfonts
if your thinking of implementing this as a plugin, then what I was thinking was to have the notes on the chart highlight when the chord is played, either strummed or arpeggiated .
Perhaps you can give each note (nut) on the chart a class name based on the string/fret such as .note6-3 for a G2, so it can be accessed. It seems I could set the "fill" in CSS via JS to create the highlighting effect on play. ( I also tried transform scale() to make the note larger, and although it works it moves its position) .... perhaps I should open this idea as its own issue! .. :-)
Clicking a single note to play it might be cool as well.
The way Im drawing my chords with including all notes in the barre makes this a little simpler to implement for me.. I guess you would have to calculate the "barre" notes as well to play the notes in the chord...