What am I doing wrong?

This is not about an issue with the TuneScope library, I just want to understand why something happens.

I have been experimenting with TuneScope. One thing I wanted to find out is how many notes (on different instruments) can be started at more or less the same time. One thing I tried was use primitive functions (coded in JavaScript, I suppose). I tried the one from:

This was my first try: TuneScope sandbox script pic (4), and it produced this error (I had to wrap it in order to get a "result pic"):

So it won't work with a number as second input. Perhaps it'll work with a function reporting a number?


TuneScope sandbox script pic (8)

Mmm ... let's try a different (identity) reporter: TuneScope sandbox script pic (11)

Does anyone understand why this third attempt works, but not the second (and first)?

The primitive block uses unevaluated inputs I think
So it’s not getting “1” it’s getting the block

That's why I tried a reporter instead of a number.
But why then doesn't it accept the first reporter I tried?

I think I figured it out

It’s returning a string not a number. Id OF returns a number because the input slot is a number. But the identity one returns a string because the input is “any”
Still not sure if this is correct

It also could be that it just doesn’t accept custom blocks

Interesting thought. However, it does accept: TuneScope sandbox script pic (14),
and that's a custom (TuneScope) block: TuneScope sandbox script pic (16).

Maybe there’s something funky going on with using call like that?

TuneScope sandbox script pic (18)
TuneScope sandbox script pic (17)

Those aren’t accurate because snap doesn’t have numbers as their own data type. The primitive blocks use js and that does
So when the blocked are called inside of js it might cause some weirdness with what’s a string and what’s a number

If you are referring to: TuneScope sandbox script pic (19)
... I only used that because there's no way to get a result pic from TuneScope sandbox script pic (20),
but that produces the same error.

Please don't use the primitive blocks, and instead use the custom blocks that use them, they eliminate having to figure out what the inputs are.

Oh, I didn’t know that because in your original post you said “warp”

"wrap" actually :wink:

And the reason you're getting an error is because it's expecting a number in the second input. This is type sensitive, which means you have to get a number, e.g. from a number input, in order to get it to work. If you put the number in the primitive block itself, then it will become a string.

Again, this is not an issue if you just use the library block that this primitive function is meant for.

I wanted to speed up the function for my experimentation, as the TuneScope library's TuneScope sandbox script pic (21) does time-consuming stuff I didn't need. Indeed it appears Snap!'s types may be somewhat different from JavaScripts; that's probably what caused the "strange" phenomena I noticed. I solved it for now by using a calculation:

TuneScope sandbox script pic (23)

This function will play any playlist consisting of records with the following specs:

  1. Instrument name (e.g. "Piano")
  2. Pitch (e.g. C#4)
  3. Duration in ms.
  4. Start time in ms

... sorted by start time, ascending.

Dislexia moment

Also I was right I knew it had something to do with thpes

I'm not saying it's an issue, I want to understand what's happening.
Thanks to you, and @cookieclickerer33 for helping me with that!

Actually, it's still very fast, and takes no time, so speed is not a reason to use the primitive blocks. It especially doesn't matter if you're putting in a wait block, which just tells me you don't actually need speed.

[tangent]
Why do you guys think the primitive block is faster than custom blocks? If you time it, it is only a couple milliseconds faster, which in this case, is not needed. Plus, you can turn on turbo mode and / or warp the script to make it run faster. Given the issue here, sometimes the primitive functions expect one value type, such as a number, which raises a lot of confusion, as strings and numbers are treated the same in snap. The primitive blocks are not meant for random snappers to put in their scripts, they're meant for library blocks only. So please stop using primitive blocks in your scripts just for the sake of speed, it really doesn't go much faster than the library blocks.
[/tangent]

The speed is for synchronization: making sure notes supposed to begin at the same time are actually started with the smallest possible timing difference. The waiting is for the next note to be started at a later time.

which you can also use the launch block for