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