Skip to content

Commit

Permalink
add noises
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Feb 13, 2024
1 parent e7d75ef commit 9623d3c
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 13 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"lodash": "^4.17.21",
"masonry-layout": "^4.2.2",
"nostr-fetch": "^0.15.0",
"nostr-tools": "^1.5.0",
"svelte": "^4.2.8"
"nostr-tools": "2.1.5",
"svelte": "^4.2.8",
"svelte-sound": "^0.6.0"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.0.1",
Expand Down
35 changes: 35 additions & 0 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
import Masonry from "masonry-layout";
import { Sound } from "svelte-sound";
import tone_file from "./assets/tone.mp3";
const tone = new Sound(tone_file);
import { generateBackground } from "./utils";
const MONITOR =
Expand Down Expand Up @@ -100,6 +106,7 @@
}
if (!initialSyncComplete) return;
processBatch();
if(!isMuted) tone.play()
// console.log(event.id)
};
Expand Down Expand Up @@ -291,6 +298,7 @@
function processBatch() {
if (!initialSyncComplete) initialSyncComplete = true;
k30066.update((currentk30066) => [...currentk30066]);
}
function calculateDimensions(event) {
Expand Down Expand Up @@ -366,6 +374,14 @@
return rtt ? `${letter}:${rtt}ms` : "";
}
let isMuted = true; // Initial state of the sound, assuming it starts muted
// Function to toggle the muted state
function toggleMute() {
isMuted = !isMuted;
// Here, you can also add logic to actually control the audio
}
window.addEventListener("resize", () => {
if (masonry) {
masonry.layout();
Expand All @@ -374,6 +390,9 @@
</script>
{#if initialSyncComplete}
<button on:click={toggleMute} class="mute">
{isMuted ? '🔇' : '🔈'}
</button>
<div id="header">
<span class="sitetitle">nostrpul.se</span>
<span class="credit">by nostr.watch</span>
Expand Down Expand Up @@ -665,6 +684,18 @@
font-size: clamp(6rem, 12vw, 25em); /* Responsive font size */
}
.mute {
display:inline;
background:none;
border:none;
position:absolute;
top:10px;
left:50%;
transform: translateX(-50%);
z-index: 100;
font-size:3em;
}
@media (max-width: 600px) {
#stats {
flex-direction: column;
Expand Down Expand Up @@ -721,5 +752,9 @@
display: inline-block;
font-weight: bolder;
}
.mute {
display:none;
}
}
</style>
Binary file added src/assets/tone.mp3
Binary file not shown.
5 changes: 4 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { svelte } from '@sveltejs/vite-plugin-svelte'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte()]
plugins: [svelte()],
optimizeDeps: {
exclude: ['svelte-sound']
}
// base: '/nip66-dataviz-demo/'
})
51 changes: 41 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@
resolved "https://registry.yarnpkg.com/@noble/ciphers/-/ciphers-0.2.0.tgz#a12cda60f3cf1ab5d7c77068c3711d2366649ed7"
integrity sha512-6YBxJDAapHSdd3bLDv6x2wRPwq4QFMUaB3HvljNBUTThDd12eSm7/3F+2lnfzx2jvM+S6Nsy0jEt9QbPqSwqRw==

"@noble/curves@1.1.0", "@noble/curves@~1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.1.0.tgz#f13fc667c89184bc04cccb9b11e8e7bae27d8c3d"
integrity sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==
"@noble/curves@1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.2.0.tgz#92d7e12e4e49b23105a2555c6984d41733d65c35"
integrity sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==
dependencies:
"@noble/hashes" "1.3.1"
"@noble/hashes" "1.3.2"

"@noble/curves@^1.1.0":
version "1.3.0"
Expand All @@ -176,11 +176,23 @@
dependencies:
"@noble/hashes" "1.3.3"

"@noble/curves@~1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.1.0.tgz#f13fc667c89184bc04cccb9b11e8e7bae27d8c3d"
integrity sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==
dependencies:
"@noble/hashes" "1.3.1"

"@noble/[email protected]":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.1.tgz#8831ef002114670c603c458ab8b11328406953a9"
integrity sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==

"@noble/[email protected]":
version "1.3.2"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39"
integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==

"@noble/[email protected]", "@noble/hashes@^1.2.0", "@noble/hashes@~1.3.0", "@noble/hashes@~1.3.1":
version "1.3.3"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699"
Expand Down Expand Up @@ -685,6 +697,11 @@ get-size@^2.0.0, get-size@^2.0.2:
resolved "https://registry.yarnpkg.com/get-size/-/get-size-2.0.3.tgz#54a1d0256b20ea7ac646516756202769941ad2ef"
integrity sha512-lXNzT/h/dTjTxRbm9BXb+SGxxzkm97h/PCIKtlN/CBCxxmkkIVV21udumMS93MuVTDX583gqc94v3RjuHmI+2Q==

howler@^2.2.3:
version "2.2.4"
resolved "https://registry.yarnpkg.com/howler/-/howler-2.2.4.tgz#bd3df4a4f68a0118a51e4bd84a2bfc2e93e6e5a1"
integrity sha512-iARIBPgcQrwtEr+tALF+rapJ8qSc+Set2GJQl7xT1MQzWaVkFebdJhR3alVlSiUf5U7nAANKuj3aWpwerocD5w==

[email protected]:
version "0.6.3"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501"
Expand Down Expand Up @@ -772,17 +789,24 @@ nostr-fetch@^0.15.0:
dependencies:
"@nostr-fetch/kernel" "^0.15.0"

nostr-tools@^1.5.0:
version "1.17.0"
resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-1.17.0.tgz#b6f62e32fedfd9e68ec0a7ce57f74c44fc768e8c"
integrity sha512-LZmR8GEWKZeElbFV5Xte75dOeE9EFUW/QLI1Ncn3JKn0kFddDKEfBbFN8Mu4TMs+L4HR/WTPha2l+PPuRnJcMw==
nostr-tools@2.1.5:
version "2.1.5"
resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-2.1.5.tgz#d38ac1139343cf13654841b8727bab8dd70563eb"
integrity sha512-Gug/j54YGQ0ewB09dZW3mS9qfXWFlcOQMlyb1MmqQsuNO/95mfNOQSBi+jZ61O++Y+jG99SzAUPFLopUsKf0MA==
dependencies:
"@noble/ciphers" "0.2.0"
"@noble/curves" "1.1.0"
"@noble/curves" "1.2.0"
"@noble/hashes" "1.3.1"
"@scure/base" "1.1.1"
"@scure/bip32" "1.3.1"
"@scure/bip39" "1.2.1"
optionalDependencies:
nostr-wasm v0.1.0

[email protected]:
version "0.1.0"
resolved "https://registry.yarnpkg.com/nostr-wasm/-/nostr-wasm-0.1.0.tgz#17af486745feb2b7dd29503fdd81613a24058d94"
integrity sha512-78BTryCLcLYv96ONU8Ws3Q1JzjlAt+43pWQhIl86xZmWeegYCNLPml7yQ+gG3vR6V5h4XGj+TxO+SS5dsThQIA==

outlayer@^2.1.0:
version "2.1.1"
Expand Down Expand Up @@ -863,6 +887,13 @@ svelte-hmr@^0.15.3:
resolved "https://registry.yarnpkg.com/svelte-hmr/-/svelte-hmr-0.15.3.tgz#df54ccde9be3f091bf5f18fc4ef7b8eb6405fbe6"
integrity sha512-41snaPswvSf8TJUhlkoJBekRrABDXDMdpNpT2tfHIv4JuhgvHqLMhEPGtaQn0BmbNSTkuz2Ed20DF2eHw0SmBQ==

svelte-sound@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/svelte-sound/-/svelte-sound-0.6.0.tgz#a80390898850915aed11fe05ac3f478dd8bb4db4"
integrity sha512-n0JJwWwNEmsGntSN9oe57yevHrIg8Lw3tW2XsfdrDhJXwrbAAmLvbBJQ0Z3TFqONUW7+OWb5Yx04CSCo7q56fA==
dependencies:
howler "^2.2.3"

svelte@^4.2.8:
version "4.2.9"
resolved "https://registry.yarnpkg.com/svelte/-/svelte-4.2.9.tgz#ece982ccc5b700c27e85cdf130c0e343c195fab5"
Expand Down

0 comments on commit 9623d3c

Please sign in to comment.