Skip to content

Commit

Permalink
feat: settings drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
fcastrovilli committed May 2, 2024
1 parent 6551042 commit bad9286
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/lib/polysynth.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
const cmaj = Scale.get('C5 major');
poly.set({
envelope: {
...$synth_options
},
volume: -24
});
$: {
poly.set({
envelope: {
...$synth_options
},
volume: -24
});
}
function attack(note: string) {
poly.triggerAttack(note);
Expand Down
64 changes: 64 additions & 0 deletions src/lib/settings.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<script lang="ts">
import { synth_options } from './store';
const maxTime = 10;
</script>

<div class="flex flex-col gap-4 p-5">
<div class="flex flex-col gap-2">
<label for="attack" class="capitalize"
>Attack <small class="px-4">{$synth_options.attack}</small></label
>
<input
type="range"
class="range"
id="attack"
min="0"
max={maxTime}
step="0.1"
bind:value={$synth_options.attack}
/>
</div>
<div class="flex flex-col gap-2">
<label for="release" class="capitalize"
>Release <small class="px-4">{$synth_options.release}</small></label
>
<input
type="range"
class="range"
id="release"
min="0"
max={maxTime}
step="0.1"
bind:value={$synth_options.release}
/>
</div>
<div class="flex flex-col gap-2">
<label for="decay" class="capitalize"
>Decay <small class="px-4">{$synth_options.decay}</small></label
>
<input
type="range"
class="range"
id="decay"
min="0"
max={maxTime}
step="0.1"
bind:value={$synth_options.decay}
/>
</div>

<div class="flex flex-col gap-2">
<label for="sustain" class="capitalize"
>Sustain <small class="px-4">{$synth_options.sustain}</small></label
>
<input
type="range"
class="range"
id="sustain"
min="0"
max="1"
step="0.1"
bind:value={$synth_options.sustain}
/>
</div>
</div>
7 changes: 7 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
import '../app.postcss';
import Start from '$lib/start.svelte';
import { app_started } from '$lib/store';
import { initializeStores, Drawer } from '@skeletonlabs/skeleton';
import Settings from '$lib/settings.svelte';
initializeStores();
</script>

{#if $app_started}
<Drawer>
<Settings />
</Drawer>
<slot />
{:else}
<Start />
Expand Down
12 changes: 12 additions & 0 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
<script lang="ts">
import Polysynth from '$lib/polysynth.svelte';
import { getDrawerStore, type DrawerSettings } from '@skeletonlabs/skeleton';
const drawerStore = getDrawerStore();
const drawerSettings: DrawerSettings = {
position: 'right',
width: 'w-full max-w-sm md:max-w-md'
};
</script>

<div class="fixed top-5 left-5">
<button on:click={() => drawerStore.open(drawerSettings)} class="btn variant-filled"
>Settings</button
>
</div>
<Polysynth />

0 comments on commit bad9286

Please sign in to comment.