28
28
#include <lualib.h>
29
29
#include <ctype.h>
30
30
31
+ #include "fftdata.h"
32
+
31
33
extern bool parse_note (const char * noteStr , s32 * note , s32 * octave );
32
34
33
35
static inline s32 getLuaNumber (lua_State * lua , s32 index )
@@ -1542,6 +1544,23 @@ static s32 lua_fft(lua_State* lua)
1542
1544
end_freq = getLuaNumber (lua , 2 );
1543
1545
}
1544
1546
1547
+ if (end_freq == -1 )
1548
+ {
1549
+ if (start_freq < 0 || start_freq >= FFT_SIZE )
1550
+ {
1551
+ luaL_error (lua , "invalid params, start_freq out of bounds (max 1024)\n" );
1552
+ return 0 ;
1553
+ }
1554
+ }
1555
+ else
1556
+ {
1557
+ if (start_freq < 0 || end_freq >= FFT_SIZE || start_freq > end_freq )
1558
+ {
1559
+ luaL_error (lua , "invalid params, range out of bounds from (min 0, max 1024)\n" );
1560
+ return 0 ;
1561
+ }
1562
+ }
1563
+
1545
1564
lua_pushnumber (lua , core -> api .fft (tic , start_freq , end_freq ));
1546
1565
return 1 ;
1547
1566
}
@@ -1568,6 +1587,23 @@ static s32 lua_ffts(lua_State* lua)
1568
1587
end_freq = getLuaNumber (lua , 2 );
1569
1588
}
1570
1589
1590
+ if (end_freq == -1 )
1591
+ {
1592
+ if (start_freq < 0 || start_freq >= FFT_SIZE )
1593
+ {
1594
+ luaL_error (lua , "invalid params, start_freq out of bounds (max 1024)\n" );
1595
+ return 0 ;
1596
+ }
1597
+ }
1598
+ else
1599
+ {
1600
+ if (start_freq < 0 || end_freq >= FFT_SIZE || start_freq > end_freq )
1601
+ {
1602
+ luaL_error (lua , "invalid params, range out of bounds from (min 0, max 1024)\n" );
1603
+ return 0 ;
1604
+ }
1605
+ }
1606
+
1571
1607
lua_pushnumber (lua , core -> api .ffts (tic , start_freq , end_freq ));
1572
1608
return 1 ;
1573
1609
}
0 commit comments