tonejs.github.io | style comments in the source code
kandi X-RAY | tonejs.github.io Summary
kandi X-RAY | tonejs.github.io Summary
Docs are autogenerated from jsdoc-style comments in the source code, examples are copied from the main repository. To fix any typos or errors, please submit a pull request to the Tone.js repo. PRs for demos are also accepted. Add a 300x300px thumbnail to assets/images and add a reference to your image as well as the title and link to your project to the demos.yaml file.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of tonejs.github.io
tonejs.github.io Key Features
tonejs.github.io Examples and Code Snippets
Community Discussions
Trending Discussions on tonejs.github.io
QUESTION
I enjoy using Howler.js for my (Meteor) application. However, the playback rate function is causing a pitch shift that I don't want (I just want the time stretch, and to preserve the pitch). My solution was to therefore implement a pitch shift to it to 'correct' the pitch. Seemed simple enough, which is why I chose to use https://tonejs.github.io/
Only problem is, I cannot for the life of me get it to work correctly. After hours of reading up on Web Audio API, and Tone.js documentation, and online discussion/troubleshoot forums, the closest to a potential solution I got was something like so (called during render of my application, just in case the issue had to do with loading prematurely):
...ANSWER
Answered 2021-Oct-18 at 19:59I think you don't need the 3rd line in your snippet. Since your first line is telling Tone.js to use the AudioContext
created by howler.js already. Therefore pShift.context
should be equal to Howler.ctx
. But it might make sense to double check.
QUESTION
EDIT: Update on other attempts. The key bit of the question below is the line sampler.triggerRelease(["A1"], 'now')
which is not working. Other things I've tried include:
sampler.releaseAll(Tone.now())
sampler.releaseAll()
sampler.triggerRelease(["A1"], Tone.now())
The relevant part of the Tone.js docs is here.
What won't work is sampler.dispose()
, because it essentially disconnects the sampler instrument from the output. But I need to continue using the sampler to retrigger the same note shortly after turning it off.
I'm trying to use a button press to stop the playing of a 'Sampler' note while it's currently playing. I thought that triggering the release phase would do this (as in my code below) but this doesn't seem to have any effect. I've tried lots of methods. This question doesn't answer mine, partly because it's for the 'Polysynth' not the 'Sampler'. Thanks in advance!
...ANSWER
Answered 2022-Feb-08 at 21:56Replacing triggerAttackRelease
with just triggerAttack
does work:
QUESTION
maybe you can give me a hand, I've been looking for all information, in order to solve this problem of mine, but nothing, I can't use the player with cordova ...
in practice I can't load mp3 files, whether they are both locally and remotely, I always get this error: "Error: buffer is either not set or not loaded", the files in the path are there.
I tried using Tone's oscilloscope to see if I was having trouble loading Tone, but this works fine.
Could it depend on some authorization, particular that I might be missing ?.
For example using cordova media plugin I can reproduce the audio, but I need to use Tonejs.
Do you have any ideas, what this might depend on. or what could I try to do? ...
even this simple example, after the device ready does not go:
...ANSWER
Answered 2022-Jan-15 at 18:49I posted an answer, here, which also solves this problem.
I don't know if the solution is the only possible way, or the best, in order to access the folders locally, I made these changes to the call. Using an XMLHttpRequest object which can be used, to request data from a web server, I got a Blob object, which I then passed to the Tone player.
QUESTION
I have a basic express.js server setup on my Mac. To this I'm trying to import Tone.js, https://tonejs.github.io, by following the instructions.
...ANSWER
Answered 2021-Aug-29 at 12:11As @lars-flieger pointed out, it's not possible to run it one a node.js server. I ended up downloading Tones.js from here and includes it as a regular script tag.
QUESTION
I have a component that instantiates a few classes from the Tone.js library (e.g audio players and filters) and defines a few functions acting on these objects, which are used as callbacks in a set of UI-rendered buttons (see relevant code below).
Two of these buttons are supposed to toggle the boolean state is3D
using the useState hook (in the updateSpatial
function) in order to enable/disable one of these buttons. However, this update obviously causes the component to re-render entirely, thus re-instantiating my classes, which prevent the defined functions to work afterwards.
In contrast, I also tried the useRef hook, which allows for is3D
update without re-rendering, but the button's disabled state is not updated as the component does not re-render.
Is there a pattern that fits with this situation? My next attempts include using HOC, Context, or Redux, but I'm not sure this is the most straighforward. Thanks!
...ANSWER
Answered 2021-May-05 at 13:50I see two things wrong with your code. First, everything within the "normal" body of the function will be executed on on every render. Hence, the need for states and hooks. States allow you to keep data between renders, and hooks allow you to do a particular action upon a state change.
Second, useEffect(()=>console.log(hi))
does not have any dependencies, hence it will run on every render.
useEffect(()=>console.log(hi),[])
will execute only on the first render.
useEffect(()=>console.log(hi),[player1])
will execute when player1 changes.
useEffect(()=>console.log(hi),[player1, player2])
will execute when player1 OR player2 change.
Be careful with hooks with dependencies. If you set the state of one of the dependencies within the hook itself, it will create an infinite loop
Here is something closer to what you want:
QUESTION
I have 4 notes playing in my Tone JS app and would like to change the 3rd note to be something else whilst the transport is currently playing. Here is my code:
JS:
...ANSWER
Answered 2020-Nov-10 at 16:47This is pretty awkward to fix the way it is structured now. The trouble is that every note you add is on its own loop, which begins whenever you call scheduleRepeat
... you would have to correct for the offset between the original loop and the new one, which seems kind of tricky.
I'd suggest that you have call scheduleRepeat
only once, and have the callback read the list of notes you have stored. That way you can just replace or alter one of those notes and the next time around it'll be changed, and you won't have any timing problems. I think that would mean including the pitch in your note schema.
QUESTION
I am using Tone JS for a project and I am using Transport.scheduleOnce to schedule events with the Sampler. Here is what I have so far, also here is a fiddle of it (you may need to click run a couple times to hear the audio come through when fiddle initially loads)
My code:
...ANSWER
Answered 2020-Sep-22 at 19:25Tone.Transport
is triggering your sample.
What you want to do is either use the Tone.Player
if you only want to play sounds like a "jukebox".
If you really need a sampler, then should to look into Envelopes because the Sampler uses one.
In short: The Tone.Transport
like the maestro in a concert. Transport
is only setting the time (only the BPM not the playback speed). Tone.Transport.start()
will trigger all registered instruments (in your case the Sampler) to start doing whatever you programmed them to do. If you want to stop the Sampler from playing in this mode. You can do samplerBuffer.releaseAll()
QUESTION
"Tone.js is a Web Audio framework for creating interactive music in the browser. "
In tone's transport object, the default number of ticks (subdivisions, or ppq) is 192 when the bpm value is at 60. It is proportional to bpm, so at 120 bpm, number of ticks (subdivisions, ppq) is 384.
Why was this number (192, or 384) chosen, instead of something like 200 (and 400 for 120 bpm)? Does it have any particular properties, that make it more suitable to be the default number of ticks for the default bpm?
...ANSWER
Answered 2020-Sep-21 at 14:22PPQ (Pulses Per Quarter-node) is often in values which are divisible by both 2 and 3 which allows it to accurately represent both triplet rhythms (divisions of 3) and duplet rhythms (divisions of 2) which are pretty common rhythmic subdivisions.
For example, with a PPQ of 6, the quarter note could be divided in three ways: by 2, 3 and 6. Those divisions would yield an 8th note (dividing the quarter in 2), a triplet 8th note (dividing by 3) and a triplet 16th note (dividing in 6 equal parts).
The higher the PPQ number, the more divisors (and therefore the more rhythms that it can represent with whole number ticks). A PPQ of 200 or 400 would be good at representing quintuplets (divisions of 5) and duplets since it's divisible by 5 and 2 many times, but wouldn't be able to be evenly divided by 3.
QUESTION
Using Tone.js I'm able to play a sound using the following code
...ANSWER
Answered 2020-Jun-05 at 16:44According to the documentation
QUESTION
I would like to accomplish two things at the same time:
1) change playback rate of a sound file to 1/2 speed
2) lower pitch by a fifth
Lastly, Instead of using a separate button to play the result I would like to hook this up to an audio tag and use the play button there.
Below is the closest I got so far using Tone.js. I am really struggling with the documentation but I understand that Tone.Transport.bpm.value = 60; changes the bpm from 120 to 60 and Tone.PitchShift transposes the song. I just don't see how to combine the two to 'stack' the effects.
Here are some links I followed:
How to change the pitch with JavaScript?
https://tonejs.github.io/docs/r12/PitchShift
https://tonejs.github.io/docs/13.8.25/Transport
Thanks in advance for the help!
...ANSWER
Answered 2020-May-04 at 22:40UPDATE: WORKING SOLUTION
I found a way that works: Set the playback rate first. Then, when setting the pitch you need to calculate how much pitch shift to add/subtract to compensate for the playback rate. In my example I had to compensate +12 pitch shift for 0.5 playback rate.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install tonejs.github.io
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page