Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.4k stars 976 forks source link

Use reciprocal of tempo when syncing time signals to Transport #1050

Closed yifanmai closed 1 year ago

yifanmai commented 2 years ago

Previously, signals with time units were synced to Transport by connecting it to the tempo signal, which has frequency units. This unit mismatch caused incorrect behavior, e.g. a time signal would double instead of halving as expected when bpm doubles. Now, signals with time units are connected to the reciprocal of the tempo signal instead, which also has time units.

fixes #879

codecov[bot] commented 2 years ago

Codecov Report

Merging #1050 (a392067) into dev (aad2d8c) will increase coverage by 0.02%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1050      +/-   ##
==========================================
+ Coverage   98.43%   98.45%   +0.02%     
==========================================
  Files         184      184              
  Lines        7691     7724      +33     
  Branches      665      679      +14     
==========================================
+ Hits         7570     7604      +34     
+ Misses         36       34       -2     
- Partials       85       86       +1     
Impacted Files Coverage Δ
Tone/core/clock/Transport.ts 98.47% <100.00%> (+0.10%) :arrow_up:
Tone/source/buffer/Player.ts 97.32% <0.00%> (-0.89%) :arrow_down:
Tone/core/context/ToneAudioBuffer.ts 99.26% <0.00%> (-0.01%) :arrow_down:
Tone/event/Pattern.ts 100.00% <0.00%> (ø)
Tone/core/clock/Ticker.ts 100.00% <0.00%> (ø)
Tone/event/PatternGenerator.ts 100.00% <0.00%> (ø)
Tone/component/analysis/Meter.ts 100.00% <0.00%> (ø)
Tone/instrument/MetalSynth.ts 97.18% <0.00%> (+0.04%) :arrow_up:
Tone/core/clock/TickSource.ts 97.33% <0.00%> (+0.56%) :arrow_up:
Tone/core/context/Context.ts 97.32% <0.00%> (+1.14%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update aad2d8c...a392067. Read the comment docs.

yifanmai commented 2 years ago

On further thought, this PR has an issue whereby the new intermediate signal operators don't get garbage collected when the signal is unsynced. I'll fix this shortly.

tambien commented 1 year ago

Great PR! thanks you!