-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add basic sample waveform visualisation * Toggle help modal * Improve responsive design * Stop editing sound label text on 'Enter' key
- Loading branch information
Showing
28 changed files
with
621 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,70 @@ | ||
#root { | ||
--max-width: 660px; | ||
margin: 0 auto; | ||
text-align: center; | ||
height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
width: 66vw; | ||
max-width: var(--max-width); | ||
.content { | ||
flex: 1; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
@media (max-width: 900px) { | ||
width: 75vw; | ||
} | ||
.navbar { | ||
background-color: var(--bg-color-2); | ||
height: 50px; | ||
display: flex; | ||
align-items: center; | ||
padding: 0 20px; | ||
|
||
@media (max-width: 768px) { | ||
width: 80vw; | ||
& ul { | ||
display: flex; | ||
list-style: none; | ||
margin-left: auto; | ||
} | ||
|
||
@media (max-width: 480px) { | ||
width: 90vw; | ||
} | ||
& li { | ||
text-decoration: none; | ||
margin: 0 10px; | ||
|
||
&.icon { | ||
& i { | ||
font-size: 36; | ||
} | ||
|
||
@media (max-width: 320px) { | ||
width: 98vw; | ||
& a { | ||
cursor: pointer; | ||
color: var(--text-white); | ||
display: flex; | ||
align-items: center; | ||
|
||
transition: color 0.25s; | ||
&:hover { | ||
color: var(--purple); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
.App { | ||
.header-title { | ||
margin: 0; | ||
} | ||
|
||
footer { | ||
background-color: var(--bg-color-2); | ||
text-align: left; | ||
height: 50px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.buttonGrid { | ||
width: 100%; | ||
display: grid; | ||
margin-top: clamp(0.125em, 2vh, 3em); | ||
gap: clamp(0.125em, 2vh, 3em) clamp(0.125em, 2vw, 3em); | ||
@media (max-height: 680px) { | ||
display: none; | ||
} | ||
|
||
grid-template-columns: repeat(4, 1fr); | ||
/* 3 column grid on small screens */ | ||
@media (max-width: 480px) { | ||
grid-template-columns: repeat(3, 1fr); | ||
@media (max-width: 480px) and (max-height: 740px) { | ||
display: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,38 @@ | ||
import 'primeflex/primeflex.css'; | ||
import { createEffect, createSignal } from 'solid-js'; | ||
import { Dynamic } from 'solid-js/web'; | ||
import { AudioContextManager } from 'src/audio'; | ||
import { BiLogosGithub, BiRegularHelpCircle } from 'solid-icons/bi'; | ||
import { createSignal } from 'solid-js'; | ||
|
||
import { ButtonPad, Modal, ParamPanel, SampleExplorer } from 'src/components'; | ||
import { NUM_PADS } from 'src/defaults/constants'; | ||
import { useAudioContext } from 'src/hooks'; | ||
import { SamplerModel } from 'src/models'; | ||
import { HelpModal, Sampler } from 'src/components'; | ||
import { appInit } from 'src/utils'; | ||
import { Defaults } from 'src/defaults/Defaults'; | ||
|
||
import './App.css'; | ||
|
||
export function App() { | ||
const appInitialized = appInit(); // Asyncronously load default samples | ||
const audioContext = useAudioContext(); | ||
|
||
// load files on context load | ||
createEffect(() => { | ||
// Add our reactive AudioContext | ||
const ctx = audioContext(); | ||
if (!ctx) { | ||
return; | ||
} | ||
samplers.forEach(async (model) => { | ||
model.audioContext.value = ctx; | ||
await appInitialized; | ||
model.loadBuffer(); | ||
}); | ||
}); | ||
|
||
// Initialise samplers | ||
const samplers = Defaults.samples | ||
.slice(0, NUM_PADS) | ||
.map(({ filename, label }) => new SamplerModel(filename, label)); | ||
|
||
const paramPanels = samplers.map((model) => () => ( | ||
<ParamPanel model={model} /> | ||
)); | ||
|
||
// Index of the selected sampler | ||
const [selectedIdx, setSelectedIndex] = createSignal(0); | ||
// Display help modal | ||
const [showHelp, setShowHelp] = createSignal(true); | ||
|
||
return ( | ||
<> | ||
<Modal | ||
show={showHelp()} | ||
onClose={() => { | ||
if (!AudioContextManager.initialized.value) { | ||
AudioContextManager.init(); | ||
} | ||
setShowHelp(false); | ||
}} | ||
buttonText="Ok" | ||
> | ||
<div class="grid"> | ||
<div class="col"> | ||
<h1>Help</h1> | ||
<ul class="text-left"> | ||
<li>Play sounds by hitting the pads</li> | ||
<li>Edit sounds in the control panel</li> | ||
<li>Load new sounds from the sample explorer</li> | ||
<li>Upload your own sounds</li> | ||
<li>Rename pads via the control panel</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</Modal> | ||
<div class="App"> | ||
<h1>SoundBored</h1> | ||
<div class="parameterPanel grid grid-nogutter"> | ||
<SampleExplorer selectedSampler={samplers[selectedIdx()]} /> | ||
<Dynamic component={paramPanels[selectedIdx()]} /> | ||
</div> | ||
<div class="buttonGrid"> | ||
{samplers.map((x, i) => ( | ||
<ButtonPad | ||
model={x} | ||
onClick={() => { | ||
setSelectedIndex(i); | ||
}} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
<HelpModal show={showHelp()} setShow={setShowHelp} /> | ||
<header class="navbar"> | ||
<h1 class="header-title">SoundBored</h1> | ||
<ul> | ||
<li class="icon"> | ||
<a href="https://github.com/grddavies/soundbored"> | ||
<BiLogosGithub size={36} /> | ||
</a> | ||
</li> | ||
<li class="icon"> | ||
<a onClick={() => setShowHelp(true)}> | ||
<BiRegularHelpCircle size={36} /> | ||
</a> | ||
</li> | ||
</ul> | ||
</header> | ||
<main role="main" class="content"> | ||
<Sampler appInitialized={appInitialized} /> | ||
</main> | ||
<footer /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Component, Setter } from 'solid-js'; | ||
import { AudioContextManager } from 'src/audio'; | ||
|
||
import { Modal } from './Modal'; | ||
|
||
type HelpModalProps = { | ||
show: boolean; | ||
setShow: Setter<boolean>; | ||
}; | ||
|
||
/** | ||
* Toggleable help modal dialogue | ||
* @param props | ||
* @returns | ||
*/ | ||
export const HelpModal: Component<HelpModalProps> = (props) => ( | ||
<Modal | ||
show={props.show} | ||
onClose={() => { | ||
if (!AudioContextManager.initialized.value) { | ||
AudioContextManager.init(); | ||
} | ||
props.setShow(false); | ||
}} | ||
buttonText="Ok" | ||
> | ||
<div class="grid"> | ||
<div class="col"> | ||
<h2 class="pb-2">SoundBored</h2> | ||
<div class="text-left"> | ||
<div class="py-2">Trigger samples by hitting the pads</div> | ||
<div class="py-2">Load new sounds from the sample explorer</div> | ||
<div class="py-2">Record and upload your own samples</div> | ||
</div> | ||
</div> | ||
</div> | ||
</Modal> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.