Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(audio): New sound set and option to change sounds #372

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/settings/settingsPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ notificationsStore.updateEnabled()
}
}"
/>
<SettingsItem :type="Control.Option" :choices="{musical: SoundSet.Musical, sharp: SoundSet.Sharp}" path="audio.soundSet" />
</template>

<template v-if="isMobile">
Expand Down
8 changes: 5 additions & 3 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,14 @@
},
"soundSet": {
"_title": "Sound set",
"_description": "Sounds used for notifications",
"_description": "Sounds played at the end of each session",
"_values": {
"musical": "Musical"
"musical": "Musical",
"sharp": "Sharp"
},
"_valueDescription": {
"musical": "The default sounds"
"musical": "The default sounds",
"sharp": "Shorter, beep-like sounds better for training"
}
}
},
Expand Down
10 changes: 7 additions & 3 deletions platforms/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export function useWeb () {
}
})

watch(() => settingsStore.audio.soundSet, (newSoundSet) => {
loadSoundSet(newSoundSet)
})

eventsStore.$subscribe(() => {
if (eventsStore.lastEvent !== null && eventsStore.lastEvent._event === EventType.NOTIFICATIONS_ENABLED && window.Notification && window.Notification.permission === 'default') {
window.Notification.requestPermission().then((newNotificationPermission) => {
Expand Down Expand Up @@ -75,7 +79,7 @@ export function useWeb () {

// check if timer is already running
if (scheduleStore.timerState === 1) {
loadSoundSet()
loadSoundSet(settingsStore.audio.soundSet)
}

// Check Visibility and register in store
Expand Down Expand Up @@ -118,7 +122,7 @@ export function useWeb () {

state.currentSoundSet = setName
} catch (err) {
// console.warn(err)
console.warn(err)
}
}

Expand All @@ -129,7 +133,7 @@ export function useWeb () {
const playSound = (key: keyof typeof state.sounds) => {
// load sound set if not already loaded
if (!state.currentSoundSet) {
loadSoundSet()
loadSoundSet(settingsStore.audio.soundSet)
}

if (state.sounds[key] !== null && settingsStore.permissions.audio) {
Expand Down
Binary file added public/audio/sharp/longpause.mp3
Binary file not shown.
Binary file added public/audio/sharp/shortpause.mp3
Binary file not shown.
Binary file added public/audio/sharp/work.mp3
Binary file not shown.
5 changes: 2 additions & 3 deletions stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export enum SectionEndAction {
}

export enum SoundSet {
Musical = 'musical'
Musical = 'musical',
Sharp = 'sharp'
}

export enum Section {
Expand Down Expand Up @@ -73,7 +74,6 @@ export interface Settings {
},
audio: {
volume: number,
repeatTimes: number,
soundSet: SoundSet
},
timerControls: {
Expand Down Expand Up @@ -154,7 +154,6 @@ export const useSettings = defineStore('settings', {
},
audio: {
volume: 0.9,
repeatTimes: 2,
soundSet: SoundSet.Musical
},
timerControls: {
Expand Down
Loading