Skip to content

Commit

Permalink
Add startup sound
Browse files Browse the repository at this point in the history
Thanks to Truck!

(Will only play if nin is not already muted on launch)
  • Loading branch information
stianjensen committed Jul 17, 2022
1 parent 58543da commit 9977f3d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions renin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@types/three": "^0.139.0",
"prettier": "^2.6.2",
"rollup": "^2.70.2",
"rollup-plugin-base64": "1.0.1",
"rollup-plugin-import-css": "^3.0.3",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-string": "^3.0.0",
Expand Down
2 changes: 2 additions & 0 deletions renin/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import typescript from '@rollup/plugin-typescript';
import { string as stringPlugin } from 'rollup-plugin-string';
import css from 'rollup-plugin-import-css';
import { base64 } from 'rollup-plugin-base64';

export default {
treeshake: false,
Expand All @@ -17,6 +18,7 @@ export default {
stringPlugin({
include: '**/*.glsl',
}),
base64({ include: '**/*.mp3' }),
css(),
],
};
15 changes: 14 additions & 1 deletion renin/src/renin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { thirdsOverlayTexture } from './ui/thirdsOverlay';
import { performancePanelTexture } from './ui/performancePanelTexture';
import { ColorManagement } from 'three/src/math/ColorManagement';
import { getSetting, setSetting } from './ui/storedSettings';
import reninSoundUrl from './ui/renin.mp3';

/* otherwise it won't be added to the build */
export * as vite from './ui/vite';
Expand Down Expand Up @@ -201,7 +202,19 @@ export class Renin {

this.scene.add(this.audioBar.obj);

this.music.setVolume(getSetting('volume'));
const initialVolume = getSetting('volume');
this.music.setVolume(initialVolume);

if (this.options.productionMode) {
return false;
}
if (!this.options.productionMode && initialVolume) {
(async () => {
const startupSound = new Audio();
startupSound.autoplay = true;
startupSound.src = 'data:audio/mp3;base64,' + reninSoundUrl;
})();
}

(async () => {
const response = await fetch(options.music.src);
Expand Down
Binary file added renin/src/ui/renin.mp3
Binary file not shown.
7 changes: 7 additions & 0 deletions renin/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@ resolve@^1.17.0, resolve@^1.22.0:
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"

rollup-plugin-base64@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-base64/-/rollup-plugin-base64-1.0.1.tgz#b3529b94d23baeb66e1e3bffd04477fa792985eb"
integrity sha512-IbdX8fjuXO/Op3hYmRPjVo0VwcSenwsQDaDTFdoe+70B5ZGoLMtr96L2yhHXCfxv7HwZVvxZqLsuWj6VwzRt3g==
dependencies:
"@rollup/pluginutils" "^3.1.0"

rollup-plugin-import-css@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/rollup-plugin-import-css/-/rollup-plugin-import-css-3.0.3.tgz#603c96e5ca55a8b1a1fda94221189f3224532fcf"
Expand Down

0 comments on commit 9977f3d

Please sign in to comment.