kopia lustrzana https://github.com/backface/turtlestitch
added basic stereo-panning support for notes
rodzic
f4a7b59c49
commit
53140c9108
|
@ -58,6 +58,7 @@
|
|||
* Objects: use AudioContext to play recorded sounds
|
||||
* Objects: new audio scheme support for the stage
|
||||
* Objects: added basic stereo-panning support for sounds (under construction)
|
||||
* Objects, Threads: added basic stereo-panning support for notes
|
||||
|
||||
### 2019-04-01
|
||||
* Objects: let the Microphone share the Note prototype's AudioContext
|
||||
|
|
|
@ -1492,6 +1492,7 @@ SpriteMorph.prototype.fullCopy = function (forClone) {
|
|||
c.stopTalking();
|
||||
c.color = this.color.copy();
|
||||
c.gainNode = null;
|
||||
c.panNode = null;
|
||||
c.blocksCache = {};
|
||||
c.paletteCache = {};
|
||||
c.cachedHSV = c.color.hsv();
|
||||
|
@ -8977,7 +8978,7 @@ Note.prototype.getAudioContext = function () {
|
|||
|
||||
// Note playing
|
||||
|
||||
Note.prototype.play = function (type, gainNode) {
|
||||
Note.prototype.play = function (type, gainNode, panNode) {
|
||||
this.oscillator = this.audioContext.createOscillator();
|
||||
if (!this.oscillator.start) {
|
||||
this.oscillator.start = this.oscillator.noteOn;
|
||||
|
@ -8994,7 +8995,8 @@ Note.prototype.play = function (type, gainNode) {
|
|||
this.oscillator.frequency.value = isNil(this.frequency) ?
|
||||
Math.pow(2, (this.pitch - 69) / 12) * 440 : this.frequency;
|
||||
this.oscillator.connect(gainNode);
|
||||
gainNode.connect(this.audioContext.destination);
|
||||
gainNode.connect(panNode);
|
||||
panNode.connect(this.audioContext.destination);
|
||||
this.oscillator.start(0);
|
||||
};
|
||||
|
||||
|
|
|
@ -4094,12 +4094,13 @@ Process.prototype.doPlayNoteForSecs = function (pitch, secs) {
|
|||
// interpolated
|
||||
var rcvr = this.blockReceiver();
|
||||
if (!this.context.startTime) {
|
||||
rcvr.setVolume(rvr.volume); // b/c Chrome needs lazy initialization
|
||||
rcvr.setVolume(rcvr.volume); // b/c Chrome needs lazy initialization
|
||||
this.context.startTime = Date.now();
|
||||
this.context.activeNote = new Note(pitch);
|
||||
this.context.activeNote.play(
|
||||
this.instrument,
|
||||
rcvr.getGainNode()
|
||||
rcvr.getGainNode(),
|
||||
rcvr.getPanNode()
|
||||
);
|
||||
}
|
||||
if ((Date.now() - this.context.startTime) >= (secs * 1000)) {
|
||||
|
|
Ładowanie…
Reference in New Issue