this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fftr, vqtr

alice 0e30c2bb e34bc5f2

+624 -5
+58
src/api.h
··· 852 852 1, \ 853 853 0, \ 854 854 double, \ 855 + tic_mem*, s32 bin) \ 856 + \ 857 + \ 858 + macro(fftr, \ 859 + "fftr(startFreq,[endFreq])", \ 860 + \ 861 + "Get raw (non-normalized) Fast Fourier Transform magnitude for frequency range.\n" \ 862 + "Reads one or averages many FFT values.\n" \ 863 + "If endFreq is not given it returns a single value.\n" \ 864 + "Returns raw magnitude without peak normalization.", \ 865 + 1, \ 866 + 2, \ 867 + 0, \ 868 + double, \ 869 + tic_mem*, s32 startFreq, s32 endFreq) \ 870 + \ 871 + \ 872 + macro(fftrs, \ 873 + "fftrs(startFreq,[endFreq])", \ 874 + \ 875 + "Get raw smoothed Fast Fourier Transform magnitude for frequency range.\n" \ 876 + "Reads one or averages many FFT values.\n" \ 877 + "If endFreq is not given it returns a single value.\n" \ 878 + "Returns raw smoothed magnitude without peak normalization.", \ 879 + 1, \ 880 + 2, \ 881 + 0, \ 882 + double, \ 883 + tic_mem*, s32 startFreq, s32 endFreq) \ 884 + \ 885 + \ 886 + macro(vqtr, \ 887 + "vqtr(bin)", \ 888 + \ 889 + "Get raw (non-normalized) Variable-Q Transform magnitude for a specific frequency bin.\n" \ 890 + "VQT provides 120 bins (0-119) with logarithmic frequency spacing for musical analysis.\n" \ 891 + "Each bin corresponds to a musical note: bin = octave * 12 + note\n" \ 892 + "where octave is 0-9 and note is 0-11 (C=0, C#=1, D=2, ..., B=11).\n" \ 893 + "Returns raw magnitude without peak normalization.", \ 894 + 1, \ 895 + 1, \ 896 + 0, \ 897 + double, \ 898 + tic_mem*, s32 bin) \ 899 + \ 900 + \ 901 + macro(vqtrs, \ 902 + "vqtrs(bin)", \ 903 + \ 904 + "Get raw smoothed Variable-Q Transform magnitude for a specific frequency bin.\n" \ 905 + "VQT provides 120 bins (0-119) with logarithmic frequency spacing for musical analysis.\n" \ 906 + "Each bin corresponds to a musical note: bin = octave * 12 + note\n" \ 907 + "where octave is 0-9 and note is 0-11 (C=0, C#=1, D=2, ..., B=11).\n" \ 908 + "Returns raw smoothed magnitude without peak normalization.", \ 909 + 1, \ 910 + 1, \ 911 + 0, \ 912 + double, \ 855 913 tic_mem*, s32 bin) 856 914 857 915 #define TIC_API_DEF(name, _, __, ___, ____, _____, ret, ...) ret tic_api_##name(__VA_ARGS__);
+50
src/api/janet.c
··· 83 83 static Janet janet_ffts(int32_t argc, Janet* argv); 84 84 static Janet janet_vqt(int32_t argc, Janet* argv); 85 85 static Janet janet_vqts(int32_t argc, Janet* argv); 86 + static Janet janet_fftr(int32_t argc, Janet* argv); 87 + static Janet janet_fftrs(int32_t argc, Janet* argv); 88 + static Janet janet_vqtr(int32_t argc, Janet* argv); 89 + static Janet janet_vqtrs(int32_t argc, Janet* argv); 86 90 87 91 static void closeJanet(tic_mem* tic); 88 92 static bool initJanet(tic_mem* tic, const char* code); ··· 150 154 {"ffts", janet_ffts, NULL}, 151 155 {"vqt", janet_vqt, NULL}, 152 156 {"vqts", janet_vqts, NULL}, 157 + {"fftr", janet_fftr, NULL}, 158 + {"fftrs", janet_fftrs, NULL}, 159 + {"vqtr", janet_vqtr, NULL}, 160 + {"vqtrs", janet_vqtrs, NULL}, 153 161 {NULL, NULL, NULL} 154 162 }; 155 163 ··· 1106 1114 1107 1115 tic_core* core = getJanetMachine(); tic_mem* tic = (tic_mem*)core; 1108 1116 return janet_wrap_number(core->api.vqts(tic, bin)); 1117 + } 1118 + 1119 + static Janet janet_fftr(int32_t argc, Janet* argv) 1120 + { 1121 + janet_arity(argc, 1, 2); 1122 + 1123 + s32 start_freq = janet_getinteger(argv, 0); 1124 + s32 end_freq = argc >= 2 ? janet_getinteger(argv, 1) : -1; 1125 + 1126 + tic_core* core = getJanetMachine(); tic_mem* tic = (tic_mem*)core; 1127 + return janet_wrap_number(core->api.fftr(tic, start_freq, end_freq)); 1128 + } 1129 + 1130 + static Janet janet_fftrs(int32_t argc, Janet* argv) 1131 + { 1132 + janet_arity(argc, 1, 2); 1133 + 1134 + s32 start_freq = janet_getinteger(argv, 0); 1135 + s32 end_freq = argc >= 2 ? janet_getinteger(argv, 1) : -1; 1136 + 1137 + tic_core* core = getJanetMachine(); tic_mem* tic = (tic_mem*)core; 1138 + return janet_wrap_number(core->api.fftrs(tic, start_freq, end_freq)); 1139 + } 1140 + 1141 + static Janet janet_vqtr(int32_t argc, Janet* argv) 1142 + { 1143 + janet_fixarity(argc, 1); 1144 + 1145 + s32 bin = janet_getinteger(argv, 0); 1146 + 1147 + tic_core* core = getJanetMachine(); tic_mem* tic = (tic_mem*)core; 1148 + return janet_wrap_number(core->api.vqtr(tic, bin)); 1149 + } 1150 + 1151 + static Janet janet_vqtrs(int32_t argc, Janet* argv) 1152 + { 1153 + janet_fixarity(argc, 1); 1154 + 1155 + s32 bin = janet_getinteger(argv, 0); 1156 + 1157 + tic_core* core = getJanetMachine(); tic_mem* tic = (tic_mem*)core; 1158 + return janet_wrap_number(core->api.vqtrs(tic, bin)); 1109 1159 } 1110 1160 1111 1161 /* ***************** */
+34
src/api/js.c
··· 1048 1048 return JS_NewFloat64(ctx, core->api.vqts(tic, bin)); 1049 1049 } 1050 1050 1051 + static JSValue js_fftr(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueConst *argv) 1052 + { 1053 + tic_core* core = getCore(ctx); tic_mem* tic = (tic_mem*)core; 1054 + s32 startFreq = getInteger(ctx, argv[0]); 1055 + s32 endFreq = argc >= 2 ? getInteger(ctx, argv[1]) : -1; 1056 + 1057 + return JS_NewFloat64(ctx, core->api.fftr(tic, startFreq, endFreq)); 1058 + } 1059 + 1060 + static JSValue js_fftrs(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueConst *argv) 1061 + { 1062 + tic_core* core = getCore(ctx); tic_mem* tic = (tic_mem*)core; 1063 + s32 startFreq = getInteger(ctx, argv[0]); 1064 + s32 endFreq = argc >= 2 ? getInteger(ctx, argv[1]) : -1; 1065 + 1066 + return JS_NewFloat64(ctx, core->api.fftrs(tic, startFreq, endFreq)); 1067 + } 1068 + 1069 + static JSValue js_vqtr(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueConst *argv) 1070 + { 1071 + tic_core* core = getCore(ctx); tic_mem* tic = (tic_mem*)core; 1072 + s32 bin = getInteger(ctx, argv[0]); 1073 + 1074 + return JS_NewFloat64(ctx, core->api.vqtr(tic, bin)); 1075 + } 1076 + 1077 + static JSValue js_vqtrs(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueConst *argv) 1078 + { 1079 + tic_core* core = getCore(ctx); tic_mem* tic = (tic_mem*)core; 1080 + s32 bin = getInteger(ctx, argv[0]); 1081 + 1082 + return JS_NewFloat64(ctx, core->api.vqtrs(tic, bin)); 1083 + } 1084 + 1051 1085 static bool initJavascript(tic_mem* tic, const char* code) 1052 1086 { 1053 1087 closeJavascript(tic);
+76 -3
src/api/luaapi.c
··· 21 21 // SOFTWARE. 22 22 23 23 #include "core/core.h" 24 - #include "ext/vqt.h" 25 24 26 25 #include <stdlib.h> 27 26 #include <lua.h> ··· 1606 1605 { 1607 1606 s32 bin = getLuaNumber(lua, 1); 1608 1607 1609 - lua_pushnumber(lua, tic_api_vqt(tic, bin)); 1608 + lua_pushnumber(lua, core->api.vqt(tic, bin)); 1610 1609 return 1; 1611 1610 } 1612 1611 ··· 1624 1623 { 1625 1624 s32 bin = getLuaNumber(lua, 1); 1626 1625 1627 - lua_pushnumber(lua, tic_api_vqts(tic, bin)); 1626 + lua_pushnumber(lua, core->api.vqts(tic, bin)); 1628 1627 return 1; 1629 1628 } 1630 1629 1631 1630 luaL_error(lua, "invalid params, vqts(bin)\n"); 1631 + return 0; 1632 + } 1633 + 1634 + static s32 lua_fftr(lua_State* lua) 1635 + { 1636 + tic_core* core = getLuaCore(lua); 1637 + tic_mem* tic = (tic_mem*)core; 1638 + s32 top = lua_gettop(lua); 1639 + 1640 + if (top >= 1) 1641 + { 1642 + s32 startFreq = getLuaNumber(lua, 1); 1643 + s32 endFreq = top >= 2 ? getLuaNumber(lua, 2) : -1; 1644 + 1645 + lua_pushnumber(lua, core->api.fftr(tic, startFreq, endFreq)); 1646 + return 1; 1647 + } 1648 + 1649 + luaL_error(lua, "invalid params, fftr(startFreq [, endFreq])\n"); 1650 + return 0; 1651 + } 1652 + 1653 + static s32 lua_fftrs(lua_State* lua) 1654 + { 1655 + tic_core* core = getLuaCore(lua); 1656 + tic_mem* tic = (tic_mem*)core; 1657 + s32 top = lua_gettop(lua); 1658 + 1659 + if (top >= 1) 1660 + { 1661 + s32 startFreq = getLuaNumber(lua, 1); 1662 + s32 endFreq = top >= 2 ? getLuaNumber(lua, 2) : -1; 1663 + 1664 + lua_pushnumber(lua, core->api.fftrs(tic, startFreq, endFreq)); 1665 + return 1; 1666 + } 1667 + 1668 + luaL_error(lua, "invalid params, fftrs(startFreq [, endFreq])\n"); 1669 + return 0; 1670 + } 1671 + 1672 + static s32 lua_vqtr(lua_State* lua) 1673 + { 1674 + tic_core* core = getLuaCore(lua); 1675 + tic_mem* tic = (tic_mem*)core; 1676 + s32 top = lua_gettop(lua); 1677 + 1678 + if (top >= 1) 1679 + { 1680 + s32 bin = getLuaNumber(lua, 1); 1681 + 1682 + lua_pushnumber(lua, core->api.vqtr(tic, bin)); 1683 + return 1; 1684 + } 1685 + 1686 + luaL_error(lua, "invalid params, vqtr(bin)\n"); 1687 + return 0; 1688 + } 1689 + 1690 + static s32 lua_vqtrs(lua_State* lua) 1691 + { 1692 + tic_core* core = getLuaCore(lua); 1693 + tic_mem* tic = (tic_mem*)core; 1694 + s32 top = lua_gettop(lua); 1695 + 1696 + if (top >= 1) 1697 + { 1698 + s32 bin = getLuaNumber(lua, 1); 1699 + 1700 + lua_pushnumber(lua, core->api.vqtrs(tic, bin)); 1701 + return 1; 1702 + } 1703 + 1704 + luaL_error(lua, "invalid params, vqtrs(bin)\n"); 1632 1705 return 0; 1633 1706 } 1634 1707
+76
src/api/mruby.c
··· 606 606 } 607 607 } 608 608 609 + static mrb_value mrb_fftr(mrb_state* mrb, mrb_value self) 610 + { 611 + mrb_int start_freq, end_freq = -1; 612 + mrb_int argc = mrb_get_args(mrb, "i|i", &start_freq, &end_freq); 613 + 614 + tic_core* core = getMRubyMachine(mrb); 615 + tic_mem* tic = (tic_mem*)core; 616 + 617 + if (argc == 0) 618 + { 619 + mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid params, fftr [ start_freq end_freq ]\n"); 620 + return mrb_nil_value(); 621 + } 622 + else 623 + { 624 + return mrb_float_value(mrb, core->api.fftr(tic, start_freq, end_freq)); 625 + } 626 + } 627 + 628 + static mrb_value mrb_fftrs(mrb_state* mrb, mrb_value self) 629 + { 630 + mrb_int start_freq, end_freq = -1; 631 + mrb_int argc = mrb_get_args(mrb, "i|i", &start_freq, &end_freq); 632 + 633 + tic_core* core = getMRubyMachine(mrb); 634 + tic_mem* tic = (tic_mem*)core; 635 + 636 + if (argc == 0) 637 + { 638 + mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid params, fftrs [ start_freq end_freq ]\n"); 639 + return mrb_nil_value(); 640 + } 641 + else 642 + { 643 + return mrb_float_value(mrb, core->api.fftrs(tic, start_freq, end_freq)); 644 + } 645 + } 646 + 647 + static mrb_value mrb_vqtr(mrb_state* mrb, mrb_value self) 648 + { 649 + mrb_int bin; 650 + mrb_int argc = mrb_get_args(mrb, "i", &bin); 651 + 652 + tic_core* core = getMRubyMachine(mrb); 653 + tic_mem* tic = (tic_mem*)core; 654 + 655 + if (argc == 0) 656 + { 657 + mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid params, vqtr(bin)\n"); 658 + return mrb_nil_value(); 659 + } 660 + else 661 + { 662 + return mrb_float_value(mrb, core->api.vqtr(tic, bin)); 663 + } 664 + } 665 + 666 + static mrb_value mrb_vqtrs(mrb_state* mrb, mrb_value self) 667 + { 668 + mrb_int bin; 669 + mrb_int argc = mrb_get_args(mrb, "i", &bin); 670 + 671 + tic_core* core = getMRubyMachine(mrb); 672 + tic_mem* tic = (tic_mem*)core; 673 + 674 + if (argc == 0) 675 + { 676 + mrb_raise(mrb, E_ARGUMENT_ERROR, "invalid params, vqtrs(bin)\n"); 677 + return mrb_nil_value(); 678 + } 679 + else 680 + { 681 + return mrb_float_value(mrb, core->api.vqtrs(tic, bin)); 682 + } 683 + } 684 + 609 685 typedef struct 610 686 { 611 687 mrb_state* mrb;
+46
src/api/scheme.c
··· 794 794 return s7_make_real(sc, core->api.vqts(tic, bin)); 795 795 } 796 796 797 + s7_pointer scheme_fftr(s7_scheme* sc, s7_pointer args) 798 + { 799 + // fftr(int start_freq, int end_freq=-1) -> float_value 800 + tic_core* core = getSchemeCore(sc); 801 + tic_mem* tic = (tic_mem*)core; 802 + const int argn = s7_list_length(sc, args); 803 + const s32 start_freq = argn > 0 ? s7_integer(s7_car(args)) : -1; 804 + const s32 end_freq = argn > 1 ? s7_integer(s7_cadr(args)) : -1; 805 + 806 + return s7_make_real(sc, core->api.fftr(tic, start_freq, end_freq)); 807 + } 808 + 809 + s7_pointer scheme_fftrs(s7_scheme* sc, s7_pointer args) 810 + { 811 + // fftrs(int start_freq, int end_freq=-1) -> float_value 812 + tic_core* core = getSchemeCore(sc); 813 + tic_mem* tic = (tic_mem*)core; 814 + const int argn = s7_list_length(sc, args); 815 + const s32 start_freq = argn > 0 ? s7_integer(s7_car(args)) : -1; 816 + const s32 end_freq = argn > 1 ? s7_integer(s7_cadr(args)) : -1; 817 + 818 + return s7_make_real(sc, core->api.fftrs(tic, start_freq, end_freq)); 819 + } 820 + 821 + s7_pointer scheme_vqtr(s7_scheme* sc, s7_pointer args) 822 + { 823 + // vqtr(int bin) -> float_value 824 + tic_core* core = getSchemeCore(sc); 825 + tic_mem* tic = (tic_mem*)core; 826 + const int argn = s7_list_length(sc, args); 827 + const s32 bin = argn > 0 ? s7_integer(s7_car(args)) : 0; 828 + 829 + return s7_make_real(sc, core->api.vqtr(tic, bin)); 830 + } 831 + 832 + s7_pointer scheme_vqtrs(s7_scheme* sc, s7_pointer args) 833 + { 834 + // vqtrs(int bin) -> float_value 835 + tic_core* core = getSchemeCore(sc); 836 + tic_mem* tic = (tic_mem*)core; 837 + const int argn = s7_list_length(sc, args); 838 + const s32 bin = argn > 0 ? s7_integer(s7_car(args)) : 0; 839 + 840 + return s7_make_real(sc, core->api.vqtrs(tic, bin)); 841 + } 842 + 797 843 static void initAPI(tic_core* core) 798 844 { 799 845 s7_scheme* sc = core->currentVM;
+92
src/api/squirrel.c
··· 1621 1621 return 0; 1622 1622 } 1623 1623 1624 + static SQInteger squirrel_fftr(HSQUIRRELVM vm) 1625 + { 1626 + tic_core* core = getSquirrelCore(vm); 1627 + tic_mem* tic = (tic_mem*)core; 1628 + 1629 + SQInteger top = sq_gettop(vm); 1630 + 1631 + if (top >= 2) 1632 + { 1633 + double start_freq = getSquirrelNumber(vm, 2); 1634 + double end_freq = -1; 1635 + 1636 + if (top >= 3) 1637 + { 1638 + end_freq = getSquirrelNumber(vm, 3); 1639 + } 1640 + 1641 + sq_pushfloat(vm, (SQFloat)(core->api.fftr(tic, start_freq, end_freq))); 1642 + return 1; 1643 + } 1644 + 1645 + sq_throwerror(vm, "invalid params, fftr(start_freq, end_freq)\n"); 1646 + 1647 + return 0; 1648 + } 1649 + 1650 + static SQInteger squirrel_fftrs(HSQUIRRELVM vm) 1651 + { 1652 + tic_core* core = getSquirrelCore(vm); 1653 + tic_mem* tic = (tic_mem*)core; 1654 + 1655 + SQInteger top = sq_gettop(vm); 1656 + 1657 + if (top >= 2) 1658 + { 1659 + double start_freq = getSquirrelNumber(vm, 2); 1660 + double end_freq = -1; 1661 + 1662 + if (top >= 3) 1663 + { 1664 + end_freq = getSquirrelNumber(vm, 3); 1665 + } 1666 + 1667 + sq_pushfloat(vm, (SQFloat)(core->api.fftrs(tic, start_freq, end_freq))); 1668 + return 1; 1669 + } 1670 + 1671 + sq_throwerror(vm, "invalid params, fftrs(start_freq, end_freq)\n"); 1672 + 1673 + return 0; 1674 + } 1675 + 1676 + static SQInteger squirrel_vqtr(HSQUIRRELVM vm) 1677 + { 1678 + tic_core* core = getSquirrelCore(vm); 1679 + tic_mem* tic = (tic_mem*)core; 1680 + 1681 + SQInteger top = sq_gettop(vm); 1682 + 1683 + if (top >= 2) 1684 + { 1685 + double bin = getSquirrelNumber(vm, 2); 1686 + 1687 + sq_pushfloat(vm, (SQFloat)(core->api.vqtr(tic, bin))); 1688 + return 1; 1689 + } 1690 + 1691 + sq_throwerror(vm, "invalid params, vqtr(bin)\n"); 1692 + 1693 + return 0; 1694 + } 1695 + 1696 + static SQInteger squirrel_vqtrs(HSQUIRRELVM vm) 1697 + { 1698 + tic_core* core = getSquirrelCore(vm); 1699 + tic_mem* tic = (tic_mem*)core; 1700 + 1701 + SQInteger top = sq_gettop(vm); 1702 + 1703 + if (top >= 2) 1704 + { 1705 + double bin = getSquirrelNumber(vm, 2); 1706 + 1707 + sq_pushfloat(vm, (SQFloat)(core->api.vqtrs(tic, bin))); 1708 + return 1; 1709 + } 1710 + 1711 + sq_throwerror(vm, "invalid params, vqtrs(bin)\n"); 1712 + 1713 + return 0; 1714 + } 1715 + 1624 1716 static SQInteger squirrel_dofile(HSQUIRRELVM vm) 1625 1717 { 1626 1718 return sq_throwerror(vm, "unknown method: \"dofile\"\n");
+74
src/api/wren.c
··· 1541 1541 wrenError(vm, "invalid params, vqts(bin)\n"); 1542 1542 } 1543 1543 1544 + static void wren_fftr(WrenVM* vm) 1545 + { 1546 + tic_core* core = getWrenCore(vm); 1547 + tic_mem* tic = (tic_mem*)core; 1548 + s32 top = wrenGetSlotCount(vm); 1549 + 1550 + if (top > 1) 1551 + { 1552 + double startFreq = getWrenNumber(vm, 1); 1553 + double endFreq = top > 2 ? getWrenNumber(vm, 2) : -1; 1554 + 1555 + wrenSetSlotDouble(vm, 0, core->api.fftr(tic, startFreq, endFreq)); 1556 + return; 1557 + } 1558 + 1559 + wrenError(vm, "invalid params, fftr(startFreq [, endFreq])\n"); 1560 + } 1561 + 1562 + static void wren_fftrs(WrenVM* vm) 1563 + { 1564 + tic_core* core = getWrenCore(vm); 1565 + tic_mem* tic = (tic_mem*)core; 1566 + s32 top = wrenGetSlotCount(vm); 1567 + 1568 + if (top > 1) 1569 + { 1570 + double startFreq = getWrenNumber(vm, 1); 1571 + double endFreq = top > 2 ? getWrenNumber(vm, 2) : -1; 1572 + 1573 + wrenSetSlotDouble(vm, 0, core->api.fftrs(tic, startFreq, endFreq)); 1574 + return; 1575 + } 1576 + 1577 + wrenError(vm, "invalid params, fftrs(startFreq [, endFreq])\n"); 1578 + } 1579 + 1580 + static void wren_vqtr(WrenVM* vm) 1581 + { 1582 + tic_core* core = getWrenCore(vm); 1583 + tic_mem* tic = (tic_mem*)core; 1584 + s32 top = wrenGetSlotCount(vm); 1585 + 1586 + if (top > 1) 1587 + { 1588 + double bin = getWrenNumber(vm, 1); 1589 + 1590 + wrenSetSlotDouble(vm, 0, core->api.vqtr(tic, bin)); 1591 + return; 1592 + } 1593 + 1594 + wrenError(vm, "invalid params, vqtr(bin)\n"); 1595 + } 1596 + 1597 + static void wren_vqtrs(WrenVM* vm) 1598 + { 1599 + tic_core* core = getWrenCore(vm); 1600 + tic_mem* tic = (tic_mem*)core; 1601 + s32 top = wrenGetSlotCount(vm); 1602 + 1603 + if (top > 1) 1604 + { 1605 + double bin = getWrenNumber(vm, 1); 1606 + 1607 + wrenSetSlotDouble(vm, 0, core->api.vqtrs(tic, bin)); 1608 + return; 1609 + } 1610 + 1611 + wrenError(vm, "invalid params, vqtrs(bin)\n"); 1612 + } 1613 + 1544 1614 static WrenForeignMethodFn foreignTicMethods(const char* signature) 1545 1615 { 1546 1616 if (strcmp(signature, "static TIC.btn()" ) == 0) return wren_btn; ··· 1656 1726 if (strcmp(signature, "static TIC.ffts(_,_)" ) == 0) return wren_ffts; 1657 1727 if (strcmp(signature, "static TIC.vqt(_)" ) == 0) return wren_vqt; 1658 1728 if (strcmp(signature, "static TIC.vqts(_)" ) == 0) return wren_vqts; 1729 + if (strcmp(signature, "static TIC.fftr(_,_)" ) == 0) return wren_fftr; 1730 + if (strcmp(signature, "static TIC.fftrs(_,_)" ) == 0) return wren_fftrs; 1731 + if (strcmp(signature, "static TIC.vqtr(_)" ) == 0) return wren_vqtr; 1732 + if (strcmp(signature, "static TIC.vqtrs(_)" ) == 0) return wren_vqtrs; 1659 1733 1660 1734 // internal functions 1661 1735 if (strcmp(signature, "static TIC.map_width__" ) == 0) return wren_map_width;
+83
src/ext/fft.c
··· 342 342 { 343 343 float val = 2.0f * sqrtf(out[i].r * out[i].r + out[i].i * out[i].i); 344 344 if (val > peakValue) peakValue = val; 345 + fftRawData[i] = val; // Store raw magnitude 345 346 _samples[i] = val * fAmplification; 346 347 } 347 348 if (peakValue > fPeakSmoothValue) ··· 357 358 float fFFTSmoothingFactor = 0.6f; 358 359 for (int i = 0; i < FFT_SIZE; i++) 359 360 { 361 + fftRawSmoothingData[i] = fftRawSmoothingData[i] * fFFTSmoothingFactor + (1 - fFFTSmoothingFactor) * fftRawData[i]; 360 362 fftSmoothingData[i] = fftSmoothingData[i] * fFFTSmoothingFactor + (1 - fFFTSmoothingFactor) * _samples[i]; 361 363 } 362 364 ··· 445 447 return fft(startFreq, endFreq, true); 446 448 #endif 447 449 } 450 + 451 + // Raw FFT access function 452 + static double fftr(s32 startFreq, s32 endFreq, bool smoothing) 453 + { 454 + #ifdef TIC80_FFT_UNSUPPORTED 455 + return 0.0; 456 + #else 457 + if (!fftEnabled) 458 + { 459 + FFT_DebugLog(FFT_LOG_TRACE, "FFT: fft not enabled\n"); 460 + return 0.0; 461 + } 462 + 463 + if (endFreq == -1) 464 + { 465 + if (startFreq < 0 || startFreq >= FFT_SIZE) 466 + { 467 + FFT_DebugLog(FFT_LOG_TRACE, "FFT: freq out of bounds at %d\n", startFreq); 468 + return 0.0; 469 + } 470 + return smoothing ? fftRawSmoothingData[startFreq] : fftRawData[startFreq]; 471 + } 472 + else 473 + { 474 + if ((startFreq < 0 && endFreq < 0) || (startFreq >= FFT_SIZE && endFreq >= FFT_SIZE)) 475 + { 476 + FFT_DebugLog(FFT_LOG_TRACE, "FFT: both startFreq and endFreq out of bounds, startFreq %d, endFreq %d\n", startFreq, endFreq); 477 + return 0.0; 478 + } 479 + 480 + if (startFreq < 0) 481 + { 482 + FFT_DebugLog(FFT_LOG_TRACE, "FFT: clamped startFreq to 0\n"); 483 + startFreq = 0; 484 + } 485 + 486 + if (startFreq >= FFT_SIZE) 487 + { 488 + FFT_DebugLog(FFT_LOG_TRACE, "FFT: clamped startFreq to %d\n", FFT_SIZE - 1); 489 + startFreq = 0; 490 + } 491 + 492 + if (endFreq >= FFT_SIZE) 493 + { 494 + FFT_DebugLog(FFT_LOG_TRACE, "FFT: clamped endFreq to %d\n", FFT_SIZE - 1); 495 + endFreq = FFT_SIZE - 1; 496 + } 497 + 498 + if (startFreq > endFreq) 499 + { 500 + FFT_DebugLog(FFT_LOG_TRACE, "FFT: clamped startFreq to endFreq\n"); 501 + endFreq = startFreq; 502 + } 503 + 504 + double sum = 0.0; 505 + for (int i = startFreq; i <= endFreq; i++) 506 + { 507 + sum += smoothing ? fftRawSmoothingData[i] : fftRawData[i]; 508 + } 509 + return sum; 510 + } 511 + #endif 512 + } 513 + 514 + double tic_api_fftr(tic_mem* memory, s32 startFreq, s32 endFreq) 515 + { 516 + #ifdef TIC80_FFT_UNSUPPORTED 517 + return 0.0; 518 + #else 519 + return fftr(startFreq, endFreq, false); 520 + #endif 521 + } 522 + 523 + double tic_api_fftrs(tic_mem* memory, s32 startFreq, s32 endFreq) 524 + { 525 + #ifdef TIC80_FFT_UNSUPPORTED 526 + return 0.0; 527 + #else 528 + return fftr(startFreq, endFreq, true); 529 + #endif 530 + }
+25 -2
src/ext/vqt.c
··· 426 426 if (bin < 0 || bin >= VQT_BINS) 427 427 return 0.0; 428 428 429 - // Return raw VQT data (normalized but unsmoothed) 429 + // Return normalized VQT data 430 430 return vqtData[bin] / vqtPeakSmoothValue; 431 431 } 432 432 ··· 436 436 if (bin < 0 || bin >= VQT_BINS) 437 437 return 0.0; 438 438 439 - // Return smoothed VQT data (smoothed + normalized) 439 + // Return smoothed normalized VQT data 440 440 return vqtNormalizedData[bin]; 441 441 } 442 442 443 + // Raw (non-normalized) VQT access functions 444 + double tic_api_vqtr(tic_mem* memory, s32 bin) 445 + { 446 + // Validate bin range 447 + if (bin < 0 || bin >= VQT_BINS) 448 + return 0.0; 449 + 450 + // Return raw VQT data (non-normalized) 451 + return vqtData[bin]; 452 + } 453 + 454 + double tic_api_vqtrs(tic_mem* memory, s32 bin) 455 + { 456 + // Validate bin range 457 + if (bin < 0 || bin >= VQT_BINS) 458 + return 0.0; 459 + 460 + // Return raw smoothed VQT data (non-normalized) 461 + return vqtSmoothingData[bin]; 462 + } 463 + 443 464 #else // TIC80_FFT_UNSUPPORTED 444 465 445 466 // Stub implementations when FFT is unsupported ··· 451 472 // API stubs when FFT is unsupported 452 473 double tic_api_vqt(tic_mem* memory, s32 bin) { return 0.0; } 453 474 double tic_api_vqts(tic_mem* memory, s32 bin) { return 0.0; } 475 + double tic_api_vqtr(tic_mem* memory, s32 bin) { return 0.0; } 476 + double tic_api_vqtrs(tic_mem* memory, s32 bin) { return 0.0; } 454 477 455 478 #endif // TIC80_FFT_UNSUPPORTED
+4
src/fftdata.c
··· 14 14 float fftNormalizedData[FFT_SIZE] = {0}; 15 15 float fftNormalizedMaxData[FFT_SIZE] = {0}; 16 16 17 + // Raw (non-normalized) FFT data 18 + float fftRawData[FFT_SIZE] = {0}; 19 + float fftRawSmoothingData[FFT_SIZE] = {0}; 20 + 17 21 bool fftEnabled = false; 18 22 19 23 #define FFT_DEBUG
+4
src/fftdata.h
··· 10 10 extern float fftNormalizedData[FFT_SIZE]; 11 11 extern float fftNormalizedMaxData[FFT_SIZE]; 12 12 13 + // Raw (non-normalized) FFT data 14 + extern float fftRawData[FFT_SIZE]; 15 + extern float fftRawSmoothingData[FFT_SIZE]; 16 + 13 17 extern bool fftEnabled; 14 18 15 19 typedef enum
+2
src/studio/studio.c
··· 1596 1596 memset(fftSmoothingData, 0, sizeof(fftSmoothingData[0]) * FFT_SIZE); 1597 1597 memset(fftNormalizedData, 0, sizeof(fftNormalizedData[0]) * FFT_SIZE); 1598 1598 memset(fftNormalizedMaxData, 0, sizeof(fftNormalizedMaxData[0]) * FFT_SIZE); 1599 + memset(fftRawData, 0, sizeof(fftRawData[0]) * FFT_SIZE); 1600 + memset(fftRawSmoothingData, 0, sizeof(fftRawSmoothingData[0]) * FFT_SIZE); 1599 1601 } 1600 1602 #endif 1601 1603