experimenting with a soundfont

This commit is contained in:
Eric Rosenbaum 2016-09-28 13:20:51 -04:00
parent 54c5c82fde
commit fbaad0fe06
3 changed files with 11 additions and 2 deletions

View file

@ -1,5 +1,13 @@
function AudioEngine () { function AudioEngine () {
// soundfont setup
Soundfont.instrument(Tone.context, 'acoustic_grand_piano').then(function (piano) {
this.instrument = piano;
}.bind(this));
// tone setup
this.tone = new Tone(); this.tone = new Tone();
// effects setup // effects setup
@ -40,8 +48,7 @@ AudioEngine.prototype.getSoundDuration = function (soundNum) {
}; };
AudioEngine.prototype.playNoteForBeats = function(note, beats) { AudioEngine.prototype.playNoteForBeats = function(note, beats) {
var freq = this._midiToFreq(note); this.instrument.play(note, this.tone.now(), beats);
this.synth.triggerAttackRelease(freq, beats);
}; };
AudioEngine.prototype.playDrumForBeats = function(drumNum, beats) { AudioEngine.prototype.playDrumForBeats = function(drumNum, beats) {

View file

@ -805,6 +805,7 @@
<!-- Audio --> <!-- Audio -->
<script src="./AudioEngine.js"></script> <script src="./AudioEngine.js"></script>
<script src="./Tone.min.js"></script> <script src="./Tone.min.js"></script>
<script src="./soundfont-player.min.js"></script>
<script> <script>
function toXml() { function toXml() {
var output = document.getElementById('importExport'); var output = document.getElementById('importExport');

1
playground/soundfont-player.min.js vendored Normal file

File diff suppressed because one or more lines are too long