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 May 27, 2023
1 parent 8c88267 commit a5b9a87
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions renin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@types/three": "^0.144.0",
"prettier": "^2.7.1",
"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(),
],
};
12 changes: 11 additions & 1 deletion renin/src/renin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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 @@ -247,7 +248,16 @@ 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 && 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.
9 changes: 8 additions & 1 deletion renin/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"@rollup/pluginutils" "^4.2.1"
resolve "^1.22.1"

"@rollup/pluginutils@^3.0.9":
"@rollup/pluginutils@^3.0.9", "@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
Expand Down Expand Up @@ -494,6 +494,13 @@ resolve@^1.22.1:
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"

[email protected]:
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 a5b9a87

Please sign in to comment.