Giter Club home page Giter Club logo

webaudio-kotlin's Introduction

WebAudio Kotlin


A library of KotlinJS externals for the WebAudio API. Currently still a Work In Progress.

Using

This library can be added as a local maven artifact. Clone, publish to Maven local and import it with gradle into your KotlinJS project. It then can be used directly.

Example

fun main() {
    /*
    The Audio Context can be created with a JS object. 
    This library includes a jsObject helper function
    to create JS objects.
     */
    val ctx = AudioContext(jsObject {
        latencyHint = "interactive"
        sampleRate = 44100
    })

    val osc = ctx.createOscillator()
    osc.type = "square"
    osc.frequency.setValueAtTime(440.0,ctx.currentTime)
    osc.start()

    val gain = ctx.createGain()
    gain.gain.setValueAtTime(0.0,ctx.currentTime)

    osc.connect(gain)
    gain.connect(ctx.destination)

    window.addEventListener("mousedown",{ e ->
        gain.gain.setValueAtTime(1.0,ctx.currentTime)
        console.log("mouse down")
    })
    window.addEventListener("mouseup",{ e ->
        gain.gain.setValueAtTime(0.0,ctx.currentTime)
        console.log("mouse up")
    })
}

Contributing

As this is just a library of externals, contributing is easy! If you see something that isn't here but is in the WebAudio API Docs, please do help out by filling in the external declarations.

Notes

For some reason, KotlinJS doesn't come with bindings for WebAudio. An issue has been brought up on Jetbrains's youtrack. But there has been no follow up.

webaudio-kotlin's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.