SeanArchibald / scale-workshop

Design microtonal scales and play them in your web browser. Export your scales for use with VST instruments. Convert Scala files to various tuning formats.
https://sevish.com/scaleworkshop/
146 stars 23 forks source link

Unexpected output in moduloLine() #125

Closed SeanArchibald closed 2 years ago

SeanArchibald commented 3 years ago

moduloLine("1,7","3/2") returns 2,550000

vsicurella commented 3 years ago

thanks for recording this! I've been wanting to fix this stuff for the PRs I have open. I'd love to unit test these extended math functions but having little time to work on that held me back. Just finished a bunch of work though so I'd like to revisit this very soon.

SeanArchibald commented 3 years ago

Your moduloLine() function is super helpful for new features I'm working on, so I'm glad you've added it, big thanks!

When you're ready to revisit this, if you think it would be helpful for us to have a chat to work through any merges, testing etc. we can set something up. Otherwise will look forward to the PRs.

vsicurella commented 3 years ago

Love to hear it!

I started writing tests (in the ./dev/test/ folder @meszaros-lajos-gyorgy set up) for the helper functions I've added, but it will take me a few more days to finish writing all of them.

For now I don't think I'll need much help as I'm more or less cleaning up my previous work, but I'm making notes of some boring style and syntax questions (for example, what to do with a negative ratio) as I think of them. After writing a few more tests, I can post them here or send them in a FB group message with @meszaros-lajos-gyorgy if that's preferable!

vsicurella commented 3 years ago

I think this is safe to close, see #107 !

SeanArchibald commented 3 years ago

While I did merge #107 into develop earlier today, I just discovered unusual results when using decimal linetype in moduloLine()

Commadecimal seems ok: moduloLine("4,0","2,0") = '1,000000'

Decimal results are different to what is above: moduloLine("4.0","2.0") = '0.000000'

@vsicurella if you have any ideas please let me know! Otherwise I can dig further next time I'm working on SW

vsicurella commented 3 years ago

That's because the second example is 4 cents modulo 2 cents. :) It is a bit confusing the functions are called "commadecimal" but the line type is "decimal". Maybe that should be refactored to commadecimal, since the function names need to differentiate decimal numbers.

SeanArchibald commented 3 years ago

Oh of course! I got confused how decimals are represented in the code vs how cents intervals are notated.