diff --git a/assets/sounds/LastHit1.ogg b/assets/sounds/LastHit1.ogg
deleted file mode 100644
index 52f240f..0000000
Binary files a/assets/sounds/LastHit1.ogg and /dev/null differ
diff --git a/assets/sounds/LastHit10.ogg b/assets/sounds/LastHit10.ogg
deleted file mode 100644
index 275aea4..0000000
Binary files a/assets/sounds/LastHit10.ogg and /dev/null differ
diff --git a/assets/sounds/LastHit2.ogg b/assets/sounds/LastHit2.ogg
deleted file mode 100644
index 1ff7ca5..0000000
Binary files a/assets/sounds/LastHit2.ogg and /dev/null differ
diff --git a/assets/sounds/LastHit3.ogg b/assets/sounds/LastHit3.ogg
deleted file mode 100644
index 643b9f5..0000000
Binary files a/assets/sounds/LastHit3.ogg and /dev/null differ
diff --git a/assets/sounds/LastHit4.ogg b/assets/sounds/LastHit4.ogg
deleted file mode 100644
index 241a921..0000000
Binary files a/assets/sounds/LastHit4.ogg and /dev/null differ
diff --git a/assets/sounds/LastHit5.ogg b/assets/sounds/LastHit5.ogg
deleted file mode 100644
index 4a0ef5b..0000000
Binary files a/assets/sounds/LastHit5.ogg and /dev/null differ
diff --git a/assets/sounds/LastHit6.ogg b/assets/sounds/LastHit6.ogg
deleted file mode 100644
index 22d9016..0000000
Binary files a/assets/sounds/LastHit6.ogg and /dev/null differ
diff --git a/assets/sounds/LastHit7.ogg b/assets/sounds/LastHit7.ogg
deleted file mode 100644
index 2989336..0000000
Binary files a/assets/sounds/LastHit7.ogg and /dev/null differ
diff --git a/assets/sounds/LastHit8.ogg b/assets/sounds/LastHit8.ogg
deleted file mode 100644
index 68585b9..0000000
Binary files a/assets/sounds/LastHit8.ogg and /dev/null differ
diff --git a/assets/sounds/LastHit9.ogg b/assets/sounds/LastHit9.ogg
deleted file mode 100644
index 7962401..0000000
Binary files a/assets/sounds/LastHit9.ogg and /dev/null differ
diff --git a/assets/sounds/hit1.ogg b/assets/sounds/hit1.ogg
index 5eaf8fe..6e1504d 100644
Binary files a/assets/sounds/hit1.ogg and b/assets/sounds/hit1.ogg differ
diff --git a/assets/sounds/hit10.ogg b/assets/sounds/hit10.ogg
index 7c5005a..17f4f38 100644
Binary files a/assets/sounds/hit10.ogg and b/assets/sounds/hit10.ogg differ
diff --git a/assets/sounds/hit10left.ogg b/assets/sounds/hit10left.ogg
new file mode 100644
index 0000000..e657d60
Binary files /dev/null and b/assets/sounds/hit10left.ogg differ
diff --git a/assets/sounds/hit10right.ogg b/assets/sounds/hit10right.ogg
new file mode 100644
index 0000000..b8c9bc0
Binary files /dev/null and b/assets/sounds/hit10right.ogg differ
diff --git a/assets/sounds/hit1left.ogg b/assets/sounds/hit1left.ogg
new file mode 100644
index 0000000..9f7051b
Binary files /dev/null and b/assets/sounds/hit1left.ogg differ
diff --git a/assets/sounds/hit1right.ogg b/assets/sounds/hit1right.ogg
new file mode 100644
index 0000000..b4f8efe
Binary files /dev/null and b/assets/sounds/hit1right.ogg differ
diff --git a/assets/sounds/hit2.ogg b/assets/sounds/hit2.ogg
index c57b642..10af045 100644
Binary files a/assets/sounds/hit2.ogg and b/assets/sounds/hit2.ogg differ
diff --git a/assets/sounds/hit2left.ogg b/assets/sounds/hit2left.ogg
new file mode 100644
index 0000000..cb2f958
Binary files /dev/null and b/assets/sounds/hit2left.ogg differ
diff --git a/assets/sounds/hit2right.ogg b/assets/sounds/hit2right.ogg
new file mode 100644
index 0000000..faaf333
Binary files /dev/null and b/assets/sounds/hit2right.ogg differ
diff --git a/assets/sounds/hit3.ogg b/assets/sounds/hit3.ogg
index 94146d3..9eb2dff 100644
Binary files a/assets/sounds/hit3.ogg and b/assets/sounds/hit3.ogg differ
diff --git a/assets/sounds/hit3left.ogg b/assets/sounds/hit3left.ogg
new file mode 100644
index 0000000..bd45255
Binary files /dev/null and b/assets/sounds/hit3left.ogg differ
diff --git a/assets/sounds/hit3right.ogg b/assets/sounds/hit3right.ogg
new file mode 100644
index 0000000..7af8475
Binary files /dev/null and b/assets/sounds/hit3right.ogg differ
diff --git a/assets/sounds/hit4.ogg b/assets/sounds/hit4.ogg
index cfb2a50..1f6f868 100644
Binary files a/assets/sounds/hit4.ogg and b/assets/sounds/hit4.ogg differ
diff --git a/assets/sounds/hit4left.ogg b/assets/sounds/hit4left.ogg
new file mode 100644
index 0000000..944b35f
Binary files /dev/null and b/assets/sounds/hit4left.ogg differ
diff --git a/assets/sounds/hit4right.ogg b/assets/sounds/hit4right.ogg
new file mode 100644
index 0000000..94f0387
Binary files /dev/null and b/assets/sounds/hit4right.ogg differ
diff --git a/assets/sounds/hit5.ogg b/assets/sounds/hit5.ogg
index 857fc99..0e2db75 100644
Binary files a/assets/sounds/hit5.ogg and b/assets/sounds/hit5.ogg differ
diff --git a/assets/sounds/hit5left.ogg b/assets/sounds/hit5left.ogg
new file mode 100644
index 0000000..e16b4b6
Binary files /dev/null and b/assets/sounds/hit5left.ogg differ
diff --git a/assets/sounds/hit5right.ogg b/assets/sounds/hit5right.ogg
new file mode 100644
index 0000000..4a9b0b3
Binary files /dev/null and b/assets/sounds/hit5right.ogg differ
diff --git a/assets/sounds/hit6.ogg b/assets/sounds/hit6.ogg
index 5d842ea..b2567db 100644
Binary files a/assets/sounds/hit6.ogg and b/assets/sounds/hit6.ogg differ
diff --git a/assets/sounds/hit6left.ogg b/assets/sounds/hit6left.ogg
new file mode 100644
index 0000000..5e75ce7
Binary files /dev/null and b/assets/sounds/hit6left.ogg differ
diff --git a/assets/sounds/hit6right.ogg b/assets/sounds/hit6right.ogg
new file mode 100644
index 0000000..0885a73
Binary files /dev/null and b/assets/sounds/hit6right.ogg differ
diff --git a/assets/sounds/hit7.ogg b/assets/sounds/hit7.ogg
index 0c075bb..435e16c 100644
Binary files a/assets/sounds/hit7.ogg and b/assets/sounds/hit7.ogg differ
diff --git a/assets/sounds/hit7left.ogg b/assets/sounds/hit7left.ogg
new file mode 100644
index 0000000..00a7508
Binary files /dev/null and b/assets/sounds/hit7left.ogg differ
diff --git a/assets/sounds/hit7right.ogg b/assets/sounds/hit7right.ogg
new file mode 100644
index 0000000..95f7ba9
Binary files /dev/null and b/assets/sounds/hit7right.ogg differ
diff --git a/assets/sounds/hit8.ogg b/assets/sounds/hit8.ogg
index 5345ff4..5046ee5 100644
Binary files a/assets/sounds/hit8.ogg and b/assets/sounds/hit8.ogg differ
diff --git a/assets/sounds/hit8left.ogg b/assets/sounds/hit8left.ogg
new file mode 100644
index 0000000..c10486a
Binary files /dev/null and b/assets/sounds/hit8left.ogg differ
diff --git a/assets/sounds/hit8right.ogg b/assets/sounds/hit8right.ogg
new file mode 100644
index 0000000..e4ab87a
Binary files /dev/null and b/assets/sounds/hit8right.ogg differ
diff --git a/assets/sounds/hit9.ogg b/assets/sounds/hit9.ogg
index ad6d811..bd4950b 100644
Binary files a/assets/sounds/hit9.ogg and b/assets/sounds/hit9.ogg differ
diff --git a/assets/sounds/hit9left.ogg b/assets/sounds/hit9left.ogg
new file mode 100644
index 0000000..44ddd6d
Binary files /dev/null and b/assets/sounds/hit9left.ogg differ
diff --git a/assets/sounds/hit9right.ogg b/assets/sounds/hit9right.ogg
new file mode 100644
index 0000000..3861c31
Binary files /dev/null and b/assets/sounds/hit9right.ogg differ
diff --git a/src/assets.html b/src/assets.html
index 832519e..4d6d14b 100644
--- a/src/assets.html
+++ b/src/assets.html
@@ -18,10 +18,38 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/beat-hit-sound.js b/src/components/beat-hit-sound.js
index 3898404..9396271 100644
--- a/src/components/beat-hit-sound.js
+++ b/src/components/beat-hit-sound.js
@@ -6,6 +6,7 @@ const LAYER_MIDDLE = 'middle';
const LAYER_TOP = 'top';
// Allows for modifying detune. PR has been sent to three.js.
+/*
THREE.Audio.prototype.play = function () {
if (this.isPlaying === true) {
console.warn('THREE.Audio: Audio is already playing.');
@@ -32,19 +33,41 @@ THREE.Audio.prototype.play = function () {
this.source = source;
return this.connect();
};
+*/
/**
* Beat hit sound using positional audio and audio buffer source.
*/
AFRAME.registerComponent('beat-hit-sound', {
+
+ directionsToSounds: {
+ 'up': '',
+ 'down': '',
+ 'upleft': 'left',
+ 'upright': 'right',
+ 'downleft': 'left',
+ 'downright': 'right',
+ 'left': 'left',
+ 'right': 'right'
+ },
+
init: function () {
this.currentBeatEl = null;
this.currentCutDirection = '';
- this.el.setAttribute('sound__beathit', {
- poolSize: 12,
- src: '#hitSound9',
- volume: 0.9
- });
+ for (let i = 1; i <= 10; i++) {
+ this.el.setAttribute(`sound__beathit${i}`, {
+ poolSize: 4,
+ src: `#hitSound${i}`
+ });
+ this.el.setAttribute(`sound__beathit${i}left`, {
+ poolSize: 4,
+ src: `#hitSound${i}left`
+ });
+ this.el.setAttribute(`sound__beathit${i}right`, {
+ poolSize: 4,
+ src: `#hitSound${i}right`
+ });
+ }
this.processSound = this.processSound.bind(this);
sourceCreatedCallback = this.sourceCreatedCallback.bind(this);
@@ -52,18 +75,34 @@ AFRAME.registerComponent('beat-hit-sound', {
play: function () {
// Kick three.js loader...Don't know why sometimes doesn't load.
- if (!this.el.components.sound__beathit.loaded) {
- console.log('[beat-hit-sound] Kicking three.js AudioLoader / sound component...');
- this.el.setAttribute('sound__beathit', 'src', '');
- this.el.setAttribute('sound__beathit', 'src', '#hitSound9');
+ for (let i = 1; i <= 10; i++) {
+ if (!this.el.components[`sound__beathit${i}`].loaded) {
+ console.log(`[beat-hit-sound: hit${i}] Kicking three.js AudioLoader / sound component...`);
+ this.el.setAttribute(`sound__beathit${i}`, 'src', '');
+ this.el.setAttribute(`sound__beathit${i}`, 'src', `#hitSound${i}`);
+ }
+ if (!this.el.components[`sound__beathit${i}left`].loaded) {
+ console.log(`[beat-hit-sound: hit${i}left] Kicking three.js AudioLoader / sound component...`);
+ this.el.setAttribute(`sound__beathit${i}left`, 'src', '');
+ this.el.setAttribute(`sound__beathit${i}left`, 'src', `#hitSound${i}left`);
+ }
+ if (!this.el.components[`sound__beathit${i}right`].loaded) {
+ console.log(`[beat-hit-sound: hit${i}right] Kicking three.js AudioLoader / sound component...`);
+ this.el.setAttribute(`sound__beathit${i}right`, 'src', '');
+ this.el.setAttribute(`sound__beathit${i}right`, 'src', `#hitSound${i}right`);
+ }
}
},
playSound: function (beatEl, cutDirection) {
- const soundPool = this.el.components.sound__beathit;
+ const rand = 1 + Math.floor(Math.random() * 10);
+ const dir = this.directionsToSounds[cutDirection || 'up'];
+ //console.log(`sound__beathit${rand}${dir}`);
+ const soundPool = this.el.components[`sound__beathit${rand}${dir}`];
this.currentBeatEl = beatEl;
this.currentCutDirection = cutDirection;
- soundPool.playSound(this.processSound);
+ //soundPool.playSound(this.processSound);
+ soundPool.playSound();
},
processSound: function (audio) {
diff --git a/src/index.html b/src/index.html
index 30f42e4..485b0c0 100644
--- a/src/index.html
+++ b/src/index.html
@@ -60,7 +60,37 @@
id="beatContainer"
beat-hit-sound
bind__pause="isPaused: !isPlaying"
- sound__beathit="poolSize: 12; src: assets/sounds/hit9.ogg">
+ sound__beathit1="poolSize: 4; src: assets/sounds/hit1.ogg"
+ sound__beathit2="poolSize: 4; src: assets/sounds/hit2.ogg"
+ sound__beathit3="poolSize: 4; src: assets/sounds/hit3.ogg"
+ sound__beathit4="poolSize: 4; src: assets/sounds/hit4.ogg"
+ sound__beathit5="poolSize: 4; src: assets/sounds/hit5.ogg"
+ sound__beathit6="poolSize: 4; src: assets/sounds/hit6.ogg"
+ sound__beathit7="poolSize: 4; src: assets/sounds/hit7.ogg"
+ sound__beathit8="poolSize: 4; src: assets/sounds/hit8.ogg"
+ sound__beathit9="poolSize: 4; src: assets/sounds/hit9.ogg"
+ sound__beathit10="poolSize: 4; src: assets/sounds/hit10.ogg"
+ sound__beathit1left="poolSize: 4; src: assets/sounds/hit1left.ogg"
+ sound__beathit2left="poolSize: 4; src: assets/sounds/hit2left.ogg"
+ sound__beathit3left="poolSize: 4; src: assets/sounds/hit3left.ogg"
+ sound__beathit4left="poolSize: 4; src: assets/sounds/hit4left.ogg"
+ sound__beathit5left="poolSize: 4; src: assets/sounds/hit5left.ogg"
+ sound__beathit6left="poolSize: 4; src: assets/sounds/hit6left.ogg"
+ sound__beathit7left="poolSize: 4; src: assets/sounds/hit7left.ogg"
+ sound__beathit8left="poolSize: 4; src: assets/sounds/hit8left.ogg"
+ sound__beathit9left="poolSize: 4; src: assets/sounds/hit9left.ogg"
+ sound__beathit10left="poolSize: 4; src: assets/sounds/hit10left.ogg"
+ sound__beathit1right="poolSize: 4; src: assets/sounds/hit1right.ogg"
+ sound__beathit2right="poolSize: 4; src: assets/sounds/hit2right.ogg"
+ sound__beathit3right="poolSize: 4; src: assets/sounds/hit3right.ogg"
+ sound__beathit4right="poolSize: 4; src: assets/sounds/hit4right.ogg"
+ sound__beathit5right="poolSize: 4; src: assets/sounds/hit5right.ogg"
+ sound__beathit6right="poolSize: 4; src: assets/sounds/hit6right.ogg"
+ sound__beathit7right="poolSize: 4; src: assets/sounds/hit7right.ogg"
+ sound__beathit8right="poolSize: 4; src: assets/sounds/hit8right.ogg"
+ sound__beathit9right="poolSize: 4; src: assets/sounds/hit9right.ogg"
+ sound__beathit10right="poolSize: 4; src: assets/sounds/hit10right.ogg"
+ >
{% include './templates/stage.html' %}
{% include './templates/loading.html' %}
{% include './templates/score.html' %}