From 7d7241fa3fb22f2f160a8ac91eb612f48cfdd6e2 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Tue, 23 Dec 2025 15:01:12 +0100 Subject: [PATCH] lua test --- .gitignore | 1 + .vscode/settings.json | 2 +- LICENCE | 37 ++++++++++++++++++++----------------- README.md | 4 ++-- src/fm95.c | 14 ++++++++++++++ 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 745df5c..206b360 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ modules.order Module.symvers Mkfile.old dkms.conf +.vscode/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 717ab41..b325726 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -47,5 +47,5 @@ "compare": "c", "cstdint": "c" }, - "C_Cpp.errorSquiggles": "disabled" + "C_Cpp.errorSquiggles": "disabled", } \ No newline at end of file diff --git a/LICENCE b/LICENCE index df75e5b..c32dd18 100644 --- a/LICENCE +++ b/LICENCE @@ -1,21 +1,24 @@ -MIT License +This is free and unencumbered software released into the public domain. -Copyright (c) 2024 Kuba +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +For more information, please refer to \ No newline at end of file diff --git a/README.md b/README.md index 0b31552..aa09f79 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ FM95 is a audio processor for FM, it does: - Pre-Emphasis - Low Pass Filtering - AGC -- Stereo (Polar too) +- Stereo - SCA - BS412 (mpx power limiter, simplest implementation ever) @@ -40,7 +40,7 @@ Should run completly fine on a pi 5, fine on a pi 3b (30% cpu, 45% with lpf) ## Other Apps -FM95 also includes some other apps, such as chimer95 which generates GTS tones each half hour, and dcf95 which creates a DCF77 compatible signal, and vban95 now which is a buffered VBAN receiver. And now also SCA generation was moved to sca95 from fm95! +FM95 also includes some other apps, such as chimer95 which generates GTS tones each half hour, and vban95 now which is a buffered VBAN receiver. And now also SCA generation was moved to sca95 from fm95! ## Usage of other projects diff --git a/src/fm95.c b/src/fm95.c index daeb839..d303b40 100644 --- a/src/fm95.c +++ b/src/fm95.c @@ -14,6 +14,10 @@ #include "../filter/bs412.h" #include "../filter/gain_control.h" +#include +#include +#include + #define BUFFER_SIZE 4096 // This defines how many samples to process at a time, because the loop here is this: get signal -> process signal -> output signal, and when we get signal we actually get BUFFER_SIZE of them #include "../io/audio.h" @@ -88,6 +92,7 @@ typedef struct BS412Compressor bs412; StereoEncoder stencode; AGC agc; + lua_State* lua; } FM95_Runtime; typedef struct { @@ -231,6 +236,12 @@ int run_fm95(const FM95_Config config, FM95_Runtime* runtime) { mod_r = apply_preemphasis(&runtime->preemp_r, mod_r); } + lua_pushnumber(runtime->lua, mod_l); + lua_setglobal(runtime->lua, "left"); + lua_pushnumber(runtime->lua, mod_r); + lua_setglobal(runtime->lua, "right"); + luaL_dofile(runtime->lua, "/home/user/fm95_lua_test.lua"); + mpx = stereo_encode(&runtime->stencode, config.stereo, mod_l, mod_r); if(rds_on) { @@ -266,6 +277,7 @@ int run_fm95(const FM95_Config config, FM95_Runtime* runtime) { break; } } + lua_gc(runtime.lua, LUA_GCSTEP); } return 0; @@ -580,6 +592,8 @@ int main(int argc, char **argv) { FM95_Runtime runtime; memset(&runtime, 0, sizeof(runtime)); + runtime.lua = luaL_newstate(); + lua_gc(runtime.lua, LUA_GCSTOP); config.options.mpx_on = (strlen(dv_names.mpx) != 0); config.options.rds_on = (strlen(dv_names.rds) != 0 && config.rds_streams != 0);