mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
experimenting with a soundfont
This commit is contained in:
parent
54c5c82fde
commit
fbaad0fe06
3 changed files with 11 additions and 2 deletions
|
@ -1,5 +1,13 @@
|
|||
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();
|
||||
|
||||
// effects setup
|
||||
|
@ -40,8 +48,7 @@ AudioEngine.prototype.getSoundDuration = function (soundNum) {
|
|||
};
|
||||
|
||||
AudioEngine.prototype.playNoteForBeats = function(note, beats) {
|
||||
var freq = this._midiToFreq(note);
|
||||
this.synth.triggerAttackRelease(freq, beats);
|
||||
this.instrument.play(note, this.tone.now(), beats);
|
||||
};
|
||||
|
||||
AudioEngine.prototype.playDrumForBeats = function(drumNum, beats) {
|
||||
|
|
|
@ -805,6 +805,7 @@
|
|||
<!-- Audio -->
|
||||
<script src="./AudioEngine.js"></script>
|
||||
<script src="./Tone.min.js"></script>
|
||||
<script src="./soundfont-player.min.js"></script>
|
||||
<script>
|
||||
function toXml() {
|
||||
var output = document.getElementById('importExport');
|
||||
|
|
1
playground/soundfont-player.min.js
vendored
Normal file
1
playground/soundfont-player.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue