From 28c921f93acfb1510715dbffa981f5a7c108a0a3 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Tue, 30 Apr 2024 10:02:34 -0400 Subject: [PATCH] Release 14.9.x (#1240) * Update test.yml * Update test.yml * Less verbose unit types (#1181) Co-authored-by: IntGrah * reverting isNote test, fixing workflow * fixing job dependencies * Deprecating singleton variables, use singleton getter instead (#1233) * Deprecating singleton variables, use singleton getter instead * updating references * moving over to getters instead of global vars * Simplifying oscillator type strings using templates (#1234) * simplifying interface types using templates * uploading codecov threshold * adjusting thresh * updating checkout * organizing docs (#1235) * Updating link syntax (#1236) * Using @see typedoc (#1237) * updating link to Context instead of BaseContext (#1238) * Update README.md * Small doc updates and tweaks (#1239) --------- Co-authored-by: IntGrah --- .github/codecov.yml | 6 + .github/workflows/publish.yml | 33 -- .github/workflows/test.yml | 46 ++- README.md | 117 ++++--- Tone/component/analysis/Analyser.ts | 6 +- Tone/component/analysis/DCMeter.ts | 3 +- Tone/component/analysis/FFT.ts | 6 +- Tone/component/analysis/Meter.ts | 11 +- Tone/component/analysis/Waveform.ts | 2 +- Tone/component/channel/Channel.ts | 12 +- Tone/component/channel/MidSideMerge.ts | 4 +- Tone/component/channel/MidSideSplit.ts | 2 +- Tone/component/channel/Recorder.ts | 2 +- Tone/component/dynamics/Gate.ts | 7 +- Tone/component/dynamics/Limiter.ts | 2 +- Tone/component/dynamics/MidSideCompressor.ts | 5 +- .../component/dynamics/MultibandCompressor.ts | 3 +- Tone/component/envelope/FrequencyEnvelope.ts | 4 +- Tone/component/filter/BiquadFilter.ts | 2 +- Tone/component/filter/LowpassCombFilter.ts | 2 +- Tone/core/Global.ts | 2 +- Tone/core/clock/TickParam.ts | 4 +- Tone/core/clock/Transport.test.ts | 120 ++++---- Tone/core/clock/Transport.ts | 46 +-- Tone/core/clock/TransportEvent.test.ts | 8 +- Tone/core/clock/TransportEvent.ts | 4 +- Tone/core/clock/TransportRepeatEvent.test.ts | 8 +- Tone/core/clock/TransportRepeatEvent.ts | 2 +- Tone/core/context/AbstractParam.ts | 8 +- Tone/core/context/BaseContext.ts | 8 +- Tone/core/context/Context.test.ts | 16 +- Tone/core/context/Context.ts | 29 +- Tone/core/context/Destination.test.ts | 4 +- Tone/core/context/Destination.ts | 8 +- Tone/core/context/DummyContext.ts | 8 +- Tone/core/context/Listener.test.ts | 4 +- Tone/core/context/Listener.ts | 6 +- Tone/core/context/Offline.ts | 2 +- Tone/core/context/ToneAudioNode.ts | 3 +- Tone/core/context/ToneWithContext.ts | 63 ++-- Tone/core/index.ts | 1 + Tone/core/type/NoteUnits.ts | 34 +-- Tone/core/type/Time.ts | 4 +- Tone/core/type/Units.ts | 7 +- Tone/core/util/Defaults.ts | 2 + Tone/core/util/Draw.test.ts | 4 +- Tone/core/util/Draw.ts | 4 +- Tone/core/util/IntervalTimeline.ts | 1 + Tone/core/util/StateTimeline.ts | 1 + Tone/core/util/Timeline.ts | 1 + Tone/core/util/TypeCheck.ts | 17 +- .../ToneAudioWorkletProcessor.worklet.ts | 2 +- Tone/effect/AutoPanner.ts | 2 +- Tone/effect/AutoWah.ts | 2 +- Tone/effect/Chorus.ts | 7 +- Tone/effect/Freeverb.ts | 2 +- Tone/effect/JCReverb.ts | 4 +- Tone/effect/LFOEffect.ts | 6 +- Tone/effect/Reverb.ts | 6 +- Tone/effect/StereoXFeedbackEffect.ts | 2 +- Tone/effect/Tremolo.ts | 2 +- Tone/event/Part.ts | 4 +- Tone/event/Pattern.ts | 2 +- Tone/event/Sequence.ts | 4 +- Tone/fromContext.ts | 16 +- Tone/index.test.ts | 18 +- Tone/index.ts | 59 ++-- Tone/instrument/DuoSynth.ts | 2 +- Tone/instrument/Instrument.ts | 2 +- Tone/instrument/MetalSynth.ts | 4 +- Tone/instrument/NoiseSynth.ts | 2 +- Tone/instrument/PluckSynth.ts | 2 +- Tone/instrument/Sampler.ts | 2 +- Tone/instrument/Synth.ts | 2 +- Tone/signal/Add.ts | 2 +- Tone/signal/AudioToGain.ts | 2 +- Tone/signal/GainToAudio.ts | 2 +- Tone/signal/Multiply.ts | 2 +- Tone/signal/ScaleExp.ts | 4 +- Tone/signal/Signal.ts | 2 +- Tone/signal/SyncedSignal.ts | 4 +- Tone/signal/WaveShaper.ts | 2 +- Tone/source/Source.ts | 3 +- Tone/source/buffer/Player.ts | 2 +- Tone/source/buffer/Players.ts | 2 +- Tone/source/oscillator/LFO.ts | 8 +- Tone/source/oscillator/OmniOscillator.ts | 19 +- Tone/source/oscillator/Oscillator.ts | 2 +- Tone/source/oscillator/OscillatorInterface.ts | 289 ++++++++++-------- Tone/source/oscillator/ToneOscillatorNode.ts | 2 +- scripts/typedoc.json | 7 + 91 files changed, 660 insertions(+), 552 deletions(-) create mode 100644 .github/codecov.yml delete mode 100644 .github/workflows/publish.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 00000000..61acfc08 --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + target: auto + threshold: 1% \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 6577cce0..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Publish -on: - workflow_run: - workflows: ["Tests"] - types: - - completed -jobs: - publish: - runs-on: ubuntu-latest - # not on PRs - if: github.event_name != 'pull_request' - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - GITHUB_CI: true - steps: - - uses: actions/checkout@v4 - # Setup .npmrc file to publish to npm - - uses: actions/setup-node@v4 - with: - node-version: 18.12.0 - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: npm install - - name: Build - run: npm run build - - name: Increment version - run: npm run increment - - name: Publish @next - run: npm publish --tag next - if: ${{ github.ref == 'refs/heads/dev' }} - - name: Publish @latest - run: npm publish - if: ${{ github.ref == 'refs/heads/main' }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 266563e4..5da7e469 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,7 @@ on: types: [opened, reopened, synchronize] branches: - dev + - main push: branches: - dev @@ -21,7 +22,7 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} steps: - name: Check out Git repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Nodejs uses: actions/setup-node@v4 with: @@ -36,7 +37,8 @@ jobs: - name: Upload coverage uses: codecov/codecov-action@v4 with: - fail_ci_if_error: true + fail_ci_if_error: false + codecov_yml_path: ./.github/codecov.yml token: ${{ secrets.CODECOV_TOKEN }} test-code-examples: name: Check typedocs @@ -46,7 +48,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out Git repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Nodejs uses: actions/setup-node@v4 with: @@ -66,7 +68,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out Git repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Nodejs uses: actions/setup-node@v4 with: @@ -86,7 +88,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out Git repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Nodejs uses: actions/setup-node@v4 with: @@ -104,7 +106,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out Git repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup Nodejs uses: actions/setup-node@v4 with: @@ -115,4 +117,34 @@ jobs: - name: Build run: npm run build - name: Test - run: npm run test:readme \ No newline at end of file + run: npm run test:readme + publish: + runs-on: ubuntu-latest + # make sure all the tests pass first + needs: [run-tests, test-code-examples, test-html-examples, test-lint, test-readme] + # not on PRs + if: github.event_name != 'pull_request' + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_CI: true + steps: + - uses: actions/checkout@v4 + # Setup .npmrc file to publish to npm + - uses: actions/setup-node@v4 + with: + node-version: 18.12.0 + registry-url: 'https://registry.npmjs.org' + - name: Install dependencies + run: npm install + - name: Build + run: npm run build + - name: Increment version + run: npm run increment + - name: Publish @next + # dev branch gets published with @next tag + run: npm publish --tag next + if: ${{ github.ref == 'refs/heads/dev' }} + - name: Publish @latest + # main branch gets published with @latest tag + run: npm publish + if: ${{ github.ref == 'refs/heads/main' }} diff --git a/README.md b/README.md index 657aadcc..1e544a6e 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,11 @@ -Tone.js -========= +# Tone.js [![codecov](https://codecov.io/gh/Tonejs/Tone.js/branch/dev/graph/badge.svg)](https://codecov.io/gh/Tonejs/Tone.js) - Tone.js is a Web Audio framework for creating interactive music in the browser. The architecture of Tone.js aims to be familiar to both musicians and audio programmers creating web-based audio applications. On the high-level, Tone offers common DAW (digital audio workstation) features like a global transport for synchronizing and scheduling events as well as prebuilt synths and effects. Additionally, Tone provides high-performance building blocks to create your own synthesizers, effects, and complex control signals. -* [API](https://tonejs.github.io/docs/) -* [Examples](https://tonejs.github.io/examples/) -* [Demos](https://tonejs.github.io/demos) +- [API](https://tonejs.github.io/docs/) +- [Examples](https://tonejs.github.io/examples/) # Installation @@ -22,14 +19,13 @@ npm install tone@next // Or, alternatively, use the 'next' version Add Tone.js to a project using the JavaScript `import` syntax: ```js -import * as Tone from 'tone'; +import * as Tone from "tone"; ``` Tone.js is also hosted at unpkg.com. It can be added directly within an HTML document, as long as it precedes any project scripts. [See the example here](https://github.com/Tonejs/Tone.js/blob/master/examples/simpleHtml.html) for more details. ```html - ``` # Hello Tone @@ -44,7 +40,7 @@ synth.triggerAttackRelease("C4", "8n"); ## Tone.Synth -[Tone.Synth](https://tonejs.github.io/docs/Synth) is a basic synthesizer with a single [oscillator](https://tonejs.github.io/docs/OmniOscillator) and an [ADSR envelope](https://tonejs.github.io/docs/Envelope). +`Tone.Synth` is a basic synthesizer with a single oscillator and an ADSR envelope. ### triggerAttack / triggerRelease @@ -52,36 +48,36 @@ synth.triggerAttackRelease("C4", "8n"); ```javascript const synth = new Tone.Synth().toDestination(); -const now = Tone.now() +const now = Tone.now(); // trigger the attack immediately -synth.triggerAttack("C4", now) +synth.triggerAttack("C4", now); // wait one second before triggering the release -synth.triggerRelease(now + 1) +synth.triggerRelease(now + 1); ``` ### triggerAttackRelease `triggerAttackRelease` is a combination of `triggerAttack` and `triggerRelease` -The first argument to the note which can either be a frequency in hertz (like `440`) or as "pitch-octave" notation (like `"D#2"`). +The first argument to the note which can either be a frequency in hertz (like `440`) or as "pitch-octave" notation (like `"D#2"`). -The second argument is the duration that the note is held. This value can either be in seconds, or as a [tempo-relative value](https://github.com/Tonejs/Tone.js/wiki/Time). +The second argument is the duration that the note is held. This value can either be in seconds, or as a [tempo-relative value](https://github.com/Tonejs/Tone.js/wiki/Time). The third (optional) argument of `triggerAttackRelease` is _when_ along the AudioContext time the note should play. It can be used to schedule events in the future. ```javascript const synth = new Tone.Synth().toDestination(); -const now = Tone.now() -synth.triggerAttackRelease("C4", "8n", now) -synth.triggerAttackRelease("E4", "8n", now + 0.5) -synth.triggerAttackRelease("G4", "8n", now + 1) +const now = Tone.now(); +synth.triggerAttackRelease("C4", "8n", now); +synth.triggerAttackRelease("E4", "8n", now + 0.5); +synth.triggerAttackRelease("G4", "8n", now + 1); ``` ## Time Web Audio has advanced, sample accurate scheduling capabilities. The AudioContext time is what the Web Audio API uses to schedule events, starts at 0 when the page loads and counts up in **seconds**. -`Tone.now()` gets the current time of the AudioContext. +`Tone.now()` gets the current time of the AudioContext. ```javascript setInterval(() => console.log(Tone.now()), 100); @@ -93,57 +89,57 @@ Tone.js abstracts away the AudioContext time. Instead of defining all values in # Starting Audio -**IMPORTANT**: Browsers will not play _any_ audio until a user clicks something (like a play button). Run your Tone.js code only after calling `Tone.start()` from a event listener which is triggered by a user action such as "click" or "keydown". +**IMPORTANT**: Browsers will not play _any_ audio until a user clicks something (like a play button). Run your Tone.js code only after calling `Tone.start()` from a event listener which is triggered by a user action such as "click" or "keydown". `Tone.start()` returns a promise, the audio will be ready only after that promise is resolved. Scheduling or playing audio before the AudioContext is running will result in silence or incorrect scheduling. ```javascript //attach a click listener to a play button -document.querySelector('button')?.addEventListener('click', async () => { - await Tone.start() - console.log('audio is ready') -}) -``` +document.querySelector("button")?.addEventListener("click", async () => { + await Tone.start(); + console.log("audio is ready"); +}); +``` # Scheduling ## Transport -[Tone.Transport](https://tonejs.github.io/docs/Transport) is the main timekeeper. Unlike the AudioContext clock, it can be started, stopped, looped and adjusted on the fly. You can think of it like the arrangement view in a Digital Audio Workstation or channels in a Tracker. +`Tone.getTransport()` returns the main timekeeper. Unlike the AudioContext clock, it can be started, stopped, looped and adjusted on the fly. You can think of it like the arrangement view in a Digital Audio Workstation. -Multiple events and parts can be arranged and synchronized along the Transport. [Tone.Loop](https://tonejs.github.io/docs/Loop) is a simple way to create a looped callback that can be scheduled to start and stop. +Multiple events and parts can be arranged and synchronized along the Transport. `Tone.Loop` is a simple way to create a looped callback that can be scheduled to start and stop. ```javascript // create two monophonic synths const synthA = new Tone.FMSynth().toDestination(); const synthB = new Tone.AMSynth().toDestination(); //play a note every quarter-note -const loopA = new Tone.Loop(time => { +const loopA = new Tone.Loop((time) => { synthA.triggerAttackRelease("C2", "8n", time); }, "4n").start(0); //play another note every off quarter-note, by starting it "8n" -const loopB = new Tone.Loop(time => { +const loopB = new Tone.Loop((time) => { synthB.triggerAttackRelease("C4", "8n", time); }, "4n").start("8n"); -// the loops start when the Transport is started -Tone.Transport.start() +// all loops start when the Transport is started +Tone.getTransport().start(); // ramp up to 800 bpm over 10 seconds -Tone.Transport.bpm.rampTo(800, 10); +Tone.getTransport().bpm.rampTo(800, 10); ``` Since Javascript callbacks are **not precisely timed**, the sample-accurate time of the event is passed into the callback function. **Use this time value to schedule the events**. # Instruments -There are numerous synths to choose from including [Tone.FMSynth](https://tonejs.github.io/docs/FMSynth), [Tone.AMSynth](https://tonejs.github.io/docs/AMSynth) and [Tone.NoiseSynth](https://tonejs.github.io/docs/NoiseSynth). +There are numerous synths to choose from including `Tone.FMSynth`, `Tone.AMSynth` and `Tone.NoiseSynth`. -All of these instruments are **monophonic** (single voice) which means that they can only play one note at a time. +All of these instruments are **monophonic** (single voice) which means that they can only play one note at a time. -To create a **polyphonic** synthesizer, use [Tone.PolySynth](https://tonejs.github.io/docs/PolySynth), which accepts a monophonic synth as its first parameter and automatically handles the note allocation so you can pass in multiple notes. The API is similar to the monophonic synths, except `triggerRelease` must be given a note or array of notes. +To create a **polyphonic** synthesizer, use `Tone.PolySynth`, which accepts a monophonic synth as its first parameter and automatically handles the note allocation so you can pass in multiple notes. The API is similar to the monophonic synths, except `triggerRelease` must be given a note or array of notes. ```javascript const synth = new Tone.PolySynth(Tone.Synth).toDestination(); -const now = Tone.now() +const now = Tone.now(); synth.triggerAttack("D4", now); synth.triggerAttack("F4", now + 0.5); synth.triggerAttack("A4", now + 1); @@ -154,30 +150,32 @@ synth.triggerRelease(["D4", "F4", "A4", "C5", "E5"], now + 4); # Samples -Sound generation is not limited to synthesized sounds. You can also load a sample and play that back in a number of ways. [Tone.Player](https://tonejs.github.io/docs/Player) is one way to load and play back an audio file. +Sound generation is not limited to synthesized sounds. You can also load a sample and play that back in a number of ways. `Tone.Player` is one way to load and play back an audio file. ```javascript -const player = new Tone.Player("https://tonejs.github.io/audio/berklee/gong_1.mp3").toDestination(); +const player = new Tone.Player( + "https://tonejs.github.io/audio/berklee/gong_1.mp3" +).toDestination(); Tone.loaded().then(() => { player.start(); }); ``` -`Tone.loaded()` returns a promise which resolves when _all_ audio files are loaded. It's a helpful shorthand instead of waiting on each individual audio buffer's `onload` event to resolve. +`Tone.loaded()` returns a promise which resolves when _all_ audio files are loaded. It's a helpful shorthand instead of waiting on each individual audio buffer's `onload` event to resolve. ## Tone.Sampler -Multiple samples can also be combined into an instrument. If you have audio files organized by note, [Tone.Sampler](https://tonejs.github.io/docs/Sampler) will pitch shift the samples to fill in gaps between notes. So for example, if you only have every 3rd note on a piano sampled, you could turn that into a full piano sample. +Multiple samples can also be combined into an instrument. If you have audio files organized by note, `Tone.Sampler` will pitch shift the samples to fill in gaps between notes. So for example, if you only have every 3rd note on a piano sampled, you could turn that into a full piano sample. Unlike the other synths, Tone.Sampler is polyphonic so doesn't need to be passed into Tone.PolySynth ```javascript const sampler = new Tone.Sampler({ urls: { - "C4": "C4.mp3", + C4: "C4.mp3", "D#4": "Ds4.mp3", "F#4": "Fs4.mp3", - "A4": "A4.mp3", + A4: "A4.mp3", }, release: 1, baseUrl: "https://tonejs.github.io/audio/salamander/", @@ -185,33 +183,33 @@ const sampler = new Tone.Sampler({ Tone.loaded().then(() => { sampler.triggerAttackRelease(["Eb4", "G4", "Bb4"], 4); -}) +}); ``` # Effects -In the above examples, the sources were always connected directly to the [Destination](https://tonejs.github.io/docs/Destination), but the output of the synth could also be routed through one (or more) effects before going to the speakers. +In the above examples, the sources were always connected directly to the `Destination`, but the output of the synth could also be routed through one (or more) effects before going to the speakers. ```javascript const player = new Tone.Player({ url: "https://tonejs.github.io/audio/berklee/gurgling_theremin_1.mp3", loop: true, autostart: true, -}) +}); //create a distortion effect const distortion = new Tone.Distortion(0.4).toDestination(); //connect a player to the distortion player.connect(distortion); ``` -The connection routing is very flexible. Connections can run serially or in parallel. +The connection routing is flexible, connections can run serially or in parallel. ```javascript const player = new Tone.Player({ url: "https://tonejs.github.io/audio/drum-samples/loops/ominous.mp3", autostart: true, }); -const filter = new Tone.Filter(400, 'lowpass').toDestination(); +const filter = new Tone.Filter(400, "lowpass").toDestination(); const feedbackDelay = new Tone.FeedbackDelay(0.125, 0.5).toDestination(); // connect the player to the feedback delay and filter in parallel @@ -219,15 +217,15 @@ player.connect(filter); player.connect(feedbackDelay); ``` -Multiple nodes can be connected to the same input enabling sources to share effects. [Tone.Gain](https://tonejs.github.io/docs/Gain) is very useful utility node for creating complex routing. +Multiple nodes can be connected to the same input enabling sources to share effects. `Tone.Gain` is useful utility node for creating complex routing. # Signals Like the underlying Web Audio API, Tone.js is built with audio-rate signal control over nearly everything. This is a powerful feature which allows for sample-accurate synchronization and scheduling of parameters. -[Signal](https://tonejs.github.io/docs/Signal) properties have a few built in methods for creating automation curves. +`Signal` properties have a few built in methods for creating automation curves. -For example, the `frequency` parameter on [Oscillator](https://tonejs.github.io/docs/Signal) is a Signal so you can create a smooth ramp from one frequency to another. +For example, the `frequency` parameter on `Oscillator` is a Signal so you can create a smooth ramp from one frequency to another. ```javascript const osc = new Tone.Oscillator().toDestination(); @@ -241,7 +239,7 @@ osc.start().stop("+3"); # AudioContext -Tone.js creates an AudioContext when it loads and shims it for maximum browser compatibility using [standardized-audio-context](https://github.com/chrisguttandin/standardized-audio-context). The AudioContext can be accessed at `Tone.context`. Or set your own AudioContext using `Tone.setContext(audioContext)`. +Tone.js creates an AudioContext when it loads and shims it for maximum browser compatibility using [standardized-audio-context](https://github.com/chrisguttandin/standardized-audio-context). The AudioContext can be accessed at `Tone.getContext`. Or set your own AudioContext using `Tone.setContext(audioContext)`. # MIDI @@ -249,13 +247,13 @@ To use MIDI files, you'll first need to convert them into a JSON format which To # Performance -Tone.js makes extensive use of the native Web Audio Nodes such as the GainNode and WaveShaperNode for all signal processing, which enables Tone.js to work well on both desktop and mobile browsers. +Tone.js makes extensive use of the native Web Audio Nodes such as the GainNode and WaveShaperNode for all signal processing, which enables Tone.js to work well on both desktop and mobile browsers. [This wiki](https://github.com/Tonejs/Tone.js/wiki/Performance) article has some suggestions related to performance for best practices. # Testing -Tone.js runs an extensive test suite using [mocha](https://mochajs.org/) and [chai](http://chaijs.com/) with nearly 100% coverage. Each commit and pull request is run on [Travis-CI](https://app.travis-ci.com/github/Tonejs/Tone.js) across browsers and versions. Passing builds on the 'dev' branch are published on npm as `tone@next`. +Tone.js runs an extensive test suite using [mocha](https://mochajs.org/) and [chai](http://chaijs.com/) with nearly 100% coverage. Passing builds on the 'dev' branch are published on npm as `tone@next`. # Contributing @@ -265,10 +263,9 @@ If you have questions (or answers) that are not necessarily bugs/issues, please # References and Inspiration -* [Tuna.js](https://github.com/Dinahmoe/tuna) -* [Many of Chris Wilson's Repositories](https://github.com/cwilso) -* [Many of Mohayonao's Repositories](https://github.com/mohayonao) -* [The Spec](http://webaudio.github.io/web-audio-api/) -* [Sound on Sound - Synth Secrets](http://www.soundonsound.com/sos/may99/articles/synthsec.htm) -* [Miller Puckette - Theory and Techniques of Electronic Music](http://msp.ucsd.edu/techniques.htm) -* [standardized-audio-context](https://github.com/chrisguttandin/standardized-audio-context) +- [Many of Chris Wilson's Repositories](https://github.com/cwilso) +- [Many of Mohayonao's Repositories](https://github.com/mohayonao) +- [The Spec](http://webaudio.github.io/web-audio-api/) +- [Sound on Sound - Synth Secrets](http://www.soundonsound.com/sos/may99/articles/synthsec.htm) +- [Miller Puckette - Theory and Techniques of Electronic Music](http://msp.ucsd.edu/techniques.htm) +- [standardized-audio-context](https://github.com/chrisguttandin/standardized-audio-context) diff --git a/Tone/component/analysis/Analyser.ts b/Tone/component/analysis/Analyser.ts index 9718cb23..7f685b48 100644 --- a/Tone/component/analysis/Analyser.ts +++ b/Tone/component/analysis/Analyser.ts @@ -92,8 +92,8 @@ export class Analyser extends ToneAudioNode { } /** - * Run the analysis given the current settings. If [[channels]] = 1, - * it will return a Float32Array. If [[channels]] > 1, it will + * Run the analysis given the current settings. If {@link channels} = 1, + * it will return a Float32Array. If {@link channels} > 1, it will * return an array of Float32Arrays where each index in the array * represents the analysis done on a channel. */ @@ -128,7 +128,7 @@ export class Analyser extends ToneAudioNode { /** * The number of channels the analyser does the analysis on. Channel - * separation is done using [[Split]] + * separation is done using {@link Split} */ get channels(): number { return this._analysers.length; diff --git a/Tone/component/analysis/DCMeter.ts b/Tone/component/analysis/DCMeter.ts index d36c9ed8..5da5770c 100644 --- a/Tone/component/analysis/DCMeter.ts +++ b/Tone/component/analysis/DCMeter.ts @@ -4,7 +4,8 @@ import { MeterBase, MeterBaseOptions } from "./MeterBase"; export type DCMeterOptions = MeterBaseOptions; /** - * DCMeter gets the raw value of the input signal at the current time. See also {@link Meter}. + * DCMeter gets the raw value of the input signal at the current time. + * @see {@link Meter}. * * @example * const meter = new Tone.DCMeter(); diff --git a/Tone/component/analysis/FFT.ts b/Tone/component/analysis/FFT.ts index 3aca60d6..30d0a862 100644 --- a/Tone/component/analysis/FFT.ts +++ b/Tone/component/analysis/FFT.ts @@ -51,7 +51,7 @@ export class FFT extends MeterBase { /** * Gets the current frequency data from the connected audio source. - * Returns the frequency data of length [[size]] as a Float32Array of decibel values. + * Returns the frequency data of length {@link size} as a Float32Array of decibel values. */ getValue(): Float32Array { const values = this._analyser.getValue() as Float32Array; @@ -60,7 +60,7 @@ export class FFT extends MeterBase { /** * The size of analysis. This must be a power of two in the range 16 to 16384. - * Determines the size of the array returned by [[getValue]] (i.e. the number of + * Determines the size of the array returned by {@link getValue} (i.e. the number of * frequency bins). Large FFT sizes may be costly to compute. */ get size(): PowerOfTwo { @@ -81,7 +81,7 @@ export class FFT extends MeterBase { } /** - * Returns the frequency value in hertz of each of the indices of the FFT's [[getValue]] response. + * Returns the frequency value in hertz of each of the indices of the FFT's {@link getValue} response. * @example * const fft = new Tone.FFT(32); * console.log([0, 1, 2, 3, 4].map(index => fft.getFrequencyOfIndex(index))); diff --git a/Tone/component/analysis/Meter.ts b/Tone/component/analysis/Meter.ts index 2709c074..1a8f00b4 100644 --- a/Tone/component/analysis/Meter.ts +++ b/Tone/component/analysis/Meter.ts @@ -16,7 +16,8 @@ export interface MeterOptions extends MeterBaseOptions { * of an input signal. It can also get the raw value of the input signal. * Setting `normalRange` to `true` will covert the output to a range of * 0-1. See an example using a graphical display - * [here](https://tonejs.github.io/examples/meter). See also {@link DCMeter}. + * [here](https://tonejs.github.io/examples/meter). + * @see {@link DCMeter}. * * @example * const meter = new Tone.Meter(); @@ -80,7 +81,7 @@ export class Meter extends MeterBase { } /** - * Use [[getValue]] instead. For the previous getValue behavior, use DCMeter. + * Use {@link getValue} instead. For the previous getValue behavior, use DCMeter. * @deprecated */ getLevel(): number | number[] { @@ -90,9 +91,9 @@ export class Meter extends MeterBase { /** * Get the current value of the incoming signal. - * Output is in decibels when [[normalRange]] is `false`. - * If [[channels]] = 1, then the output is a single number - * representing the value of the input signal. When [[channels]] > 1, + * Output is in decibels when {@link normalRange} is `false`. + * If {@link channels} = 1, then the output is a single number + * representing the value of the input signal. When {@link channels} > 1, * then each channel is returned as a value in a number array. */ getValue(): number | number[] { diff --git a/Tone/component/analysis/Waveform.ts b/Tone/component/analysis/Waveform.ts index bd8831c5..b66dc34b 100644 --- a/Tone/component/analysis/Waveform.ts +++ b/Tone/component/analysis/Waveform.ts @@ -46,7 +46,7 @@ export class Waveform extends MeterBase { /** * The size of analysis. This must be a power of two in the range 16 to 16384. - * Determines the size of the array returned by [[getValue]]. + * Determines the size of the array returned by {@link getValue}. */ get size(): PowerOfTwo { return this._analyser.size; diff --git a/Tone/component/channel/Channel.ts b/Tone/component/channel/Channel.ts index b7741bf5..6b199f23 100644 --- a/Tone/component/channel/Channel.ts +++ b/Tone/component/channel/Channel.ts @@ -17,7 +17,7 @@ export interface ChannelOptions extends ToneAudioNodeOptions { /** * Channel provides a channel strip interface with volume, pan, solo and mute controls. - * See [[PanVol]] and [[Solo]] + * @see {@link PanVol} and {@link Solo} * @example * // pan the incoming signal left and drop the volume 12db * const channel = new Tone.Channel(-0.25, -12); @@ -91,7 +91,7 @@ export class Channel extends ToneAudioNode { } /** - * Solo/unsolo the channel. Soloing is only relative to other [[Channel]]s and [[Solo]] instances + * Solo/unsolo the channel. Soloing is only relative to other {@link Channel}s and {@link Solo} instances */ get solo(): boolean { return this._solo.solo; @@ -137,9 +137,9 @@ export class Channel extends ToneAudioNode { /** * Send audio to another channel using a string. `send` is a lot like - * [[connect]], except it uses a string instead of an object. This can - * be useful in large applications to decouple sections since [[send]] - * and [[receive]] can be invoked separately in order to connect an object + * {@link connect}, except it uses a string instead of an object. This can + * be useful in large applications to decouple sections since {@link send} + * and {@link receive} can be invoked separately in order to connect an object * @param name The channel name to send the audio * @param volume The amount of the signal to send. * Defaults to 0db, i.e. send the entire signal @@ -158,7 +158,7 @@ export class Channel extends ToneAudioNode { } /** - * Receive audio from a channel which was connected with [[send]]. + * Receive audio from a channel which was connected with {@link send}. * @param name The channel name to receive audio from. */ receive(name: string): this { diff --git a/Tone/component/channel/MidSideMerge.ts b/Tone/component/channel/MidSideMerge.ts index 45934e51..08f6741d 100644 --- a/Tone/component/channel/MidSideMerge.ts +++ b/Tone/component/channel/MidSideMerge.ts @@ -9,7 +9,7 @@ import { optionsFromArguments } from "../../core/util/Defaults"; export type MidSideMergeOptions = ToneAudioNodeOptions; /** - * MidSideMerge merges the mid and side signal after they've been separated by [[MidSideSplit]] + * MidSideMerge merges the mid and side signal after they've been separated by {@link MidSideSplit} * ``` * Mid = (Left+Right)/sqrt(2); // obtain mid-signal from left and right * Side = (Left-Right)/sqrt(2); // obtain side-signal from left and right @@ -21,7 +21,7 @@ export class MidSideMerge extends ToneAudioNode { readonly name: string = "MidSideMerge"; /** - * There is no input, connect sources to either [[mid]] or [[side]] inputs. + * There is no input, connect sources to either {@link mid} or {@link side} inputs. */ readonly input: undefined; diff --git a/Tone/component/channel/MidSideSplit.ts b/Tone/component/channel/MidSideSplit.ts index ab2bccbb..1c9be390 100644 --- a/Tone/component/channel/MidSideSplit.ts +++ b/Tone/component/channel/MidSideSplit.ts @@ -23,7 +23,7 @@ export class MidSideSplit extends ToneAudioNode { readonly input: Split; /** - * There is no output node, use either [[mid]] or [[side]] outputs. + * There is no output node, use either {@link mid} or {@link side} outputs. */ readonly output: undefined; /** diff --git a/Tone/component/channel/Recorder.ts b/Tone/component/channel/Recorder.ts index 44ce0284..00ab9c60 100644 --- a/Tone/component/channel/Recorder.ts +++ b/Tone/component/channel/Recorder.ts @@ -127,7 +127,7 @@ export class Recorder extends ToneAudioNode { /** * Stop the recorder. Returns a promise with the recorded content until this point - * encoded as [[mimeType]] + * encoded as {@link mimeType} */ async stop(): Promise { assert(this.state !== "stopped", "Recorder is not started"); diff --git a/Tone/component/dynamics/Gate.ts b/Tone/component/dynamics/Gate.ts index 52f9c580..809425b6 100644 --- a/Tone/component/dynamics/Gate.ts +++ b/Tone/component/dynamics/Gate.ts @@ -13,8 +13,8 @@ export interface GateOptions extends ToneAudioNodeOptions { /** * Gate only passes a signal through when the incoming - * signal exceeds a specified threshold. It uses [[Follower]] to follow the ampltiude - * of the incoming signal and compares it to the [[threshold]] value using [[GreaterThan]]. + * signal exceeds a specified threshold. It uses {@link Follower} to follow the ampltiude + * of the incoming signal and compares it to the {@link threshold} value using {@link GreaterThan}. * * @example * const gate = new Tone.Gate(-30, 0.2).toDestination(); @@ -90,7 +90,8 @@ export class Gate extends ToneAudioNode { } /** - * The attack/decay speed of the gate. See [[Follower.smoothing]] + * The attack/decay speed of the gate. + * @see {@link Follower.smoothing} */ get smoothing(): Time { return this._follower.smoothing; diff --git a/Tone/component/dynamics/Limiter.ts b/Tone/component/dynamics/Limiter.ts index c9a9076b..5c880f65 100644 --- a/Tone/component/dynamics/Limiter.ts +++ b/Tone/component/dynamics/Limiter.ts @@ -11,7 +11,7 @@ export interface LimiterOptions extends ToneAudioNodeOptions { /** * Limiter will limit the loudness of an incoming signal. - * Under the hood it's composed of a [[Compressor]] with a fast attack + * Under the hood it's composed of a {@link Compressor} with a fast attack * and release and max compression ratio. * * @example diff --git a/Tone/component/dynamics/MidSideCompressor.ts b/Tone/component/dynamics/MidSideCompressor.ts index e4922bc3..1b42d8e4 100644 --- a/Tone/component/dynamics/MidSideCompressor.ts +++ b/Tone/component/dynamics/MidSideCompressor.ts @@ -11,8 +11,9 @@ export interface MidSideCompressorOptions extends ToneAudioNodeOptions { } /** - * MidSideCompressor applies two different compressors to the [[mid]] - * and [[side]] signal components of the input. See [[MidSideSplit]] and [[MidSideMerge]]. + * MidSideCompressor applies two different compressors to the {@link mid} + * and {@link side} signal components of the input. + * @see {@link MidSideSplit} and {@link MidSideMerge}. * @category Component */ export class MidSideCompressor extends ToneAudioNode { diff --git a/Tone/component/dynamics/MultibandCompressor.ts b/Tone/component/dynamics/MultibandCompressor.ts index 5c78336f..9290c7dd 100644 --- a/Tone/component/dynamics/MultibandCompressor.ts +++ b/Tone/component/dynamics/MultibandCompressor.ts @@ -16,7 +16,8 @@ export interface MultibandCompressorOptions extends ToneAudioNodeOptions { } /** - * A compressor with separate controls over low/mid/high dynamics. See [[Compressor]] and [[MultibandSplit]] + * A compressor with separate controls over low/mid/high dynamics. + * @see {@link Compressor} and {@link MultibandSplit} * * @example * const multiband = new Tone.MultibandCompressor({ diff --git a/Tone/component/envelope/FrequencyEnvelope.ts b/Tone/component/envelope/FrequencyEnvelope.ts index 465386d2..8dca9920 100644 --- a/Tone/component/envelope/FrequencyEnvelope.ts +++ b/Tone/component/envelope/FrequencyEnvelope.ts @@ -11,8 +11,8 @@ export interface FrequencyEnvelopeOptions extends EnvelopeOptions { exponent: number; } /** - * FrequencyEnvelope is an [[Envelope]] which ramps between [[baseFrequency]] - * and [[octaves]]. It can also have an optional [[exponent]] to adjust the curve + * FrequencyEnvelope is an {@link Envelope} which ramps between {@link baseFrequency} + * and {@link octaves}. It can also have an optional {@link exponent} to adjust the curve * which it ramps. * @example * const oscillator = new Tone.Oscillator().toDestination().start(); diff --git a/Tone/component/filter/BiquadFilter.ts b/Tone/component/filter/BiquadFilter.ts index a52c5671..c09e069d 100644 --- a/Tone/component/filter/BiquadFilter.ts +++ b/Tone/component/filter/BiquadFilter.ts @@ -14,7 +14,7 @@ export interface BiquadFilterOptions extends ToneAudioNodeOptions { /** * Thin wrapper around the native Web Audio [BiquadFilterNode](https://webaudio.github.io/web-audio-api/#biquadfilternode). - * BiquadFilter is similar to [[Filter]] but doesn't have the option to set the "rolloff" value. + * BiquadFilter is similar to {@link Filter} but doesn't have the option to set the "rolloff" value. * @category Component */ export class BiquadFilter extends ToneAudioNode { diff --git a/Tone/component/filter/LowpassCombFilter.ts b/Tone/component/filter/LowpassCombFilter.ts index 69836e4a..38728315 100644 --- a/Tone/component/filter/LowpassCombFilter.ts +++ b/Tone/component/filter/LowpassCombFilter.ts @@ -14,7 +14,7 @@ interface LowpassCombFilterOptions extends ToneAudioNodeOptions { /** * A lowpass feedback comb filter. It is similar to - * [[FeedbackCombFilter]], but includes a lowpass filter. + * {@link FeedbackCombFilter}, but includes a lowpass filter. * @category Component */ export class LowpassCombFilter extends ToneAudioNode { diff --git a/Tone/core/Global.ts b/Tone/core/Global.ts index c4e3c471..13e93de2 100644 --- a/Tone/core/Global.ts +++ b/Tone/core/Global.ts @@ -18,7 +18,7 @@ const dummyContext = new DummyContext(); let globalContext: BaseContext = dummyContext; /** - * Returns the default system-wide [[Context]] + * Returns the default system-wide {@link Context} * @category Core */ export function getContext(): BaseContext { diff --git a/Tone/core/clock/TickParam.ts b/Tone/core/clock/TickParam.ts index b9ed6255..e9a0f77c 100644 --- a/Tone/core/clock/TickParam.ts +++ b/Tone/core/clock/TickParam.ts @@ -13,7 +13,7 @@ interface TickParamOptions extends ParamOptions extends Param } /** - * The inverse of [[ticksToTime]]. Convert a duration in + * The inverse of {@link ticksToTime}. Convert a duration in * seconds to the corresponding number of ticks accounting for any * automation curves starting at the given time. * @param duration The time interval to convert to ticks. diff --git a/Tone/core/clock/Transport.test.ts b/Tone/core/clock/Transport.test.ts index 3c7039f9..493598ed 100644 --- a/Tone/core/clock/Transport.test.ts +++ b/Tone/core/clock/Transport.test.ts @@ -4,7 +4,7 @@ import { Time } from "Tone/core/type/Time"; import { noOp } from "Tone/core/util/Interface"; import { Signal } from "../../signal/Signal"; import { TransportTime } from "../type/TransportTime"; -import { Transport } from "./Transport"; +import { TransportClass } from "./Transport"; // importing for side affects import "../context/Destination"; import { warns } from "test/helper/Basic"; @@ -16,7 +16,7 @@ describe("Transport", () => { it("can get and set bpm", () => { return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.bpm.value = 125; expect(transport.bpm.value).to.be.closeTo(125, 0.001); transport.bpm.value = 120; @@ -26,7 +26,7 @@ describe("Transport", () => { it("can get and set timeSignature as both an array or number", () => { return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.timeSignature = [6, 8]; expect(transport.timeSignature).to.equal(3); transport.timeSignature = 5; @@ -36,7 +36,7 @@ describe("Transport", () => { it("can get and set timeSignature as both an array or number", () => { return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.timeSignature = [6, 8]; expect(transport.timeSignature).to.equal(3); transport.timeSignature = 5; @@ -50,7 +50,7 @@ describe("Transport", () => { it("can get and set loop points", () => { return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.loopStart = 0.2; transport.loopEnd = 0.4; expect(transport.loopStart).to.be.closeTo(0.2, 0.01); @@ -64,7 +64,7 @@ describe("Transport", () => { it("can loop events scheduled on the transport", () => { let invocations = 0; return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.schedule((time) => { invocations++; }, 0); @@ -78,7 +78,7 @@ describe("Transport", () => { it("jumps to the loopStart after the loopEnd point", () => { let looped = false; return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.on("loop", () => { looped = true; }); @@ -97,14 +97,14 @@ describe("Transport", () => { it("returns 0 if the transports not started", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); expect(transport.nextSubdivision()).to.equal(0); }); }); it("can get the next subdivision of the transport", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.start(0); return time => { whenBetween(time, 0.05, 0.07, () => { @@ -126,7 +126,7 @@ describe("Transport", () => { it("can get and set pulses per quarter", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.PPQ = 96; expect(transport.PPQ).to.equal(96); }); @@ -134,7 +134,7 @@ describe("Transport", () => { it("schedules a quarter note at the same time with a different PPQ", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.PPQ = 1; const id = transport.schedule(time => { expect(time).to.be.closeTo(transport.toSeconds("4n"), 0.1); @@ -146,7 +146,7 @@ describe("Transport", () => { it("invokes the right number of ticks with a different PPQ", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.bpm.value = 120; const ppq = 20; transport.PPQ = ppq; @@ -166,7 +166,7 @@ describe("Transport", () => { it("can jump to a specific tick number", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.ticks = 200; expect(transport.ticks).to.equal(200); transport.start(0); @@ -182,7 +182,7 @@ describe("Transport", () => { it("can get the current position in BarsBeatsSixteenths", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); expect(transport.position).to.equal("0:0:0"); transport.start(0); return atTime(0.05, () => { @@ -193,7 +193,7 @@ describe("Transport", () => { it("can get the current position in seconds", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); expect(transport.seconds).to.equal(0); transport.start(0.05); return time => { @@ -206,7 +206,7 @@ describe("Transport", () => { it("can get the current position in seconds during a bpm ramp", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); expect(transport.seconds).to.equal(0); transport.start(0.05); transport.bpm.linearRampTo(60, 0.5, 0.5); @@ -220,7 +220,7 @@ describe("Transport", () => { it("can set the current position in seconds", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); expect(transport.seconds).to.equal(0); transport.seconds = 3; expect(transport.seconds).to.be.closeTo(3, 0.01); @@ -229,7 +229,7 @@ describe("Transport", () => { it("can set the current position in BarsBeatsSixteenths", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); expect(transport.position).to.equal("0:0:0"); transport.position = "3:0"; expect(transport.position).to.equal("3:0:0"); @@ -240,7 +240,7 @@ describe("Transport", () => { it("can get the progress of the loop", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.setLoopPoints(0, "1m").start(); transport.loop = true; expect(transport.progress).to.be.equal(0); @@ -316,7 +316,7 @@ describe("Transport", () => { it("resets ticks on stop but not on pause", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.start(0).pause(0.1).stop(0.2); expect(transport.getTicksAtTime(0)).to.be.equal(Math.floor(transport.PPQ * 0)); expect(transport.getTicksAtTime(0.05)).to.be.equal(Math.floor(transport.PPQ * 0.1)); @@ -329,7 +329,7 @@ describe("Transport", () => { it("tracks ticks after start", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.bpm.value = 120; const ppq = transport.PPQ; transport.start(); @@ -344,7 +344,7 @@ describe("Transport", () => { it("can start with a tick offset", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.start(0, "200i"); return time => { @@ -357,7 +357,7 @@ describe("Transport", () => { it("can toggle the state of the transport", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.toggle(0); transport.toggle(0.2); @@ -376,7 +376,7 @@ describe("Transport", () => { it("tracks ticks correctly with a different PPQ and BPM", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.PPQ = 96; transport.bpm.value = 90; transport.start(); @@ -413,7 +413,7 @@ describe("Transport", () => { it("can schedule an event on the timeline", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const eventID = transport.schedule(() => { }, 0); expect(eventID).to.be.a("number"); }); @@ -422,7 +422,7 @@ describe("Transport", () => { it("scheduled event gets invoked with the time of the event", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const startTime = 0.1; transport.schedule(time => { expect(time).to.be.closeTo(startTime, 0.01); @@ -437,7 +437,7 @@ describe("Transport", () => { it("can schedule events with TransportTime", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const startTime = 0.1; const eighth = transport.toSeconds("8n"); transport.schedule(time => { @@ -452,7 +452,7 @@ describe("Transport", () => { it("can clear a scheduled event", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const eventID = transport.schedule(() => { throw new Error("should not call this function"); }, 0); @@ -463,7 +463,7 @@ describe("Transport", () => { it("can cancel the timeline of scheduled object", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.schedule(() => { throw new Error("should not call this"); }, 0); @@ -474,7 +474,7 @@ describe("Transport", () => { it("can cancel the timeline of scheduleOnce object", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.scheduleOnce(() => { throw new Error("should not call this"); }, 0); @@ -486,7 +486,7 @@ describe("Transport", () => { it("scheduled event anywhere along the timeline", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const startTime = transport.now(); transport.schedule(time => { expect(time).to.be.closeTo(startTime + 0.5, 0.001); @@ -501,7 +501,7 @@ describe("Transport", () => { it("can schedule multiple events and invoke them in the right order", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); let first = false; transport.schedule(() => { first = true; @@ -519,7 +519,7 @@ describe("Transport", () => { it("invokes the event again if the timeline is restarted", () => { let iterations = 0; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.schedule(() => { iterations++; }, 0.05); @@ -532,7 +532,7 @@ describe("Transport", () => { it("can add an event after the Transport is started", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.start(0); let wasScheduled = false; return time => { @@ -567,7 +567,7 @@ describe("Transport", () => { it("can schedule a repeated event", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const eventID = transport.scheduleRepeat(noOp, 1); expect(eventID).to.be.a("number"); }); @@ -576,7 +576,7 @@ describe("Transport", () => { it("scheduled event gets invoked with the time of the event", () => { let invoked = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const startTime = 0.1; const eventID = transport.scheduleRepeat(time => { expect(time).to.be.closeTo(startTime, 0.01); @@ -591,7 +591,7 @@ describe("Transport", () => { it("can cancel the timeline of scheduleRepeat", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.scheduleRepeat(() => { throw new Error("should not call this"); }, 0.01, 0); @@ -603,7 +603,7 @@ describe("Transport", () => { it("can schedule events with TransportTime", () => { let invoked = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const startTime = 0.1; const eighth = transport.toSeconds("8n"); transport.scheduleRepeat(time => { @@ -618,7 +618,7 @@ describe("Transport", () => { it("can clear a scheduled event", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const eventID = transport.scheduleRepeat(() => { throw new Error("should not call this function"); }, 1, 0); @@ -630,7 +630,7 @@ describe("Transport", () => { it("can be scheduled in the future", () => { let invoked = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const startTime = 0.1; const eventID = transport.scheduleRepeat(time => { transport.clear(eventID); @@ -646,7 +646,7 @@ describe("Transport", () => { it("repeats a repeat event", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.scheduleRepeat(() => { invocations++; }, 0.1, 0); @@ -659,7 +659,7 @@ describe("Transport", () => { it("repeats at the repeat interval", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); let repeatTime = -1; transport.scheduleRepeat(time => { if (repeatTime !== -1) { @@ -678,7 +678,7 @@ describe("Transport", () => { let first = false; let second = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const firstID = transport.scheduleRepeat(() => { first = true; transport.clear(firstID); @@ -698,7 +698,7 @@ describe("Transport", () => { it("repeats for the given interval", () => { let repeatCount = 0; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.scheduleRepeat(time => { repeatCount++; }, 0.1, 0, 0.5); @@ -711,7 +711,7 @@ describe("Transport", () => { it("can add an event after the Transport is started", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.start(0); let wasScheduled = false; const times = [0.15, 0.3]; @@ -732,7 +732,7 @@ describe("Transport", () => { it("can add an event to the past after the Transport is started", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.start(0); let wasScheduled = false; const times = [0.15, 0.25]; @@ -756,7 +756,7 @@ describe("Transport", () => { it("can schedule a single event on the timeline", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const eventID = transport.scheduleOnce(() => {}, 0); expect(eventID).to.be.a("number"); }); @@ -765,7 +765,7 @@ describe("Transport", () => { it("scheduled event gets invoked with the time of the event", () => { let invoked = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const startTime = 0.1; const eventID = transport.scheduleOnce(time => { invoked = true; @@ -781,7 +781,7 @@ describe("Transport", () => { it("can schedule events with TransportTime", () => { let invoked = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const startTime = 0.1; const eighth = transport.toSeconds("8n"); transport.scheduleOnce(time => { @@ -796,7 +796,7 @@ describe("Transport", () => { it("can clear a scheduled event", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const eventID = transport.scheduleOnce(() => { throw new Error("should not call this function"); }, 0); @@ -808,7 +808,7 @@ describe("Transport", () => { it("can be scheduled in the future", () => { let invoked = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const startTime = transport.now() + 0.1; const eventID = transport.scheduleOnce(time => { transport.clear(eventID); @@ -824,7 +824,7 @@ describe("Transport", () => { it("the event is removed after is is invoked", () => { let iterations = 0; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.scheduleOnce(() => { iterations++; }, 0); @@ -841,7 +841,7 @@ describe("Transport", () => { it("invokes start/stop/pause events", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.on("start", () => { invocations++; }); @@ -860,7 +860,7 @@ describe("Transport", () => { it("invokes start event with correct offset", () => { let wasCalled = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.on("start", (time, offset) => { expect(time).to.be.closeTo(0.2, 0.01); expect(offset).to.be.closeTo(0.5, 0.001); @@ -875,7 +875,7 @@ describe("Transport", () => { it("invokes the event just before the scheduled time", () => { let invoked = false; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.on("start", (time, offset) => { expect(time - transport.context.currentTime).to.be.closeTo(0, 0.01); expect(offset).to.equal(0); @@ -890,7 +890,7 @@ describe("Transport", () => { it("passes in the time argument to the events", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const now = transport.now(); transport.on("start", time => { invocations++; @@ -909,7 +909,7 @@ describe("Transport", () => { it("invokes the 'loop' method on loop", () => { let loops = 0; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const sixteenth = transport.toSeconds("16n"); transport.setLoopPoints(0, sixteenth); transport.loop = true; @@ -932,7 +932,7 @@ describe("Transport", () => { it("can get/set the swing subdivision", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.swingSubdivision = "8n"; expect(transport.swingSubdivision).to.equal("8n"); transport.swingSubdivision = "4n"; @@ -942,7 +942,7 @@ describe("Transport", () => { it("can get/set the swing amount", () => { return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.swing = 0.5; expect(transport.swing).to.equal(0.5); transport.swing = 0; @@ -953,7 +953,7 @@ describe("Transport", () => { it("can swing", () => { let invocations = 0; return Offline(context => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.swing = 1; transport.swingSubdivision = "8n"; const eightNote = transport.toSeconds("8n"); diff --git a/Tone/core/clock/Transport.ts b/Tone/core/clock/Transport.ts index cbd6fb0a..effe2588 100644 --- a/Tone/core/clock/Transport.ts +++ b/Tone/core/clock/Transport.ts @@ -79,15 +79,15 @@ type TransportCallback = (time: Seconds) => void; * @example * const osc = new Tone.Oscillator().toDestination(); * // repeated event every 8th note - * Tone.Transport.scheduleRepeat((time) => { + * Tone.getTransport().scheduleRepeat((time) => { * // use the callback time to schedule events * osc.start(time).stop(time + 0.1); * }, "8n"); * // transport must be started before it starts invoking events - * Tone.Transport.start(); + * Tone.getTransport().start(); * @category Core */ -export class Transport +export class TransportClass extends ToneWithContext implements Emitter { readonly name: string = "Transport"; @@ -130,14 +130,14 @@ export class Transport * The Beats Per Minute of the Transport. * @example * const osc = new Tone.Oscillator().toDestination(); - * Tone.Transport.bpm.value = 80; + * Tone.getTransport().bpm.value = 80; * // start/stop the oscillator every quarter note - * Tone.Transport.scheduleRepeat(time => { + * Tone.getTransport().scheduleRepeat(time => { * osc.start(time).stop(time + 0.1); * }, "4n"); - * Tone.Transport.start(); + * Tone.getTransport().start(); * // ramp the bpm to 120 over 10 seconds - * Tone.Transport.bpm.rampTo(120, 10); + * Tone.getTransport().bpm.rampTo(120, 10); */ bpm: TickParam<"bpm">; @@ -187,9 +187,9 @@ export class Transport constructor(options?: Partial); constructor() { - super(optionsFromArguments(Transport.getDefaults(), arguments)); + super(optionsFromArguments(TransportClass.getDefaults(), arguments)); const options = optionsFromArguments( - Transport.getDefaults(), + TransportClass.getDefaults(), arguments ); @@ -280,7 +280,7 @@ export class Transport * @return The id of the event which can be used for canceling the event. * @example * // schedule an event on the 16th measure - * Tone.Transport.schedule((time) => { + * Tone.getTransport().schedule((time) => { * // invoked on measure 16 * console.log("measure 16!"); * }, "16:0:0"); @@ -308,7 +308,7 @@ export class Transport * @example * const osc = new Tone.Oscillator().toDestination().start(); * // a callback invoked every eighth note after the first measure - * Tone.Transport.scheduleRepeat((time) => { + * Tone.getTransport().scheduleRepeat((time) => { * osc.start(time).stop(time + 0.1); * }, "8n", "1m"); */ @@ -427,7 +427,7 @@ export class Transport * @param offset The timeline offset to start the transport. * @example * // start the transport in one second starting at beginning of the 5th measure. - * Tone.Transport.start("+1", "4:0:0"); + * Tone.getTransport().start("+1", "4:0:0"); */ start(time?: Time, offset?: TransportTime): this { // start the context @@ -445,7 +445,7 @@ export class Transport * Stop the transport and all sources synced to the transport. * @param time The time when the transport should stop. * @example - * Tone.Transport.stop(); + * Tone.getTransport().stop(); */ stop(time?: Time): this { this._clock.stop(time); @@ -484,11 +484,11 @@ export class Transport * For example 4/4 would be just 4 and 6/8 would be 3. * @example * // common time - * Tone.Transport.timeSignature = 4; + * Tone.getTransport().timeSignature = 4; * // 7/8 - * Tone.Transport.timeSignature = [7, 8]; + * Tone.getTransport().timeSignature = [7, 8]; * // this will be reduced to a single number - * Tone.Transport.timeSignature; // returns 3.5 + * Tone.getTransport().timeSignature; // returns 3.5 */ get timeSignature(): TimeSignature { return this._timeSignature; @@ -534,8 +534,8 @@ export class Transport * Set the loop start and stop at the same time. * @example * // loop over the first measure - * Tone.Transport.setLoopPoints(0, "1m"); - * Tone.Transport.loop = true; + * Tone.getTransport().setLoopPoints(0, "1m"); + * Tone.getTransport().loop = true; */ setLoopPoints( startPosition: TransportTime, @@ -682,8 +682,8 @@ export class Transport * @return The context time of the next subdivision. * @example * // the transport must be started, otherwise returns 0 - * Tone.Transport.start(); - * Tone.Transport.nextSubdivision("4n"); + * Tone.getTransport().start(); + * Tone.getTransport().nextSubdivision("4n"); */ nextSubdivision(subdivision?: Time): Seconds { subdivision = this.toTicks(subdivision); @@ -756,7 +756,7 @@ export class Transport /** * Unsyncs a previously synced signal from the transport's control. - * See Transport.syncSignal. + * @see {@link syncSignal}. */ unsyncSignal(signal: Signal): this { for (let i = this._syncedSignals.length - 1; i >= 0; i--) { @@ -801,14 +801,14 @@ export class Transport emit!: (event: any, ...args: any[]) => this; } -Emitter.mixin(Transport); +Emitter.mixin(TransportClass); //------------------------------------- // INITIALIZATION //------------------------------------- onContextInit((context) => { - context.transport = new Transport({ context }); + context.transport = new TransportClass({ context }); }); onContextClose((context) => { diff --git a/Tone/core/clock/TransportEvent.test.ts b/Tone/core/clock/TransportEvent.test.ts index e0769308..3675edff 100644 --- a/Tone/core/clock/TransportEvent.test.ts +++ b/Tone/core/clock/TransportEvent.test.ts @@ -1,13 +1,13 @@ import { expect } from "chai"; import { Offline } from "test/helper/Offline"; -import { Transport } from "./Transport"; +import { TransportClass } from "./Transport"; import { TransportEvent } from "./TransportEvent"; describe("TransportEvent", () => { it("can be created and disposed", () => { return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const event = new TransportEvent(transport, { time: 0, }); @@ -17,7 +17,7 @@ describe("TransportEvent", () => { it("has a unique id", () => { return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const event = new TransportEvent(transport, { time: 0, }); @@ -29,7 +29,7 @@ describe("TransportEvent", () => { it("can invoke the callback", () => { let wasInvoked = false; return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const event = new TransportEvent(transport, { callback: (time) => { expect(time).to.equal(100); diff --git a/Tone/core/clock/TransportEvent.ts b/Tone/core/clock/TransportEvent.ts index acd019e8..9563ff66 100644 --- a/Tone/core/clock/TransportEvent.ts +++ b/Tone/core/clock/TransportEvent.ts @@ -1,7 +1,7 @@ import { Seconds, Ticks } from "../type/Units"; import { noOp } from "../util/Interface"; -type Transport = import("../clock/Transport").Transport; +type Transport = import("../clock/Transport").TransportClass; export interface TransportEventOptions { callback: (time: number) => void; @@ -10,7 +10,7 @@ export interface TransportEventOptions { } /** - * TransportEvent is an internal class used by [[Transport]] + * TransportEvent is an internal class used by {@link TransportClass} * to schedule events. Do no invoke this class directly, it is * handled from within Tone.Transport. */ diff --git a/Tone/core/clock/TransportRepeatEvent.test.ts b/Tone/core/clock/TransportRepeatEvent.test.ts index 5c1305e4..2b52a997 100644 --- a/Tone/core/clock/TransportRepeatEvent.test.ts +++ b/Tone/core/clock/TransportRepeatEvent.test.ts @@ -1,13 +1,13 @@ import { expect } from "chai"; import { Offline } from "test/helper/Offline"; -import { Transport } from "./Transport"; +import { TransportClass } from "./Transport"; import { TransportRepeatEvent } from "./TransportRepeatEvent"; describe("TransportRepeatEvent", () => { it("can be created and disposed", () => { return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const event = new TransportRepeatEvent(transport, { duration: 100, interval: 4, @@ -19,7 +19,7 @@ describe("TransportRepeatEvent", () => { it("generates a unique event ID", () => { return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const event = new TransportRepeatEvent(transport, { time: 0, }); @@ -30,7 +30,7 @@ describe("TransportRepeatEvent", () => { it("is removed from the Transport when disposed", () => { return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); const event = new TransportRepeatEvent(transport, { time: 0, }); diff --git a/Tone/core/clock/TransportRepeatEvent.ts b/Tone/core/clock/TransportRepeatEvent.ts index b680d52c..6e339f00 100644 --- a/Tone/core/clock/TransportRepeatEvent.ts +++ b/Tone/core/clock/TransportRepeatEvent.ts @@ -4,7 +4,7 @@ import { Seconds, Ticks, Time } from "../type/Units"; import { TransportEvent, TransportEventOptions } from "./TransportEvent"; import { GT, LT } from "../util/Math"; -type Transport = import("../clock/Transport").Transport; +type Transport = import("../clock/Transport").TransportClass; interface TransportRepeatEventOptions extends TransportEventOptions { interval: Ticks; diff --git a/Tone/core/context/AbstractParam.ts b/Tone/core/context/AbstractParam.ts index b53c8217..8dc79d77 100644 --- a/Tone/core/context/AbstractParam.ts +++ b/Tone/core/context/AbstractParam.ts @@ -1,7 +1,7 @@ import { Time, UnitMap, UnitName } from "../type/Units"; /** - * Abstract base class for [[Param]] and [[Signal]] + * Abstract base class for {@link Param} and {@link Signal} */ export abstract class AbstractParam { @@ -37,8 +37,8 @@ export abstract class AbstractParam { /** * Creates a schedule point with the current value at the current time. - * Automation methods like [[linearRampToValueAtTime]] and [[exponentialRampToValueAtTime]] - * require a starting automation value usually set by [[setValueAtTime]]. This method + * Automation methods like {@link linearRampToValueAtTime} and {@link exponentialRampToValueAtTime} + * require a starting automation value usually set by {@link setValueAtTime}. This method * is useful since it will do a `setValueAtTime` with whatever the currently computed * value at the given time is. * @param time When to add a ramp point. @@ -196,7 +196,7 @@ export abstract class AbstractParam { abstract cancelScheduledValues(time: Time): this; /** - * This is similar to [[cancelScheduledValues]] except + * This is similar to {@link cancelScheduledValues} except * it holds the automated value at time until the next automated event. * @example * return Tone.Offline(() => { diff --git a/Tone/core/context/BaseContext.ts b/Tone/core/context/BaseContext.ts index ba831424..c07af471 100644 --- a/Tone/core/context/BaseContext.ts +++ b/Tone/core/context/BaseContext.ts @@ -2,10 +2,10 @@ import { Seconds } from "../type/Units"; import { Emitter } from "../util/Emitter"; import { AnyAudioContext } from "./AudioContext"; -type Draw = import("../util/Draw").Draw; -type Destination = import("./Destination").Destination; -type Transport = import("../clock/Transport").Transport; -type Listener = import("./Listener").Listener; +type Draw = import("../util/Draw").DrawClass; +type Destination = import("./Destination").DestinationClass; +type Transport = import("../clock/Transport").TransportClass; +type Listener = import("./Listener").ListenerClass; // these are either not used in Tone.js or deprecated and not implemented. export type ExcludedFromBaseAudioContext = diff --git a/Tone/core/context/Context.test.ts b/Tone/core/context/Context.test.ts index bf61d218..fc39c610 100644 --- a/Tone/core/context/Context.test.ts +++ b/Tone/core/context/Context.test.ts @@ -2,13 +2,13 @@ import { expect } from "chai"; import { ConstantOutput } from "test/helper/ConstantOutput"; import { Offline } from "test/helper/Offline"; import { ONLINE_TESTING } from "test/helper/Supports"; -import { Transport } from "../clock/Transport"; +import { TransportClass } from "../clock/Transport"; import { getContext } from "../Global"; import { createAudioContext } from "./AudioContext"; import { Context } from "./Context"; -import { Destination } from "./Destination"; -import { Listener } from "./Listener"; -import { Draw } from "../util/Draw"; +import { DestinationClass } from "./Destination"; +import { ListenerClass } from "./Listener"; +import { DrawClass } from "../util/Draw"; import { connect } from "./ToneAudioNode"; describe("Context", () => { @@ -19,9 +19,9 @@ describe("Context", () => { const ctxDraw = context.draw; const ctxTransport = context.transport; const ctxListener = context.listener; - expect(context.destination).is.instanceOf(Destination); - expect(context.draw).is.instanceOf(Draw); - expect(context.listener).is.instanceOf(Listener); + expect(context.destination).is.instanceOf(DestinationClass); + expect(context.draw).is.instanceOf(DrawClass); + expect(context.listener).is.instanceOf(ListenerClass); await context.close(); expect(ctxDest.disposed).to.be.true; expect(ctxDraw.disposed).to.be.true; @@ -218,7 +218,7 @@ describe("Context", () => { it("is invoked in the offline context", () => { return Offline((context) => { - const transport = new Transport({ context }); + const transport = new TransportClass({ context }); transport.context.setTimeout(() => { expect(transport.now()).to.be.closeTo(0.01, 0.005); }, 0.01); diff --git a/Tone/core/context/Context.ts b/Tone/core/context/Context.ts index dc3ecd01..b83cbadf 100644 --- a/Tone/core/context/Context.ts +++ b/Tone/core/context/Context.ts @@ -13,10 +13,10 @@ import { closeContext, initializeContext } from "./ContextInitialization"; import { BaseContext, ContextLatencyHint } from "./BaseContext"; import { assert } from "../util/Debug"; -type Transport = import("../clock/Transport").Transport; -type Destination = import("./Destination").Destination; -type Listener = import("./Listener").Listener; -type Draw = import("../util/Draw").Draw; +type Transport = import("../clock/Transport").TransportClass; +type Destination = import("./Destination").DestinationClass; +type Listener = import("./Listener").ListenerClass; +type Draw = import("../util/Draw").DrawClass; export interface ContextOptions { clockSource: TickerClockSource; @@ -349,7 +349,7 @@ export class Context extends BaseContext { /** * Create an audio worklet node from a name and options. The module - * must first be loaded using [[addAudioWorkletModule]]. + * must first be loaded using {@link addAudioWorkletModule}. */ createAudioWorkletNode( name: string, @@ -413,7 +413,7 @@ export class Context extends BaseContext { * The amount of time into the future events are scheduled. Giving Web Audio * a short amount of time into the future to schedule events can reduce clicks and * improve performance. This value can be set to 0 to get the lowest latency. - * Adjusting this value also affects the [[updateInterval]]. + * Adjusting this value also affects the {@link updateInterval}. */ get lookAhead(): Seconds { return this._lookAhead; @@ -452,7 +452,7 @@ export class Context extends BaseContext { } /** - * The current audio context time plus a short [[lookAhead]]. + * The current audio context time plus a short {@link lookAhead}. * @example * setInterval(() => { * console.log("now", Tone.now()); @@ -463,11 +463,11 @@ export class Context extends BaseContext { } /** - * The current audio context time without the [[lookAhead]]. - * In most cases it is better to use [[now]] instead of [[immediate]] since - * with [[now]] the [[lookAhead]] is applied equally to _all_ components including internal components, - * to making sure that everything is scheduled in sync. Mixing [[now]] and [[immediate]] - * can cause some timing issues. If no lookAhead is desired, you can set the [[lookAhead]] to `0`. + * The current audio context time without the {@link lookAhead}. + * In most cases it is better to use {@link now} instead of {@link immediate} since + * with {@link now} the {@link lookAhead} is applied equally to _all_ components including internal components, + * to making sure that everything is scheduled in sync. Mixing {@link now} and {@link immediate} + * can cause some timing issues. If no lookAhead is desired, you can set the {@link lookAhead} to `0`. */ immediate(): Seconds { return this._context.currentTime; @@ -475,7 +475,8 @@ export class Context extends BaseContext { /** * Starts the audio context from a suspended state. This is required - * to initially start the AudioContext. See [[start]] + * to initially start the AudioContext. + * @see {@link start} */ resume(): Promise { if (isAudioContext(this._context)) { @@ -593,7 +594,7 @@ export class Context extends BaseContext { } /** - * Clear the function scheduled by [[setInterval]] + * Clear the function scheduled by {@link setInterval} */ clearInterval(id: number): this { return this.clearTimeout(id); diff --git a/Tone/core/context/Destination.test.ts b/Tone/core/context/Destination.test.ts index 94b28bb3..60320f8c 100644 --- a/Tone/core/context/Destination.test.ts +++ b/Tone/core/context/Destination.test.ts @@ -4,12 +4,12 @@ import { Offline } from "test/helper/Offline"; import { PassAudio } from "test/helper/PassAudio"; import { Oscillator } from "Tone/source/oscillator/Oscillator"; import { getContext } from "../Global"; -import { Destination } from "./Destination"; +import { DestinationClass } from "./Destination"; describe("Destination", () => { it("creates itself on the context", () => { - expect(getContext().destination).instanceOf(Destination); + expect(getContext().destination).instanceOf(DestinationClass); }); it("can be muted and unmuted", () => { diff --git a/Tone/core/context/Destination.ts b/Tone/core/context/Destination.ts index bee7fc69..7b3c70e7 100644 --- a/Tone/core/context/Destination.ts +++ b/Tone/core/context/Destination.ts @@ -26,7 +26,7 @@ interface DestinationOptions extends ToneAudioNodeOptions { * oscillator.toDestination(); * @category Core */ -export class Destination extends ToneAudioNode { +export class DestinationClass extends ToneAudioNode { readonly name: string = "Destination"; @@ -46,8 +46,8 @@ export class Destination extends ToneAudioNode { constructor(options: Partial); constructor() { - super(optionsFromArguments(Destination.getDefaults(), arguments)); - const options = optionsFromArguments(Destination.getDefaults(), arguments); + super(optionsFromArguments(DestinationClass.getDefaults(), arguments)); + const options = optionsFromArguments(DestinationClass.getDefaults(), arguments); connectSeries(this.input, this.output, this.context.rawContext.destination); @@ -120,7 +120,7 @@ export class Destination extends ToneAudioNode { //------------------------------------- onContextInit(context => { - context.destination = new Destination({ context }); + context.destination = new DestinationClass({ context }); }); onContextClose(context => { diff --git a/Tone/core/context/DummyContext.ts b/Tone/core/context/DummyContext.ts index 3af54180..75f9a382 100644 --- a/Tone/core/context/DummyContext.ts +++ b/Tone/core/context/DummyContext.ts @@ -2,10 +2,10 @@ import { BaseContext } from "./BaseContext"; import { Seconds } from "../type/Units"; import { AnyAudioContext } from "./AudioContext"; -type Draw = import("../util/Draw").Draw; -type Destination = import("./Destination").Destination; -type Transport = import("../clock/Transport").Transport; -type Listener = import("./Listener").Listener; +type Draw = import("../util/Draw").DrawClass; +type Destination = import("./Destination").DestinationClass; +type Transport = import("../clock/Transport").TransportClass; +type Listener = import("./Listener").ListenerClass; export class DummyContext extends BaseContext { //--------------------------- diff --git a/Tone/core/context/Listener.test.ts b/Tone/core/context/Listener.test.ts index b24c7f58..ac3e03c3 100644 --- a/Tone/core/context/Listener.test.ts +++ b/Tone/core/context/Listener.test.ts @@ -1,12 +1,12 @@ import { expect } from "chai"; import { Offline } from "test/helper/Offline"; import { getContext } from "../Global"; -import { Listener } from "./Listener"; +import { ListenerClass } from "./Listener"; describe("Listener", () => { it("creates itself on the context", () => { - expect(getContext().listener).instanceOf(Listener); + expect(getContext().listener).instanceOf(ListenerClass); }); it("can get and set values as an object", () => { diff --git a/Tone/core/context/Listener.ts b/Tone/core/context/Listener.ts index 61909f02..68c0f7f1 100644 --- a/Tone/core/context/Listener.ts +++ b/Tone/core/context/Listener.ts @@ -16,11 +16,11 @@ export interface ListenerOptions extends ToneAudioNodeOptions{ /** * Tone.Listener is a thin wrapper around the AudioListener. Listener combined - * with [[Panner3D]] makes up the Web Audio API's 3D panning system. Panner3D allows you + * with {@link Panner3D} makes up the Web Audio API's 3D panning system. Panner3D allows you * to place sounds in 3D and Listener allows you to navigate the 3D sound environment from * a first-person perspective. There is only one listener per audio context. */ -export class Listener extends ToneAudioNode { +export class ListenerClass extends ToneAudioNode { readonly name: string = "Listener"; @@ -109,7 +109,7 @@ export class Listener extends ToneAudioNode { //------------------------------------- onContextInit(context => { - context.listener = new Listener({ context }); + context.listener = new ListenerClass({ context }); }); onContextClose(context => { diff --git a/Tone/core/context/Offline.ts b/Tone/core/context/Offline.ts index 4ffa0a78..f33d6632 100644 --- a/Tone/core/context/Offline.ts +++ b/Tone/core/context/Offline.ts @@ -6,7 +6,7 @@ import { ToneAudioBuffer } from "./ToneAudioBuffer"; /** * Generate a buffer by rendering all of the Tone.js code within the callback using the OfflineAudioContext. * The OfflineAudioContext is capable of rendering much faster than real time in many cases. - * The callback function also passes in an offline instance of [[Context]] which can be used + * The callback function also passes in an offline instance of {@link Context} which can be used * to schedule events along the Transport. * @param callback All Tone.js nodes which are created and scheduled within this callback are recorded into the output Buffer. * @param duration the amount of time to record for. diff --git a/Tone/core/context/ToneAudioNode.ts b/Tone/core/context/ToneAudioNode.ts index 6276dedd..bebb3d75 100644 --- a/Tone/core/context/ToneAudioNode.ts +++ b/Tone/core/context/ToneAudioNode.ts @@ -20,6 +20,7 @@ export type ToneAudioNodeOptions = ToneWithContextOptions; /** * ToneAudioNode is the base class for classes which process audio. + * @category Core */ export abstract class ToneAudioNode extends ToneWithContext { @@ -211,7 +212,7 @@ export abstract class ToneAudioNode extends Tone { - +export abstract class ToneWithContext< + Options extends ToneWithContextOptions +> extends Tone { /** * The context belonging to the node. */ @@ -37,11 +49,15 @@ export abstract class ToneWithContext ex /** * Pass in a constructor as the first argument */ - constructor(context?: BaseContext) + constructor(context?: BaseContext); constructor(options?: Partial); constructor() { super(); - const options = optionsFromArguments(ToneWithContext.getDefaults(), arguments, ["context"]); + const options = optionsFromArguments( + ToneWithContext.getDefaults(), + arguments, + ["context"] + ); if (this.defaultContext) { this.context = this.defaultContext; } else { @@ -79,8 +95,6 @@ export abstract class ToneWithContext ex /** * The duration in seconds of one sample. - * @example - * console.log(Tone.Transport.sampleTime); */ get sampleTime(): Seconds { return 1 / this.context.sampleRate; @@ -96,8 +110,8 @@ export abstract class ToneWithContext ex } /** - * Convert the incoming time to seconds. - * This is calculated against the current [[Transport]] bpm + * Convert the incoming time to seconds. + * This is calculated against the current {@link TransportClass} bpm * @example * const gain = new Tone.Gain(); * setInterval(() => console.log(gain.toSeconds("4n")), 100); @@ -139,7 +153,7 @@ export abstract class ToneWithContext ex protected _getPartialProperties(props: Options): Partial { const options = this.get(); // remove attributes from the prop that are not in the partial - Object.keys(options).forEach(name => { + Object.keys(options).forEach((name) => { if (isUndef(props[name])) { delete options[name]; } @@ -155,15 +169,26 @@ export abstract class ToneWithContext ex */ get(): Options { const defaults = getDefaultsFromInstance(this) as Options; - Object.keys(defaults).forEach(attribute => { + Object.keys(defaults).forEach((attribute) => { if (Reflect.has(this, attribute)) { const member = this[attribute]; - if (isDefined(member) && isDefined(member.value) && isDefined(member.setValueAtTime)) { + if ( + isDefined(member) && + isDefined(member.value) && + isDefined(member.setValueAtTime) + ) { defaults[attribute] = member.value; } else if (member instanceof ToneWithContext) { - defaults[attribute] = member._getPartialProperties(defaults[attribute]); + defaults[attribute] = member._getPartialProperties( + defaults[attribute] + ); // otherwise make sure it's a serializable type - } else if (isArray(member) || isNumber(member) || isString(member) || isBoolean(member)) { + } else if ( + isArray(member) || + isNumber(member) || + isString(member) || + isBoolean(member) + ) { defaults[attribute] = member; } else { // remove all undefined and unserializable attributes @@ -188,9 +213,13 @@ export abstract class ToneWithContext ex * player.autostart = true; */ set(props: RecursivePartial): this { - Object.keys(props).forEach(attribute => { + Object.keys(props).forEach((attribute) => { if (Reflect.has(this, attribute) && isDefined(this[attribute])) { - if (this[attribute] && isDefined(this[attribute].value) && isDefined(this[attribute].setValueAtTime)) { + if ( + this[attribute] && + isDefined(this[attribute].value) && + isDefined(this[attribute].setValueAtTime) + ) { // small optimization if (this[attribute].value !== props[attribute]) { this[attribute].value = props[attribute]; diff --git a/Tone/core/index.ts b/Tone/core/index.ts index 1d3b4f18..8f98a207 100644 --- a/Tone/core/index.ts +++ b/Tone/core/index.ts @@ -35,4 +35,5 @@ export { Unit }; // export the debug stuff as Debug import * as debug from "./util/Debug"; +/** @internal */ export { debug }; diff --git a/Tone/core/type/NoteUnits.ts b/Tone/core/type/NoteUnits.ts index f3215afa..c6f4cd46 100644 --- a/Tone/core/type/NoteUnits.ts +++ b/Tone/core/type/NoteUnits.ts @@ -1,4 +1,8 @@ -// this file contains all of the valid note names for all pitches between C-4 and C11 +// This file contains all of the valid note names for all pitches between C-4 and C11 + +type Letter = "C" | "D" | "E" | "F" | "G" | "A" | "B"; +type Accidental = "bb" | "b" | "" | "#" | "x"; +type Octave = -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11; /** * A note in Scientific pitch notation. @@ -6,31 +10,13 @@ * e.g. "C4", "D#3", "G-1" * @category Unit */ -export type Note = "Cbb-4" | "Cb-4" | "C-4" | "C#-4" | "Cx-4" | "Dbb-4" | "Db-4" | "D-4" | "D#-4" | "Dx-4" | "Ebb-4" | "Eb-4" | "E-4" | "E#-4" | "Ex-4" | "Fbb-4" | "Fb-4" | "F-4" | "F#-4" | "Fx-4" | "Gbb-4" | "Gb-4" | "G-4" | "G#-4" | "Gx-4" | "Abb-4" | "Ab-4" | "A-4" | "A#-4" | "Ax-4" | "Bbb-4" | "Bb-4" | "B-4" | "B#-4" | "Bx-4" | -"Cbb-3" | "Cb-3" | "C-3" | "C#-3" | "Cx-3" | "Dbb-3" | "Db-3" | "D-3" | "D#-3" | "Dx-3" | "Ebb-3" | "Eb-3" | "E-3" | "E#-3" | "Ex-3" | "Fbb-3" | "Fb-3" | "F-3" | "F#-3" | "Fx-3" | "Gbb-3" | "Gb-3" | "G-3" | "G#-3" | "Gx-3" | "Abb-3" | "Ab-3" | "A-3" | "A#-3" | "Ax-3" | "Bbb-3" | "Bb-3" | "B-3" | "B#-3" | "Bx-3" | -"Cbb-2" | "Cb-2" | "C-2" | "C#-2" | "Cx-2" | "Dbb-2" | "Db-2" | "D-2" | "D#-2" | "Dx-2" | "Ebb-2" | "Eb-2" | "E-2" | "E#-2" | "Ex-2" | "Fbb-2" | "Fb-2" | "F-2" | "F#-2" | "Fx-2" | "Gbb-2" | "Gb-2" | "G-2" | "G#-2" | "Gx-2" | "Abb-2" | "Ab-2" | "A-2" | "A#-2" | "Ax-2" | "Bbb-2" | "Bb-2" | "B-2" | "B#-2" | "Bx-2" | -"Cbb-1" | "Cb-1" | "C-1" | "C#-1" | "Cx-1" | "Dbb-1" | "Db-1" | "D-1" | "D#-1" | "Dx-1" | "Ebb-1" | "Eb-1" | "E-1" | "E#-1" | "Ex-1" | "Fbb-1" | "Fb-1" | "F-1" | "F#-1" | "Fx-1" | "Gbb-1" | "Gb-1" | "G-1" | "G#-1" | "Gx-1" | "Abb-1" | "Ab-1" | "A-1" | "A#-1" | "Ax-1" | "Bbb-1" | "Bb-1" | "B-1" | "B#-1" | "Bx-1" | -"Cbb0" | "Cb0" | "C0" | "C#0" | "Cx0" | "Dbb0" | "Db0" | "D0" | "D#0" | "Dx0" | "Ebb0" | "Eb0" | "E0" | "E#0" | "Ex0" | "Fbb0" | "Fb0" | "F0" | "F#0" | "Fx0" | "Gbb0" | "Gb0" | "G0" | "G#0" | "Gx0" | "Abb0" | "Ab0" | "A0" | "A#0" | "Ax0" | "Bbb0" | "Bb0" | "B0" | "B#0" | "Bx0" | -"Cbb1" | "Cb1" | "C1" | "C#1" | "Cx1" | "Dbb1" | "Db1" | "D1" | "D#1" | "Dx1" | "Ebb1" | "Eb1" | "E1" | "E#1" | "Ex1" | "Fbb1" | "Fb1" | "F1" | "F#1" | "Fx1" | "Gbb1" | "Gb1" | "G1" | "G#1" | "Gx1" | "Abb1" | "Ab1" | "A1" | "A#1" | "Ax1" | "Bbb1" | "Bb1" | "B1" | "B#1" | "Bx1" | -"Cbb2" | "Cb2" | "C2" | "C#2" | "Cx2" | "Dbb2" | "Db2" | "D2" | "D#2" | "Dx2" | "Ebb2" | "Eb2" | "E2" | "E#2" | "Ex2" | "Fbb2" | "Fb2" | "F2" | "F#2" | "Fx2" | "Gbb2" | "Gb2" | "G2" | "G#2" | "Gx2" | "Abb2" | "Ab2" | "A2" | "A#2" | "Ax2" | "Bbb2" | "Bb2" | "B2" | "B#2" | "Bx2" | -"Cbb3" | "Cb3" | "C3" | "C#3" | "Cx3" | "Dbb3" | "Db3" | "D3" | "D#3" | "Dx3" | "Ebb3" | "Eb3" | "E3" | "E#3" | "Ex3" | "Fbb3" | "Fb3" | "F3" | "F#3" | "Fx3" | "Gbb3" | "Gb3" | "G3" | "G#3" | "Gx3" | "Abb3" | "Ab3" | "A3" | "A#3" | "Ax3" | "Bbb3" | "Bb3" | "B3" | "B#3" | "Bx3" | -"Cbb4" | "Cb4" | "C4" | "C#4" | "Cx4" | "Dbb4" | "Db4" | "D4" | "D#4" | "Dx4" | "Ebb4" | "Eb4" | "E4" | "E#4" | "Ex4" | "Fbb4" | "Fb4" | "F4" | "F#4" | "Fx4" | "Gbb4" | "Gb4" | "G4" | "G#4" | "Gx4" | "Abb4" | "Ab4" | "A4" | "A#4" | "Ax4" | "Bbb4" | "Bb4" | "B4" | "B#4" | "Bx4" | -"Cbb5" | "Cb5" | "C5" | "C#5" | "Cx5" | "Dbb5" | "Db5" | "D5" | "D#5" | "Dx5" | "Ebb5" | "Eb5" | "E5" | "E#5" | "Ex5" | "Fbb5" | "Fb5" | "F5" | "F#5" | "Fx5" | "Gbb5" | "Gb5" | "G5" | "G#5" | "Gx5" | "Abb5" | "Ab5" | "A5" | "A#5" | "Ax5" | "Bbb5" | "Bb5" | "B5" | "B#5" | "Bx5" | -"Cbb6" | "Cb6" | "C6" | "C#6" | "Cx6" | "Dbb6" | "Db6" | "D6" | "D#6" | "Dx6" | "Ebb6" | "Eb6" | "E6" | "E#6" | "Ex6" | "Fbb6" | "Fb6" | "F6" | "F#6" | "Fx6" | "Gbb6" | "Gb6" | "G6" | "G#6" | "Gx6" | "Abb6" | "Ab6" | "A6" | "A#6" | "Ax6" | "Bbb6" | "Bb6" | "B6" | "B#6" | "Bx6" | -"Cbb7" | "Cb7" | "C7" | "C#7" | "Cx7" | "Dbb7" | "Db7" | "D7" | "D#7" | "Dx7" | "Ebb7" | "Eb7" | "E7" | "E#7" | "Ex7" | "Fbb7" | "Fb7" | "F7" | "F#7" | "Fx7" | "Gbb7" | "Gb7" | "G7" | "G#7" | "Gx7" | "Abb7" | "Ab7" | "A7" | "A#7" | "Ax7" | "Bbb7" | "Bb7" | "B7" | "B#7" | "Bx7" | -"Cbb8" | "Cb8" | "C8" | "C#8" | "Cx8" | "Dbb8" | "Db8" | "D8" | "D#8" | "Dx8" | "Ebb8" | "Eb8" | "E8" | "E#8" | "Ex8" | "Fbb8" | "Fb8" | "F8" | "F#8" | "Fx8" | "Gbb8" | "Gb8" | "G8" | "G#8" | "Gx8" | "Abb8" | "Ab8" | "A8" | "A#8" | "Ax8" | "Bbb8" | "Bb8" | "B8" | "B#8" | "Bx8" | -"Cbb9" | "Cb9" | "C9" | "C#9" | "Cx9" | "Dbb9" | "Db9" | "D9" | "D#9" | "Dx9" | "Ebb9" | "Eb9" | "E9" | "E#9" | "Ex9" | "Fbb9" | "Fb9" | "F9" | "F#9" | "Fx9" | "Gbb9" | "Gb9" | "G9" | "G#9" | "Gx9" | "Abb9" | "Ab9" | "A9" | "A#9" | "Ax9" | "Bbb9" | "Bb9" | "B9" | "B#9" | "Bx9" | -"Cbb10" | "Cb10" | "C10" | "C#10" | "Cx10" | "Dbb10" | "Db10" | "D10" | "D#10" | "Dx10" | "Ebb10" | "Eb10" | "E10" | "E#10" | "Ex10" | "Fbb10" | "Fb10" | "F10" | "F#10" | "Fx10" | "Gbb10" | "Gb10" | "G10" | "G#10" | "Gx10" | "Abb10" | "Ab10" | "A10" | "A#10" | "Ax10" | "Bbb10" | "Bb10" | "B10" | "B#10" | "Bx10" | -"Cbb11" | "Cb11" | "C11" | "C#11" | "Cx11" | "Dbb11" | "Db11" | "D11" | "D#11" | "Dx11" | "Ebb11" | "Eb11" | "E11" | "E#11" | "Ex11" | "Fbb11" | "Fb11" | "F11" | "F#11" | "Fx11" | "Gbb11" | "Gb11" | "G11" | "G#11" | "Gx11" | "Abb11" | "Ab11" | "A11" | "A#11" | "Ax11" | "Bbb11" | "Bb11" | "B11" | "B#11" | "Bx11"; +export type Note = `${Letter}${Accidental}${Octave}`; + +type IntegerRange = + A["length"] extends N ? A[number] : IntegerRange; /** * A number representing a midi note. Integers between 0-127 * @category Unit */ -export type MidiNote = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -121 | 122 | 123 | 124 | 125 | 126 | 127; +export type MidiNote = IntegerRange<128>; diff --git a/Tone/core/type/Time.ts b/Tone/core/type/Time.ts index 1af83730..196e5135 100644 --- a/Tone/core/type/Time.ts +++ b/Tone/core/type/Time.ts @@ -104,7 +104,7 @@ export class TimeClass(arrayA: T[], arrayB: T[]): boolean { /** * Convert an args array into an object. + * @internal */ export function optionsFromArguments( defaults: T, @@ -101,6 +102,7 @@ export function getDefaultsFromInstance(instance: T): BaseToneOptions { /** * Returns the fallback if the given object is undefined. * Take an array of arguments and return a formatted options object. + * @internal */ export function defaultArg(given: T, fallback: T): T { if (isUndef(given)) { diff --git a/Tone/core/util/Draw.test.ts b/Tone/core/util/Draw.test.ts index 1941745e..5cc66a5f 100644 --- a/Tone/core/util/Draw.test.ts +++ b/Tone/core/util/Draw.test.ts @@ -1,12 +1,12 @@ import { expect } from "chai"; import { ONLINE_TESTING } from "test/helper/Supports"; -import { Draw } from "./Draw"; +import { DrawClass } from "./Draw"; describe("Draw", () => { if (ONLINE_TESTING) { - const draw = new Draw(); + const draw = new DrawClass(); after(() => { draw.dispose(); diff --git a/Tone/core/util/Draw.ts b/Tone/core/util/Draw.ts index c7a34245..0cc3061d 100644 --- a/Tone/core/util/Draw.ts +++ b/Tone/core/util/Draw.ts @@ -25,7 +25,7 @@ interface DrawEvent extends TimelineEvent { * Tone.Transport.start(); * @category Core */ -export class Draw extends ToneWithContext { +export class DrawClass extends ToneWithContext { readonly name: string = "Draw"; @@ -117,7 +117,7 @@ export class Draw extends ToneWithContext { //------------------------------------- onContextInit(context => { - context.draw = new Draw({ context }); + context.draw = new DrawClass({ context }); }); onContextClose(context => { diff --git a/Tone/core/util/IntervalTimeline.ts b/Tone/core/util/IntervalTimeline.ts index c43f1bda..395bfa3a 100644 --- a/Tone/core/util/IntervalTimeline.ts +++ b/Tone/core/util/IntervalTimeline.ts @@ -20,6 +20,7 @@ type IteratorCallback = (event: IntervalTimelineEvent) => void; * for querying an intersection point with the timeline * events. Internally uses an [Interval Tree](https://en.wikipedia.org/wiki/Interval_tree) * to represent the data. + * @internal */ export class IntervalTimeline extends Tone { diff --git a/Tone/core/util/StateTimeline.ts b/Tone/core/util/StateTimeline.ts index 21790cd0..79074538 100644 --- a/Tone/core/util/StateTimeline.ts +++ b/Tone/core/util/StateTimeline.ts @@ -12,6 +12,7 @@ export interface StateTimelineEvent extends TimelineEvent { /** * A Timeline State. Provides the methods: `setStateAtTime("state", time)` and `getValueAtTime(time)` * @param initial The initial state of the StateTimeline. Defaults to `undefined` + * @internal */ export class StateTimeline = Record> extends Timeline { diff --git a/Tone/core/util/Timeline.ts b/Tone/core/util/Timeline.ts index d724b760..de65d93e 100644 --- a/Tone/core/util/Timeline.ts +++ b/Tone/core/util/Timeline.ts @@ -26,6 +26,7 @@ export interface TimelineEvent { * along a timeline. All events must have a "time" property. * Internally, events are stored in time order for fast * retrieval. + * @internal */ export class Timeline extends Tone { diff --git a/Tone/core/util/TypeCheck.ts b/Tone/core/util/TypeCheck.ts index 44427d5f..f0e76a7a 100644 --- a/Tone/core/util/TypeCheck.ts +++ b/Tone/core/util/TypeCheck.ts @@ -4,14 +4,14 @@ import { Note } from "../type/Units"; * Test if the arg is undefined */ export function isUndef(arg: any): arg is undefined { - return typeof arg === "undefined"; + return arg === undefined; } /** * Test if the arg is not undefined */ export function isDefined(arg: T | undefined): arg is T { - return !isUndef(arg); + return arg !== undefined; } /** @@ -25,35 +25,38 @@ export function isFunction(arg: any): arg is (a: any) => any { * Test if the argument is a number. */ export function isNumber(arg: any): arg is number { - return (typeof arg === "number"); + return typeof arg === "number"; } /** * Test if the given argument is an object literal (i.e. `{}`); */ export function isObject(arg: any): arg is object { - return (Object.prototype.toString.call(arg) === "[object Object]" && arg.constructor === Object); + return ( + Object.prototype.toString.call(arg) === "[object Object]" && + arg.constructor === Object + ); } /** * Test if the argument is a boolean. */ export function isBoolean(arg: any): arg is boolean { - return (typeof arg === "boolean"); + return typeof arg === "boolean"; } /** * Test if the argument is an Array */ export function isArray(arg: any): arg is any[] { - return (Array.isArray(arg)); + return Array.isArray(arg); } /** * Test if the argument is a string. */ export function isString(arg: any): arg is string { - return (typeof arg === "string"); + return typeof arg === "string"; } /** diff --git a/Tone/core/worklet/ToneAudioWorkletProcessor.worklet.ts b/Tone/core/worklet/ToneAudioWorkletProcessor.worklet.ts index f5ee9565..92fe5b07 100644 --- a/Tone/core/worklet/ToneAudioWorkletProcessor.worklet.ts +++ b/Tone/core/worklet/ToneAudioWorkletProcessor.worklet.ts @@ -2,7 +2,7 @@ import { addToWorklet } from "./WorkletGlobalScope"; const toneAudioWorkletProcessor = /* javascript */ ` /** - * The base AudioWorkletProcessor for use in Tone.js. Works with the [[ToneAudioWorklet]]. + * The base AudioWorkletProcessor for use in Tone.js. Works with the {@link ToneAudioWorklet}. */ class ToneAudioWorkletProcessor extends AudioWorkletProcessor { diff --git a/Tone/effect/AutoPanner.ts b/Tone/effect/AutoPanner.ts index dcc105e0..22088dbf 100644 --- a/Tone/effect/AutoPanner.ts +++ b/Tone/effect/AutoPanner.ts @@ -8,7 +8,7 @@ export interface AutoPannerOptions extends LFOEffectOptions { } /** - * AutoPanner is a [[Panner]] with an [[LFO]] connected to the pan amount. + * AutoPanner is a {@link Panner} with an {@link LFO} connected to the pan amount. * [Related Reading](https://www.ableton.com/en/blog/autopan-chopper-effect-and-more-liveschool/). * * @example diff --git a/Tone/effect/AutoWah.ts b/Tone/effect/AutoWah.ts index 1ff59a46..9c978adb 100644 --- a/Tone/effect/AutoWah.ts +++ b/Tone/effect/AutoWah.ts @@ -19,7 +19,7 @@ export interface AutoWahOptions extends EffectOptions { } /** - * AutoWah connects a [[Follower]] to a [[Filter]]. + * AutoWah connects a {@link Follower} to a {@link Filter}. * The frequency of the filter, follows the input amplitude curve. * Inspiration from [Tuna.js](https://github.com/Dinahmoe/tuna). * diff --git a/Tone/effect/Chorus.ts b/Tone/effect/Chorus.ts index d4d3e089..32aacd75 100644 --- a/Tone/effect/Chorus.ts +++ b/Tone/effect/Chorus.ts @@ -16,8 +16,8 @@ export interface ChorusOptions extends StereoFeedbackEffectOptions { } /** - * Chorus is a stereo chorus effect composed of a left and right delay with an [[LFO]] applied to the delayTime of each channel. - * When [[feedback]] is set to a value larger than 0, you also get Flanger-type effects. + * Chorus is a stereo chorus effect composed of a left and right delay with an {@link LFO} applied to the delayTime of each channel. + * When {@link feedback} is set to a value larger than 0, you also get Flanger-type effects. * Inspiration from [Tuna.js](https://github.com/Dinahmoe/tuna/blob/master/tuna.js). * Read more on the chorus effect on [Sound On Sound](http://www.soundonsound.com/sos/jun04/articles/synthsecrets.htm). * @@ -196,7 +196,8 @@ export class Chorus extends StereoFeedbackEffect { } /** - * Sync the filter to the transport. See [[LFO.sync]] + * Sync the filter to the transport. + * @see {@link LFO.sync} */ sync(): this { this._lfoL.sync(); diff --git a/Tone/effect/Freeverb.ts b/Tone/effect/Freeverb.ts index 3f7178bb..d2044acc 100644 --- a/Tone/effect/Freeverb.ts +++ b/Tone/effect/Freeverb.ts @@ -23,7 +23,7 @@ const allpassFilterFrequencies = [225, 556, 441, 341]; /** * Freeverb is a reverb based on [Freeverb](https://ccrma.stanford.edu/~jos/pasp/Freeverb.html). * Read more on reverb on [Sound On Sound](https://web.archive.org/web/20160404083902/http://www.soundonsound.com:80/sos/feb01/articles/synthsecrets.asp). - * Freeverb is now implemented with an AudioWorkletNode which may result on performance degradation on some platforms. Consider using [[Reverb]]. + * Freeverb is now implemented with an AudioWorkletNode which may result on performance degradation on some platforms. Consider using {@link Reverb}. * @example * const freeverb = new Tone.Freeverb().toDestination(); * freeverb.dampening = 1000; diff --git a/Tone/effect/JCReverb.ts b/Tone/effect/JCReverb.ts index 2edd25d9..0aeb4ca1 100644 --- a/Tone/effect/JCReverb.ts +++ b/Tone/effect/JCReverb.ts @@ -28,8 +28,8 @@ const allpassFilterFreqs = [347, 113, 37]; /** * JCReverb is a simple [Schroeder Reverberator](https://ccrma.stanford.edu/~jos/pasp/Schroeder_Reverberators.html) * tuned by John Chowning in 1970. - * It is made up of three allpass filters and four [[FeedbackCombFilter]]. - * JCReverb is now implemented with an AudioWorkletNode which may result on performance degradation on some platforms. Consider using [[Reverb]]. + * It is made up of three allpass filters and four {@link FeedbackCombFilter}. + * JCReverb is now implemented with an AudioWorkletNode which may result on performance degradation on some platforms. Consider using {@link Reverb}. * @example * const reverb = new Tone.JCReverb(0.4).toDestination(); * const delay = new Tone.FeedbackDelay(0.5); diff --git a/Tone/effect/LFOEffect.ts b/Tone/effect/LFOEffect.ts index 03c90c93..7439f1aa 100644 --- a/Tone/effect/LFOEffect.ts +++ b/Tone/effect/LFOEffect.ts @@ -76,7 +76,8 @@ export abstract class LFOEffect extends Effect } /** - * Sync the filter to the transport. See [[LFO.sync]] + * Sync the filter to the transport. + * @see {@link LFO.sync} */ sync(): this { this._lfo.sync(); @@ -92,7 +93,8 @@ export abstract class LFOEffect extends Effect } /** - * The type of the LFO's oscillator: See [[Oscillator.type]] + * The type of the LFO's oscillator. + * @see {@link Oscillator.type} * @example * const autoFilter = new Tone.AutoFilter().start().toDestination(); * const noise = new Tone.Noise().start().connect(autoFilter); diff --git a/Tone/effect/Reverb.ts b/Tone/effect/Reverb.ts index 0a274f38..e135f5d8 100644 --- a/Tone/effect/Reverb.ts +++ b/Tone/effect/Reverb.ts @@ -18,7 +18,7 @@ interface ReverbOptions extends EffectOptions { * Generates an Impulse Response Buffer * with Tone.Offline then feeds the IR into ConvolverNode. * The impulse response generation is async, so you have - * to wait until [[ready]] resolves before it will make a sound. + * to wait until {@link ready} resolves before it will make a sound. * * Inspiration from [ReverbGen](https://github.com/adelespinasse/reverbGen). * Copyright (c) 2014 Alan deLespinasse Apache 2.0 License. @@ -45,8 +45,8 @@ export class Reverb extends Effect { private _preDelay: Seconds; /** - * Resolves when the reverb buffer is generated. Whenever either [[decay]] - * or [[preDelay]] are set, you have to wait until [[ready]] resolves + * Resolves when the reverb buffer is generated. Whenever either {@link decay} + * or {@link preDelay} are set, you have to wait until {@link ready} resolves * before the IR is generated with the latest values. */ ready: Promise = Promise.resolve(); diff --git a/Tone/effect/StereoXFeedbackEffect.ts b/Tone/effect/StereoXFeedbackEffect.ts index 9e906dd5..0e463a1b 100644 --- a/Tone/effect/StereoXFeedbackEffect.ts +++ b/Tone/effect/StereoXFeedbackEffect.ts @@ -7,7 +7,7 @@ export interface StereoXFeedbackEffectOptions extends StereoFeedbackEffectOption } /** - * Just like a [[StereoFeedbackEffect]], but the feedback is routed from left to right + * Just like a {@link StereoFeedbackEffect}, but the feedback is routed from left to right * and right to left instead of on the same channel. * ``` * +--------------------------------+ feedbackL <-----------------------------------+ diff --git a/Tone/effect/Tremolo.ts b/Tone/effect/Tremolo.ts index ba750f75..fec39dcc 100644 --- a/Tone/effect/Tremolo.ts +++ b/Tone/effect/Tremolo.ts @@ -15,7 +15,7 @@ export interface TremoloOptions extends StereoEffectOptions { } /** - * Tremolo modulates the amplitude of an incoming signal using an [[LFO]]. + * Tremolo modulates the amplitude of an incoming signal using an {@link LFO}. * The effect is a stereo effect where the modulation phase is inverted in each channel. * * @example diff --git a/Tone/event/Part.ts b/Tone/event/Part.ts index 0033fe0e..693a31c9 100644 --- a/Tone/event/Part.ts +++ b/Tone/event/Part.ts @@ -60,7 +60,7 @@ export class Part extends ToneEvent { /** * @param callback The callback to invoke on each event - * @param events the array of events + * @param value the array of events */ constructor(callback?: ToneEventCallback>, value?: ValueType[]); constructor(options?: Partial>); @@ -209,7 +209,7 @@ export class Part extends ToneEvent { * Add a an event to the part. * @param time The time the note should start. If an object is passed in, it should * have a 'time' attribute and the rest of the object will be used as the 'value'. - * @param value + * @param value Any value to add to the timeline * @example * const part = new Tone.Part(); * part.add("1m", "C#+11"); diff --git a/Tone/event/Pattern.ts b/Tone/event/Pattern.ts index 0f2e0f1c..ab79d5a7 100644 --- a/Tone/event/Pattern.ts +++ b/Tone/event/Pattern.ts @@ -121,7 +121,7 @@ export class Pattern extends Loop> { } /** - * The pattern type. See Tone.CtrlPattern for the full list of patterns. + * The pattern type. */ get pattern(): PatternName { return this._type; diff --git a/Tone/event/Sequence.ts b/Tone/event/Sequence.ts index 011244a9..1c6ded00 100644 --- a/Tone/event/Sequence.ts +++ b/Tone/event/Sequence.ts @@ -5,7 +5,7 @@ import { isArray, isString } from "../core/util/TypeCheck"; import { Part } from "./Part"; import { ToneEvent, ToneEventCallback, ToneEventOptions } from "./ToneEvent"; -type SequenceEventDescription = Array>>>>; +type SequenceEventDescription = Array>; interface SequenceOptions extends Omit, "value"> { loopStart: number; @@ -59,7 +59,7 @@ export class Sequence extends ToneEvent { /** * @param callback The callback to invoke with every note - * @param sequence The sequence + * @param events The sequence of events * @param subdivision The subdivision between which events are placed. */ constructor( diff --git a/Tone/fromContext.ts b/Tone/fromContext.ts index df72a91e..afc7d852 100644 --- a/Tone/fromContext.ts +++ b/Tone/fromContext.ts @@ -1,8 +1,8 @@ import * as Classes from "./classes"; -import { Transport } from "./core/clock/Transport"; +import { TransportClass } from "./core/clock/Transport"; import { Context } from "./core/context/Context"; -import { Listener } from "./core/context/Listener"; -import { Destination } from "./core/context/Destination"; +import { ListenerClass } from "./core/context/Listener"; +import { DestinationClass } from "./core/context/Destination"; import { FrequencyClass } from "./core/type/Frequency"; import { MidiClass } from "./core/type/Midi"; import { TicksClass } from "./core/type/Ticks"; @@ -10,7 +10,7 @@ import { TimeClass } from "./core/type/Time"; import { TransportTimeClass } from "./core/type/TransportTime"; import { isDefined, isFunction } from "./core/util/TypeCheck"; import { omitFromObject } from "./core/util/Defaults"; -import { Draw } from "./core/util/Draw"; +import { DrawClass } from "./core/util/Draw"; type ClassesWithoutSingletons = Omit; @@ -19,10 +19,10 @@ type ClassesWithoutSingletons = Omit number; immediate: () => number; diff --git a/Tone/index.test.ts b/Tone/index.test.ts index 6e2bb25a..16bcb6fc 100644 --- a/Tone/index.test.ts +++ b/Tone/index.test.ts @@ -1,9 +1,9 @@ import * as Tone from "./index"; import { expect } from "chai"; -import { Destination } from "./core/context/Destination"; +import { DestinationClass } from "./core/context/Destination"; import { Context } from "./core/context/Context"; -import { Transport } from "./core/clock/Transport"; -import { Draw } from "./core/util/Draw"; +import { TransportClass } from "./core/clock/Transport"; +import { DrawClass } from "./core/util/Draw"; describe("Tone", () => { @@ -15,16 +15,16 @@ describe("Tone", () => { }); it("exports the global singletons", () => { - expect(Tone.Destination).to.be.an.instanceOf(Destination); - expect(Tone.Draw).to.be.an.instanceOf(Draw); - expect(Tone.Transport).to.be.an.instanceOf(Transport); + expect(Tone.Destination).to.be.an.instanceOf(DestinationClass); + expect(Tone.Draw).to.be.an.instanceOf(DrawClass); + expect(Tone.Transport).to.be.an.instanceOf(TransportClass); expect(Tone.context).to.be.an.instanceOf(Context); }); it("exports the global singleton getters", () => { - expect(Tone.getDestination()).to.be.an.instanceOf(Destination); - expect(Tone.getDraw()).to.be.an.instanceOf(Draw); - expect(Tone.getTransport()).to.be.an.instanceOf(Transport); + expect(Tone.getDestination()).to.be.an.instanceOf(DestinationClass); + expect(Tone.getDraw()).to.be.an.instanceOf(DrawClass); + expect(Tone.getTransport()).to.be.an.instanceOf(TransportClass); }); it("can start the global context", () => { diff --git a/Tone/index.ts b/Tone/index.ts index f2df621d..d95430de 100644 --- a/Tone/index.ts +++ b/Tone/index.ts @@ -1,4 +1,5 @@ export { getContext, setContext } from "./core/Global"; +import { Context } from "./core/context/Context"; export * from "./classes"; export * from "./version"; import { getContext } from "./core/Global"; @@ -6,10 +7,14 @@ import { ToneAudioBuffer } from "./core/context/ToneAudioBuffer"; export { start } from "./core/Global"; import { Seconds } from "./core/type/Units"; export { supported } from "./core/context/AudioContext"; +import type { TransportClass } from "./core/clock/Transport"; +import type { DestinationClass } from "./core/context/Destination"; +import type { DrawClass } from "./core/util/Draw"; +import type { ListenerClass } from "./core/context/Listener"; /** - * The current audio context time of the global [[Context]]. - * See [[Context.now]] + * The current audio context time of the global {@link BaseContext}. + * @see {@link Context.now} * @category Core */ export function now(): Seconds { @@ -17,8 +22,8 @@ export function now(): Seconds { } /** - * The current audio context time of the global [[Context]] without the [[Context.lookAhead]] - * See [[Context.immediate]] + * The current audio context time of the global {@link Context} without the {@link Context.lookAhead} + * @see {@link Context.immediate} * @category Core */ export function immediate(): Seconds { @@ -27,81 +32,86 @@ export function immediate(): Seconds { /** * The Transport object belonging to the global Tone.js Context. - * See [[Transport]] + * @see {@link TransportClass} * @category Core + * @deprecated Use {@link getTransport} instead */ export const Transport = getContext().transport; /** * The Transport object belonging to the global Tone.js Context. - * See [[Transport]] + * @see {@link TransportClass} * @category Core */ -export function getTransport(): import("./core/clock/Transport").Transport { +export function getTransport(): TransportClass { return getContext().transport; } /** * The Destination (output) belonging to the global Tone.js Context. - * See [[Destination]] + * @see {@link DestinationClass} * @category Core + * @deprecated Use {@link getDestination} instead */ export const Destination = getContext().destination; /** - * @deprecated Use [[Destination]] + * @deprecated Use {@link getDestination} instead */ export const Master = getContext().destination; /** * The Destination (output) belonging to the global Tone.js Context. - * See [[Destination]] + * @see {@link DestinationClass} * @category Core */ -export function getDestination(): import("./core/context/Destination").Destination { +export function getDestination(): DestinationClass { return getContext().destination; } /** - * The [[Listener]] belonging to the global Tone.js Context. + * The {@link ListenerClass} belonging to the global Tone.js Context. * @category Core + * @deprecated Use {@link getListener} instead */ export const Listener = getContext().listener; /** - * The [[Listener]] belonging to the global Tone.js Context. + * The {@link ListenerClass} belonging to the global Tone.js Context. * @category Core */ -export function getListener(): import("./core/context/Listener").Listener { +export function getListener(): ListenerClass { return getContext().listener; } /** - * Draw is used to synchronize the draw frame with the Transport's callbacks. - * See [[Draw]] + * Draw is used to synchronize the draw frame with the Transport's callbacks. + * @see {@link DrawClass} * @category Core + * @deprecated Use {@link getDraw} instead */ export const Draw = getContext().draw; /** - * Get the singleton attached to the global context. - * Draw is used to synchronize the draw frame with the Transport's callbacks. - * See [[Draw]] + * Get the singleton attached to the global context. + * Draw is used to synchronize the draw frame with the Transport's callbacks. + * @see {@link DrawClass} * @category Core */ -export function getDraw(): import("./core/util/Draw").Draw { +export function getDraw(): DrawClass { return getContext().draw; } /** * A reference to the global context - * See [[Context]] + * @see {@link Context} + * @deprecated Use {@link getContext} instead */ export const context = getContext(); /** - * Promise which resolves when all of the loading promises are resolved. - * Alias for static [[ToneAudioBuffer.loaded]] method. + * Promise which resolves when all of the loading promises are resolved. + * Alias for static {@link ToneAudioBuffer.loaded} method. * @category Core */ export function loaded() { @@ -111,6 +121,9 @@ export function loaded() { // this fills in name changes from 13.x to 14.x import { ToneAudioBuffers } from "./core/context/ToneAudioBuffers"; import { ToneBufferSource } from "./source/buffer/ToneBufferSource"; +/** @deprecated Use {@link ToneAudioBuffer} */ export const Buffer: typeof ToneAudioBuffer = ToneAudioBuffer; +/** @deprecated Use {@link ToneAudioBuffers} */ export const Buffers: typeof ToneAudioBuffers = ToneAudioBuffers; +/** @deprecated Use {@link ToneBufferSource} */ export const BufferSource: typeof ToneBufferSource = ToneBufferSource; diff --git a/Tone/instrument/DuoSynth.ts b/Tone/instrument/DuoSynth.ts index 09284b51..8e8f616f 100644 --- a/Tone/instrument/DuoSynth.ts +++ b/Tone/instrument/DuoSynth.ts @@ -18,7 +18,7 @@ export interface DuoSynthOptions extends MonophonicOptions { } /** - * DuoSynth is a monophonic synth composed of two [[MonoSynth]]s run in parallel with control over the + * DuoSynth is a monophonic synth composed of two {@link MonoSynth}s run in parallel with control over the * frequency ratio between the two voices and vibrato effect. * @example * const duoSynth = new Tone.DuoSynth().toDestination(); diff --git a/Tone/instrument/Instrument.ts b/Tone/instrument/Instrument.ts index def4a98f..24564f92 100644 --- a/Tone/instrument/Instrument.ts +++ b/Tone/instrument/Instrument.ts @@ -67,7 +67,7 @@ export abstract class Instrument extends Tone /** * Sync the instrument to the Transport. All subsequent calls of - * [[triggerAttack]] and [[triggerRelease]] will be scheduled along the transport. + * {@link triggerAttack} and {@link triggerRelease} will be scheduled along the transport. * @example * const fmSynth = new Tone.FMSynth().toDestination(); * fmSynth.volume.value = -6; diff --git a/Tone/instrument/MetalSynth.ts b/Tone/instrument/MetalSynth.ts index f15974b3..b5f346a2 100644 --- a/Tone/instrument/MetalSynth.ts +++ b/Tone/instrument/MetalSynth.ts @@ -91,7 +91,7 @@ export class MetalSynth extends Monophonic { /** * The envelope which is connected both to the * amplitude and a highpass filter's cutoff frequency. - * The lower-limit of the filter is controlled by the [[resonance]] + * The lower-limit of the filter is controlled by the {@link resonance} */ readonly envelope: Envelope; @@ -231,7 +231,7 @@ export class MetalSynth extends Monophonic { /** * The modulationIndex of the oscillators which make up the source. - * see [[FMOscillator.modulationIndex]] + * see {@link FMOscillator.modulationIndex} * @min 1 * @max 100 */ diff --git a/Tone/instrument/NoiseSynth.ts b/Tone/instrument/NoiseSynth.ts index 785241cb..45373f67 100644 --- a/Tone/instrument/NoiseSynth.ts +++ b/Tone/instrument/NoiseSynth.ts @@ -17,7 +17,7 @@ export interface NoiseSynthOptions extends InstrumentOptions { } /** - * Tone.NoiseSynth is composed of [[Noise]] through an [[AmplitudeEnvelope]]. + * Tone.NoiseSynth is composed of {@link Noise} through an {@link AmplitudeEnvelope}. * ``` * +-------+ +-------------------+ * | Noise +>--> AmplitudeEnvelope +>--> Output diff --git a/Tone/instrument/PluckSynth.ts b/Tone/instrument/PluckSynth.ts index 1ab13f41..27bb53ea 100644 --- a/Tone/instrument/PluckSynth.ts +++ b/Tone/instrument/PluckSynth.ts @@ -111,7 +111,7 @@ export class PluckSynth extends Instrument { } /** - * Ramp down the [[resonance]] to 0 over the duration of the release time. + * Ramp down the {@link resonance} to 0 over the duration of the release time. */ triggerRelease(time?: Time): this { this._lfcf.resonance.linearRampTo(0, this.release, time); diff --git a/Tone/instrument/Sampler.ts b/Tone/instrument/Sampler.ts index 9efb1f48..fc00c9d0 100644 --- a/Tone/instrument/Sampler.ts +++ b/Tone/instrument/Sampler.ts @@ -33,7 +33,7 @@ export interface SamplerOptions extends InstrumentOptions { * were not explicitly included which can save loading time. * * For sample or buffer playback where repitching is not necessary, - * use [[Player]]. + * use {@link Player}. * @example * const sampler = new Tone.Sampler({ * urls: { diff --git a/Tone/instrument/Synth.ts b/Tone/instrument/Synth.ts index 27ff67ef..2c4bf66d 100644 --- a/Tone/instrument/Synth.ts +++ b/Tone/instrument/Synth.ts @@ -17,7 +17,7 @@ export interface SynthOptions extends MonophonicOptions { } /** - * Synth is composed simply of a [[OmniOscillator]] routed through an [[AmplitudeEnvelope]]. + * Synth is composed simply of a {@link OmniOscillator} routed through an {@link AmplitudeEnvelope}. * ``` * +----------------+ +-------------------+ * | OmniOscillator +>--> AmplitudeEnvelope +>--> Output diff --git a/Tone/signal/Add.ts b/Tone/signal/Add.ts index f084d8b0..4f12cd4d 100644 --- a/Tone/signal/Add.ts +++ b/Tone/signal/Add.ts @@ -39,7 +39,7 @@ export class Add extends Signal { readonly addend: Param<"number"> = this._param; /** - * @param value If no value is provided, will sum the input and [[addend]]. + * @param value If no value is provided, will sum the input and {@link addend}. */ constructor(value?: number); constructor(options?: Partial>); diff --git a/Tone/signal/AudioToGain.ts b/Tone/signal/AudioToGain.ts index 8c515ee3..743ea600 100644 --- a/Tone/signal/AudioToGain.ts +++ b/Tone/signal/AudioToGain.ts @@ -4,7 +4,7 @@ import { WaveShaper } from "./WaveShaper"; /** * AudioToGain converts an input in AudioRange [-1,1] to NormalRange [0,1]. - * See [[GainToAudio]]. + * @see {@link GainToAudio}. * @category Signal */ export class AudioToGain extends SignalOperator { diff --git a/Tone/signal/GainToAudio.ts b/Tone/signal/GainToAudio.ts index 3aacdad1..6948217f 100644 --- a/Tone/signal/GainToAudio.ts +++ b/Tone/signal/GainToAudio.ts @@ -4,7 +4,7 @@ import { WaveShaper } from "./WaveShaper"; /** * GainToAudio converts an input in NormalRange [0,1] to AudioRange [-1,1]. - * See [[AudioToGain]]. + * @see {@link AudioToGain}. * @category Signal */ export class GainToAudio extends SignalOperator { diff --git a/Tone/signal/Multiply.ts b/Tone/signal/Multiply.ts index 0dc4bce9..9b22b423 100644 --- a/Tone/signal/Multiply.ts +++ b/Tone/signal/Multiply.ts @@ -43,7 +43,7 @@ export class Multiply extends input: InputNode; /** - * The product of the input and [[factor]] + * The product of the input and {@link factor} */ output: OutputNode; diff --git a/Tone/signal/ScaleExp.ts b/Tone/signal/ScaleExp.ts index fdfdccfa..a66b75e1 100644 --- a/Tone/signal/ScaleExp.ts +++ b/Tone/signal/ScaleExp.ts @@ -50,8 +50,8 @@ export class ScaleExp extends Scale { } /** - * Instead of interpolating linearly between the [[min]] and - * [[max]] values, setting the exponent will interpolate between + * Instead of interpolating linearly between the {@link min} and + * {@link max} values, setting the exponent will interpolate between * the two values with an exponential curve. */ get exponent(): Positive { diff --git a/Tone/signal/Signal.ts b/Tone/signal/Signal.ts index afc919f9..bc667ac6 100644 --- a/Tone/signal/Signal.ts +++ b/Tone/signal/Signal.ts @@ -192,7 +192,7 @@ export class Signal extends ToneAudioNode< } /** - * See [[Param.apply]]. + * @see {@link Param.apply}. */ apply(param: Param | AudioParam): this { this._param.apply(param); diff --git a/Tone/signal/SyncedSignal.ts b/Tone/signal/SyncedSignal.ts index 1b9fa214..fbdd3029 100644 --- a/Tone/signal/SyncedSignal.ts +++ b/Tone/signal/SyncedSignal.ts @@ -4,9 +4,11 @@ import { optionsFromArguments } from "../core/util/Defaults"; import { TransportTimeClass } from "../core/type/TransportTime"; import { ToneConstantSource } from "./ToneConstantSource"; import { OutputNode } from "../core/context/ToneAudioNode"; +import type { TransportClass } from "../core/clock/Transport"; /** - * Adds the ability to synchronize the signal to the [[Transport]] + * Adds the ability to synchronize the signal to the {@link TransportClass} + * @category Signal */ export class SyncedSignal extends Signal { diff --git a/Tone/signal/WaveShaper.ts b/Tone/signal/WaveShaper.ts index 70f2dab3..b46463d6 100644 --- a/Tone/signal/WaveShaper.ts +++ b/Tone/signal/WaveShaper.ts @@ -55,7 +55,7 @@ export class WaveShaper extends SignalOperator { * signal is an AudioRange [-1, 1] value and the output * signal can take on any numerical values. * - * @param bufferLen The length of the WaveShaperNode buffer. + * @param length The length of the WaveShaperNode buffer. */ constructor(mapping?: WaveShaperMapping, length?: number); constructor(options?: Partial); diff --git a/Tone/source/Source.ts b/Tone/source/Source.ts index d2d7bbac..72c838e4 100644 --- a/Tone/source/Source.ts +++ b/Tone/source/Source.ts @@ -362,7 +362,8 @@ export abstract class Source< } /** - * Unsync the source to the Transport. See Source.sync + * Unsync the source to the Transport. + * @see {@link sync} */ unsync(): this { if (this._synced) { diff --git a/Tone/source/buffer/Player.ts b/Tone/source/buffer/Player.ts index fbb88ab5..1d36c03e 100644 --- a/Tone/source/buffer/Player.ts +++ b/Tone/source/buffer/Player.ts @@ -432,7 +432,7 @@ export class Player extends Source { } /** - * If the buffer should be reversed. Note that this sets the underlying [[ToneAudioBuffer.reverse]], so + * If the buffer should be reversed. Note that this sets the underlying {@link ToneAudioBuffer.reverse}, so * if multiple players are pointing at the same ToneAudioBuffer, they will all be reversed. * @example * const player = new Tone.Player("https://tonejs.github.io/audio/berklee/chime_1.mp3").toDestination(); diff --git a/Tone/source/buffer/Players.ts b/Tone/source/buffer/Players.ts index c75b45a9..056b308b 100644 --- a/Tone/source/buffer/Players.ts +++ b/Tone/source/buffer/Players.ts @@ -23,7 +23,7 @@ export interface PlayersOptions extends SourceOptions { } /** - * Players combines multiple [[Player]] objects. + * Players combines multiple {@link Player} objects. * @category Source */ export class Players extends ToneAudioNode { diff --git a/Tone/source/oscillator/LFO.ts b/Tone/source/oscillator/LFO.ts index a5fc6971..5d1e13c4 100644 --- a/Tone/source/oscillator/LFO.ts +++ b/Tone/source/oscillator/LFO.ts @@ -94,7 +94,7 @@ export class LFO extends ToneAudioNode { private _units: UnitName = "number"; /** - * If the input value is converted using the [[units]] + * If the input value is converted using the {@link units} */ convert = true; @@ -238,7 +238,8 @@ export class LFO extends ToneAudioNode { } /** - * The type of the oscillator: See [[Oscillator.type]] + * The type of the oscillator. + * @see {@link Oscillator.type} */ get type(): ToneOscillatorType { return this._oscillator.type; @@ -249,7 +250,8 @@ export class LFO extends ToneAudioNode { } /** - * The oscillator's partials array: See [[Oscillator.partials]] + * The oscillator's partials array. + * @see {@link Oscillator.partials} */ get partials(): number[] { return this._oscillator.partials; diff --git a/Tone/source/oscillator/OmniOscillator.ts b/Tone/source/oscillator/OmniOscillator.ts index 562d2ee2..b17ca69e 100644 --- a/Tone/source/oscillator/OmniOscillator.ts +++ b/Tone/source/oscillator/OmniOscillator.ts @@ -192,7 +192,7 @@ export class OmniOscillator /** * The value is an empty array when the type is not "custom". * This is not available on "pwm" and "pulse" oscillator types. - * See [[Oscillator.partials]] + * @see {@link Oscillator.partials} */ get partials(): number[] { return this._oscillator.partials; @@ -297,7 +297,8 @@ export class OmniOscillator } /** - * The base type of the oscillator. See [[Oscillator.baseType]] + * The base type of the oscillator. + * @see {@link Oscillator.baseType} * @example * const omniOsc = new Tone.OmniOscillator(440, "fmsquare4"); * console.log(omniOsc.sourceType, omniOsc.baseType, omniOsc.partialCount); @@ -315,7 +316,7 @@ export class OmniOscillator /** * The width of the oscillator when sourceType === "pulse". - * See [[PWMOscillator]] + * @see {@link PWMOscillator} */ get width(): IsPulseOscillator> { if (this._getOscType(this._oscillator, "pulse")) { @@ -327,7 +328,7 @@ export class OmniOscillator /** * The number of detuned oscillators when sourceType === "fat". - * See [[FatOscillator.count]] + * @see {@link FatOscillator.count} */ get count(): IsFatOscillator { if (this._getOscType(this._oscillator, "fat")) { @@ -344,7 +345,7 @@ export class OmniOscillator /** * The detune spread between the oscillators when sourceType === "fat". - * See [[FatOscillator.count]] + * @see {@link FatOscillator.count} */ get spread(): IsFatOscillator { if (this._getOscType(this._oscillator, "fat")) { @@ -361,7 +362,7 @@ export class OmniOscillator /** * The type of the modulator oscillator. Only if the oscillator is set to "am" or "fm" types. - * See [[AMOscillator]] or [[FMOscillator]] + * @see {@link AMOscillator} or {@link FMOscillator} */ get modulationType(): IsAmOrFmOscillator { if (this._getOscType(this._oscillator, "fm") || this._getOscType(this._oscillator, "am")) { @@ -378,7 +379,7 @@ export class OmniOscillator /** * The modulation index when the sourceType === "fm" - * See [[FMOscillator]]. + * @see {@link FMOscillator}. */ get modulationIndex(): IsFMOscillator> { if (this._getOscType(this._oscillator, "fm")) { @@ -390,7 +391,7 @@ export class OmniOscillator /** * Harmonicity is the frequency ratio between the carrier and the modulator oscillators. - * See [[AMOscillator]] or [[FMOscillator]] + * @see {@link AMOscillator} or {@link FMOscillator} */ get harmonicity(): IsAmOrFmOscillator> { if (this._getOscType(this._oscillator, "fm") || this._getOscType(this._oscillator, "am")) { @@ -402,7 +403,7 @@ export class OmniOscillator /** * The modulationFrequency Signal of the oscillator when sourceType === "pwm" - * see [[PWMOscillator]] + * see {@link PWMOscillator} * @min 0.1 * @max 5 */ diff --git a/Tone/source/oscillator/Oscillator.ts b/Tone/source/oscillator/Oscillator.ts index ca85439b..89d256f1 100644 --- a/Tone/source/oscillator/Oscillator.ts +++ b/Tone/source/oscillator/Oscillator.ts @@ -180,7 +180,7 @@ export class Oscillator extends Source implements ToneOsc /** * Unsync the oscillator's frequency from the Transport. - * See Oscillator.syncFrequency + * @see {@link syncFrequency} */ unsyncFrequency(): this { this.context.transport.unsyncSignal(this.frequency); diff --git a/Tone/source/oscillator/OscillatorInterface.ts b/Tone/source/oscillator/OscillatorInterface.ts index f2a4802c..acb7734e 100644 --- a/Tone/source/oscillator/OscillatorInterface.ts +++ b/Tone/source/oscillator/OscillatorInterface.ts @@ -1,4 +1,10 @@ -import { AudioRange, Cents, Degrees, Frequency, Positive } from "../../core/type/Units"; +import { + AudioRange, + Cents, + Degrees, + Frequency, + Positive, +} from "../../core/type/Units"; import { Omit } from "../../core/util/Interface"; import { Signal } from "../../signal/Signal"; import { SourceOptions } from "../Source"; @@ -8,7 +14,6 @@ import { OfflineContext } from "../../core/context/OfflineContext"; * The common interface of all Oscillators */ export interface ToneOscillatorInterface { - /** * The oscillator type without the partialsCount appended to the end * @example @@ -19,8 +24,8 @@ export interface ToneOscillatorInterface { baseType: OscillatorType | "pulse" | "pwm"; /** - * The oscillator's type. Also capable of setting the first x number of partials of the oscillator. - * For example: "sine4" would set be the first 4 partials of the sine wave and "triangle8" would + * The oscillator's type. Also capable of setting the first x number of partials of the oscillator. + * For example: "sine4" would set be the first 4 partials of the sine wave and "triangle8" would * set the first 8 partials of the triangle wave. * @example * return Tone.Offline(() => { @@ -52,7 +57,7 @@ export interface ToneOscillatorInterface { /** * The phase is the starting position within the oscillator's cycle. For example - * a phase of 180 would start halfway through the oscillator's cycle. + * a phase of 180 would start halfway through the oscillator's cycle. * @example * return Tone.Offline(() => { * const osc = new Tone.Oscillator({ @@ -64,11 +69,11 @@ export interface ToneOscillatorInterface { phase: Degrees; /** - * The partials describes the relative amplitude of each of the harmonics of the oscillator. - * The first value in the array is the first harmonic (i.e. the fundamental frequency), the + * The partials describes the relative amplitude of each of the harmonics of the oscillator. + * The first value in the array is the first harmonic (i.e. the fundamental frequency), the * second harmonic is an octave up, the third harmonic is an octave and a fifth, etc. The resulting - * oscillator output is composed of a sine tone at the relative amplitude at each of the harmonic intervals. - * + * oscillator output is composed of a sine tone at the relative amplitude at each of the harmonic intervals. + * * Setting this value will automatically set the type to "custom". * The value is an empty array when the type is not "custom". * @example @@ -107,49 +112,83 @@ export interface ToneOscillatorInterface { /** * Render a segment of the oscillator to an offline context and return the results as an array */ -export async function generateWaveform(instance: any, length: number): Promise { +export async function generateWaveform( + instance: any, + length: number +): Promise { const duration = length / instance.context.sampleRate; - const context = new OfflineContext(1, duration, instance.context.sampleRate); - const clone = new instance.constructor(Object.assign(instance.get(), { - // should do 2 iterations - frequency: 2 / duration, - // zero out the detune - detune: 0, - context - })).toDestination(); + const context = new OfflineContext( + 1, + duration, + instance.context.sampleRate + ); + const clone = new instance.constructor( + Object.assign(instance.get(), { + // should do 2 iterations + frequency: 2 / duration, + // zero out the detune + detune: 0, + context, + }) + ).toDestination(); clone.start(0); const buffer = await context.render(); return buffer.getChannelData(0); } +/** + * The supported number of partials + */ +type PartialsRange = + | 1 + | 2 + | 3 + | 4 + | 5 + | 6 + | 7 + | 8 + | 9 + | 10 + | 11 + | 12 + | 13 + | 14 + | 15 + | 16 + | 17 + | 18 + | 19 + | 20 + | 21 + | 22 + | 23 + | 24 + | 25 + | 26 + | 27 + | 28 + | 29 + | 30 + | 31 + | 32; + /** * Oscillators with partials */ -type SineWithPartials = - "sine1" | "sine2" | "sine3" | "sine4" | "sine5" | "sine6" | "sine7" | "sine8" | "sine9" | - "sine10" | "sine11" | "sine12" | "sine13" | "sine14" | "sine15" | "sine16" | "sine17" | "sine18" | "sine19" | - "sine20" | "sine21" | "sine22" | "sine23" | "sine24" | "sine25" | "sine26" | "sine27" | "sine28" | "sine29" | - "sine30" | "sine31" | "sine32"; +type SineWithPartials = `sine${PartialsRange}`; -type SquareWithPartials = - "square1" | "square2" | "square3" | "square4" | "square5" | "square6" | "square7" | "square8" | "square9" | - "square10" | "square11" | "square12" | "square13" | "square14" | "square15" | "square16" | "square17" | "square18" | "square19" | - "square20" | "square21" | "square22" | "square23" | "square24" | "square25" | "square26" | "square27" | "square28" | "square29" | - "square30" | "square31" | "square32"; +type SquareWithPartials = `square${PartialsRange}`; -type SawtoothWithPartials = - "sawtooth1" | "sawtooth2" | "sawtooth3" | "sawtooth4" | "sawtooth5" | "sawtooth6" | "sawtooth7" | "sawtooth8" | "sawtooth9" | - "sawtooth10" | "sawtooth11" | "sawtooth12" | "sawtooth13" | "sawtooth14" | "sawtooth15" | "sawtooth16" | "sawtooth17" | "sawtooth18" | "sawtooth19" | - "sawtooth20" | "sawtooth21" | "sawtooth22" | "sawtooth23" | "sawtooth24" | "sawtooth25" | "sawtooth26" | "sawtooth27" | "sawtooth28" | "sawtooth29" | - "sawtooth30" | "sawtooth31" | "sawtooth32"; +type SawtoothWithPartials = `sawtooth${PartialsRange}`; -type TriangleWithPartials = - "triangle1" | "triangle2" | "triangle3" | "triangle4" | "triangle5" | "triangle6" | "triangle7" | "triangle8" | "triangle9" | - "triangle10" | "triangle11" | "triangle12" | "triangle13" | "triangle14" | "triangle15" | "triangle16" | "triangle17" | "triangle18" | "triangle19" | - "triangle20" | "triangle21" | "triangle22" | "triangle23" | "triangle24" | "triangle25" | "triangle26" | "triangle27" | "triangle28" | "triangle29" | - "triangle30" | "triangle31" | "triangle32"; +type TriangleWithPartials = `triangle${PartialsRange}`; -type TypeWithPartials = SineWithPartials | SquareWithPartials | TriangleWithPartials | SawtoothWithPartials; +type TypeWithPartials = + | SineWithPartials + | SquareWithPartials + | TriangleWithPartials + | SawtoothWithPartials; interface BaseOscillatorOptions extends SourceOptions { frequency: Frequency; @@ -182,7 +221,10 @@ interface TonePartialOscillatorOptions extends BaseOscillatorOptions { type: TypeWithPartials; } -export type ToneOscillatorConstructorOptions = ToneCustomOscillatorOptions | ToneTypeOscillatorOptions | TonePartialOscillatorOptions; +export type ToneOscillatorConstructorOptions = + | ToneCustomOscillatorOptions + | ToneTypeOscillatorOptions + | TonePartialOscillatorOptions; export interface ToneOscillatorOptions extends BaseOscillatorOptions { type: ToneOscillatorType; @@ -213,7 +255,10 @@ interface FMPartialsOscillatorOptions extends FMBaseOscillatorOptions { type: TypeWithPartials; } -export type FMConstructorOptions = FMTypeOscillatorOptions | FMCustomOscillatorOptions | FMPartialsOscillatorOptions; +export type FMConstructorOptions = + | FMTypeOscillatorOptions + | FMCustomOscillatorOptions + | FMPartialsOscillatorOptions; export interface FMOscillatorOptions extends ToneOscillatorOptions { harmonicity: Positive; @@ -243,7 +288,10 @@ interface AMPartialsOscillatorOptions extends AMBaseOscillatorOptions { type: TypeWithPartials; } -export type AMConstructorOptions = AMCustomOscillatorOptions | AMTypeOscillatorOptions | AMPartialsOscillatorOptions; +export type AMConstructorOptions = + | AMCustomOscillatorOptions + | AMTypeOscillatorOptions + | AMPartialsOscillatorOptions; export interface AMOscillatorOptions extends ToneOscillatorOptions { harmonicity: Positive; @@ -271,7 +319,10 @@ interface FatPartialsOscillatorOptions extends FatBaseOscillatorOptions { type: TypeWithPartials; } -export type FatConstructorOptions = FatCustomOscillatorOptions | FatTypeOscillatorOptions | FatPartialsOscillatorOptions; +export type FatConstructorOptions = + | FatCustomOscillatorOptions + | FatTypeOscillatorOptions + | FatPartialsOscillatorOptions; export interface FatOscillatorOptions extends ToneOscillatorOptions { spread: Cents; @@ -301,89 +352,53 @@ export interface PWMOscillatorOptions extends BaseOscillatorOptions { /** * FM Oscillators with partials */ -type FMSineWithPartials = - "fmsine1" | "fmsine2" | "fmsine3" | "fmsine4" | "fmsine5" | "fmsine6" | "fmsine7" | "fmsine8" | "fmsine9" | - "fmsine10" | "fmsine11" | "fmsine12" | "fmsine13" | "fmsine14" | "fmsine15" | "fmsine16" | "fmsine17" | "fmsine18" | "fmsine19" | - "fmsine20" | "fmsine21" | "fmsine22" | "fmsine23" | "fmsine24" | "fmsine25" | "fmsine26" | "fmsine27" | "fmsine28" | "fmsine29" | - "fmsine30" | "fmsine31" | "fmsine32"; +type FMSineWithPartials = `fmsine${PartialsRange}`; -type FMSquareWithPartials = - "fmsquare1" | "fmsquare2" | "fmsquare3" | "fmsquare4" | "fmsquare5" | "fmsquare6" | "fmsquare7" | "fmsquare8" | "fmsquare9" | - "fmsquare10" | "fmsquare11" | "fmsquare12" | "fmsquare13" | "fmsquare14" | "fmsquare15" | "fmsquare16" | "fmsquare17" | "fmsquare18" | "fmsquare19" | - "fmsquare20" | "fmsquare21" | "fmsquare22" | "fmsquare23" | "fmsquare24" | "fmsquare25" | "fmsquare26" | "fmsquare27" | "fmsquare28" | "fmsquare29" | - "fmsquare30" | "fmsquare31" | "fmsquare32"; +type FMSquareWithPartials = `fmsquare${PartialsRange}`; -type FMSawtoothWithPartials = - "fmsawtooth1" | "fmsawtooth2" | "fmsawtooth3" | "fmsawtooth4" | "fmsawtooth5" | "fmsawtooth6" | "fmsawtooth7" | "fmsawtooth8" | "fmsawtooth9" | - "fmsawtooth10" | "fmsawtooth11" | "fmsawtooth12" | "fmsawtooth13" | "fmsawtooth14" | "fmsawtooth15" | "fmsawtooth16" | "fmsawtooth17" | "fmsawtooth18" | "fmsawtooth19" | - "fmsawtooth20" | "fmsawtooth21" | "fmsawtooth22" | "fmsawtooth23" | "fmsawtooth24" | "fmsawtooth25" | "fmsawtooth26" | "fmsawtooth27" | "fmsawtooth28" | "fmsawtooth29" | - "fmsawtooth30" | "fmsawtooth31" | "fmsawtooth32"; +type FMSawtoothWithPartials = `fmsawtooth${PartialsRange}`; -type FMTriangleWithPartials = - "fmtriangle1" | "fmtriangle2" | "fmtriangle3" | "fmtriangle4" | "fmtriangle5" | "fmtriangle6" | "fmtriangle7" | "fmtriangle8" | "fmtriangle9" | - "fmtriangle10" | "fmtriangle11" | "fmtriangle12" | "fmtriangle13" | "fmtriangle14" | "fmtriangle15" | "fmtriangle16" | "fmtriangle17" | "fmtriangle18" | "fmtriangle19" | - "fmtriangle20" | "fmtriangle21" | "fmtriangle22" | "fmtriangle23" | "fmtriangle24" | "fmtriangle25" | "fmtriangle26" | "fmtriangle27" | "fmtriangle28" | "fmtriangle29" | - "fmtriangle30" | "fmtriangle31" | "fmtriangle32"; +type FMTriangleWithPartials = `fmtriangle${PartialsRange}`; -type FMTypeWithPartials = FMSineWithPartials | FMSquareWithPartials | FMSawtoothWithPartials | FMTriangleWithPartials; +type FMTypeWithPartials = + | FMSineWithPartials + | FMSquareWithPartials + | FMSawtoothWithPartials + | FMTriangleWithPartials; /** * AM Oscillators with partials */ -type AMSineWithPartials = - "amsine1" | "amsine2" | "amsine3" | "amsine4" | "amsine5" | "amsine6" | "amsine7" | "amsine8" | "amsine9" | - "amsine10" | "amsine11" | "amsine12" | "amsine13" | "amsine14" | "amsine15" | "amsine16" | "amsine17" | "amsine18" | "amsine19" | - "amsine20" | "amsine21" | "amsine22" | "amsine23" | "amsine24" | "amsine25" | "amsine26" | "amsine27" | "amsine28" | "amsine29" | - "amsine30" | "amsine31" | "amsine32"; +type AMSineWithPartials = `amsine${PartialsRange}`; -type AMSquareWithPartials = - "amsquare1" | "amsquare2" | "amsquare3" | "amsquare4" | "amsquare5" | "amsquare6" | "amsquare7" | "amsquare8" | "amsquare9" | - "amsquare10" | "amsquare11" | "amsquare12" | "amsquare13" | "amsquare14" | "amsquare15" | "amsquare16" | "amsquare17" | "amsquare18" | "amsquare19" | - "amsquare20" | "amsquare21" | "amsquare22" | "amsquare23" | "amsquare24" | "amsquare25" | "amsquare26" | "amsquare27" | "amsquare28" | "amsquare29" | - "amsquare30" | "amsquare31" | "amsquare32"; +type AMSquareWithPartials = `amsquare${PartialsRange}`; -type AMSawtoothWithPartials = - "amsawtooth1" | "amsawtooth2" | "amsawtooth3" | "amsawtooth4" | "amsawtooth5" | "amsawtooth6" | "amsawtooth7" | "amsawtooth8" | "amsawtooth9" | - "amsawtooth10" | "amsawtooth11" | "amsawtooth12" | "amsawtooth13" | "amsawtooth14" | "amsawtooth15" | "amsawtooth16" | "amsawtooth17" | "amsawtooth18" | "amsawtooth19" | - "amsawtooth20" | "amsawtooth21" | "amsawtooth22" | "amsawtooth23" | "amsawtooth24" | "amsawtooth25" | "amsawtooth26" | "amsawtooth27" | "amsawtooth28" | "amsawtooth29" | - "amsawtooth30" | "amsawtooth31" | "amsawtooth32"; +type AMSawtoothWithPartials = `amsawtooth${PartialsRange}`; -type AMTriangleWithPartials = - "amtriangle1" | "amtriangle2" | "amtriangle3" | "amtriangle4" | "amtriangle5" | "amtriangle6" | "amtriangle7" | "amtriangle8" | "amtriangle9" | - "amtriangle10" | "amtriangle11" | "amtriangle12" | "amtriangle13" | "amtriangle14" | "amtriangle15" | "amtriangle16" | "amtriangle17" | "amtriangle18" | "amtriangle19" | - "amtriangle20" | "amtriangle21" | "amtriangle22" | "amtriangle23" | "amtriangle24" | "amtriangle25" | "amtriangle26" | "amtriangle27" | "amtriangle28" | "amtriangle29" | - "amtriangle30" | "amtriangle31" | "amtriangle32"; +type AMTriangleWithPartials = `amtriangle${PartialsRange}`; -type AMTypeWithPartials = AMSineWithPartials | AMSquareWithPartials | AMSawtoothWithPartials | AMTriangleWithPartials; +type AMTypeWithPartials = + | AMSineWithPartials + | AMSquareWithPartials + | AMSawtoothWithPartials + | AMTriangleWithPartials; /** * Fat Oscillators with partials */ -type FatSineWithPartials = - "fatsine1" | "fatsine2" | "fatsine3" | "fatsine4" | "fatsine5" | "fatsine6" | "fatsine7" | "fatsine8" | "fatsine9" | - "fatsine10" | "fatsine11" | "fatsine12" | "fatsine13" | "fatsine14" | "fatsine15" | "fatsine16" | "fatsine17" | "fatsine18" | "fatsine19" | - "fatsine20" | "fatsine21" | "fatsine22" | "fatsine23" | "fatsine24" | "fatsine25" | "fatsine26" | "fatsine27" | "fatsine28" | "fatsine29" | - "fatsine30" | "fatsine31" | "fatsine32"; +type FatSineWithPartials = `fatsine${PartialsRange}`; -type FatSquareWithPartials = - "fatsquare1" | "fatsquare2" | "fatsquare3" | "fatsquare4" | "fatsquare5" | "fatsquare6" | "fatsquare7" | "fatsquare8" | "fatsquare9" | - "fatsquare10" | "fatsquare11" | "fatsquare12" | "fatsquare13" | "fatsquare14" | "fatsquare15" | "fatsquare16" | "fatsquare17" | "fatsquare18" | "fatsquare19" | - "fatsquare20" | "fatsquare21" | "fatsquare22" | "fatsquare23" | "fatsquare24" | "fatsquare25" | "fatsquare26" | "fatsquare27" | "fatsquare28" | "fatsquare29" | - "fatsquare30" | "fatsquare31" | "fatsquare32"; +type FatSquareWithPartials = `fatsquare${PartialsRange}`; -type FatSawtoothWithPartials = - "fatsawtooth1" | "fatsawtooth2" | "fatsawtooth3" | "fatsawtooth4" | "fatsawtooth5" | "fatsawtooth6" | "fatsawtooth7" | "fatsawtooth8" | "fatsawtooth9" | - "fatsawtooth10" | "fatsawtooth11" | "fatsawtooth12" | "fatsawtooth13" | "fatsawtooth14" | "fatsawtooth15" | "fatsawtooth16" | "fatsawtooth17" | "fatsawtooth18" | "fatsawtooth19" | - "fatsawtooth20" | "fatsawtooth21" | "fatsawtooth22" | "fatsawtooth23" | "fatsawtooth24" | "fatsawtooth25" | "fatsawtooth26" | "fatsawtooth27" | "fatsawtooth28" | "fatsawtooth29" | - "fatsawtooth30" | "fatsawtooth31" | "fatsawtooth32"; +type FatSawtoothWithPartials = `fatsawtooth${PartialsRange}`; -type FatTriangleWithPartials = - "fattriangle1" | "fattriangle2" | "fattriangle3" | "fattriangle4" | "fattriangle5" | "fattriangle6" | "fattriangle7" | "fattriangle8" | "fattriangle9" | - "fattriangle10" | "fattriangle11" | "fattriangle12" | "fattriangle13" | "fattriangle14" | "fattriangle15" | "fattriangle16" | "fattriangle17" | "fattriangle18" | "fattriangle19" | - "fattriangle20" | "fattriangle21" | "fattriangle22" | "fattriangle23" | "fattriangle24" | "fattriangle25" | "fattriangle26" | "fattriangle27" | "fattriangle28" | "fattriangle29" | - "fattriangle30" | "fattriangle31" | "fattriangle32"; +type FatTriangleWithPartials = `fattriangle${PartialsRange}`; -type FatTypeWithPartials = FatSineWithPartials | FatSquareWithPartials | FatSawtoothWithPartials | FatTriangleWithPartials; +type FatTypeWithPartials = + | FatSineWithPartials + | FatSquareWithPartials + | FatSawtoothWithPartials + | FatTriangleWithPartials; /** * Omni FM @@ -437,17 +452,42 @@ interface OmniFatPartialsOscillatorOptions extends FatBaseOscillatorOptions { } export type OmniOscillatorType = - "fatsine" | "fatsquare" | "fatsawtooth" | "fattriangle" | "fatcustom" | FatTypeWithPartials | - "fmsine" | "fmsquare" | "fmsawtooth" | "fmtriangle" | "fmcustom" | FMTypeWithPartials | - "amsine" | "amsquare" | "amsawtooth" | "amtriangle" | "amcustom" | AMTypeWithPartials | - TypeWithPartials | OscillatorType | "pulse" | "pwm"; + | "fatsine" + | "fatsquare" + | "fatsawtooth" + | "fattriangle" + | "fatcustom" + | FatTypeWithPartials + | "fmsine" + | "fmsquare" + | "fmsawtooth" + | "fmtriangle" + | "fmcustom" + | FMTypeWithPartials + | "amsine" + | "amsquare" + | "amsawtooth" + | "amtriangle" + | "amcustom" + | AMTypeWithPartials + | TypeWithPartials + | OscillatorType + | "pulse" + | "pwm"; export type OmniOscillatorOptions = - PulseOscillatorOptions | PWMOscillatorOptions | - OmniFatCustomOscillatorOptions | OmniFatTypeOscillatorOptions | OmniFatPartialsOscillatorOptions | - OmniFMCustomOscillatorOptions | OmniFMTypeOscillatorOptions | OmniFMPartialsOscillatorOptions | - OmniAMCustomOscillatorOptions | OmniAMTypeOscillatorOptions | OmniAMPartialsOscillatorOptions | - ToneOscillatorConstructorOptions; + | PulseOscillatorOptions + | PWMOscillatorOptions + | OmniFatCustomOscillatorOptions + | OmniFatTypeOscillatorOptions + | OmniFatPartialsOscillatorOptions + | OmniFMCustomOscillatorOptions + | OmniFMTypeOscillatorOptions + | OmniFMPartialsOscillatorOptions + | OmniAMCustomOscillatorOptions + | OmniAMTypeOscillatorOptions + | OmniAMPartialsOscillatorOptions + | ToneOscillatorConstructorOptions; type OmitSourceOptions = Omit; @@ -455,8 +495,17 @@ type OmitSourceOptions = Omit | OmitSourceOptions | - OmitSourceOptions | OmitSourceOptions | OmitSourceOptions | - OmitSourceOptions | OmitSourceOptions | OmitSourceOptions | - OmitSourceOptions | OmitSourceOptions | OmitSourceOptions | - OmitSourceOptions | OmitSourceOptions | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions + | OmitSourceOptions; diff --git a/Tone/source/oscillator/ToneOscillatorNode.ts b/Tone/source/oscillator/ToneOscillatorNode.ts index 47ea576e..5766085c 100644 --- a/Tone/source/oscillator/ToneOscillatorNode.ts +++ b/Tone/source/oscillator/ToneOscillatorNode.ts @@ -14,7 +14,7 @@ export interface ToneOscillatorNodeOptions extends OneShotSourceOptions { /** * Wrapper around the native fire-and-forget OscillatorNode. * Adds the ability to reschedule the stop method. - * ***[[Oscillator]] is better for most use-cases*** + * ***{@link Oscillator} is better for most use-cases*** * @category Source */ export class ToneOscillatorNode extends OneShotSource { diff --git a/scripts/typedoc.json b/scripts/typedoc.json index a497d987..054c4304 100644 --- a/scripts/typedoc.json +++ b/scripts/typedoc.json @@ -5,8 +5,15 @@ "defaultCategory" : "Global", "categorizeByGroup" : true, "categoryOrder" : ["Core", "Source", "Instrument", "Effect", "Component", "Signal"], + "navigation" : { + "includeCategories": true, + "includeFolders": false, + "includeGroups": true + }, "externalPattern": ["**/node_modules/**"], "excludeProtected" : true, "excludePrivate" : true, "hideGenerator": true, + "includeVersion": false, + "excludeInternal": true, } \ No newline at end of file