forked from oamaok/modulate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
2,078 additions
and
568 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,3 +1,4 @@ | ||
node_modules | ||
dist | ||
data/database.sqlite3 | ||
data/database.sqlite3 | ||
cert |
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,27 @@ | ||
# TODO | ||
|
||
## View offset stuffs: | ||
|
||
- Single transform on a container | ||
- Calculate bounding box for the cable SVG instead of using the viewport h/w. Should be easy just by iterating over socket positions. Maybe still resize so that the user cannot drag the cables outside the bounding box, so i.e. the SVG element's boundary will alway hug the viewport edge, but the minimum size will be defined by the bounding box. | ||
|
||
## Modules | ||
|
||
- Keyboard UI component (svg?) | ||
- MIDI input | ||
- Better oscillator, maybe multiple | ||
|
||
## Knobs | ||
|
||
- Exponential curves (for e.g. ADSR timings: presice short timings, impresice long ones) | ||
- Unit types (seconds, Hz, volts, etc) | ||
|
||
# Module selector | ||
|
||
- Starred items | ||
- Only accesible via hotkey? | ||
|
||
# General UI/UX | ||
|
||
- Hotkey configuration? | ||
- Global volume control |
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,59 @@ | ||
const fs = require('fs/promises') | ||
const { resolve } = require('path') | ||
const postcss = require('postcss') | ||
const postcssModules = require('postcss-modules') | ||
const cssnano = require('cssnano') | ||
|
||
const classNames = {} | ||
|
||
let currentId = 0 | ||
const nextName = () => { | ||
return '_' + (currentId++).toString(36) | ||
} | ||
|
||
const CssModulesPlugin = () => ({ | ||
name: 'CssModulesPlugin', | ||
setup(build) { | ||
const cssContent = {} | ||
|
||
build.onLoad({ filter: /\.css$/ }, async ({ resolveDir, path }) => { | ||
const filePath = resolve(resolveDir, path) | ||
classNames[filePath] = classNames[filePath] ?? {} | ||
let classNameMap = {} | ||
const { css } = await postcss([ | ||
postcssModules({ | ||
getJSON(_, map) { | ||
classNameMap = map | ||
}, | ||
generateScopedName(name) { | ||
if (!classNames[filePath][name]) { | ||
classNames[filePath][name] = nextName() | ||
} | ||
|
||
const scopedName = classNames[filePath][name] | ||
return scopedName | ||
}, | ||
}), | ||
cssnano({ preset: 'default' }), | ||
]).process(await fs.readFile(filePath)) | ||
|
||
cssContent[filePath] = css | ||
|
||
return { | ||
contents: `export default ${JSON.stringify(classNameMap)}`, | ||
} | ||
}) | ||
|
||
build.onEnd(async () => { | ||
const bundlePath = resolve(build.initialOptions.outdir, 'index.css') | ||
await fs.writeFile( | ||
bundlePath, | ||
Object.keys(cssContent) | ||
.map((key) => cssContent[key]) | ||
.join('\n') | ||
) | ||
}) | ||
}, | ||
}) | ||
|
||
module.exports = CssModulesPlugin |
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,16 @@ | ||
import { User } from '../../common/types' | ||
import state from './state' | ||
|
||
export const get = () => { | ||
return localStorage.getItem('authorization') | ||
} | ||
|
||
export const set = ({ user, token }: { user: User; token: string }) => { | ||
localStorage.setItem('authorization', token) | ||
state.user = user | ||
} | ||
|
||
export const reset = () => { | ||
localStorage.removeItem('authorization') | ||
state.user = null | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,87 @@ | ||
import { h, Fragment, useEffect } from 'kaiku' | ||
import Header from '../header/Header' | ||
import classNames from 'classnames/bind' | ||
import styles from './app.css' | ||
import UserBar from '../user-bar/user-bar' | ||
import ModuleSelector from '../module-selector/ModuleSelector' | ||
import Patch from '../patch/Patch' | ||
import Hint from '../hint/Hint' | ||
import { initializeAudio } from '../../audio' | ||
import state, { patch } from '../../state' | ||
import * as types from '../../../../common/types' | ||
import * as api from '../../api' | ||
|
||
const css = classNames.bind(styles) | ||
|
||
const loadSaveState = async () => { | ||
const rawSaveState = localStorage.getItem('savestate') | ||
if (rawSaveState) { | ||
loadPatch(JSON.parse(rawSaveState)) | ||
} else { | ||
state.initialized = true | ||
} | ||
} | ||
|
||
const initialize = async () => { | ||
await initializeAudio() | ||
|
||
switch (state.route.name) { | ||
case 'index': { | ||
await loadSaveState() | ||
break | ||
} | ||
|
||
case 'patch': { | ||
const patch = await api.getLatestPatchVersion(state.route.patchId) | ||
|
||
if (!patch) { | ||
history.replaceState({}, '', '/') | ||
loadSaveState() | ||
} else { | ||
loadPatch(patch.patch) | ||
} | ||
|
||
break | ||
} | ||
} | ||
} | ||
|
||
const loadPatch = async (savedPatch: types.Patch) => { | ||
const { currentId, modules, knobs, cables } = savedPatch | ||
patch.knobs = knobs | ||
patch.currentId = currentId | ||
patch.modules = modules | ||
state.initialized = true | ||
await new Promise((resolve) => requestAnimationFrame(resolve)) | ||
patch.cables = cables | ||
} | ||
|
||
const App = () => { | ||
useEffect(() => { | ||
if (!state.initialized) return | ||
if (state.route.name !== 'index') return | ||
|
||
console.log('savestate') | ||
localStorage.setItem('savestate', JSON.stringify(patch)) | ||
}) | ||
|
||
if (!state.initialized) { | ||
return ( | ||
<button className="launch-button" onClick={initialize}> | ||
Start | ||
</button> | ||
) | ||
} | ||
|
||
return ( | ||
<> | ||
<Patch /> | ||
<Header /> | ||
<UserBar /> | ||
<ModuleSelector /> | ||
<Hint /> | ||
</> | ||
) | ||
} | ||
|
||
export default App |
Empty file.
Oops, something went wrong.