summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2014-08-04 11:10:21 +0200
committerGubolin <gubolin@fantasymail.de>2014-08-04 11:10:21 +0200
commit90e62b4313f300de1da3013a558d51f7d4c883a6 (patch)
treefc98cc505f547f3bfaac53d6949e4f20d0c12f61
parent8acc6a32d414160b8de71d19457868b769768649 (diff)
downloadsnap-90e62b4313f300de1da3013a558d51f7d4c883a6.tar.gz
snap-90e62b4313f300de1da3013a558d51f7d4c883a6.zip
allow changing the volume of notes
-rw-r--r--objects.js5
-rw-r--r--threads.js3
2 files changed, 5 insertions, 3 deletions
diff --git a/objects.js b/objects.js
index b385ee9..1a42e0f 100644
--- a/objects.js
+++ b/objects.js
@@ -6352,12 +6352,13 @@ Note.prototype.setupContext = function () {
}
Note.prototype.audioContext = new AudioContext();
Note.prototype.gainNode = Note.prototype.audioContext.createGain();
- Note.prototype.gainNode.gain.value = 0.25; // reduce volume by 1/4
};
// Note playing
-Note.prototype.play = function () {
+Note.prototype.play = function (volume) {
+ this.gainNode.gain.value = 0.25 * volume / 100; // reduce volume by 1/4
+
this.oscillator = this.audioContext.createOscillator();
if (!this.oscillator.start) {
this.oscillator.start = this.oscillator.noteOn;
diff --git a/threads.js b/threads.js
index 3324ac6..56ff45a 100644
--- a/threads.js
+++ b/threads.js
@@ -2716,10 +2716,11 @@ Process.prototype.doPlayNote = function (pitch, beats) {
Process.prototype.doPlayNoteForSecs = function (pitch, secs) {
// interpolated
+ var volume = this.homeContext.receiver.volume;
if (!this.context.startTime) {
this.context.startTime = Date.now();
this.context.activeNote = new Note(pitch);
- this.context.activeNote.play();
+ this.context.activeNote.play(volume);
}
if ((Date.now() - this.context.startTime) >= (secs * 1000)) {
if (this.context.activeNote) {