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.
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.
npm install @types/tone --save
leads to:
npm ERR! code E404
npm ERR! 404 Not Found: @types/tone@latest
Am I doing something wrong?
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'.
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!
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.
TypeScript developers expect npm install @types/tone --save
to work. Not sure how to install this typing easily.
Thanks!
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.