errer prone implementation of Audio math node
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
from inspect import cleandoc
|
||||
import torch
|
||||
from antlr4 import CommonTokenStream, InputStream
|
||||
from .Parser.MathExprParser import MathExprParser
|
||||
from .Parser.MathExprLexer import MathExprLexer
|
||||
from .Parser.TensorEvalVisitor import TensorEvalVisitor
|
||||
from .helper_functions import getIndexTensorAlongDim
|
||||
|
||||
class AudioMathNode:
|
||||
"""
|
||||
This node enables the use of math expressions on AUDIO tensors.
|
||||
INPUTS:
|
||||
a, b, c, d:
|
||||
AUDIO, bound to variables with the same name. Defaults to zero AUDIO if not provided.
|
||||
w, x, y, z:
|
||||
Floats, bound to variables of the expression. Defaults to 0.0 if not provided.
|
||||
Audio expression:
|
||||
String, describing expression to apply to audio tensors.
|
||||
|
||||
OUTPUTS:
|
||||
AUDIO:
|
||||
Returns an AUDIO object that contains the result of the math expression applied to the input audio tensors.
|
||||
"""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
"""
|
||||
"""
|
||||
return {
|
||||
"required": {
|
||||
"a": ("AUDIO", {
|
||||
"description": "Input audio tensor"
|
||||
}),
|
||||
"AudioExpr": ("STRING", {
|
||||
"multiline": False,
|
||||
"default": "a*(1-w)+b*w",
|
||||
"description": "Expression to apply on input audio tensors"
|
||||
}),
|
||||
},
|
||||
"optional": {
|
||||
"b": ("AUDIO", {
|
||||
"default": 0,
|
||||
"description": "Second input audio tensor"
|
||||
}),
|
||||
"c": ("AUDIO", {
|
||||
"default": 0,
|
||||
"description": "Third input audio tensor"
|
||||
}),
|
||||
"d": ("AUDIO", {
|
||||
"default": 0,
|
||||
"description": "Fourth input audio tensor"
|
||||
}),
|
||||
"w": ("FLOAT", {
|
||||
"default": 0,
|
||||
"forceInput": True
|
||||
}),
|
||||
"x": ("FLOAT", {
|
||||
"default": 0,
|
||||
"forceInput": True
|
||||
}),
|
||||
"y": ("FLOAT", {
|
||||
"default": 0,
|
||||
"forceInput": True
|
||||
}),
|
||||
"z": ("FLOAT", {
|
||||
"default": 0,
|
||||
"forceInput": True
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("AUDIO",)
|
||||
DESCRIPTION = cleandoc(__doc__)
|
||||
FUNCTION = "audioMathNode"
|
||||
CATEGORY = "More math"
|
||||
|
||||
def audioMathNode(self, a, AudioExpr, b=None, c=None, d=None, w=0.0, x=0.0, y=0.0, z=0.0):
|
||||
|
||||
|
||||
bv = b if b else {'waveform':torch.zeros_like(a['waveform']),'sample_rate':a['sample_rate']}
|
||||
cv = c if c else {'waveform':torch.zeros_like(a['waveform']),'sample_rate':a['sample_rate']}
|
||||
dv = d if d else {'waveform':torch.zeros_like(a['waveform']),'sample_rate':a['sample_rate']}
|
||||
print("AudioMathNode: a shape:", a['waveform'].shape)
|
||||
|
||||
|
||||
B = getIndexTensorAlongDim(a['waveform'], 0)
|
||||
C = getIndexTensorAlongDim(a['waveform'], 1)
|
||||
T = getIndexTensorAlongDim(a['waveform'], 2)
|
||||
|
||||
|
||||
variables = {
|
||||
'a': a['waveform'], 'b': bv['waveform'], 'c': cv['waveform'], 'd': dv['waveform'],
|
||||
'w': w, 'x': x, 'y': y, 'z': z,
|
||||
'B': B, 'C': C, 'T': T
|
||||
}
|
||||
|
||||
input_stream = InputStream(AudioExpr)
|
||||
lexer = MathExprLexer(input_stream)
|
||||
stream = CommonTokenStream(lexer)
|
||||
parser = MathExprParser(stream)
|
||||
tree = parser.expr()
|
||||
|
||||
visitor = TensorEvalVisitor(variables, a['waveform'].shape)
|
||||
result_tensor = visitor.visit(tree)
|
||||
|
||||
# Create output dictionary with the same sample rate
|
||||
output = {
|
||||
'waveform': result_tensor,
|
||||
'sample_rate': a['sample_rate']
|
||||
}
|
||||
|
||||
return (output,)
|
||||
@@ -68,6 +68,8 @@ func1
|
||||
| ROUND '(' expr ')' # RoundFunc
|
||||
| GAMMA '(' expr ')' # GammaFunc
|
||||
| SIGM '(' expr ')' # sigmoidFunc
|
||||
| SFFT '(' expr ')' # sfftFunc
|
||||
| SIFFT '(' expr ')' # sifftFunc
|
||||
|
||||
;
|
||||
|
||||
@@ -121,6 +123,8 @@ GAMMA : 'gamma';
|
||||
POWE : 'pow';
|
||||
SIGM : 'sigm';
|
||||
CLAMP : 'clamp';
|
||||
SFFT : 'fft';
|
||||
SIFFT : 'ifft';
|
||||
|
||||
PLUS : '+';
|
||||
MINUS : '-';
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -32,16 +32,18 @@ GAMMA=31
|
||||
POWE=32
|
||||
SIGM=33
|
||||
CLAMP=34
|
||||
PLUS=35
|
||||
MINUS=36
|
||||
MULT=37
|
||||
DIV=38
|
||||
MOD=39
|
||||
POW=40
|
||||
CONSTANT=41
|
||||
NUMBER=42
|
||||
VARIABLE=43
|
||||
WS=44
|
||||
SFFT=35
|
||||
SIFFT=36
|
||||
PLUS=37
|
||||
MINUS=38
|
||||
MULT=39
|
||||
DIV=40
|
||||
MOD=41
|
||||
POW=42
|
||||
CONSTANT=43
|
||||
NUMBER=44
|
||||
VARIABLE=45
|
||||
WS=46
|
||||
'('=1
|
||||
')'=2
|
||||
','=3
|
||||
@@ -76,9 +78,11 @@ WS=44
|
||||
'pow'=32
|
||||
'sigm'=33
|
||||
'clamp'=34
|
||||
'+'=35
|
||||
'-'=36
|
||||
'*'=37
|
||||
'/'=38
|
||||
'%'=39
|
||||
'^'=40
|
||||
'fft'=35
|
||||
'ifft'=36
|
||||
'+'=37
|
||||
'-'=38
|
||||
'*'=39
|
||||
'/'=40
|
||||
'%'=41
|
||||
'^'=42
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -10,110 +10,115 @@ else:
|
||||
|
||||
def serializedATN():
|
||||
return [
|
||||
4,0,44,297,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,
|
||||
4,0,46,310,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,
|
||||
2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,
|
||||
13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,
|
||||
19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,
|
||||
26,7,26,2,27,7,27,2,28,7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,
|
||||
32,2,33,7,33,2,34,7,34,2,35,7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,
|
||||
39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,1,0,1,0,1,1,1,1,
|
||||
1,2,1,2,1,3,1,3,1,3,1,3,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,6,1,6,
|
||||
1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,9,1,9,1,9,
|
||||
1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,11,1,11,1,11,1,11,1,11,1,
|
||||
12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,14,1,14,1,
|
||||
14,1,14,1,14,1,14,1,15,1,15,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,
|
||||
16,1,17,1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,19,1,19,1,19,1,19,1,
|
||||
20,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,1,22,1,
|
||||
22,1,23,1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24,1,24,1,25,1,25,1,
|
||||
25,1,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,
|
||||
27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29,1,29,1,
|
||||
29,1,30,1,30,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,31,1,32,1,32,1,
|
||||
32,1,32,1,32,1,33,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,35,1,35,1,
|
||||
36,1,36,1,37,1,37,1,38,1,38,1,39,1,39,1,40,1,40,1,40,1,40,1,40,3,
|
||||
40,269,8,40,1,41,4,41,272,8,41,11,41,12,41,273,1,41,1,41,4,41,278,
|
||||
8,41,11,41,12,41,279,3,41,282,8,41,1,42,1,42,5,42,286,8,42,10,42,
|
||||
12,42,289,9,42,1,43,4,43,292,8,43,11,43,12,43,293,1,43,1,43,0,0,
|
||||
44,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,
|
||||
13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,
|
||||
24,49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,
|
||||
35,71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,44,1,0,5,2,
|
||||
0,69,69,101,101,1,0,48,57,3,0,65,90,95,95,97,122,4,0,48,57,65,90,
|
||||
95,95,97,122,3,0,9,10,13,13,32,32,303,0,1,1,0,0,0,0,3,1,0,0,0,0,
|
||||
5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,
|
||||
1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,
|
||||
1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,
|
||||
1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,
|
||||
1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,
|
||||
1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,
|
||||
1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,
|
||||
1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,
|
||||
1,0,0,0,0,87,1,0,0,0,1,89,1,0,0,0,3,91,1,0,0,0,5,93,1,0,0,0,7,95,
|
||||
1,0,0,0,9,99,1,0,0,0,11,103,1,0,0,0,13,107,1,0,0,0,15,112,1,0,0,
|
||||
0,17,117,1,0,0,0,19,122,1,0,0,0,21,128,1,0,0,0,23,133,1,0,0,0,25,
|
||||
138,1,0,0,0,27,143,1,0,0,0,29,149,1,0,0,0,31,155,1,0,0,0,33,161,
|
||||
1,0,0,0,35,165,1,0,0,0,37,170,1,0,0,0,39,173,1,0,0,0,41,177,1,0,
|
||||
0,0,43,181,1,0,0,0,45,186,1,0,0,0,47,191,1,0,0,0,49,196,1,0,0,0,
|
||||
51,201,1,0,0,0,53,207,1,0,0,0,55,213,1,0,0,0,57,219,1,0,0,0,59,224,
|
||||
1,0,0,0,61,230,1,0,0,0,63,236,1,0,0,0,65,240,1,0,0,0,67,245,1,0,
|
||||
0,0,69,251,1,0,0,0,71,253,1,0,0,0,73,255,1,0,0,0,75,257,1,0,0,0,
|
||||
77,259,1,0,0,0,79,261,1,0,0,0,81,268,1,0,0,0,83,271,1,0,0,0,85,283,
|
||||
1,0,0,0,87,291,1,0,0,0,89,90,5,40,0,0,90,2,1,0,0,0,91,92,5,41,0,
|
||||
0,92,4,1,0,0,0,93,94,5,44,0,0,94,6,1,0,0,0,95,96,5,115,0,0,96,97,
|
||||
5,105,0,0,97,98,5,110,0,0,98,8,1,0,0,0,99,100,5,99,0,0,100,101,5,
|
||||
111,0,0,101,102,5,115,0,0,102,10,1,0,0,0,103,104,5,116,0,0,104,105,
|
||||
5,97,0,0,105,106,5,110,0,0,106,12,1,0,0,0,107,108,5,97,0,0,108,109,
|
||||
5,115,0,0,109,110,5,105,0,0,110,111,5,110,0,0,111,14,1,0,0,0,112,
|
||||
113,5,97,0,0,113,114,5,99,0,0,114,115,5,111,0,0,115,116,5,115,0,
|
||||
0,116,16,1,0,0,0,117,118,5,97,0,0,118,119,5,116,0,0,119,120,5,97,
|
||||
0,0,120,121,5,110,0,0,121,18,1,0,0,0,122,123,5,97,0,0,123,124,5,
|
||||
116,0,0,124,125,5,97,0,0,125,126,5,110,0,0,126,127,5,50,0,0,127,
|
||||
20,1,0,0,0,128,129,5,115,0,0,129,130,5,105,0,0,130,131,5,110,0,0,
|
||||
131,132,5,104,0,0,132,22,1,0,0,0,133,134,5,99,0,0,134,135,5,111,
|
||||
0,0,135,136,5,115,0,0,136,137,5,104,0,0,137,24,1,0,0,0,138,139,5,
|
||||
116,0,0,139,140,5,97,0,0,140,141,5,110,0,0,141,142,5,104,0,0,142,
|
||||
26,1,0,0,0,143,144,5,97,0,0,144,145,5,115,0,0,145,146,5,105,0,0,
|
||||
146,147,5,110,0,0,147,148,5,104,0,0,148,28,1,0,0,0,149,150,5,97,
|
||||
0,0,150,151,5,99,0,0,151,152,5,111,0,0,152,153,5,115,0,0,153,154,
|
||||
5,104,0,0,154,30,1,0,0,0,155,156,5,97,0,0,156,157,5,116,0,0,157,
|
||||
158,5,97,0,0,158,159,5,110,0,0,159,160,5,104,0,0,160,32,1,0,0,0,
|
||||
161,162,5,97,0,0,162,163,5,98,0,0,163,164,5,115,0,0,164,34,1,0,0,
|
||||
0,165,166,5,115,0,0,166,167,5,113,0,0,167,168,5,114,0,0,168,169,
|
||||
5,116,0,0,169,36,1,0,0,0,170,171,5,108,0,0,171,172,5,110,0,0,172,
|
||||
38,1,0,0,0,173,174,5,108,0,0,174,175,5,111,0,0,175,176,5,103,0,0,
|
||||
176,40,1,0,0,0,177,178,5,101,0,0,178,179,5,120,0,0,179,180,5,112,
|
||||
0,0,180,42,1,0,0,0,181,182,5,115,0,0,182,183,5,109,0,0,183,184,5,
|
||||
105,0,0,184,185,5,110,0,0,185,44,1,0,0,0,186,187,5,115,0,0,187,188,
|
||||
5,109,0,0,188,189,5,97,0,0,189,190,5,120,0,0,190,46,1,0,0,0,191,
|
||||
192,5,116,0,0,192,193,5,109,0,0,193,194,5,105,0,0,194,195,5,110,
|
||||
0,0,195,48,1,0,0,0,196,197,5,116,0,0,197,198,5,109,0,0,198,199,5,
|
||||
97,0,0,199,200,5,120,0,0,200,50,1,0,0,0,201,202,5,116,0,0,202,203,
|
||||
5,110,0,0,203,204,5,111,0,0,204,205,5,114,0,0,205,206,5,109,0,0,
|
||||
206,52,1,0,0,0,207,208,5,115,0,0,208,209,5,110,0,0,209,210,5,111,
|
||||
0,0,210,211,5,114,0,0,211,212,5,109,0,0,212,54,1,0,0,0,213,214,5,
|
||||
102,0,0,214,215,5,108,0,0,215,216,5,111,0,0,216,217,5,111,0,0,217,
|
||||
218,5,114,0,0,218,56,1,0,0,0,219,220,5,99,0,0,220,221,5,101,0,0,
|
||||
221,222,5,105,0,0,222,223,5,108,0,0,223,58,1,0,0,0,224,225,5,114,
|
||||
0,0,225,226,5,111,0,0,226,227,5,117,0,0,227,228,5,110,0,0,228,229,
|
||||
5,100,0,0,229,60,1,0,0,0,230,231,5,103,0,0,231,232,5,97,0,0,232,
|
||||
233,5,109,0,0,233,234,5,109,0,0,234,235,5,97,0,0,235,62,1,0,0,0,
|
||||
236,237,5,112,0,0,237,238,5,111,0,0,238,239,5,119,0,0,239,64,1,0,
|
||||
0,0,240,241,5,115,0,0,241,242,5,105,0,0,242,243,5,103,0,0,243,244,
|
||||
5,109,0,0,244,66,1,0,0,0,245,246,5,99,0,0,246,247,5,108,0,0,247,
|
||||
248,5,97,0,0,248,249,5,109,0,0,249,250,5,112,0,0,250,68,1,0,0,0,
|
||||
251,252,5,43,0,0,252,70,1,0,0,0,253,254,5,45,0,0,254,72,1,0,0,0,
|
||||
255,256,5,42,0,0,256,74,1,0,0,0,257,258,5,47,0,0,258,76,1,0,0,0,
|
||||
259,260,5,37,0,0,260,78,1,0,0,0,261,262,5,94,0,0,262,80,1,0,0,0,
|
||||
263,264,5,112,0,0,264,269,5,105,0,0,265,266,5,80,0,0,266,269,5,73,
|
||||
0,0,267,269,7,0,0,0,268,263,1,0,0,0,268,265,1,0,0,0,268,267,1,0,
|
||||
0,0,269,82,1,0,0,0,270,272,7,1,0,0,271,270,1,0,0,0,272,273,1,0,0,
|
||||
0,273,271,1,0,0,0,273,274,1,0,0,0,274,281,1,0,0,0,275,277,5,46,0,
|
||||
0,276,278,7,1,0,0,277,276,1,0,0,0,278,279,1,0,0,0,279,277,1,0,0,
|
||||
0,279,280,1,0,0,0,280,282,1,0,0,0,281,275,1,0,0,0,281,282,1,0,0,
|
||||
0,282,84,1,0,0,0,283,287,7,2,0,0,284,286,7,3,0,0,285,284,1,0,0,0,
|
||||
286,289,1,0,0,0,287,285,1,0,0,0,287,288,1,0,0,0,288,86,1,0,0,0,289,
|
||||
287,1,0,0,0,290,292,7,4,0,0,291,290,1,0,0,0,292,293,1,0,0,0,293,
|
||||
291,1,0,0,0,293,294,1,0,0,0,294,295,1,0,0,0,295,296,6,43,0,0,296,
|
||||
88,1,0,0,0,7,0,268,273,279,281,287,293,1,6,0,0
|
||||
39,7,39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,
|
||||
45,1,0,1,0,1,1,1,1,1,2,1,2,1,3,1,3,1,3,1,3,1,4,1,4,1,4,1,4,1,5,1,
|
||||
5,1,5,1,5,1,6,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,
|
||||
8,1,8,1,9,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,10,1,11,1,11,
|
||||
1,11,1,11,1,11,1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,
|
||||
1,13,1,14,1,14,1,14,1,14,1,14,1,14,1,15,1,15,1,15,1,15,1,15,1,15,
|
||||
1,16,1,16,1,16,1,16,1,17,1,17,1,17,1,17,1,17,1,18,1,18,1,18,1,19,
|
||||
1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,22,
|
||||
1,22,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24,
|
||||
1,24,1,25,1,25,1,25,1,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,
|
||||
1,27,1,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,29,1,29,
|
||||
1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,30,1,30,1,30,1,31,1,31,1,31,
|
||||
1,31,1,32,1,32,1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,33,1,33,1,34,
|
||||
1,34,1,34,1,34,1,35,1,35,1,35,1,35,1,35,1,36,1,36,1,37,1,37,1,38,
|
||||
1,38,1,39,1,39,1,40,1,40,1,41,1,41,1,42,1,42,1,42,1,42,1,42,3,42,
|
||||
282,8,42,1,43,4,43,285,8,43,11,43,12,43,286,1,43,1,43,4,43,291,8,
|
||||
43,11,43,12,43,292,3,43,295,8,43,1,44,1,44,5,44,299,8,44,10,44,12,
|
||||
44,302,9,44,1,45,4,45,305,8,45,11,45,12,45,306,1,45,1,45,0,0,46,
|
||||
1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,
|
||||
27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,
|
||||
49,25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,
|
||||
71,36,73,37,75,38,77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,46,
|
||||
1,0,5,2,0,69,69,101,101,1,0,48,57,3,0,65,90,95,95,97,122,4,0,48,
|
||||
57,65,90,95,95,97,122,3,0,9,10,13,13,32,32,316,0,1,1,0,0,0,0,3,1,
|
||||
0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,
|
||||
0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,
|
||||
0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,
|
||||
0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,
|
||||
0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,
|
||||
0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,
|
||||
0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,
|
||||
0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,
|
||||
0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,1,93,1,0,
|
||||
0,0,3,95,1,0,0,0,5,97,1,0,0,0,7,99,1,0,0,0,9,103,1,0,0,0,11,107,
|
||||
1,0,0,0,13,111,1,0,0,0,15,116,1,0,0,0,17,121,1,0,0,0,19,126,1,0,
|
||||
0,0,21,132,1,0,0,0,23,137,1,0,0,0,25,142,1,0,0,0,27,147,1,0,0,0,
|
||||
29,153,1,0,0,0,31,159,1,0,0,0,33,165,1,0,0,0,35,169,1,0,0,0,37,174,
|
||||
1,0,0,0,39,177,1,0,0,0,41,181,1,0,0,0,43,185,1,0,0,0,45,190,1,0,
|
||||
0,0,47,195,1,0,0,0,49,200,1,0,0,0,51,205,1,0,0,0,53,211,1,0,0,0,
|
||||
55,217,1,0,0,0,57,223,1,0,0,0,59,228,1,0,0,0,61,234,1,0,0,0,63,240,
|
||||
1,0,0,0,65,244,1,0,0,0,67,249,1,0,0,0,69,255,1,0,0,0,71,259,1,0,
|
||||
0,0,73,264,1,0,0,0,75,266,1,0,0,0,77,268,1,0,0,0,79,270,1,0,0,0,
|
||||
81,272,1,0,0,0,83,274,1,0,0,0,85,281,1,0,0,0,87,284,1,0,0,0,89,296,
|
||||
1,0,0,0,91,304,1,0,0,0,93,94,5,40,0,0,94,2,1,0,0,0,95,96,5,41,0,
|
||||
0,96,4,1,0,0,0,97,98,5,44,0,0,98,6,1,0,0,0,99,100,5,115,0,0,100,
|
||||
101,5,105,0,0,101,102,5,110,0,0,102,8,1,0,0,0,103,104,5,99,0,0,104,
|
||||
105,5,111,0,0,105,106,5,115,0,0,106,10,1,0,0,0,107,108,5,116,0,0,
|
||||
108,109,5,97,0,0,109,110,5,110,0,0,110,12,1,0,0,0,111,112,5,97,0,
|
||||
0,112,113,5,115,0,0,113,114,5,105,0,0,114,115,5,110,0,0,115,14,1,
|
||||
0,0,0,116,117,5,97,0,0,117,118,5,99,0,0,118,119,5,111,0,0,119,120,
|
||||
5,115,0,0,120,16,1,0,0,0,121,122,5,97,0,0,122,123,5,116,0,0,123,
|
||||
124,5,97,0,0,124,125,5,110,0,0,125,18,1,0,0,0,126,127,5,97,0,0,127,
|
||||
128,5,116,0,0,128,129,5,97,0,0,129,130,5,110,0,0,130,131,5,50,0,
|
||||
0,131,20,1,0,0,0,132,133,5,115,0,0,133,134,5,105,0,0,134,135,5,110,
|
||||
0,0,135,136,5,104,0,0,136,22,1,0,0,0,137,138,5,99,0,0,138,139,5,
|
||||
111,0,0,139,140,5,115,0,0,140,141,5,104,0,0,141,24,1,0,0,0,142,143,
|
||||
5,116,0,0,143,144,5,97,0,0,144,145,5,110,0,0,145,146,5,104,0,0,146,
|
||||
26,1,0,0,0,147,148,5,97,0,0,148,149,5,115,0,0,149,150,5,105,0,0,
|
||||
150,151,5,110,0,0,151,152,5,104,0,0,152,28,1,0,0,0,153,154,5,97,
|
||||
0,0,154,155,5,99,0,0,155,156,5,111,0,0,156,157,5,115,0,0,157,158,
|
||||
5,104,0,0,158,30,1,0,0,0,159,160,5,97,0,0,160,161,5,116,0,0,161,
|
||||
162,5,97,0,0,162,163,5,110,0,0,163,164,5,104,0,0,164,32,1,0,0,0,
|
||||
165,166,5,97,0,0,166,167,5,98,0,0,167,168,5,115,0,0,168,34,1,0,0,
|
||||
0,169,170,5,115,0,0,170,171,5,113,0,0,171,172,5,114,0,0,172,173,
|
||||
5,116,0,0,173,36,1,0,0,0,174,175,5,108,0,0,175,176,5,110,0,0,176,
|
||||
38,1,0,0,0,177,178,5,108,0,0,178,179,5,111,0,0,179,180,5,103,0,0,
|
||||
180,40,1,0,0,0,181,182,5,101,0,0,182,183,5,120,0,0,183,184,5,112,
|
||||
0,0,184,42,1,0,0,0,185,186,5,115,0,0,186,187,5,109,0,0,187,188,5,
|
||||
105,0,0,188,189,5,110,0,0,189,44,1,0,0,0,190,191,5,115,0,0,191,192,
|
||||
5,109,0,0,192,193,5,97,0,0,193,194,5,120,0,0,194,46,1,0,0,0,195,
|
||||
196,5,116,0,0,196,197,5,109,0,0,197,198,5,105,0,0,198,199,5,110,
|
||||
0,0,199,48,1,0,0,0,200,201,5,116,0,0,201,202,5,109,0,0,202,203,5,
|
||||
97,0,0,203,204,5,120,0,0,204,50,1,0,0,0,205,206,5,116,0,0,206,207,
|
||||
5,110,0,0,207,208,5,111,0,0,208,209,5,114,0,0,209,210,5,109,0,0,
|
||||
210,52,1,0,0,0,211,212,5,115,0,0,212,213,5,110,0,0,213,214,5,111,
|
||||
0,0,214,215,5,114,0,0,215,216,5,109,0,0,216,54,1,0,0,0,217,218,5,
|
||||
102,0,0,218,219,5,108,0,0,219,220,5,111,0,0,220,221,5,111,0,0,221,
|
||||
222,5,114,0,0,222,56,1,0,0,0,223,224,5,99,0,0,224,225,5,101,0,0,
|
||||
225,226,5,105,0,0,226,227,5,108,0,0,227,58,1,0,0,0,228,229,5,114,
|
||||
0,0,229,230,5,111,0,0,230,231,5,117,0,0,231,232,5,110,0,0,232,233,
|
||||
5,100,0,0,233,60,1,0,0,0,234,235,5,103,0,0,235,236,5,97,0,0,236,
|
||||
237,5,109,0,0,237,238,5,109,0,0,238,239,5,97,0,0,239,62,1,0,0,0,
|
||||
240,241,5,112,0,0,241,242,5,111,0,0,242,243,5,119,0,0,243,64,1,0,
|
||||
0,0,244,245,5,115,0,0,245,246,5,105,0,0,246,247,5,103,0,0,247,248,
|
||||
5,109,0,0,248,66,1,0,0,0,249,250,5,99,0,0,250,251,5,108,0,0,251,
|
||||
252,5,97,0,0,252,253,5,109,0,0,253,254,5,112,0,0,254,68,1,0,0,0,
|
||||
255,256,5,102,0,0,256,257,5,102,0,0,257,258,5,116,0,0,258,70,1,0,
|
||||
0,0,259,260,5,105,0,0,260,261,5,102,0,0,261,262,5,102,0,0,262,263,
|
||||
5,116,0,0,263,72,1,0,0,0,264,265,5,43,0,0,265,74,1,0,0,0,266,267,
|
||||
5,45,0,0,267,76,1,0,0,0,268,269,5,42,0,0,269,78,1,0,0,0,270,271,
|
||||
5,47,0,0,271,80,1,0,0,0,272,273,5,37,0,0,273,82,1,0,0,0,274,275,
|
||||
5,94,0,0,275,84,1,0,0,0,276,277,5,112,0,0,277,282,5,105,0,0,278,
|
||||
279,5,80,0,0,279,282,5,73,0,0,280,282,7,0,0,0,281,276,1,0,0,0,281,
|
||||
278,1,0,0,0,281,280,1,0,0,0,282,86,1,0,0,0,283,285,7,1,0,0,284,283,
|
||||
1,0,0,0,285,286,1,0,0,0,286,284,1,0,0,0,286,287,1,0,0,0,287,294,
|
||||
1,0,0,0,288,290,5,46,0,0,289,291,7,1,0,0,290,289,1,0,0,0,291,292,
|
||||
1,0,0,0,292,290,1,0,0,0,292,293,1,0,0,0,293,295,1,0,0,0,294,288,
|
||||
1,0,0,0,294,295,1,0,0,0,295,88,1,0,0,0,296,300,7,2,0,0,297,299,7,
|
||||
3,0,0,298,297,1,0,0,0,299,302,1,0,0,0,300,298,1,0,0,0,300,301,1,
|
||||
0,0,0,301,90,1,0,0,0,302,300,1,0,0,0,303,305,7,4,0,0,304,303,1,0,
|
||||
0,0,305,306,1,0,0,0,306,304,1,0,0,0,306,307,1,0,0,0,307,308,1,0,
|
||||
0,0,308,309,6,45,0,0,309,92,1,0,0,0,7,0,281,286,292,294,300,306,
|
||||
1,6,0,0
|
||||
]
|
||||
|
||||
class MathExprLexer(Lexer):
|
||||
@@ -156,16 +161,18 @@ class MathExprLexer(Lexer):
|
||||
POWE = 32
|
||||
SIGM = 33
|
||||
CLAMP = 34
|
||||
PLUS = 35
|
||||
MINUS = 36
|
||||
MULT = 37
|
||||
DIV = 38
|
||||
MOD = 39
|
||||
POW = 40
|
||||
CONSTANT = 41
|
||||
NUMBER = 42
|
||||
VARIABLE = 43
|
||||
WS = 44
|
||||
SFFT = 35
|
||||
SIFFT = 36
|
||||
PLUS = 37
|
||||
MINUS = 38
|
||||
MULT = 39
|
||||
DIV = 40
|
||||
MOD = 41
|
||||
POW = 42
|
||||
CONSTANT = 43
|
||||
NUMBER = 44
|
||||
VARIABLE = 45
|
||||
WS = 46
|
||||
|
||||
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
|
||||
|
||||
@@ -177,23 +184,24 @@ class MathExprLexer(Lexer):
|
||||
"'acosh'", "'atanh'", "'abs'", "'sqrt'", "'ln'", "'log'", "'exp'",
|
||||
"'smin'", "'smax'", "'tmin'", "'tmax'", "'tnorm'", "'snorm'",
|
||||
"'floor'", "'ceil'", "'round'", "'gamma'", "'pow'", "'sigm'",
|
||||
"'clamp'", "'+'", "'-'", "'*'", "'/'", "'%'", "'^'" ]
|
||||
"'clamp'", "'fft'", "'ifft'", "'+'", "'-'", "'*'", "'/'", "'%'",
|
||||
"'^'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>",
|
||||
"SIN", "COS", "TAN", "ASIN", "ACOS", "ATAN", "ATAN2", "SINH",
|
||||
"COSH", "TANH", "ASINH", "ACOSH", "ATANH", "ABS", "SQRT", "LN",
|
||||
"LOG", "EXP", "SMIN", "SMAX", "TMIN", "TMAX", "TNORM", "SNORM",
|
||||
"FLOOR", "CEIL", "ROUND", "GAMMA", "POWE", "SIGM", "CLAMP",
|
||||
"PLUS", "MINUS", "MULT", "DIV", "MOD", "POW", "CONSTANT", "NUMBER",
|
||||
"VARIABLE", "WS" ]
|
||||
"SFFT", "SIFFT", "PLUS", "MINUS", "MULT", "DIV", "MOD", "POW",
|
||||
"CONSTANT", "NUMBER", "VARIABLE", "WS" ]
|
||||
|
||||
ruleNames = [ "T__0", "T__1", "T__2", "SIN", "COS", "TAN", "ASIN", "ACOS",
|
||||
"ATAN", "ATAN2", "SINH", "COSH", "TANH", "ASINH", "ACOSH",
|
||||
"ATANH", "ABS", "SQRT", "LN", "LOG", "EXP", "SMIN", "SMAX",
|
||||
"TMIN", "TMAX", "TNORM", "SNORM", "FLOOR", "CEIL", "ROUND",
|
||||
"GAMMA", "POWE", "SIGM", "CLAMP", "PLUS", "MINUS", "MULT",
|
||||
"DIV", "MOD", "POW", "CONSTANT", "NUMBER", "VARIABLE",
|
||||
"WS" ]
|
||||
"GAMMA", "POWE", "SIGM", "CLAMP", "SFFT", "SIFFT", "PLUS",
|
||||
"MINUS", "MULT", "DIV", "MOD", "POW", "CONSTANT", "NUMBER",
|
||||
"VARIABLE", "WS" ]
|
||||
|
||||
grammarFileName = "MathExpr.g4"
|
||||
|
||||
|
||||
@@ -32,16 +32,18 @@ GAMMA=31
|
||||
POWE=32
|
||||
SIGM=33
|
||||
CLAMP=34
|
||||
PLUS=35
|
||||
MINUS=36
|
||||
MULT=37
|
||||
DIV=38
|
||||
MOD=39
|
||||
POW=40
|
||||
CONSTANT=41
|
||||
NUMBER=42
|
||||
VARIABLE=43
|
||||
WS=44
|
||||
SFFT=35
|
||||
SIFFT=36
|
||||
PLUS=37
|
||||
MINUS=38
|
||||
MULT=39
|
||||
DIV=40
|
||||
MOD=41
|
||||
POW=42
|
||||
CONSTANT=43
|
||||
NUMBER=44
|
||||
VARIABLE=45
|
||||
WS=46
|
||||
'('=1
|
||||
')'=2
|
||||
','=3
|
||||
@@ -76,9 +78,11 @@ WS=44
|
||||
'pow'=32
|
||||
'sigm'=33
|
||||
'clamp'=34
|
||||
'+'=35
|
||||
'-'=36
|
||||
'*'=37
|
||||
'/'=38
|
||||
'%'=39
|
||||
'^'=40
|
||||
'fft'=35
|
||||
'ifft'=36
|
||||
'+'=37
|
||||
'-'=38
|
||||
'*'=39
|
||||
'/'=40
|
||||
'%'=41
|
||||
'^'=42
|
||||
|
||||
@@ -413,6 +413,24 @@ class MathExprListener(ParseTreeListener):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by MathExprParser#sfftFunc.
|
||||
def enterSfftFunc(self, ctx:MathExprParser.SfftFuncContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by MathExprParser#sfftFunc.
|
||||
def exitSfftFunc(self, ctx:MathExprParser.SfftFuncContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by MathExprParser#sifftFunc.
|
||||
def enterSifftFunc(self, ctx:MathExprParser.SifftFuncContext):
|
||||
pass
|
||||
|
||||
# Exit a parse tree produced by MathExprParser#sifftFunc.
|
||||
def exitSifftFunc(self, ctx:MathExprParser.SifftFuncContext):
|
||||
pass
|
||||
|
||||
|
||||
# Enter a parse tree produced by MathExprParser#PowFunc.
|
||||
def enterPowFunc(self, ctx:MathExprParser.PowFuncContext):
|
||||
pass
|
||||
|
||||
@@ -10,7 +10,7 @@ else:
|
||||
|
||||
def serializedATN():
|
||||
return [
|
||||
4,1,44,268,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
|
||||
4,1,46,278,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
|
||||
6,2,7,7,7,2,8,7,8,2,9,7,9,1,0,1,0,3,0,23,8,0,1,1,1,1,1,1,1,1,1,1,
|
||||
1,1,1,1,1,1,1,1,5,1,34,8,1,10,1,12,1,37,9,1,1,2,1,2,1,2,1,2,1,2,
|
||||
1,2,1,2,1,2,1,2,1,2,1,2,1,2,5,2,51,8,2,10,2,12,2,54,9,2,1,3,1,3,
|
||||
@@ -23,85 +23,88 @@ def serializedATN():
|
||||
1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,
|
||||
1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,
|
||||
1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,
|
||||
1,6,1,6,1,6,3,6,203,8,6,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,
|
||||
1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,3,6,213,8,6,
|
||||
1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,
|
||||
1,7,1,7,3,7,233,8,7,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,9,1,9,
|
||||
1,9,1,9,1,9,4,9,249,8,9,11,9,12,9,250,1,9,1,9,1,9,1,9,1,9,1,9,1,
|
||||
9,4,9,260,8,9,11,9,12,9,261,1,9,1,9,3,9,266,8,9,1,9,0,2,2,4,10,0,
|
||||
2,4,6,8,10,12,14,16,18,0,0,302,0,22,1,0,0,0,2,24,1,0,0,0,4,38,1,
|
||||
0,0,0,6,60,1,0,0,0,8,67,1,0,0,0,10,80,1,0,0,0,12,202,1,0,0,0,14,
|
||||
232,1,0,0,0,16,234,1,0,0,0,18,265,1,0,0,0,20,23,3,10,5,0,21,23,3,
|
||||
2,1,0,22,20,1,0,0,0,22,21,1,0,0,0,23,1,1,0,0,0,24,25,6,1,-1,0,25,
|
||||
26,3,4,2,0,26,35,1,0,0,0,27,28,10,3,0,0,28,29,5,35,0,0,29,34,3,4,
|
||||
2,0,30,31,10,2,0,0,31,32,5,36,0,0,32,34,3,4,2,0,33,27,1,0,0,0,33,
|
||||
30,1,0,0,0,34,37,1,0,0,0,35,33,1,0,0,0,35,36,1,0,0,0,36,3,1,0,0,
|
||||
0,37,35,1,0,0,0,38,39,6,2,-1,0,39,40,3,6,3,0,40,52,1,0,0,0,41,42,
|
||||
10,4,0,0,42,43,5,37,0,0,43,51,3,6,3,0,44,45,10,3,0,0,45,46,5,38,
|
||||
0,0,46,51,3,6,3,0,47,48,10,2,0,0,48,49,5,39,0,0,49,51,3,6,3,0,50,
|
||||
41,1,0,0,0,50,44,1,0,0,0,50,47,1,0,0,0,51,54,1,0,0,0,52,50,1,0,0,
|
||||
0,52,53,1,0,0,0,53,5,1,0,0,0,54,52,1,0,0,0,55,56,3,8,4,0,56,57,5,
|
||||
40,0,0,57,58,3,6,3,0,58,61,1,0,0,0,59,61,3,8,4,0,60,55,1,0,0,0,60,
|
||||
59,1,0,0,0,61,7,1,0,0,0,62,63,5,35,0,0,63,68,3,8,4,0,64,65,5,36,
|
||||
0,0,65,68,3,8,4,0,66,68,3,10,5,0,67,62,1,0,0,0,67,64,1,0,0,0,67,
|
||||
66,1,0,0,0,68,9,1,0,0,0,69,81,3,12,6,0,70,81,3,14,7,0,71,81,3,16,
|
||||
8,0,72,81,3,18,9,0,73,81,5,43,0,0,74,81,5,42,0,0,75,81,5,41,0,0,
|
||||
76,77,5,1,0,0,77,78,3,0,0,0,78,79,5,2,0,0,79,81,1,0,0,0,80,69,1,
|
||||
0,0,0,80,70,1,0,0,0,80,71,1,0,0,0,80,72,1,0,0,0,80,73,1,0,0,0,80,
|
||||
74,1,0,0,0,80,75,1,0,0,0,80,76,1,0,0,0,81,11,1,0,0,0,82,83,5,4,0,
|
||||
0,83,84,5,1,0,0,84,85,3,0,0,0,85,86,5,2,0,0,86,203,1,0,0,0,87,88,
|
||||
5,5,0,0,88,89,5,1,0,0,89,90,3,0,0,0,90,91,5,2,0,0,91,203,1,0,0,0,
|
||||
92,93,5,6,0,0,93,94,5,1,0,0,94,95,3,0,0,0,95,96,5,2,0,0,96,203,1,
|
||||
0,0,0,97,98,5,7,0,0,98,99,5,1,0,0,99,100,3,0,0,0,100,101,5,2,0,0,
|
||||
101,203,1,0,0,0,102,103,5,8,0,0,103,104,5,1,0,0,104,105,3,0,0,0,
|
||||
105,106,5,2,0,0,106,203,1,0,0,0,107,108,5,9,0,0,108,109,5,1,0,0,
|
||||
109,110,3,0,0,0,110,111,5,2,0,0,111,203,1,0,0,0,112,113,5,11,0,0,
|
||||
113,114,5,1,0,0,114,115,3,0,0,0,115,116,5,2,0,0,116,203,1,0,0,0,
|
||||
117,118,5,12,0,0,118,119,5,1,0,0,119,120,3,0,0,0,120,121,5,2,0,0,
|
||||
121,203,1,0,0,0,122,123,5,13,0,0,123,124,5,1,0,0,124,125,3,0,0,0,
|
||||
125,126,5,2,0,0,126,203,1,0,0,0,127,128,5,14,0,0,128,129,5,1,0,0,
|
||||
129,130,3,0,0,0,130,131,5,2,0,0,131,203,1,0,0,0,132,133,5,15,0,0,
|
||||
133,134,5,1,0,0,134,135,3,0,0,0,135,136,5,2,0,0,136,203,1,0,0,0,
|
||||
137,138,5,16,0,0,138,139,5,1,0,0,139,140,3,0,0,0,140,141,5,2,0,0,
|
||||
141,203,1,0,0,0,142,143,5,17,0,0,143,144,5,1,0,0,144,145,3,0,0,0,
|
||||
145,146,5,2,0,0,146,203,1,0,0,0,147,148,5,18,0,0,148,149,5,1,0,0,
|
||||
149,150,3,0,0,0,150,151,5,2,0,0,151,203,1,0,0,0,152,153,5,19,0,0,
|
||||
153,154,5,1,0,0,154,155,3,0,0,0,155,156,5,2,0,0,156,203,1,0,0,0,
|
||||
157,158,5,20,0,0,158,159,5,1,0,0,159,160,3,0,0,0,160,161,5,2,0,0,
|
||||
161,203,1,0,0,0,162,163,5,21,0,0,163,164,5,1,0,0,164,165,3,0,0,0,
|
||||
165,166,5,2,0,0,166,203,1,0,0,0,167,168,5,26,0,0,168,169,5,1,0,0,
|
||||
169,170,3,0,0,0,170,171,5,2,0,0,171,203,1,0,0,0,172,173,5,27,0,0,
|
||||
173,174,5,1,0,0,174,175,3,0,0,0,175,176,5,2,0,0,176,203,1,0,0,0,
|
||||
177,178,5,28,0,0,178,179,5,1,0,0,179,180,3,0,0,0,180,181,5,2,0,0,
|
||||
181,203,1,0,0,0,182,183,5,29,0,0,183,184,5,1,0,0,184,185,3,0,0,0,
|
||||
185,186,5,2,0,0,186,203,1,0,0,0,187,188,5,30,0,0,188,189,5,1,0,0,
|
||||
189,190,3,0,0,0,190,191,5,2,0,0,191,203,1,0,0,0,192,193,5,31,0,0,
|
||||
193,194,5,1,0,0,194,195,3,0,0,0,195,196,5,2,0,0,196,203,1,0,0,0,
|
||||
197,198,5,33,0,0,198,199,5,1,0,0,199,200,3,0,0,0,200,201,5,2,0,0,
|
||||
201,203,1,0,0,0,202,82,1,0,0,0,202,87,1,0,0,0,202,92,1,0,0,0,202,
|
||||
97,1,0,0,0,202,102,1,0,0,0,202,107,1,0,0,0,202,112,1,0,0,0,202,117,
|
||||
1,0,0,0,202,122,1,0,0,0,202,127,1,0,0,0,202,132,1,0,0,0,202,137,
|
||||
1,0,0,0,202,142,1,0,0,0,202,147,1,0,0,0,202,152,1,0,0,0,202,157,
|
||||
1,0,0,0,202,162,1,0,0,0,202,167,1,0,0,0,202,172,1,0,0,0,202,177,
|
||||
1,0,0,0,202,182,1,0,0,0,202,187,1,0,0,0,202,192,1,0,0,0,202,197,
|
||||
1,0,0,0,203,13,1,0,0,0,204,205,5,32,0,0,205,206,5,1,0,0,206,207,
|
||||
3,0,0,0,207,208,5,3,0,0,208,209,3,0,0,0,209,210,5,2,0,0,210,233,
|
||||
1,0,0,0,211,212,5,10,0,0,212,213,5,1,0,0,213,214,3,0,0,0,214,215,
|
||||
5,3,0,0,215,216,3,0,0,0,216,217,5,2,0,0,217,233,1,0,0,0,218,219,
|
||||
5,24,0,0,219,220,5,1,0,0,220,221,3,0,0,0,221,222,5,3,0,0,222,223,
|
||||
3,0,0,0,223,224,5,2,0,0,224,233,1,0,0,0,225,226,5,25,0,0,226,227,
|
||||
5,1,0,0,227,228,3,0,0,0,228,229,5,3,0,0,229,230,3,0,0,0,230,231,
|
||||
5,2,0,0,231,233,1,0,0,0,232,204,1,0,0,0,232,211,1,0,0,0,232,218,
|
||||
1,0,0,0,232,225,1,0,0,0,233,15,1,0,0,0,234,235,5,34,0,0,235,236,
|
||||
5,1,0,0,236,237,3,0,0,0,237,238,5,3,0,0,238,239,3,0,0,0,239,240,
|
||||
5,3,0,0,240,241,3,0,0,0,241,242,5,2,0,0,242,17,1,0,0,0,243,244,5,
|
||||
22,0,0,244,245,5,1,0,0,245,248,3,0,0,0,246,247,5,3,0,0,247,249,3,
|
||||
0,0,0,248,246,1,0,0,0,249,250,1,0,0,0,250,248,1,0,0,0,250,251,1,
|
||||
0,0,0,251,252,1,0,0,0,252,253,5,2,0,0,253,266,1,0,0,0,254,255,5,
|
||||
23,0,0,255,256,5,1,0,0,256,259,3,0,0,0,257,258,5,3,0,0,258,260,3,
|
||||
0,0,0,259,257,1,0,0,0,260,261,1,0,0,0,261,259,1,0,0,0,261,262,1,
|
||||
0,0,0,262,263,1,0,0,0,263,264,5,2,0,0,264,266,1,0,0,0,265,243,1,
|
||||
0,0,0,265,254,1,0,0,0,266,19,1,0,0,0,13,22,33,35,50,52,60,67,80,
|
||||
202,232,250,261,265
|
||||
1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,1,7,3,7,243,8,7,1,8,
|
||||
1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,9,1,9,4,9,259,8,9,
|
||||
11,9,12,9,260,1,9,1,9,1,9,1,9,1,9,1,9,1,9,4,9,270,8,9,11,9,12,9,
|
||||
271,1,9,1,9,3,9,276,8,9,1,9,0,2,2,4,10,0,2,4,6,8,10,12,14,16,18,
|
||||
0,0,314,0,22,1,0,0,0,2,24,1,0,0,0,4,38,1,0,0,0,6,60,1,0,0,0,8,67,
|
||||
1,0,0,0,10,80,1,0,0,0,12,212,1,0,0,0,14,242,1,0,0,0,16,244,1,0,0,
|
||||
0,18,275,1,0,0,0,20,23,3,10,5,0,21,23,3,2,1,0,22,20,1,0,0,0,22,21,
|
||||
1,0,0,0,23,1,1,0,0,0,24,25,6,1,-1,0,25,26,3,4,2,0,26,35,1,0,0,0,
|
||||
27,28,10,3,0,0,28,29,5,37,0,0,29,34,3,4,2,0,30,31,10,2,0,0,31,32,
|
||||
5,38,0,0,32,34,3,4,2,0,33,27,1,0,0,0,33,30,1,0,0,0,34,37,1,0,0,0,
|
||||
35,33,1,0,0,0,35,36,1,0,0,0,36,3,1,0,0,0,37,35,1,0,0,0,38,39,6,2,
|
||||
-1,0,39,40,3,6,3,0,40,52,1,0,0,0,41,42,10,4,0,0,42,43,5,39,0,0,43,
|
||||
51,3,6,3,0,44,45,10,3,0,0,45,46,5,40,0,0,46,51,3,6,3,0,47,48,10,
|
||||
2,0,0,48,49,5,41,0,0,49,51,3,6,3,0,50,41,1,0,0,0,50,44,1,0,0,0,50,
|
||||
47,1,0,0,0,51,54,1,0,0,0,52,50,1,0,0,0,52,53,1,0,0,0,53,5,1,0,0,
|
||||
0,54,52,1,0,0,0,55,56,3,8,4,0,56,57,5,42,0,0,57,58,3,6,3,0,58,61,
|
||||
1,0,0,0,59,61,3,8,4,0,60,55,1,0,0,0,60,59,1,0,0,0,61,7,1,0,0,0,62,
|
||||
63,5,37,0,0,63,68,3,8,4,0,64,65,5,38,0,0,65,68,3,8,4,0,66,68,3,10,
|
||||
5,0,67,62,1,0,0,0,67,64,1,0,0,0,67,66,1,0,0,0,68,9,1,0,0,0,69,81,
|
||||
3,12,6,0,70,81,3,14,7,0,71,81,3,16,8,0,72,81,3,18,9,0,73,81,5,45,
|
||||
0,0,74,81,5,44,0,0,75,81,5,43,0,0,76,77,5,1,0,0,77,78,3,0,0,0,78,
|
||||
79,5,2,0,0,79,81,1,0,0,0,80,69,1,0,0,0,80,70,1,0,0,0,80,71,1,0,0,
|
||||
0,80,72,1,0,0,0,80,73,1,0,0,0,80,74,1,0,0,0,80,75,1,0,0,0,80,76,
|
||||
1,0,0,0,81,11,1,0,0,0,82,83,5,4,0,0,83,84,5,1,0,0,84,85,3,0,0,0,
|
||||
85,86,5,2,0,0,86,213,1,0,0,0,87,88,5,5,0,0,88,89,5,1,0,0,89,90,3,
|
||||
0,0,0,90,91,5,2,0,0,91,213,1,0,0,0,92,93,5,6,0,0,93,94,5,1,0,0,94,
|
||||
95,3,0,0,0,95,96,5,2,0,0,96,213,1,0,0,0,97,98,5,7,0,0,98,99,5,1,
|
||||
0,0,99,100,3,0,0,0,100,101,5,2,0,0,101,213,1,0,0,0,102,103,5,8,0,
|
||||
0,103,104,5,1,0,0,104,105,3,0,0,0,105,106,5,2,0,0,106,213,1,0,0,
|
||||
0,107,108,5,9,0,0,108,109,5,1,0,0,109,110,3,0,0,0,110,111,5,2,0,
|
||||
0,111,213,1,0,0,0,112,113,5,11,0,0,113,114,5,1,0,0,114,115,3,0,0,
|
||||
0,115,116,5,2,0,0,116,213,1,0,0,0,117,118,5,12,0,0,118,119,5,1,0,
|
||||
0,119,120,3,0,0,0,120,121,5,2,0,0,121,213,1,0,0,0,122,123,5,13,0,
|
||||
0,123,124,5,1,0,0,124,125,3,0,0,0,125,126,5,2,0,0,126,213,1,0,0,
|
||||
0,127,128,5,14,0,0,128,129,5,1,0,0,129,130,3,0,0,0,130,131,5,2,0,
|
||||
0,131,213,1,0,0,0,132,133,5,15,0,0,133,134,5,1,0,0,134,135,3,0,0,
|
||||
0,135,136,5,2,0,0,136,213,1,0,0,0,137,138,5,16,0,0,138,139,5,1,0,
|
||||
0,139,140,3,0,0,0,140,141,5,2,0,0,141,213,1,0,0,0,142,143,5,17,0,
|
||||
0,143,144,5,1,0,0,144,145,3,0,0,0,145,146,5,2,0,0,146,213,1,0,0,
|
||||
0,147,148,5,18,0,0,148,149,5,1,0,0,149,150,3,0,0,0,150,151,5,2,0,
|
||||
0,151,213,1,0,0,0,152,153,5,19,0,0,153,154,5,1,0,0,154,155,3,0,0,
|
||||
0,155,156,5,2,0,0,156,213,1,0,0,0,157,158,5,20,0,0,158,159,5,1,0,
|
||||
0,159,160,3,0,0,0,160,161,5,2,0,0,161,213,1,0,0,0,162,163,5,21,0,
|
||||
0,163,164,5,1,0,0,164,165,3,0,0,0,165,166,5,2,0,0,166,213,1,0,0,
|
||||
0,167,168,5,26,0,0,168,169,5,1,0,0,169,170,3,0,0,0,170,171,5,2,0,
|
||||
0,171,213,1,0,0,0,172,173,5,27,0,0,173,174,5,1,0,0,174,175,3,0,0,
|
||||
0,175,176,5,2,0,0,176,213,1,0,0,0,177,178,5,28,0,0,178,179,5,1,0,
|
||||
0,179,180,3,0,0,0,180,181,5,2,0,0,181,213,1,0,0,0,182,183,5,29,0,
|
||||
0,183,184,5,1,0,0,184,185,3,0,0,0,185,186,5,2,0,0,186,213,1,0,0,
|
||||
0,187,188,5,30,0,0,188,189,5,1,0,0,189,190,3,0,0,0,190,191,5,2,0,
|
||||
0,191,213,1,0,0,0,192,193,5,31,0,0,193,194,5,1,0,0,194,195,3,0,0,
|
||||
0,195,196,5,2,0,0,196,213,1,0,0,0,197,198,5,33,0,0,198,199,5,1,0,
|
||||
0,199,200,3,0,0,0,200,201,5,2,0,0,201,213,1,0,0,0,202,203,5,35,0,
|
||||
0,203,204,5,1,0,0,204,205,3,0,0,0,205,206,5,2,0,0,206,213,1,0,0,
|
||||
0,207,208,5,36,0,0,208,209,5,1,0,0,209,210,3,0,0,0,210,211,5,2,0,
|
||||
0,211,213,1,0,0,0,212,82,1,0,0,0,212,87,1,0,0,0,212,92,1,0,0,0,212,
|
||||
97,1,0,0,0,212,102,1,0,0,0,212,107,1,0,0,0,212,112,1,0,0,0,212,117,
|
||||
1,0,0,0,212,122,1,0,0,0,212,127,1,0,0,0,212,132,1,0,0,0,212,137,
|
||||
1,0,0,0,212,142,1,0,0,0,212,147,1,0,0,0,212,152,1,0,0,0,212,157,
|
||||
1,0,0,0,212,162,1,0,0,0,212,167,1,0,0,0,212,172,1,0,0,0,212,177,
|
||||
1,0,0,0,212,182,1,0,0,0,212,187,1,0,0,0,212,192,1,0,0,0,212,197,
|
||||
1,0,0,0,212,202,1,0,0,0,212,207,1,0,0,0,213,13,1,0,0,0,214,215,5,
|
||||
32,0,0,215,216,5,1,0,0,216,217,3,0,0,0,217,218,5,3,0,0,218,219,3,
|
||||
0,0,0,219,220,5,2,0,0,220,243,1,0,0,0,221,222,5,10,0,0,222,223,5,
|
||||
1,0,0,223,224,3,0,0,0,224,225,5,3,0,0,225,226,3,0,0,0,226,227,5,
|
||||
2,0,0,227,243,1,0,0,0,228,229,5,24,0,0,229,230,5,1,0,0,230,231,3,
|
||||
0,0,0,231,232,5,3,0,0,232,233,3,0,0,0,233,234,5,2,0,0,234,243,1,
|
||||
0,0,0,235,236,5,25,0,0,236,237,5,1,0,0,237,238,3,0,0,0,238,239,5,
|
||||
3,0,0,239,240,3,0,0,0,240,241,5,2,0,0,241,243,1,0,0,0,242,214,1,
|
||||
0,0,0,242,221,1,0,0,0,242,228,1,0,0,0,242,235,1,0,0,0,243,15,1,0,
|
||||
0,0,244,245,5,34,0,0,245,246,5,1,0,0,246,247,3,0,0,0,247,248,5,3,
|
||||
0,0,248,249,3,0,0,0,249,250,5,3,0,0,250,251,3,0,0,0,251,252,5,2,
|
||||
0,0,252,17,1,0,0,0,253,254,5,22,0,0,254,255,5,1,0,0,255,258,3,0,
|
||||
0,0,256,257,5,3,0,0,257,259,3,0,0,0,258,256,1,0,0,0,259,260,1,0,
|
||||
0,0,260,258,1,0,0,0,260,261,1,0,0,0,261,262,1,0,0,0,262,263,5,2,
|
||||
0,0,263,276,1,0,0,0,264,265,5,23,0,0,265,266,5,1,0,0,266,269,3,0,
|
||||
0,0,267,268,5,3,0,0,268,270,3,0,0,0,269,267,1,0,0,0,270,271,1,0,
|
||||
0,0,271,269,1,0,0,0,271,272,1,0,0,0,272,273,1,0,0,0,273,274,5,2,
|
||||
0,0,274,276,1,0,0,0,275,253,1,0,0,0,275,264,1,0,0,0,276,19,1,0,0,
|
||||
0,13,22,33,35,50,52,60,67,80,212,242,260,271,275
|
||||
]
|
||||
|
||||
class MathExprParser ( Parser ):
|
||||
@@ -120,17 +123,17 @@ class MathExprParser ( Parser ):
|
||||
"'abs'", "'sqrt'", "'ln'", "'log'", "'exp'", "'smin'",
|
||||
"'smax'", "'tmin'", "'tmax'", "'tnorm'", "'snorm'",
|
||||
"'floor'", "'ceil'", "'round'", "'gamma'", "'pow'",
|
||||
"'sigm'", "'clamp'", "'+'", "'-'", "'*'", "'/'", "'%'",
|
||||
"'^'" ]
|
||||
"'sigm'", "'clamp'", "'fft'", "'ifft'", "'+'", "'-'",
|
||||
"'*'", "'/'", "'%'", "'^'" ]
|
||||
|
||||
symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||||
"SIN", "COS", "TAN", "ASIN", "ACOS", "ATAN", "ATAN2",
|
||||
"SINH", "COSH", "TANH", "ASINH", "ACOSH", "ATANH",
|
||||
"ABS", "SQRT", "LN", "LOG", "EXP", "SMIN", "SMAX",
|
||||
"TMIN", "TMAX", "TNORM", "SNORM", "FLOOR", "CEIL",
|
||||
"ROUND", "GAMMA", "POWE", "SIGM", "CLAMP", "PLUS",
|
||||
"MINUS", "MULT", "DIV", "MOD", "POW", "CONSTANT",
|
||||
"NUMBER", "VARIABLE", "WS" ]
|
||||
"ROUND", "GAMMA", "POWE", "SIGM", "CLAMP", "SFFT",
|
||||
"SIFFT", "PLUS", "MINUS", "MULT", "DIV", "MOD", "POW",
|
||||
"CONSTANT", "NUMBER", "VARIABLE", "WS" ]
|
||||
|
||||
RULE_expr = 0
|
||||
RULE_addExpr = 1
|
||||
@@ -181,16 +184,18 @@ class MathExprParser ( Parser ):
|
||||
POWE=32
|
||||
SIGM=33
|
||||
CLAMP=34
|
||||
PLUS=35
|
||||
MINUS=36
|
||||
MULT=37
|
||||
DIV=38
|
||||
MOD=39
|
||||
POW=40
|
||||
CONSTANT=41
|
||||
NUMBER=42
|
||||
VARIABLE=43
|
||||
WS=44
|
||||
SFFT=35
|
||||
SIFFT=36
|
||||
PLUS=37
|
||||
MINUS=38
|
||||
MULT=39
|
||||
DIV=40
|
||||
MOD=41
|
||||
POW=42
|
||||
CONSTANT=43
|
||||
NUMBER=44
|
||||
VARIABLE=45
|
||||
WS=46
|
||||
|
||||
def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
|
||||
super().__init__(input, output)
|
||||
@@ -861,7 +866,7 @@ class MathExprParser ( Parser ):
|
||||
self.state = 67
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [35]:
|
||||
if token in [37]:
|
||||
localctx = MathExprParser.UnaryPlusContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 62
|
||||
@@ -869,7 +874,7 @@ class MathExprParser ( Parser ):
|
||||
self.state = 63
|
||||
self.unaryExpr()
|
||||
pass
|
||||
elif token in [36]:
|
||||
elif token in [38]:
|
||||
localctx = MathExprParser.UnaryMinusContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 2)
|
||||
self.state = 64
|
||||
@@ -877,7 +882,7 @@ class MathExprParser ( Parser ):
|
||||
self.state = 65
|
||||
self.unaryExpr()
|
||||
pass
|
||||
elif token in [1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 41, 42, 43]:
|
||||
elif token in [1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 43, 44, 45]:
|
||||
localctx = MathExprParser.ToAtomContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 3)
|
||||
self.state = 66
|
||||
@@ -1118,7 +1123,7 @@ class MathExprParser ( Parser ):
|
||||
self.state = 80
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 26, 27, 28, 29, 30, 31, 33]:
|
||||
if token in [4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 26, 27, 28, 29, 30, 31, 33, 35, 36]:
|
||||
localctx = MathExprParser.Func1ExpContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 69
|
||||
@@ -1142,19 +1147,19 @@ class MathExprParser ( Parser ):
|
||||
self.state = 72
|
||||
self.funcN()
|
||||
pass
|
||||
elif token in [43]:
|
||||
elif token in [45]:
|
||||
localctx = MathExprParser.VariableExpContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 5)
|
||||
self.state = 73
|
||||
self.match(MathExprParser.VARIABLE)
|
||||
pass
|
||||
elif token in [42]:
|
||||
elif token in [44]:
|
||||
localctx = MathExprParser.NumberExpContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 6)
|
||||
self.state = 74
|
||||
self.match(MathExprParser.NUMBER)
|
||||
pass
|
||||
elif token in [41]:
|
||||
elif token in [43]:
|
||||
localctx = MathExprParser.ConstantExpContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 7)
|
||||
self.state = 75
|
||||
@@ -1199,33 +1204,6 @@ class MathExprParser ( Parser ):
|
||||
|
||||
|
||||
|
||||
class TanFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def TAN(self):
|
||||
return self.getToken(MathExprParser.TAN, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterTanFunc" ):
|
||||
listener.enterTanFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitTanFunc" ):
|
||||
listener.exitTanFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitTanFunc" ):
|
||||
return visitor.visitTanFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class TanhFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
@@ -1280,60 +1258,6 @@ class MathExprParser ( Parser ):
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class GammaFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def GAMMA(self):
|
||||
return self.getToken(MathExprParser.GAMMA, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterGammaFunc" ):
|
||||
listener.enterGammaFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitGammaFunc" ):
|
||||
listener.exitGammaFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitGammaFunc" ):
|
||||
return visitor.visitGammaFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class CosFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def COS(self):
|
||||
return self.getToken(MathExprParser.COS, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterCosFunc" ):
|
||||
listener.enterCosFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitCosFunc" ):
|
||||
listener.exitCosFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitCosFunc" ):
|
||||
return visitor.visitCosFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class SqrtFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
@@ -1442,60 +1366,6 @@ class MathExprParser ( Parser ):
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class AsinFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def ASIN(self):
|
||||
return self.getToken(MathExprParser.ASIN, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterAsinFunc" ):
|
||||
listener.enterAsinFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitAsinFunc" ):
|
||||
listener.exitAsinFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitAsinFunc" ):
|
||||
return visitor.visitAsinFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class AsinhFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def ASINH(self):
|
||||
return self.getToken(MathExprParser.ASINH, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterAsinhFunc" ):
|
||||
listener.enterAsinhFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitAsinhFunc" ):
|
||||
listener.exitAsinhFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitAsinhFunc" ):
|
||||
return visitor.visitAsinhFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class AbsFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
@@ -1631,33 +1501,6 @@ class MathExprParser ( Parser ):
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class AtanhFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def ATANH(self):
|
||||
return self.getToken(MathExprParser.ATANH, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterAtanhFunc" ):
|
||||
listener.enterAtanhFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitAtanhFunc" ):
|
||||
listener.exitAtanhFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitAtanhFunc" ):
|
||||
return visitor.visitAtanhFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class LnFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
@@ -1766,33 +1609,6 @@ class MathExprParser ( Parser ):
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class ExpFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def EXP(self):
|
||||
return self.getToken(MathExprParser.EXP, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterExpFunc" ):
|
||||
listener.enterExpFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitExpFunc" ):
|
||||
listener.exitExpFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitExpFunc" ):
|
||||
return visitor.visitExpFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class AcosFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
@@ -1847,13 +1663,256 @@ class MathExprParser ( Parser ):
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class TanFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def TAN(self):
|
||||
return self.getToken(MathExprParser.TAN, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterTanFunc" ):
|
||||
listener.enterTanFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitTanFunc" ):
|
||||
listener.exitTanFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitTanFunc" ):
|
||||
return visitor.visitTanFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class SifftFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def SIFFT(self):
|
||||
return self.getToken(MathExprParser.SIFFT, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterSifftFunc" ):
|
||||
listener.enterSifftFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitSifftFunc" ):
|
||||
listener.exitSifftFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitSifftFunc" ):
|
||||
return visitor.visitSifftFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class GammaFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def GAMMA(self):
|
||||
return self.getToken(MathExprParser.GAMMA, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterGammaFunc" ):
|
||||
listener.enterGammaFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitGammaFunc" ):
|
||||
listener.exitGammaFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitGammaFunc" ):
|
||||
return visitor.visitGammaFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class CosFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def COS(self):
|
||||
return self.getToken(MathExprParser.COS, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterCosFunc" ):
|
||||
listener.enterCosFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitCosFunc" ):
|
||||
listener.exitCosFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitCosFunc" ):
|
||||
return visitor.visitCosFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class AsinFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def ASIN(self):
|
||||
return self.getToken(MathExprParser.ASIN, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterAsinFunc" ):
|
||||
listener.enterAsinFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitAsinFunc" ):
|
||||
listener.exitAsinFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitAsinFunc" ):
|
||||
return visitor.visitAsinFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class AsinhFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def ASINH(self):
|
||||
return self.getToken(MathExprParser.ASINH, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterAsinhFunc" ):
|
||||
listener.enterAsinhFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitAsinhFunc" ):
|
||||
listener.exitAsinhFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitAsinhFunc" ):
|
||||
return visitor.visitAsinhFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class SfftFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def SFFT(self):
|
||||
return self.getToken(MathExprParser.SFFT, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterSfftFunc" ):
|
||||
listener.enterSfftFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitSfftFunc" ):
|
||||
listener.exitSfftFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitSfftFunc" ):
|
||||
return visitor.visitSfftFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class AtanhFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def ATANH(self):
|
||||
return self.getToken(MathExprParser.ATANH, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterAtanhFunc" ):
|
||||
listener.enterAtanhFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitAtanhFunc" ):
|
||||
listener.exitAtanhFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitAtanhFunc" ):
|
||||
return visitor.visitAtanhFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
class ExpFuncContext(Func1Context):
|
||||
|
||||
def __init__(self, parser, ctx:ParserRuleContext): # actually a MathExprParser.Func1Context
|
||||
super().__init__(parser)
|
||||
self.copyFrom(ctx)
|
||||
|
||||
def EXP(self):
|
||||
return self.getToken(MathExprParser.EXP, 0)
|
||||
def expr(self):
|
||||
return self.getTypedRuleContext(MathExprParser.ExprContext,0)
|
||||
|
||||
|
||||
def enterRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "enterExpFunc" ):
|
||||
listener.enterExpFunc(self)
|
||||
|
||||
def exitRule(self, listener:ParseTreeListener):
|
||||
if hasattr( listener, "exitExpFunc" ):
|
||||
listener.exitExpFunc(self)
|
||||
|
||||
def accept(self, visitor:ParseTreeVisitor):
|
||||
if hasattr( visitor, "visitExpFunc" ):
|
||||
return visitor.visitExpFunc(self)
|
||||
else:
|
||||
return visitor.visitChildren(self)
|
||||
|
||||
|
||||
|
||||
def func1(self):
|
||||
|
||||
localctx = MathExprParser.Func1Context(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 12, self.RULE_func1)
|
||||
try:
|
||||
self.state = 202
|
||||
self.state = 212
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [4]:
|
||||
@@ -2144,6 +2203,30 @@ class MathExprParser ( Parser ):
|
||||
self.state = 200
|
||||
self.match(MathExprParser.T__1)
|
||||
pass
|
||||
elif token in [35]:
|
||||
localctx = MathExprParser.SfftFuncContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 25)
|
||||
self.state = 202
|
||||
self.match(MathExprParser.SFFT)
|
||||
self.state = 203
|
||||
self.match(MathExprParser.T__0)
|
||||
self.state = 204
|
||||
self.expr()
|
||||
self.state = 205
|
||||
self.match(MathExprParser.T__1)
|
||||
pass
|
||||
elif token in [36]:
|
||||
localctx = MathExprParser.SifftFuncContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 26)
|
||||
self.state = 207
|
||||
self.match(MathExprParser.SIFFT)
|
||||
self.state = 208
|
||||
self.match(MathExprParser.T__0)
|
||||
self.state = 209
|
||||
self.expr()
|
||||
self.state = 210
|
||||
self.match(MathExprParser.T__1)
|
||||
pass
|
||||
else:
|
||||
raise NoViableAltException(self)
|
||||
|
||||
@@ -2299,71 +2382,71 @@ class MathExprParser ( Parser ):
|
||||
localctx = MathExprParser.Func2Context(self, self._ctx, self.state)
|
||||
self.enterRule(localctx, 14, self.RULE_func2)
|
||||
try:
|
||||
self.state = 232
|
||||
self.state = 242
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [32]:
|
||||
localctx = MathExprParser.PowFuncContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 204
|
||||
self.state = 214
|
||||
self.match(MathExprParser.POWE)
|
||||
self.state = 205
|
||||
self.state = 215
|
||||
self.match(MathExprParser.T__0)
|
||||
self.state = 206
|
||||
self.state = 216
|
||||
self.expr()
|
||||
self.state = 207
|
||||
self.state = 217
|
||||
self.match(MathExprParser.T__2)
|
||||
self.state = 208
|
||||
self.state = 218
|
||||
self.expr()
|
||||
self.state = 209
|
||||
self.state = 219
|
||||
self.match(MathExprParser.T__1)
|
||||
pass
|
||||
elif token in [10]:
|
||||
localctx = MathExprParser.Atan2FuncContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 2)
|
||||
self.state = 211
|
||||
self.state = 221
|
||||
self.match(MathExprParser.ATAN2)
|
||||
self.state = 212
|
||||
self.state = 222
|
||||
self.match(MathExprParser.T__0)
|
||||
self.state = 213
|
||||
self.state = 223
|
||||
self.expr()
|
||||
self.state = 214
|
||||
self.state = 224
|
||||
self.match(MathExprParser.T__2)
|
||||
self.state = 215
|
||||
self.state = 225
|
||||
self.expr()
|
||||
self.state = 216
|
||||
self.state = 226
|
||||
self.match(MathExprParser.T__1)
|
||||
pass
|
||||
elif token in [24]:
|
||||
localctx = MathExprParser.TMinFuncContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 3)
|
||||
self.state = 218
|
||||
self.state = 228
|
||||
self.match(MathExprParser.TMIN)
|
||||
self.state = 219
|
||||
self.state = 229
|
||||
self.match(MathExprParser.T__0)
|
||||
self.state = 220
|
||||
self.state = 230
|
||||
self.expr()
|
||||
self.state = 221
|
||||
self.state = 231
|
||||
self.match(MathExprParser.T__2)
|
||||
self.state = 222
|
||||
self.state = 232
|
||||
self.expr()
|
||||
self.state = 223
|
||||
self.state = 233
|
||||
self.match(MathExprParser.T__1)
|
||||
pass
|
||||
elif token in [25]:
|
||||
localctx = MathExprParser.TMaxFuncContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 4)
|
||||
self.state = 225
|
||||
self.state = 235
|
||||
self.match(MathExprParser.TMAX)
|
||||
self.state = 226
|
||||
self.state = 236
|
||||
self.match(MathExprParser.T__0)
|
||||
self.state = 227
|
||||
self.state = 237
|
||||
self.expr()
|
||||
self.state = 228
|
||||
self.state = 238
|
||||
self.match(MathExprParser.T__2)
|
||||
self.state = 229
|
||||
self.state = 239
|
||||
self.expr()
|
||||
self.state = 230
|
||||
self.state = 240
|
||||
self.match(MathExprParser.T__1)
|
||||
pass
|
||||
else:
|
||||
@@ -2433,21 +2516,21 @@ class MathExprParser ( Parser ):
|
||||
try:
|
||||
localctx = MathExprParser.ClampFuncContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 234
|
||||
self.state = 244
|
||||
self.match(MathExprParser.CLAMP)
|
||||
self.state = 235
|
||||
self.state = 245
|
||||
self.match(MathExprParser.T__0)
|
||||
self.state = 236
|
||||
self.state = 246
|
||||
self.expr()
|
||||
self.state = 237
|
||||
self.state = 247
|
||||
self.match(MathExprParser.T__2)
|
||||
self.state = 238
|
||||
self.state = 248
|
||||
self.expr()
|
||||
self.state = 239
|
||||
self.state = 249
|
||||
self.match(MathExprParser.T__2)
|
||||
self.state = 240
|
||||
self.state = 250
|
||||
self.expr()
|
||||
self.state = 241
|
||||
self.state = 251
|
||||
self.match(MathExprParser.T__1)
|
||||
except RecognitionException as re:
|
||||
localctx.exception = re
|
||||
@@ -2542,59 +2625,59 @@ class MathExprParser ( Parser ):
|
||||
self.enterRule(localctx, 18, self.RULE_funcN)
|
||||
self._la = 0 # Token type
|
||||
try:
|
||||
self.state = 265
|
||||
self.state = 275
|
||||
self._errHandler.sync(self)
|
||||
token = self._input.LA(1)
|
||||
if token in [22]:
|
||||
localctx = MathExprParser.SMinFuncContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 1)
|
||||
self.state = 243
|
||||
self.state = 253
|
||||
self.match(MathExprParser.SMIN)
|
||||
self.state = 244
|
||||
self.state = 254
|
||||
self.match(MathExprParser.T__0)
|
||||
self.state = 245
|
||||
self.state = 255
|
||||
self.expr()
|
||||
self.state = 248
|
||||
self.state = 258
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while True:
|
||||
self.state = 246
|
||||
self.state = 256
|
||||
self.match(MathExprParser.T__2)
|
||||
self.state = 247
|
||||
self.state = 257
|
||||
self.expr()
|
||||
self.state = 250
|
||||
self.state = 260
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if not (_la==3):
|
||||
break
|
||||
|
||||
self.state = 252
|
||||
self.state = 262
|
||||
self.match(MathExprParser.T__1)
|
||||
pass
|
||||
elif token in [23]:
|
||||
localctx = MathExprParser.SMaxFuncContext(self, localctx)
|
||||
self.enterOuterAlt(localctx, 2)
|
||||
self.state = 254
|
||||
self.state = 264
|
||||
self.match(MathExprParser.SMAX)
|
||||
self.state = 255
|
||||
self.state = 265
|
||||
self.match(MathExprParser.T__0)
|
||||
self.state = 256
|
||||
self.state = 266
|
||||
self.expr()
|
||||
self.state = 259
|
||||
self.state = 269
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
while True:
|
||||
self.state = 257
|
||||
self.state = 267
|
||||
self.match(MathExprParser.T__2)
|
||||
self.state = 258
|
||||
self.state = 268
|
||||
self.expr()
|
||||
self.state = 261
|
||||
self.state = 271
|
||||
self._errHandler.sync(self)
|
||||
_la = self._input.LA(1)
|
||||
if not (_la==3):
|
||||
break
|
||||
|
||||
self.state = 263
|
||||
self.state = 273
|
||||
self.match(MathExprParser.T__1)
|
||||
pass
|
||||
else:
|
||||
|
||||
@@ -234,6 +234,16 @@ class MathExprVisitor(ParseTreeVisitor):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by MathExprParser#sfftFunc.
|
||||
def visitSfftFunc(self, ctx:MathExprParser.SfftFuncContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by MathExprParser#sifftFunc.
|
||||
def visitSifftFunc(self, ctx:MathExprParser.SifftFuncContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
|
||||
# Visit a parse tree produced by MathExprParser#PowFunc.
|
||||
def visitPowFunc(self, ctx:MathExprParser.PowFuncContext):
|
||||
return self.visitChildren(ctx)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from tkinter import SE
|
||||
import torch
|
||||
import torch.special
|
||||
|
||||
from ..helper_functions import freq_to_time, time_to_freq
|
||||
from .MathExprVisitor import MathExprVisitor
|
||||
|
||||
class TensorEvalVisitor(MathExprVisitor):
|
||||
@@ -111,6 +113,37 @@ class TensorEvalVisitor(MathExprVisitor):
|
||||
def visitGammaFunc(self, ctx): return torch.special.gamma(self.visit(ctx.expr())).exp()
|
||||
def visitSigmoidFunc(self, ctx): return torch.sigmoid(self.visit(ctx.expr()))
|
||||
def visitClampFunc(self, ctx): return torch.clamp(self.visit(ctx.expr(0)), self.visit(ctx.expr(1)), self.visit(ctx.expr(2)))
|
||||
def visitSfftFunc(self, ctx):
|
||||
s = self.shape
|
||||
|
||||
hop_length = 256
|
||||
n_fft = 512
|
||||
if len(s) < 4:
|
||||
raise ValueError("Input tensor must have at least 4 dimensions for SFFT operation. You might be forgetting to to use inverse function (ifft) before leaving node.")
|
||||
self.shape=(s[0],
|
||||
s[1],
|
||||
s[3] * hop_length)
|
||||
|
||||
val = self.visit(ctx.expr());
|
||||
self.shape = s;
|
||||
return time_to_freq(val, n_fft, hop_length)
|
||||
def visitSifftFunc(self, ctx):
|
||||
s = self.shape
|
||||
|
||||
hop_length = 256
|
||||
n_fft = 512
|
||||
|
||||
|
||||
self.shape = (s[0],
|
||||
s[1],
|
||||
n_fft // 2 + 1, # Frequency bins
|
||||
s[2]//hop_length+1)
|
||||
|
||||
val = self.visit(ctx.expr())
|
||||
return freq_to_time(val, n_fft, hop_length)
|
||||
self.shape = s;
|
||||
|
||||
|
||||
|
||||
# Two-argument functions
|
||||
def visitPowFunc(self, ctx):
|
||||
|
||||
@@ -13,3 +13,75 @@ def getIndexTensorAlongDim(tensor, dim):
|
||||
|
||||
# Broadcast to full shape
|
||||
return values.expand(*shape)
|
||||
|
||||
def time_to_freq(audio_dict: torch.Tensor, n_fft: int = 512, hop_length: int = 256) -> torch.Tensor:
|
||||
waveform = audio_dict
|
||||
|
||||
# Ensure the waveform is 3D with shape [batch, channels, time]
|
||||
if waveform.ndimension() != 3:
|
||||
raise ValueError(f"Expected 3D tensor, got {waveform.ndimension()}D tensor")
|
||||
|
||||
# Create Hann window
|
||||
window = torch.hann_window(n_fft, device=waveform.device)
|
||||
|
||||
# Initialize the output spectrogram
|
||||
spectrogram = torch.zeros(
|
||||
waveform.shape[0],
|
||||
waveform.shape[1],
|
||||
n_fft // 2 + 1, # Frequency bins
|
||||
waveform.shape[2]//hop_length+1, # Time steps
|
||||
dtype=torch.complex64,
|
||||
device=waveform.device
|
||||
)
|
||||
|
||||
# Compute STFT on the last dimension for each value
|
||||
for b in range(waveform.shape[0]):
|
||||
for c in range(waveform.shape[1]):
|
||||
stft_result = torch.stft(
|
||||
waveform[b, c],
|
||||
n_fft=n_fft,
|
||||
hop_length=hop_length,
|
||||
win_length=n_fft,
|
||||
window=window,
|
||||
center=True,
|
||||
return_complex=True
|
||||
)
|
||||
spectrogram[b, c] = stft_result
|
||||
|
||||
return spectrogram
|
||||
|
||||
def freq_to_time(freq_dict: torch.Tensor, n_fft: int = 512, hop_length: int = 256) -> torch.Tensor:
|
||||
spectrogram = freq_dict
|
||||
|
||||
# Ensure the spectrogram is 3D with shape [batch, channels, freq, time]
|
||||
if spectrogram.ndimension() != 4:
|
||||
raise ValueError(f"Expected 4D tensor, got {spectrogram.ndimension()}D tensor")
|
||||
|
||||
# Initialize the output waveform
|
||||
waveform = torch.zeros(
|
||||
spectrogram.shape[0],
|
||||
spectrogram.shape[1],
|
||||
spectrogram.shape[3] * hop_length, # Total time samples
|
||||
dtype=torch.float32,
|
||||
device=spectrogram.device
|
||||
)
|
||||
|
||||
# Create Hann window
|
||||
window = torch.hann_window(n_fft, device=spectrogram.device)
|
||||
|
||||
# Compute iSTFT on the last dimension for each value
|
||||
for b in range(spectrogram.shape[0]):
|
||||
for c in range(spectrogram.shape[1]):
|
||||
istft_result = torch.istft(
|
||||
spectrogram[b, c],
|
||||
n_fft=n_fft,
|
||||
hop_length=hop_length,
|
||||
win_length=n_fft,
|
||||
window=window,
|
||||
center=True,
|
||||
normalized=False,
|
||||
length=spectrogram.shape[3] * hop_length
|
||||
)
|
||||
waveform[b, c] = istft_result
|
||||
|
||||
return waveform
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import torch
|
||||
|
||||
from .NoiseMathNode import NoiseMathNode
|
||||
from .FloatMathNode import FloatMathNode
|
||||
from .ConditioningMathNode import ConditioningMathNode
|
||||
from .LatentMathNode import LatentMathNode
|
||||
from .ImageMathNode import ImageMathNode
|
||||
from .AudioMathNode import AudioMathNode
|
||||
|
||||
class IntToFloatNode:
|
||||
"""
|
||||
@@ -51,6 +53,7 @@ NODE_CLASS_MAPPINGS = {
|
||||
"mrmth_NoiseMathNode": NoiseMathNode,
|
||||
"mrmth_IntToFloat": IntToFloatNode,
|
||||
"mrmth_FloatToInt": FloatToIntNode,
|
||||
"mrmth_AudioMathNode": AudioMathNode,
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
@@ -59,6 +62,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"mrmth_ImageMathNode": "Image math",
|
||||
"mrmth_FloatMathNode": "Float math",
|
||||
"mrmth_NoiseMathNode": "Noise math",
|
||||
"mrmth_AudioMathNode": "Audio math",
|
||||
"mrmth_IntToFloat": "Int → Float",
|
||||
"mrmth_FloatToInt": "Float → Int",
|
||||
"Tensor": "Tensor expression",
|
||||
|
||||
Reference in New Issue
Block a user