mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-27 03:23:54 +01:00
lua test
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -51,3 +51,4 @@ modules.order
|
|||||||
Module.symvers
|
Module.symvers
|
||||||
Mkfile.old
|
Mkfile.old
|
||||||
dkms.conf
|
dkms.conf
|
||||||
|
.vscode/
|
||||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -47,5 +47,5 @@
|
|||||||
"compare": "c",
|
"compare": "c",
|
||||||
"cstdint": "c"
|
"cstdint": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.errorSquiggles": "disabled"
|
"C_Cpp.errorSquiggles": "disabled",
|
||||||
}
|
}
|
||||||
37
LICENCE
37
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
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software dedicate any and all copyright interest in the
|
||||||
in the Software without restriction, including without limitation the rights
|
software to the public domain. We make this dedication for the benefit
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
of the public at large and to the detriment of our heirs and
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
successors. We intend this dedication to be an overt act of
|
||||||
furnished to do so, subject to the following conditions:
|
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
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
copies or substantial portions of the Software.
|
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
|
For more information, please refer to <https://unlicense.org/>
|
||||||
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.
|
|
||||||
@@ -5,7 +5,7 @@ FM95 is a audio processor for FM, it does:
|
|||||||
- Pre-Emphasis
|
- Pre-Emphasis
|
||||||
- Low Pass Filtering
|
- Low Pass Filtering
|
||||||
- AGC
|
- AGC
|
||||||
- Stereo (Polar too)
|
- Stereo
|
||||||
- SCA
|
- SCA
|
||||||
- BS412 (mpx power limiter, simplest implementation ever)
|
- 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
|
## 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
|
## Usage of other projects
|
||||||
|
|
||||||
|
|||||||
14
src/fm95.c
14
src/fm95.c
@@ -14,6 +14,10 @@
|
|||||||
#include "../filter/bs412.h"
|
#include "../filter/bs412.h"
|
||||||
#include "../filter/gain_control.h"
|
#include "../filter/gain_control.h"
|
||||||
|
|
||||||
|
#include <lua.h>
|
||||||
|
#include <lualib.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
|
|
||||||
#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
|
#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"
|
#include "../io/audio.h"
|
||||||
@@ -88,6 +92,7 @@ typedef struct
|
|||||||
BS412Compressor bs412;
|
BS412Compressor bs412;
|
||||||
StereoEncoder stencode;
|
StereoEncoder stencode;
|
||||||
AGC agc;
|
AGC agc;
|
||||||
|
lua_State* lua;
|
||||||
} FM95_Runtime;
|
} FM95_Runtime;
|
||||||
|
|
||||||
typedef struct {
|
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);
|
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);
|
mpx = stereo_encode(&runtime->stencode, config.stereo, mod_l, mod_r);
|
||||||
|
|
||||||
if(rds_on) {
|
if(rds_on) {
|
||||||
@@ -266,6 +277,7 @@ int run_fm95(const FM95_Config config, FM95_Runtime* runtime) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lua_gc(runtime.lua, LUA_GCSTEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -580,6 +592,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
FM95_Runtime runtime;
|
FM95_Runtime runtime;
|
||||||
memset(&runtime, 0, sizeof(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.mpx_on = (strlen(dv_names.mpx) != 0);
|
||||||
config.options.rds_on = (strlen(dv_names.rds) != 0 && config.rds_streams != 0);
|
config.options.rds_on = (strlen(dv_names.rds) != 0 && config.rds_streams != 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user