kopia lustrzana https://github.com/backface/turtlestitch
adjusted PianoKeyboard for the new audio engine
click reduction is an ugly business, those time curves can overlap and cause mayhem...pull/89/head
rodzic
aadd556a11
commit
1db0ae0bf7
|
@ -60,6 +60,7 @@
|
|||
### 2019-04-05
|
||||
* Objects: eliminated "clicks" when playing music notes
|
||||
* Objects: eliminated "clicks" when playing a frequency
|
||||
* Widgets, Objects: Adjusted PianoKeyboard for the new audio engine
|
||||
|
||||
### 2019-04-04
|
||||
* Objects, Threads: new "play frequency" commands in the Sounds category
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<title>Snap! Build Your Own Blocks 5 - Beta -</title>
|
||||
<link rel="shortcut icon" href="src/favicon.ico">
|
||||
<script type="text/javascript" src="src/morphic.js?version=2019-02-07"></script>
|
||||
<script type="text/javascript" src="src/widgets.js?version=2018-10-02"></script>
|
||||
<script type="text/javascript" src="src/widgets.js?version=2019-04-05"></script>
|
||||
<script type="text/javascript" src="src/blocks.js?version=2019-04-04"></script>
|
||||
<script type="text/javascript" src="src/threads.js?version=2019-04-04"></script>
|
||||
<script type="text/javascript" src="src/objects.js?version=2019-04-05"></script>
|
||||
|
|
|
@ -9244,6 +9244,9 @@ Note.prototype.getAudioContext = function () {
|
|||
// Note playing
|
||||
|
||||
Note.prototype.play = function (type, gainNode, pannerNode) {
|
||||
if (!gainNode) {
|
||||
gainNode = this.audioContext.createGain();
|
||||
}
|
||||
this.fader = this.audioContext.createGain();
|
||||
this.oscillator = this.audioContext.createOscillator();
|
||||
if (!this.oscillator.start) {
|
||||
|
@ -9284,12 +9287,20 @@ Note.prototype.setInstrument = function (type) {
|
|||
}
|
||||
};
|
||||
|
||||
Note.prototype.stop = function () {
|
||||
this.fader.gain.setValueCurveAtTime(
|
||||
this.fadeOut,
|
||||
this.audioContext.currentTime,
|
||||
this.fadeTime
|
||||
);
|
||||
Note.prototype.stop = function (immediately) {
|
||||
// set "immediately" to true to terminate instantly
|
||||
// needed for widgets like the PianoKeyboard
|
||||
if (immediately && this.oscillator) {
|
||||
this.oscillator.stop(0);
|
||||
return;
|
||||
}
|
||||
if (this.fader) {
|
||||
this.fader.gain.setValueCurveAtTime(
|
||||
this.fadeOut,
|
||||
this.audioContext.currentTime,
|
||||
this.fadeTime
|
||||
);
|
||||
}
|
||||
if (this.oscillator) {
|
||||
this.oscillator.stop(this.audioContext.currentTime + this.fadeTime);
|
||||
this.oscillator = null;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
written by Jens Mönig
|
||||
jens@moenig.org
|
||||
|
||||
Copyright (C) 2018 by Jens Mönig
|
||||
Copyright (C) 2019 by Jens Mönig
|
||||
|
||||
This file is part of Snap!.
|
||||
|
||||
|
@ -85,7 +85,7 @@ HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph,
|
|||
ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences,
|
||||
ScrollFrameMorph, MenuItemMorph, Note*/
|
||||
|
||||
modules.widgets = '2018-February-08';
|
||||
modules.widgets = '2019-April-05';
|
||||
|
||||
var PushButtonMorph;
|
||||
var ToggleButtonMorph;
|
||||
|
@ -3708,14 +3708,14 @@ PianoKeyMorph.prototype.mouseEnter = function () {
|
|||
this.note.play(soundType);
|
||||
setTimeout(
|
||||
function () {
|
||||
myself.note.stop();
|
||||
myself.note.stop(true);
|
||||
},
|
||||
400
|
||||
);
|
||||
};
|
||||
|
||||
PianoKeyMorph.prototype.mouseLeave = function () {
|
||||
this.note.stop();
|
||||
this.note.stop(true);
|
||||
this.label.children[0].show();
|
||||
this.image = this.normalImage;
|
||||
this.changed();
|
||||
|
|
Ładowanie…
Reference in New Issue