SNEX For dummies 2
-
Hi guys. A few questions about SNEX (I know is being re-written but I want to move on meanwhile)
- What HISE api things are available on SNEX? I've just found this and e.getNoteNumber(); works
/* NODE_JIT_ADD_C_FUNCTION_1(int, Wrapper::getNoteNumber, HiseEvent, "getNoteNumber"); HNODE_JIT_ADD_C_FUNCTION_1(int, Wrapper::getVelocity, HiseEvent, "getVelocity"); HNODE_JIT_ADD_C_FUNCTION_1(int, Wrapper::getChannel, HiseEvent, "getChannel"); HNODE_JIT_ADD_C_FUNCTION_1(double, Wrapper::getFrequency, HiseEvent, "getFrequency"); */
- How to print messages on console?? Like Console.pint("Something");
- Anyone can tell me what does "possible lost of data" means here?? Is this the MATRIX??? :P
-
- How to print messages on console?? Like Console.pint("Something");
https://docs.hise.audio/scriptnode/manual/snex.html#variable-visibility
- Anyone can tell me what does "possible lost of data" means here?? Is this the MATRIX??? :P
This is where it appears in the source code, so all the answers must be here :p Looks like a loss can occur when converting between data types (perhaps).
void Operations::Expression::checkAndSetType(int offset /*= 0*/, Types::ID expectedType) { Types::ID exprType = expectedType; for (int i = offset; i < getNumChildStatements(); i++) { auto e = getSubExpr(i); if (auto v = dynamic_cast<VariableReference*>(e.get())) { if (!v->functionClassConstant.isVoid()) { v->type = expectedType; continue; } } auto thisType = e->getType(); if (!Types::Helpers::matchesTypeStrict(thisType, exprType)) { logWarning("Implicit cast, possible lost of data"); if (e->isConstExpr()) { replaceChildStatement(i, ConstExprEvaluator::evalCast(e.get(), exprType).get()); } else { Ptr implCast = new Operations::Cast(e->location, e, exprType); implCast->attachAsmComment("Implicit cast"); replaceChildStatement(i, implCast); } } else exprType = Types::Helpers::getMoreRestrictiveType(exprType, thisType); } type = exprType; }
-
@d-healey said in SNEX For dummies 2:
matchesTypeStrict
:O that's new for me. like everything in these last few days! thanks David
-
@hisefilo said in SNEX For dummies 2:
What HISE api things are available on SNEX
The MIDI message API will be almost identical to the HiseScript
Message
class - with the sole difference that you call the methods on the object itself:// HiseScript: function onNoteOn() { Console.print(Message.getNoteNumber()); } // SNEX: void onHiseEvent(HiseEvent e) { Console.print(e.getNoteNumber()); }
Right now I just added a few methods to make sure it works, but I'll add the rest of them when it's actually useable (it might be possible that I have to change things under the hood, so I don't want to edit all 30ish methods for event manipulation)
As you can see, the
Console.print
methods works in SNEX too, but it's limited to printing out numbers so you can't do concatened String messages like in HISE script. However there is aConsole.pause()
method that acts as breakpoint and allows variable inspection at runtime, so this might be a better debugging tool.Same with the
Math
class. There won't be aSynth
class though and most probably noEngine
class - I'll think about the latter, but SNEX has to be useable in multiple spots where the access to the "global engine" might not be available.Anyone can tell me what does "possible lost of data" means here??
"Possible lost of data" is compiler speak for a numeric conversion that is not lossless. The easiest example would be a
float
toint
conversion where the lost data is simply the fractional part, but there are more complicated issues that arise (AFAIK if you convert a really big integer number to a single precision float number, it might get truncated too). Bottomline is: whenever you see that warning, you need to cast the expression to the desired type. BTW in the new SNEX version you'll see the warning directly in place like this:If you write this the problem goes away:
int x = (int)12.0f;
Although it's stupid to cast a numeric literal when you can just write
int x = 12;
but for the sake of the example... -
@Christoph-Hart said in SNEX For dummies 2:
Same with the Math class. There won't be a Synth class though and most probably no Engine class - I'll think about the latter, but SNEX has to be useable in multiple spots where the access to the "global engine" might not be available.
Thanks mate!
My goal is to build a synth capable to generate multiple sine waves using data frames like this one below . I'm in the right place (SNEX) for my future devs???[#sine osc: freq, amplitude, phase] 1TRC 1 0 0.0249887 1TRC 0x0004 26 4 0 4720.89 0.000139671 -0.806801 1 4450.89 0.000184206 0.256434 2 3970.74 0.000126725 -0.242524 3 3735.95 0.000125689 1.58192 4 3510.61 0.000173862 0.272434 5 3342.09 0.000151657 0.521128 6 3000.99 0.000464915 -2.15388 7 518.579 0.0129921 0.942587 8 659.448 0.0225252 -0.377563 9 785.758 0.00866297 1.20015 10 926.962 0.0124319 -0.55132 11 1057.06 0.00364636 0.910611 12 1438.79 0.00743512 1.2696 13 1699.71 0.00493992 -2.72891 14 1834.94 0.00237093 -2.24004 15 1961.01 0.00362062 -0.517616 17 2223.36 0.00232627 1.38036 18 2362.46 0.00196192 0.670547 19 2483.28 0.00127425 -2.12119 20 2623.2 0.00156323 3.03368 21 2742.53 0.00078575 0.680789 22 2883.19 0.00119679 -0.48985 23 3144.71 0.000859497 1.47357 24 269.348 0.021707 1.14387 25 130.604 0.00496798 2.30956 26 390.77 0.0226341 -0.0619304 1TRC 1 0 0.0499773 1TRC 0x0004 27 4 0 4719.22 0.00041282 -0.68785 1 4451.15 0.000578673 1.61273 2 3977.44 0.000254083 0.174588 3 3738.57 0.000309721 -2.88493