strudel icon indicating copy to clipboard operation
strudel copied to clipboard

Providing too much resolution to early or late results in dropped notes

Open bpow opened this issue 3 years ago • 1 comments

This may be a case of "well don't do that then", but hopefully can be addressed.

I've noticed that if there are a lot of significant digits to the argument of late or early, then some notes end up being dropped. A quick example that shows this is:

sine.range(0, 12).late(Math.PI).segment(12).scale('C major').pianoroll()

Running this in the REPL results in some notes not being played as well as not being displayed on the piano roll (there should be 12 notes per cycle, but some end up being left out).

So far, I think somehow the Number to Fraction to Number conversion may be messing things up, resulting in whole / part components of haps with some fractions with very large numerators/denominators.

Running:

sine.range(0, 12).early(Math.PI).segment(12).queryArc(0, 1).map(e => e.show())

Results in:

[
    "(0/1 -> 1/12, 0/1 -> 355271367880050/4263256414560601, 11.480137265535536)",
    "(1/12 -> 1/6, 1/12 -> 1/6, 11.967422385140505)",
    "(1/6 -> 1/4, 947390314346802/5684341886080801 -> 888178419700124/3552713678800501, 10.855741495751651)",
    "(1/4 -> 1/3, 1/4 -> 1/3, 8.442968593921858)",
    "(1/3 -> 5/12, 1421085471520202/4263256414560601 -> 5/12, 5.3756042302161084)",
    "(5/12 -> 1/2, 2368475785867002/5684341886080801 -> 1776356839400250/3552713678800501, 2.475546208781361)",
    "(1/2 -> 7/12, 1/2 -> 7/12, 0.5198627344644546)",
    "(7/12 -> 2/3, 2486899575160352/4263256414560601 -> 2/3, 0.032577614859495174)",
    "(2/3 -> 3/4, 3789561257387202/5684341886080801 -> 2664535259100374/3552713678800501, 1.1442585042483464)",
    "(3/4 -> 5/6, 3/4 -> 5/6, 3.5570314060781407)",
    "(5/6 -> 11/12, 3552713678800502/4263256414560601 -> 11/12, 6.62439576978387)",
    "(11/12 -> 1/1, 5210646728907402/5684341886080801 -> 3552713678800500/3552713678800501, 9.524453791218637)"
]

Running with early/late shifts with fewer significant digits (e.g., does not result in this issue of dropped notes (at least not after listening for a while...

bpow avatar Aug 14 '22 01:08 bpow

this seems to be a problem with segment. without it, it works: https://strudel.tidalcycles.org?bbPVlOzXxAxn sine example https://strudel.tidalcycles.org?dZSKPnJiPMAz

felixroos avatar Aug 14 '22 10:08 felixroos

this now works :) fixed with https://github.com/tidalcycles/strudel/pull/266/files#diff-14f20a1fc98904f5caad45d561f89e2d517023d243198963ef1405606f023ad7

demo https://strudel.tidalcycles.org/#c2luZS5yYW5nZSgwLCAxMikubGF0ZShNYXRoLlBJKS5zZWdtZW50KDEyKS5zY2FsZSgnQyBtYWpvcicpLm5vdGUoKS5waWFub3JvbGwoKQ%3D%3D

felixroos avatar Nov 22 '22 17:11 felixroos