Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ItemOutOfRange error generated on import. #42

Open
tychedelia opened this issue Feb 2, 2023 · 6 comments
Open

ItemOutOfRange error generated on import. #42

tychedelia opened this issue Feb 2, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@tychedelia
Copy link

I'm sure this is technically a violation of the spec, which I'd guess is why this check is in the builder, but all the tools I use (e.g. ODDSound MTS-ESP) are happy to generate scales that violate this. For example. I realize this check might be helpful for manually building scales, but I'm wondering if there's a way we can disable it for import.

@Woyten
Copy link
Owner

Woyten commented Feb 2, 2023

Hi @tychedelia! Thanks for reporting the issue.

I think the problem you mentioned is connected to #8. Currently, scale items that are not within [0cents..period] are rejected because it would require a more sophisticated inverse search function Tuning::find_by_pitch. This function is important for finding the nearest scale step close to a spatial coordinate (e.g. the mouse pointer position).

In order to do an inverse search the Scl type needs to keep track by how many periods the scale items overshoots the period and consider this information in the inverse search.

This is not a super hard problem. It's just that I haven't prioritized it yet. If you think this feature is super important I could start working on it after the migration to Bevy is done. Unless you are interested in helping out. 🙂

@tychedelia
Copy link
Author

This is not a super hard problem. It's just that I haven't prioritized it yet. If you think this feature is super important I could start working on it after the migration to Bevy is done. Unless you are interested in helping out. 🙂

Thanks for the quick reply! I've managed to work around this for now, but am interested in contributing if I run into some free time soon. I'm mostly using this library in a simple way to write a VST, so your description of a more complex use (mouse pointer) is helpful for me understanding the problem space. I'll comment here if I have time to pick this up.

@Woyten
Copy link
Owner

Woyten commented Feb 5, 2023

@tychedelia Hi. Happy to hear that you are writing some VST software using my library! Is it available on Github?

By the way, I had a look at the problem and couldn't resist writing some code. The result is: The feature is almost fully implemented. I also added support for non-periodic scales like the one you provided in the example. Thanks for the inspiration!

The feature is available on the test branch. Feel free to test if it works for your use cases. I will do some more testing and push it on master very soon. Do you need the improved feature on crates.io?

@Woyten
Copy link
Owner

Woyten commented Feb 5, 2023

Now on master branch: d08a1a1

@tychedelia
Copy link
Author

Wow! Incredible. I'll definitely give this a test really soon. This is all built locally so no need for a crate release but very excited to give this a shot. :) Thanks again.

@Woyten Woyten added the enhancement New feature or request label Feb 6, 2023
@Woyten
Copy link
Owner

Woyten commented Feb 7, 2023

I can exactly reproduce the scale from your Scale Workshop link in tune-cli.

Input:

tune dump ref-note 36@70hz steps 3/2 1556.378085308558c 1901.9550008653873c 2298.1333228961844c \
  2746.283397529118c 3106.025951444457518c 3498.1333228961844c  3803.9100017307755c 3948.812593083507c \
4326.511923937046c 4691.5631668168035c 1/1

Output:

  ----------Source Scale----------- ‖ ----Pitch----- ‖ --------Target Scale--------
   21 | IDX  -15 | 11/9    +1¢  +3o ‖     685.000 Hz ‖   77 |      F  5 |  -33.679¢
   22 | IDX  -14 |  3/2   +25¢  +3o ‖     852.000 Hz ‖   80 |  G#/Ab  5 |  +44.020¢
   23 | IDX  -13 | 11/6   +42¢  +3o ‖    1052.000 Hz ‖   84 |      C  6 |   +9.071¢
   24 | IDX  -12 |  1/1    +0¢  +0o ‖      70.000 Hz ‖   37 |  C#/Db  2 |  +17.508¢
   25 | IDX  -11 |  3/2    +0¢  +0o ‖     105.000 Hz ‖   44 |  G#/Ab  2 |  +19.463¢
   26 | IDX  -10 | 11/9    +9¢  +1o ‖     172.000 Hz ‖   53 |      F  3 |  -26.114¢
   27 | IDX   -9 |  3/2    +0¢  +1o ‖     210.000 Hz ‖   56 |  G#/Ab  3 |  +19.463¢
   28 | IDX   -8 | 11/6   +49¢  +1o ‖     264.000 Hz ‖   60 |      C  4 |  +15.641¢
   29 | IDX   -7 | 11/9    -1¢  +2o ‖     342.000 Hz ‖   65 |      F  4 |  -36.209¢
   30 | IDX   -6 |  3/2    +4¢  +2o ‖     420.989 Hz ‖   68 |  G#/Ab  4 |  +23.534¢
   31 | IDX   -5 | 11/6   +49¢  +2o ‖     528.000 Hz ‖   72 |      C  5 |  +15.641¢
   32 | IDX   -4 |  9/8    +0¢  +3o ‖     630.000 Hz ‖   75 |  D#/Eb  5 |  +21.418¢
   33 | IDX   -3 | 11/9    +1¢  +3o ‖     685.000 Hz ‖   77 |      F  5 |  -33.679¢
   34 | IDX   -2 |  3/2   +25¢  +3o ‖     852.000 Hz ‖   80 |  G#/Ab  5 |  +44.020¢
   35 | IDX   -1 | 11/6   +42¢  +3o ‖    1052.000 Hz ‖   84 |      C  6 |   +9.071¢
>  36 | IDX    0 |  1/1    +0¢  +0o ‖      70.000 Hz ‖   37 |  C#/Db  2 |  +17.508¢
   37 | IDX    1 |  3/2    +0¢  +0o ‖     105.000 Hz ‖   44 |  G#/Ab  2 |  +19.463¢
   38 | IDX    2 | 11/9    +9¢  +1o ‖     172.000 Hz ‖   53 |      F  3 |  -26.114¢
   39 | IDX    3 |  3/2    +0¢  +1o ‖     210.000 Hz ‖   56 |  G#/Ab  3 |  +19.463¢
   40 | IDX    4 | 11/6   +49¢  +1o ‖     264.000 Hz ‖   60 |      C  4 |  +15.641¢
   41 | IDX    5 | 11/9    -1¢  +2o ‖     342.000 Hz ‖   65 |      F  4 |  -36.209¢
   42 | IDX    6 |  3/2    +4¢  +2o ‖     420.989 Hz ‖   68 |  G#/Ab  4 |  +23.534¢
   43 | IDX    7 | 11/6   +49¢  +2o ‖     528.000 Hz ‖   72 |      C  5 |  +15.641¢
   44 | IDX    8 |  9/8    +0¢  +3o ‖     630.000 Hz ‖   75 |  D#/Eb  5 |  +21.418¢
   45 | IDX    9 | 11/9    +1¢  +3o ‖     685.000 Hz ‖   77 |      F  5 |  -33.679¢
   46 | IDX   10 |  3/2   +25¢  +3o ‖     852.000 Hz ‖   80 |  G#/Ab  5 |  +44.020¢
   47 | IDX   11 | 11/6   +42¢  +3o ‖    1052.000 Hz ‖   84 |      C  6 |   +9.071¢
   48 | IDX   12 |  1/1    +0¢  +0o ‖      70.000 Hz ‖   37 |  C#/Db  2 |  +17.508¢
   49 | IDX   13 |  3/2    +0¢  +0o ‖     105.000 Hz ‖   44 |  G#/Ab  2 |  +19.463¢
   50 | IDX   14 | 11/9    +9¢  +1o ‖     172.000 Hz ‖   53 |      F  3 |  -26.114¢
   51 | IDX   15 |  3/2    +0¢  +1o ‖     210.000 Hz ‖   56 |  G#/Ab  3 |  +19.463¢
   52 | IDX   16 | 11/6   +49¢  +1o ‖     264.000 Hz ‖   60 |      C  4 |  +15.641¢
   53 | IDX   17 | 11/9    -1¢  +2o ‖     342.000 Hz ‖   65 |      F  4 |  -36.209¢
   54 | IDX   18 |  3/2    +4¢  +2o ‖     420.989 Hz ‖   68 |  G#/Ab  4 |  +23.534¢
   55 | IDX   19 | 11/6   +49¢  +2o ‖     528.000 Hz ‖   72 |      C  5 |  +15.641¢
   56 | IDX   20 |  9/8    +0¢  +3o ‖     630.000 Hz ‖   75 |  D#/Eb  5 |  +21.418¢
   57 | IDX   21 | 11/9    +1¢  +3o ‖     685.000 Hz ‖   77 |      F  5 |  -33.679¢
   58 | IDX   22 |  3/2   +25¢  +3o ‖     852.000 Hz ‖   80 |  G#/Ab  5 |  +44.020¢
   59 | IDX   23 | 11/6   +42¢  +3o ‖    1052.000 Hz ‖   84 |      C  6 |   +9.071¢
   60 | IDX   24 |  1/1    +0¢  +0o ‖      70.000 Hz ‖   37 |  C#/Db  2 |  +17.508¢
   61 | IDX   25 |  3/2    +0¢  +0o ‖     105.000 Hz ‖   44 |  G#/Ab  2 |  +19.463¢
   62 | IDX   26 | 11/9    +9¢  +1o ‖     172.000 Hz ‖   53 |      F  3 |  -26.114¢
   63 | IDX   27 |  3/2    +0¢  +1o ‖     210.000 Hz ‖   56 |  G#/Ab  3 |  +19.463¢
   64 | IDX   28 | 11/6   +49¢  +1o ‖     264.000 Hz ‖   60 |      C  4 |  +15.641¢
   65 | IDX   29 | 11/9    -1¢  +2o ‖     342.000 Hz ‖   65 |      F  4 |  -36.209¢
   66 | IDX   30 |  3/2    +4¢  +2o ‖     420.989 Hz ‖   68 |  G#/Ab  4 |  +23.534¢
   67 | IDX   31 | 11/6   +49¢  +2o ‖     528.000 Hz ‖   72 |      C  5 |  +15.641¢
   68 | IDX   32 |  9/8    +0¢  +3o ‖     630.000 Hz ‖   75 |  D#/Eb  5 |  +21.418¢
   69 | IDX   33 | 11/9    +1¢  +3o ‖     685.000 Hz ‖   77 |      F  5 |  -33.679¢
   70 | IDX   34 |  3/2   +25¢  +3o ‖     852.000 Hz ‖   80 |  G#/Ab  5 |  +44.020¢
   71 | IDX   35 | 11/6   +42¢  +3o ‖    1052.000 Hz ‖   84 |      C  6 |   +9.071¢
   72 | IDX   36 |  1/1    +0¢  +0o ‖      70.000 Hz ‖   37 |  C#/Db  2 |  +17.508¢
   73 | IDX   37 |  3/2    +0¢  +0o ‖     105.000 Hz ‖   44 |  G#/Ab  2 |  +19.463¢
   74 | IDX   38 | 11/9    +9¢  +1o ‖     172.000 Hz ‖   53 |      F  3 |  -26.114¢
   75 | IDX   39 |  3/2    +0¢  +1o ‖     210.000 Hz ‖   56 |  G#/Ab  3 |  +19.463¢
   76 | IDX   40 | 11/6   +49¢  +1o ‖     264.000 Hz ‖   60 |      C  4 |  +15.641¢
   77 | IDX   41 | 11/9    -1¢  +2o ‖     342.000 Hz ‖   65 |      F  4 |  -36.209¢
   78 | IDX   42 |  3/2    +4¢  +2o ‖     420.989 Hz ‖   68 |  G#/Ab  4 |  +23.534¢
   79 | IDX   43 | 11/6   +49¢  +2o ‖     528.000 Hz ‖   72 |      C  5 |  +15.641¢
   80 | IDX   44 |  9/8    +0¢  +3o ‖     630.000 Hz ‖   75 |  D#/Eb  5 |  +21.418¢
   81 | IDX   45 | 11/9    +1¢  +3o ‖     685.000 Hz ‖   77 |      F  5 |  -33.679¢
   82 | IDX   46 |  3/2   +25¢  +3o ‖     852.000 Hz ‖   80 |  G#/Ab  5 |  +44.020¢
   83 | IDX   47 | 11/6   +42¢  +3o ‖    1052.000 Hz ‖   84 |      C  6 |   +9.071¢
   84 | IDX   48 |  1/1    +0¢  +0o ‖      70.000 Hz ‖   37 |  C#/Db  2 |  +17.508¢
   85 | IDX   49 |  3/2    +0¢  +0o ‖     105.000 Hz ‖   44 |  G#/Ab  2 |  +19.463¢
   86 | IDX   50 | 11/9    +9¢  +1o ‖     172.000 Hz ‖   53 |      F  3 |  -26.114¢
   87 | IDX   51 |  3/2    +0¢  +1o ‖     210.000 Hz ‖   56 |  G#/Ab  3 |  +19.463¢
   88 | IDX   52 | 11/6   +49¢  +1o ‖     264.000 Hz ‖   60 |      C  4 |  +15.641¢
   89 | IDX   53 | 11/9    -1¢  +2o ‖     342.000 Hz ‖   65 |      F  4 |  -36.209¢
   90 | IDX   54 |  3/2    +4¢  +2o ‖     420.989 Hz ‖   68 |  G#/Ab  4 |  +23.534¢
   91 | IDX   55 | 11/6   +49¢  +2o ‖     528.000 Hz ‖   72 |      C  5 |  +15.641¢
   92 | IDX   56 |  9/8    +0¢  +3o ‖     630.000 Hz ‖   75 |  D#/Eb  5 |  +21.418¢
   93 | IDX   57 | 11/9    +1¢  +3o ‖     685.000 Hz ‖   77 |      F  5 |  -33.679¢
   94 | IDX   58 |  3/2   +25¢  +3o ‖     852.000 Hz ‖   80 |  G#/Ab  5 |  +44.020¢
   95 | IDX   59 | 11/6   +42¢  +3o ‖    1052.000 Hz ‖   84 |      C  6 |   +9.071¢
   96 | IDX   60 |  1/1    +0¢  +0o ‖      70.000 Hz ‖   37 |  C#/Db  2 |  +17.508¢
   97 | IDX   61 |  3/2    +0¢  +0o ‖     105.000 Hz ‖   44 |  G#/Ab  2 |  +19.463¢
   98 | IDX   62 | 11/9    +9¢  +1o ‖     172.000 Hz ‖   53 |      F  3 |  -26.114¢
   99 | IDX   63 |  3/2    +0¢  +1o ‖     210.000 Hz ‖   56 |  G#/Ab  3 |  +19.463¢
  100 | IDX   64 | 11/6   +49¢  +1o ‖     264.000 Hz ‖   60 |      C  4 |  +15.641¢
  101 | IDX   65 | 11/9    -1¢  +2o ‖     342.000 Hz ‖   65 |      F  4 |  -36.209¢
  102 | IDX   66 |  3/2    +4¢  +2o ‖     420.989 Hz ‖   68 |  G#/Ab  4 |  +23.534¢
  103 | IDX   67 | 11/6   +49¢  +2o ‖     528.000 Hz ‖   72 |      C  5 |  +15.641¢
  104 | IDX   68 |  9/8    +0¢  +3o ‖     630.000 Hz ‖   75 |  D#/Eb  5 |  +21.418¢
  105 | IDX   69 | 11/9    +1¢  +3o ‖     685.000 Hz ‖   77 |      F  5 |  -33.679¢
  106 | IDX   70 |  3/2   +25¢  +3o ‖     852.000 Hz ‖   80 |  G#/Ab  5 |  +44.020¢
  107 | IDX   71 | 11/6   +42¢  +3o ‖    1052.000 Hz ‖   84 |      C  6 |   +9.071¢
  108 | IDX   72 |  1/1    +0¢  +0o ‖      70.000 Hz ‖   37 |  C#/Db  2 |  +17.508¢

I have already published tune-0.32.1 to crates.io and will probably publish tune-cli-0.25.1 within the next hour.

I will leave this ticket open until microwave's temperament finder and UI can correctly handle the now acceptable non-periodic and negative-periodic scales.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants