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

saw/sawFloat list functions don't output correctly in Mercury4Max #96

Open
HighHarmonics2 opened this issue Nov 18, 2024 · 4 comments
Open
Labels
bug Something isn't working

Comments

@HighHarmonics2
Copy link

HighHarmonics2 commented Nov 18, 2024

In comparing output of the sineF list function to sawF, it shows that sawF just passes the arguments and doesn't evaluate the function. saw and sawF have the same problem. This is only in Mercury4Max - saw/sawF work as expected in MercuryPlayground.

// works as expected
list myList sineF(16 1 0.5 1.5)
print myList

PRINT: speeds 1 1.076537 1.141421 1.184776 1.2 1.184776 1.141421 1.076537 1 0.923463 0.858579 0.815224 0.8 0.815224 0.858579 0.923463

//print output shows a pass-thru on the function name and the arguments
list myList sawF(16 0.5 1.5)
print myList

PRINT: speeds sawF 16 1 0.8 1.2

This appears to be a bug. A low priority one.

@tmhglnd
Copy link
Owner

tmhglnd commented Nov 18, 2024

Thanks for the report, I will give it a look. It is possible that some list functions are not functioning in Mercury vs MercuryPlayground. They are running 2 different versions of interpreters... Which I want to make into 1 version at some point, because it is too much to maintain both. But since that requires quite some work it was in some cases easier to just fix these little bugs. I'll try to fix it.

Just one thing I notice in your example (but this could be due to how you wrote it), You have sawF(16 0.5 1.5), but I think this should be sawF(16 1 0.5 1.5).

@tmhglnd tmhglnd added the bug Something isn't working label Nov 18, 2024
@HighHarmonics2
Copy link
Author

HighHarmonics2 commented Nov 18, 2024

I see that square/squareF/squareFloat, binary/binaryBeat, spacingBeat are also not working in Max. These functions are missing from the handlers block of mercury.js where they are present in https://github.com/tmhglnd/mercury-playground/blob/main/node_modules/mercury-lang/src/totalSerialismIR.js

In Playground I see a set of functions/aliases for spreadExp/spreadExpFloat that are not in Max and are not documented. There are probably others. Maybe some of these are intentionally left out of the docs??

Seems like an easy fix. I could look at this and do a PR - but I'm not clear on how much you want Max functions and Playground functions to match and if you want to include undocumented functions. Maybe a simpler approach would be to just add the ones to Max that are documented and missing.

Yes, in my issue code above I typed the sawF args incorrectly.

@tmhglnd
Copy link
Owner

tmhglnd commented Nov 19, 2024

In general the plan is to have Mercury and MercuryPlayground the same as much as possible. But there will be limitations and moments where they will never be able to be the same (just due to differences/limitations with WebAudio API vs. how Max works).

For the list-functions however, it would be possible to have them exactly the same, because both versions use NodeJS.

The final intention is that the Max version uses: https://github.com/tmhglnd/mercury-lang

This is already what the browser version uses, also allowing for a much more extensive syntax (like nested functions, using arrays in instrument functions). When the Max version uses this it will be much easier to maintain both since there is only one package that handles the parsing and evaluation. Then the only difference will be in the implementation of the synth/sample/sequence engines. But this is a long-term project.

For now just including functions in the Max version like you mention is a fine solution, and i'm open to your PR if you want to have these included on a short term.

@HighHarmonics2
Copy link
Author

I put in a PR. When I looked through the code for the Mercury-Playground - I saw that there are many missing functions. So I added them all in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants