Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stagas/x-oscilloscope

Audio oscilloscope visualizer Web Component.
https://github.com/stagas/x-oscilloscope

custom-element dsp oscilloscope ui visualizer web-component webaudio

Last synced: 2 months ago
JSON representation

Audio oscilloscope visualizer Web Component.

Awesome Lists containing this project

README

        


x-oscilloscope

Audio oscilloscope visualizer Web Component



npm i x-oscilloscope

pnpm add x-oscilloscope

yarn add x-oscilloscope

## Examples

# web


    Try it live

    # view source example/web.ts

    ```ts
    import { fetchAudioBuffer } from 'webaudio-tools'
    import { OscilloscopeElement } from 'x-oscilloscope'

    customElements.define('x-oscilloscope', OscilloscopeElement)
    document.body.innerHTML = `





    `

    const ctx = new AudioContext({ sampleRate: 44100, latencyHint: 0.08 })

    const analyser = ctx.createAnalyser()
    analyser.fftSize = 8192
    analyser.smoothingTimeConstant = 0
    analyser.maxDecibels = 0
    analyser.minDecibels = -100

    // @ts-ignore
    const url = new URL('alpha_molecule.ogg', import.meta.url).toString()

    fetchAudioBuffer(ctx, url).then(audioBuffer => {
    const source = ctx.createBufferSource()
    source.buffer = audioBuffer
    source.loop = true
    source.connect(ctx.destination)
    source.start(0, 83)
    source.connect(analyser)
    ;(document.querySelector('x-oscilloscope') as OscilloscopeElement).analyser =
    analyser
    })

    window.onclick = () => ctx.state !== 'running' ? ctx.resume() : ctx.suspend()
    if (ctx.state !== 'running')
    document.body.appendChild(new Text('click to start/stop'))
    // requestAnimationFrame <- for shoty
    ```

## API

# OscilloscopeElement src/x-oscilloscope.tsx#L10

} & __module & {

# Boolean src/work/stagas/sigl/dist/types/index.d.ts#L9


    undefined | boolean

# Number src/work/stagas/sigl/dist/types/index.d.ts#L8

    undefined | number

# String src/work/stagas/sigl/dist/types/index.d.ts#L7

    undefined | string

}, "transition">> # Plot  =  ... src/x-oscilloscope.tsx#L20

    Component<PlotElement, HTMLElement>

# analyser src/x-oscilloscope.tsx#L18

    AnalyserNode

# analyserData src/x-oscilloscope.tsx#L19

    Float32Array

# autoResize  =  true src/x-oscilloscope.tsx#L11

    boolean

# background  =  '#123' src/x-oscilloscope.tsx#L14

    string

# color  =  '#1ff' src/x-oscilloscope.tsx#L15

    string

# context src/work/stagas/sigl/dist/types/sigl.d.ts#L26 # dispatch src/work/stagas/sigl/dist/types/events.d.ts#L4

    Dispatch<# (name, detail, init)

      # name


        Event | Narrow<K, string>

      # detail # init

        CustomEventInit<any>


      <K, E>(name, detail, init)  =>


        any

> # divider  =  1 src/x-oscilloscope.tsx#L16

    number

# draw src/x-oscilloscope.tsx#L23

    # ()


      ()  =>


        void

# height  =  50 src/x-oscilloscope.tsx#L13

    number

# host src/work/stagas/sigl/dist/types/sigl.d.ts#L24 # loop src/x-oscilloscope.tsx#L24

    {


    # start()


      start()  =>


        void

# stop()


    stop()  =>


      void
} # onmounted # onunmounted # plotData  =  ... src/x-oscilloscope.tsx#L21

    Float32Array

# stabilizer  =  ... src/x-oscilloscope.tsx#L22

    Stabilizer

# width  =  150 src/x-oscilloscope.tsx#L12

    number

# created(ctx)

created(ctx)  =>

    void
# mounted($) src/x-oscilloscope.tsx#L41

mounted($)  =>

    void
# on(name) # start() – Start displaying the spectrum. src/x-oscilloscope.tsx#L31


    start()  =>


      void
# stop() – Stop displaying the spectrum. src/x-oscilloscope.tsx#L37


    stop()  =>


      void
# toJSON()

## Credits

- [sigl](https://npmjs.org/package/sigl) by [stagas](https://github.com/stagas) – Web framework
- [x-plot](https://npmjs.org/package/x-plot) by [stagas](https://github.com/stagas) – A Web Component that plots zoomable and pannable waveforms.

## Contributing

[Fork](https://github.com/stagas/x-oscilloscope/fork) or [edit](https://github.dev/stagas/x-oscilloscope) and submit a PR.

All contributions are welcome!

## License

MIT © 2022 [stagas](https://github.com/stagas)