Giter VIP home page Giter VIP logo

typescript's Introduction

Tone.js homepage

Docs are autogenerated from jsdoc-style comments in the source code, examples are copied from the main repository. To fix any typos or errors, please submit a pull request to the Tone.js repo.

typescript's People

Contributors

atranimal avatar jackca avatar jasonfarrell avatar minism avatar nickhurst avatar pouyakary avatar rtalwar26 avatar tambien avatar thsoft avatar tomjamesallen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescript's Issues

Buffer seems to miss volume and url options

When I try to initialize a synth or any player with options I get the following errors.

let player = new Tone.Player({ "url": "./path/to/sample.mp3"", "callback": function() {}, "playbackRate" : 1, "autostart": false, "loop": true, "fadeIn":1.0, "fadeOut":1.0 }).toMaster()

Object literal may only specify known properties, and '"url"' does not exist in type 'Buffer'.

let synth = new Tone.MonoSynth({ "volume" : -6, "oscillator" : { "type" : "square" }, "envelope" : { "attack" : 0.1 } }).toMaster()

Object literal may only specify known properties, and '"volume"' does not exist in type 'MonoSynthOptions'.

Buffer does not have the on method

It is recommended to use Tone.Buffer.on to keep track of the loading progress. However, I do not find the type definition of Buffer.on in Typescript. What is an alternative way to check the loading progress? Thanks!

Maybe it's worth to consider dts-gen as starting point

It seems that Typescript definition currently is a handwritten file. Wouldn't it be better to start of with a dts-gen generated file and add the types to it? So it is a valid definition (with all classes / methods included), but at the beginning just with the any type.

I tried to convert it in the browser, but dts-gen crashes because of following message:

Tone.min.js:12 Uncaught TypeError: Cannot read property 'type' of undefined
    at t.Oscillator.get (Tone.min.js:12)
    at browser-bundle.js:1
    at Array.map (<anonymous>)
    at p (browser-bundle.js:1)
    at n (browser-bundle.js:1)
    at l (browser-bundle.js:1)
    at n (browser-bundle.js:1)
    at l (browser-bundle.js:1)
    at Object.s [as generateIdentifierDeclarationFile] (browser-bundle.js:1)
    at HTMLInputElement.<anonymous> (browser-bundle.js:1)

Maybe someone could try to convert it with the shell commands.

Please migrate to @types

TypeScript developers expect npm install @types/tone --save to work. Not sure how to install this typing easily.

Thanks!

Synth Config Options includes unused properties

interface SynthOptions {
    oscillator?: OscillatorOptions<OscillatorType>;
    envelope?: ADSREnvelopeOptions;
  }

The SynthOptions includes the Oscillator Options type in its entirety:

interface OscillatorOptions<T = BasicOscillatorType> {
    type?: T;
    modulationType?: T;
    modulationIndex?: number;
    harmonicity?: number;
  }

According the The documentation for the Synth options, modulationType, modulationIndex, and harmonicity are not used on the synth at all, which makes sense.

Instead of including the entire OscillatorOptions type or breaking DRY principles by defining it over again, I propose using the "Pick" type tool to pull only the type type out of the OscillatorOptions list like so:

interface SynthOptions {
    oscillator?: Pick<OscillatorOptions<OscillatorType>, 'type'>;
    envelope?: ADSREnvelopeOptions;
  }

This would communicate to users of the Synth instrument that they only relevant oscillator configuration is the type, and they would not get lost wondering what the modulator and harmonicity are doing there (like I may have done for like an hour).

If this solution is acceptable I will make the change and submit a PR. LMK

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.