amplify beat heat sound, tweak detune/playback rate, bump aframe for pooling fix (my overlay branch, rename to aframe-master to keep source map alive and easier copying)

This commit is contained in:
Kevin Ngo
2018-10-11 23:22:54 -07:00
parent 7e09031c3e
commit 5eec114f1a
5 changed files with 103 additions and 71 deletions

Binary file not shown.

View File

@@ -1,5 +1,32 @@
var audioContext = new window.AudioContext();
// 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.' );
return;
}
if ( this.hasPlaybackControl === false ) {
console.warn( 'THREE.Audio: this Audio has no playback control.' );
return;
}
var source = this.context.createBufferSource();
source.buffer = this.buffer;
source.detune.value = this.detune;
source.loop = this.loop;
source.onended = this.onEnded.bind( this );
source.playbackRate.setValueAtTime( this.playbackRate, this.startTime );
this.startTime = this.context.currentTime;
source.start( this.startTime, this.offset );
this.isPlaying = true;
this.source = source;
return this.connect();
};
/**
* Beat hit sound using positional audio and audio buffer source.
* Pitch the sound up and down using the song audioanalyser FFT.
@@ -20,9 +47,10 @@ AFRAME.registerComponent('beat-hit', {
});
},
processSound: function (sound) {
this.currentBeatEl.object3D.getWorldPosition(sound.position);
console.log(sound.position);
// this.currentBeatEl.setObject3D('sound', sound);
processSound: function (audio) {
// Randomize a bit.
audio.detune = (Math.random() * 1000) - 500;
audio.playbackRate = 0.80 + (Math.random() * .20);
this.currentBeatEl.object3D.getWorldPosition(audio.position);
}
});

View File

@@ -2,7 +2,11 @@
<html>
<head>
<title>Super Saber</title>
<script src="vendor/aframe.effects.js"></script>
{% if IS_PRODUCTION %}
<script src="vendor/aframe-master.min.js"></script>
{% else %}
<script src="vendor/aframe-master.js"></script>
{% endif %}
<script src="build/build.js"></script>
</head>
<body>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long