All Projects β†’ woodwoerk β†’ spaghetti-audio

woodwoerk / spaghetti-audio

Licence: other
A Web Audio and canvas experiment

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to spaghetti-audio

webaudio-oscilloscope
A highly customizable oscilloscope for Web Audio πŸ”ˆ 🎀
Stars: ✭ 57 (-39.36%)
Mutual labels:  web-audio-api
funny-billards
δΈ€δΈͺ用 Javascript ε†™ηš„ε°ηƒζΈΈζˆ
Stars: ✭ 29 (-69.15%)
Mutual labels:  web-audio-api
Shape-Your-Music
A web application for drawing music.
Stars: ✭ 106 (+12.77%)
Mutual labels:  tonejs
AudioMasher
Generative Audio Playground
Stars: ✭ 50 (-46.81%)
Mutual labels:  web-audio-api
finding-nora
Find your name in a field of letters (kids game)
Stars: ✭ 40 (-57.45%)
Mutual labels:  web-audio-api
Generative.fm
A platform for playing generative music in the browser.
Stars: ✭ 1,534 (+1531.91%)
Mutual labels:  web-audio-api
cycle-audio-graph
Audio graph driver for Cycle.js based on virtual-audio-graph
Stars: ✭ 19 (-79.79%)
Mutual labels:  web-audio-api
WebAudioEvaluationTool
A tool based on the HTML5 Web Audio API to perform perceptual audio evaluation tests locally or on remote machines over the web.
Stars: ✭ 101 (+7.45%)
Mutual labels:  web-audio-api
audioworklet-polyfill
strictly unofficial polyfill for Web Audio API AudioWorklet
Stars: ✭ 49 (-47.87%)
Mutual labels:  web-audio-api
chords
Text-based chord progression editor
Stars: ✭ 25 (-73.4%)
Mutual labels:  web-audio-api
react-redux-webaudio
An event manager for the Web Audio API, integrated with react-redux.
Stars: ✭ 23 (-75.53%)
Mutual labels:  web-audio-api
midio
midio will work really hard to generate you endlessly interesting audio on the fly.
Stars: ✭ 21 (-77.66%)
Mutual labels:  web-audio-api
happybot
A multi-purpose, feature-full, and powerful, highly guild-specific, Discord Bot written in Java.
Stars: ✭ 14 (-85.11%)
Mutual labels:  spaghetti
nikku
πŸ‘½ Web-based BRSTM player
Stars: ✭ 35 (-62.77%)
Mutual labels:  web-audio-api
circle
No description or website provided.
Stars: ✭ 25 (-73.4%)
Mutual labels:  web-audio-api
Keras-to-Realtime-Audio
No description or website provided.
Stars: ✭ 22 (-76.6%)
Mutual labels:  web-audio-api
webgl-3d-animation
An interactive 3D animation using WebGL to depict a 2D predator prey ecology on a grid real-time mapped onto the surface of a 3D torus. Sound file is parsed then visualized both in time and frequency domains as well as rendered using Web Audio API - this is an exercise where I taught myself how to display data for an ongoing project on sound syn…
Stars: ✭ 23 (-75.53%)
Mutual labels:  web-audio-api
tokenstealer
No description or website provided.
Stars: ✭ 16 (-82.98%)
Mutual labels:  spaghetti
ember-audio
An Ember addon that makes working with the Web Audio API super EZ.
Stars: ✭ 33 (-64.89%)
Mutual labels:  web-audio-api
simple-waveform-visualizer
JS Audio API 놀이터
Stars: ✭ 31 (-67.02%)
Mutual labels:  web-audio-api

Spaghetti Audio

The musical instrument nobody asked for

Spaghetti Audio

Spaghetti Audio combines the Web Audio API via Tone.js and an interactive canvas to let you draw and strum strings

The longer the string, the lower the pitch, just like an elastic band... or, erm, spaghetti?

On touch devices, draw strings with two fingers and strum with one

Usage

If Spaghetti Audio is exactly what you've been searching for, you too can enjoy the sonic taste of spaghetti sound waves by following these steps:

  1. Install via npm or yarn

    npm i spaghetti-audio
  2. Create some spaghetti

    import SpaghettiAudio from 'spaghetti-audio'
    
    const spaghettiAudio = new SpaghettiAudio()
    
    // All the spaghetti goodness is rendered to a canvas element, so append that to the DOM
    document.body.appendChild(spaghettiAudio.canvas)
  3. To properly clean up Spaghetti Audio (e.g. when navigating to another page in a SPA) call the destroy method. This removes event listeners and cancels animation frame requests.

    spaghettiAudio.destroy()

Appending to a wrapper

Rather than sticking the spaghetti canvas straight in the <body> and taking up the full window width, you can attach it to another element. This example attaches the spaghetti canvas to a wrapper with id "spaghetti-wrapper".

import SpaghettiAudio from 'spaghetti-audio'

const wrapper = document.querySelector('#spaghetti-wrapper')
const spaghettiAudio = new SpaghettiAudio({ wrapper })

wrapper.appendChild(spaghettiAudio.canvas)

Usage with React

Spaghetti Audio is UI framework agnostic and the mounting process is similar for React, Vue.js and other frameworks. You can think of Spaghetti Audio more like a game with a render loop rather than a reactive component. This means we need to instantiate it, attach it to a component and destroy it when that component unmounts. Here's how that looks in React:

function SpaghettiAudioWrapper() {
  const wrapperRef = useRef()

  useEffect(() => {
    const spaghettiAudio = new SpaghettiAudio({ wrapper: wrapperRef.current })

    wrapperRef.current.appendChild(spaghettiAudio.canvas)

    return () => spaghettiAudio.destroy()
  }, [])

  return <div className="spaghetti-wrapper" ref={wrapperRef} />
}

Local development

  1. Clone this repo and cd spaghetti-audio

  2. Install dependencies with npm or yarn

    npm i
  3. Spin up the dev server

    npm run start
  4. The dev server is now running at http://localhost:8080

 Settings

The following settings can be used to customise the spaghetti experience, use these when initialising spaghetti audio, e.g. new SpaghettiAudio({ damping: 0.05 })

export interface Settings {
  /** How fast motion dies down. The higher the number, the less oscillation and more al dente the spaghetti. */
  damping?: number
  /** Show the hitboxes and other helpful debugger annotations on the canvas. */
  debug?: boolean
  /** The frequency range of the keyboard. */
  hiRange?: { start: number; end: number }
  /** The key to store the spaghetti strings under in local storage. */
  localStorageKey?: string
  /** It's spaghetti, not scialatelli, so let's set a minimum length. */
  minStringLength?: number
  /** The space around the spaghetti that's interactive. */
  hitboxSize?: number
  /** Spaghetti color. */
  spaghettiColor?: string
  /** Spaghetti width. */
  spaghettiWidth?: number
  /** The total interactive points along each spaghetti string. Minimum is 3 – Two anchor points on each end, and one interactive wobbly point in the middle. */
  totalPoints?: number
  /** How quickly the spaghetti oscillates back to center. The higher the number, the stickier or more molasses-like the spaghetti. */
  viscosity?: number
  /** Show a clear button to clear all the strings. */
  withClearButton?: boolean
  /** Store the spaghetti strings in local storage. */
  withLocalStorage?: boolean
  /** A HTML element, if the spaghetti canvas is attached to a wrapper. */
  wrapper?: HTMLElement
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].