mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-04-17 11:26:00 +08:00
Spectrogram - WASM port (#26)
* wip in progress * wip * done * fix small window behavior
This commit is contained in:
@@ -1,16 +1,44 @@
|
|||||||
set(TARGET spectrogram)
|
set(TARGET spectrogram)
|
||||||
|
|
||||||
add_executable(${TARGET} main.cpp)
|
if (EMSCRIPTEN)
|
||||||
|
add_executable(${TARGET} main.cpp)
|
||||||
|
|
||||||
target_include_directories(${TARGET} PRIVATE
|
target_include_directories(${TARGET} PRIVATE
|
||||||
..
|
..
|
||||||
${SDL2_INCLUDE_DIRS}
|
${SDL2_INCLUDE_DIRS}
|
||||||
)
|
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(${TARGET} PRIVATE
|
target_link_libraries(${TARGET} PRIVATE
|
||||||
ggwave
|
ggwave
|
||||||
ggwave-common
|
ggwave-common
|
||||||
ggwave-common-sdl2
|
ggwave-common-sdl2
|
||||||
imgui-sdl2
|
ggsock
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
imgui-sdl2
|
||||||
)
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS " \
|
||||||
|
-s FORCE_FILESYSTEM=1 \
|
||||||
|
--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../assets/fonts@/ \
|
||||||
|
")
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/build_timestamp-tmpl.h ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/build_timestamp.h @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/index-tmpl.html ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/index.html @ONLY)
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/style.css ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/style.css COPYONLY)
|
||||||
|
else()
|
||||||
|
add_executable(${TARGET} main.cpp)
|
||||||
|
|
||||||
|
target_include_directories(${TARGET} PRIVATE
|
||||||
|
..
|
||||||
|
${SDL2_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${TARGET} PRIVATE
|
||||||
|
ggwave
|
||||||
|
ggwave-common
|
||||||
|
ggwave-common-sdl2
|
||||||
|
imgui-sdl2
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|||||||
1
examples/spectrogram/build_timestamp-tmpl.h
Normal file
1
examples/spectrogram/build_timestamp-tmpl.h
Normal file
@@ -0,0 +1 @@
|
|||||||
|
static const char * BUILD_TIMESTAMP="@GIT_DATE@ (@GIT_SHA1@)";
|
||||||
187
examples/spectrogram/index-tmpl.html
Normal file
187
examples/spectrogram/index-tmpl.html
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en-us">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Spectrogram</title>
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
|
||||||
|
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:title" content="Spectrogram" />
|
||||||
|
<meta name="twitter:description" content="Spectrogram" />
|
||||||
|
<meta name="twitter:image" content="https://spectrogram.ggerganov.com/spectrogram.png" />
|
||||||
|
|
||||||
|
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||||
|
<link rel="manifest" href="/manifest.json">
|
||||||
|
<meta name="msapplication-TileColor" content="#ffffff">
|
||||||
|
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
|
||||||
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="main-controls">
|
||||||
|
<div id="description" align="center">
|
||||||
|
<h2>Spectrogram</h2>
|
||||||
|
|
||||||
|
<div id="container_status" align="center">
|
||||||
|
Loading WebAssembly module - please wait ...
|
||||||
|
</div>
|
||||||
|
<div id="container_button" align="center">
|
||||||
|
<br>
|
||||||
|
<button onClick="doInit()" id="butInit" style="width:60px;height:30px;" disabled>Init</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="container_canvas" hidden>
|
||||||
|
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="footer" class="cell-version">
|
||||||
|
<span>
|
||||||
|
Build time: <span class="nav-link">@GIT_DATE@</span> |
|
||||||
|
Commit hash: <a class="nav-link" href="https://github.com/ggerganov/ggwave/commit/@GIT_SHA1@">@GIT_SHA1@</a> |
|
||||||
|
Commit subject: <span class="nav-link">@GIT_COMMIT_SUBJECT@</span> |
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="cell-about">
|
||||||
|
<a class="nav-link" href="https://github.com/ggerganov/ggwave/tree/master/examples/spectrogram"><span class="d-none d-sm-inline">View on GitHub </span>
|
||||||
|
<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-mark-github" aria-hidden="true"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
window.mobilecheck = function() {
|
||||||
|
var check = false;
|
||||||
|
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
|
||||||
|
return check;
|
||||||
|
};
|
||||||
|
|
||||||
|
var isMobile = mobilecheck();
|
||||||
|
var isInitialized = false;
|
||||||
|
|
||||||
|
window.setInterval(function(){
|
||||||
|
if (isInitialized == false) return;
|
||||||
|
var w = window,
|
||||||
|
d = document,
|
||||||
|
e = d.documentElement,
|
||||||
|
g = d.getElementsByTagName('body')[0],
|
||||||
|
x = w.innerWidth || e.clientWidth || g.clientWidth,
|
||||||
|
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
|
||||||
|
Module._set_window_size(0.99*x, y - 1.40*document.getElementById('footer').clientHeight);
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
function checkLoop() {
|
||||||
|
setTimeout(checkLoop, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkSharedArrayBuffer() {
|
||||||
|
return true;
|
||||||
|
try {
|
||||||
|
var a = SharedArrayBuffer;
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e instanceof ReferenceError); // true
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onkeydown(event) {
|
||||||
|
if (event.keyCode >= 112 && event.keyCode <= 123) {
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
document.getElementById('container_status').innerHTML = "WebAssembly module initialized successfully! Press the Init button to start:"
|
||||||
|
document.getElementById('container_status').style.color = "#00ff00";
|
||||||
|
|
||||||
|
document.getElementById("butInit").disabled = false;
|
||||||
|
|
||||||
|
window.addEventListener('keydown', onkeydown, true);
|
||||||
|
|
||||||
|
setTimeout(checkLoop, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
function doInit() {
|
||||||
|
let constraints = {
|
||||||
|
audio: {
|
||||||
|
sampleRate: 16000,
|
||||||
|
channelCount: 1,
|
||||||
|
echoCancellation: false,
|
||||||
|
autoGainControl: false,
|
||||||
|
noiseSuppression: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isInitialized == false) {
|
||||||
|
Module._do_init();
|
||||||
|
var el = document.getElementById("container_status");
|
||||||
|
el.parentNode.removeChild(el);
|
||||||
|
el = document.getElementById("container_button");
|
||||||
|
el.parentNode.removeChild(el);
|
||||||
|
isInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("description").hidden = true;
|
||||||
|
document.getElementById("container_canvas").hidden = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var Module = {
|
||||||
|
arguments: [],
|
||||||
|
preRun: [(function() {
|
||||||
|
}) ],
|
||||||
|
postRun: [(function () {
|
||||||
|
init();
|
||||||
|
})
|
||||||
|
],
|
||||||
|
canvas: (function() {
|
||||||
|
var canvas = document.getElementById('canvas');
|
||||||
|
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
|
||||||
|
|
||||||
|
return canvas;
|
||||||
|
})(),
|
||||||
|
print: (function() {
|
||||||
|
return function(text) {
|
||||||
|
text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
|
console.log(text);
|
||||||
|
};
|
||||||
|
})(),
|
||||||
|
printErr: function(text) {
|
||||||
|
text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
|
console.error(text);
|
||||||
|
},
|
||||||
|
setStatus: function(text) {
|
||||||
|
console.log("status: " + text);
|
||||||
|
},
|
||||||
|
monitorRunDependencies: function(left) {
|
||||||
|
// no run dependencies to log
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.onerror = function() {
|
||||||
|
console.log("onerror: " + JSON.stringify(event));
|
||||||
|
if (checkSharedArrayBuffer() == false) {
|
||||||
|
document.getElementById('container_status').innerHTML = "Failed to load the WebAssembly module.<br><br>Try openning this page on a PC with latest Chrome browser.";
|
||||||
|
document.getElementById('container_status').style.color = "#ff0000";
|
||||||
|
document.getElementById('container_button').hidden = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script async type="text/javascript" src="spectrogram.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -3,6 +3,13 @@
|
|||||||
#include "ggwave/ggwave.h"
|
#include "ggwave/ggwave.h"
|
||||||
#include "ggwave-common.h"
|
#include "ggwave-common.h"
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include "build_timestamp.h"
|
||||||
|
#include "emscripten/emscripten.h"
|
||||||
|
#else
|
||||||
|
#define EMSCRIPTEN_KEEPALIVE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <imgui-extra/imgui_impl.h>
|
#include <imgui-extra/imgui_impl.h>
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
@@ -326,7 +333,30 @@ void mainUpdate(void *) {
|
|||||||
g_mainUpdate();
|
g_mainUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JS interface
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
EMSCRIPTEN_KEEPALIVE
|
||||||
|
int do_init() {
|
||||||
|
return g_doInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
EMSCRIPTEN_KEEPALIVE
|
||||||
|
void set_window_size(int sizeX, int sizeY) {
|
||||||
|
g_setWindowSize(sizeX, sizeY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
printf("Build time: %s\n", BUILD_TIMESTAMP);
|
||||||
|
printf("Press the Init button to start\n");
|
||||||
|
|
||||||
|
if (argv[1]) {
|
||||||
|
GGWave_setDefaultCaptureDeviceName(argv[1]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
auto argm = parseCmdArguments(argc, argv);
|
auto argm = parseCmdArguments(argc, argv);
|
||||||
int captureId = argm["c"].empty() ? 0 : std::stoi(argm["c"]);
|
int captureId = argm["c"].empty() ? 0 : std::stoi(argm["c"]);
|
||||||
int playbackId = argm["p"].empty() ? 0 : std::stoi(argm["p"]);
|
int playbackId = argm["p"].empty() ? 0 : std::stoi(argm["p"]);
|
||||||
@@ -338,13 +368,19 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
ImGui_PreInit();
|
ImGui_PreInit();
|
||||||
|
|
||||||
int windowX = 1920;
|
int windowX = 1600;
|
||||||
int windowY = 1200;
|
int windowY = 1200;
|
||||||
|
|
||||||
const char * windowTitle = "spectrogram";
|
const char * windowTitle = "spectrogram";
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
SDL_Renderer * renderer;
|
||||||
|
SDL_Window * window;
|
||||||
|
SDL_CreateWindowAndRenderer(windowX, windowY, SDL_WINDOW_OPENGL, &window, &renderer);
|
||||||
|
#else
|
||||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
SDL_Window * window = SDL_CreateWindow(windowTitle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowX, windowY, window_flags);
|
SDL_Window * window = SDL_CreateWindow(windowTitle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowX, windowY, window_flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
void * gl_context = SDL_GL_CreateContext(window);
|
void * gl_context = SDL_GL_CreateContext(window);
|
||||||
|
|
||||||
@@ -403,6 +439,7 @@ int main(int argc, char** argv) {
|
|||||||
ImGuiWindowFlags_NoTitleBar |
|
ImGuiWindowFlags_NoTitleBar |
|
||||||
ImGuiWindowFlags_NoScrollbar |
|
ImGuiWindowFlags_NoScrollbar |
|
||||||
ImGuiWindowFlags_NoResize |
|
ImGuiWindowFlags_NoResize |
|
||||||
|
ImGuiWindowFlags_NoScrollWithMouse |
|
||||||
ImGuiWindowFlags_NoSavedSettings);
|
ImGuiWindowFlags_NoSavedSettings);
|
||||||
|
|
||||||
auto & style = ImGui::GetStyle();
|
auto & style = ImGui::GetStyle();
|
||||||
@@ -476,8 +513,8 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
if (g_showControls) {
|
if (g_showControls) {
|
||||||
ImGui::SetNextWindowFocus();
|
ImGui::SetNextWindowFocus();
|
||||||
ImGui::SetNextWindowPos({ displaySize.x - 400 - 20, 20 });
|
ImGui::SetNextWindowPos({ std::max(20.0f, displaySize.x - 400.0f - 20.0f), 20.0f });
|
||||||
ImGui::SetNextWindowSize({ 400, 180 });
|
ImGui::SetNextWindowSize({ std::min(displaySize.x - 40.0f, 400.0f), 180.0f });
|
||||||
ImGui::Begin("Controls", &g_showControls);
|
ImGui::Begin("Controls", &g_showControls);
|
||||||
ImGui::Text("Press 'c' to hide/show this window");
|
ImGui::Text("Press 'c' to hide/show this window");
|
||||||
{
|
{
|
||||||
@@ -516,6 +553,9 @@ int main(int argc, char** argv) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
emscripten_set_main_loop_arg(mainUpdate, NULL, 0, true);
|
||||||
|
#else
|
||||||
if (g_doInit() == false) {
|
if (g_doInit() == false) {
|
||||||
printf("Error: failed to initialize audio\n");
|
printf("Error: failed to initialize audio\n");
|
||||||
return -2;
|
return -2;
|
||||||
@@ -535,6 +575,7 @@ int main(int argc, char** argv) {
|
|||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
SDL_CloseAudio();
|
SDL_CloseAudio();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
323
examples/spectrogram/style.css
Normal file
323
examples/spectrogram/style.css
Normal file
@@ -0,0 +1,323 @@
|
|||||||
|
body {
|
||||||
|
margin: 0; background-color: black;
|
||||||
|
-webkit-font-smoothing: subpixel-antialiased;
|
||||||
|
font-smoothing: subpixel-antialiased;
|
||||||
|
}
|
||||||
|
#screen {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
height: 100%;
|
||||||
|
font: sans-serif;
|
||||||
|
}
|
||||||
|
.no-sel {
|
||||||
|
-moz-user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-webkit-touch-callout: none;
|
||||||
|
-ms-user-select:none;
|
||||||
|
user-select:none;
|
||||||
|
-o-user-select:none;
|
||||||
|
}
|
||||||
|
.cell {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.cell-version {
|
||||||
|
padding-left: 4px;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
text-align: left;
|
||||||
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
|
color: rgba(0, 0, 0, 0.75);
|
||||||
|
}
|
||||||
|
.cell-about {
|
||||||
|
padding-right: 24px;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
text-align: right;
|
||||||
|
display: inline-block;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
.nav-link {
|
||||||
|
text-decoration: none;
|
||||||
|
color: rgba(0, 0, 0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#main-container {
|
||||||
|
font-size:12px;
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
font-size:12px;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
|
||||||
|
div.emscripten_border { border: 1px solid black; }
|
||||||
|
|
||||||
|
canvas.emscripten {
|
||||||
|
border: 0px none;
|
||||||
|
background-color: black;
|
||||||
|
text-shadow: 4px 4px #1f1f1fb4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
height: 30px;
|
||||||
|
width: 30px;
|
||||||
|
margin: 0;
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-left: 20px;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
|
||||||
|
-webkit-animation: rotation .8s linear infinite;
|
||||||
|
-moz-animation: rotation .8s linear infinite;
|
||||||
|
-o-animation: rotation .8s linear infinite;
|
||||||
|
animation: rotation 0.8s linear infinite;
|
||||||
|
|
||||||
|
border-left: 5px solid rgb(235, 235, 235);
|
||||||
|
border-right: 5px solid rgb(235, 235, 235);
|
||||||
|
border-bottom: 5px solid rgb(235, 235, 235);
|
||||||
|
border-top: 5px solid rgb(120, 120, 120);
|
||||||
|
|
||||||
|
border-radius: 100%;
|
||||||
|
background-color: rgb(189, 215, 46);
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes rotation {
|
||||||
|
from {-webkit-transform: rotate(0deg);}
|
||||||
|
to {-webkit-transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
@-moz-keyframes rotation {
|
||||||
|
from {-moz-transform: rotate(0deg);}
|
||||||
|
to {-moz-transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
@-o-keyframes rotation {
|
||||||
|
from {-o-transform: rotate(0deg);}
|
||||||
|
to {-o-transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
@keyframes rotation {
|
||||||
|
from {transform: rotate(0deg);}
|
||||||
|
to {transform: rotate(360deg);}
|
||||||
|
}
|
||||||
|
|
||||||
|
#status {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
margin-top: 30px;
|
||||||
|
margin-left: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: rgb(120, 120, 120);
|
||||||
|
}
|
||||||
|
|
||||||
|
#progress {
|
||||||
|
height: 20px;
|
||||||
|
width: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#output {
|
||||||
|
width: 800px;
|
||||||
|
height: 200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
margin-top: 10px;
|
||||||
|
border-left: 0px;
|
||||||
|
border-right: 0px;
|
||||||
|
padding-left: 0px;
|
||||||
|
padding-right: 0px;
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
font-size:10px;
|
||||||
|
font-family: 'Lucida Console', Monaco, monospace;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.led-box {
|
||||||
|
height: 30px;
|
||||||
|
width: 25%;
|
||||||
|
margin: 10px 0;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.led-box p {
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
|
margin: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.led-red {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
background-color: #F00;
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 12px;
|
||||||
|
-webkit-animation: blinkRed 0.5s infinite;
|
||||||
|
-moz-animation: blinkRed 0.5s infinite;
|
||||||
|
-ms-animation: blinkRed 0.5s infinite;
|
||||||
|
-o-animation: blinkRed 0.5s infinite;
|
||||||
|
animation: blinkRed 0.5s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes blinkRed {
|
||||||
|
from { background-color: #F00; }
|
||||||
|
50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;}
|
||||||
|
to { background-color: #F00; }
|
||||||
|
}
|
||||||
|
@-moz-keyframes blinkRed {
|
||||||
|
from { background-color: #F00; }
|
||||||
|
50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;}
|
||||||
|
to { background-color: #F00; }
|
||||||
|
}
|
||||||
|
@-ms-keyframes blinkRed {
|
||||||
|
from { background-color: #F00; }
|
||||||
|
50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;}
|
||||||
|
to { background-color: #F00; }
|
||||||
|
}
|
||||||
|
@-o-keyframes blinkRed {
|
||||||
|
from { background-color: #F00; }
|
||||||
|
50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;}
|
||||||
|
to { background-color: #F00; }
|
||||||
|
}
|
||||||
|
@keyframes blinkRed {
|
||||||
|
from { background-color: #F00; }
|
||||||
|
50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;}
|
||||||
|
to { background-color: #F00; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.led-yellow {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
background-color: #FF0;
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 12px;
|
||||||
|
-webkit-animation: blinkYellow 1s infinite;
|
||||||
|
-moz-animation: blinkYellow 1s infinite;
|
||||||
|
-ms-animation: blinkYellow 1s infinite;
|
||||||
|
-o-animation: blinkYellow 1s infinite;
|
||||||
|
animation: blinkYellow 1s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@-webkit-keyframes blinkYellow {
|
||||||
|
from { background-color: #FF0; }
|
||||||
|
50% { background-color: #AA0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 0; }
|
||||||
|
to { background-color: #FF0; }
|
||||||
|
}
|
||||||
|
@-moz-keyframes blinkYellow {
|
||||||
|
from { background-color: #FF0; }
|
||||||
|
50% { background-color: #AA0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 0; }
|
||||||
|
to { background-color: #FF0; }
|
||||||
|
}
|
||||||
|
@-ms-keyframes blinkYellow {
|
||||||
|
from { background-color: #FF0; }
|
||||||
|
50% { background-color: #AA0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 0; }
|
||||||
|
to { background-color: #FF0; }
|
||||||
|
}
|
||||||
|
@-o-keyframes blinkYellow {
|
||||||
|
from { background-color: #FF0; }
|
||||||
|
50% { background-color: #AA0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 0; }
|
||||||
|
to { background-color: #FF0; }
|
||||||
|
}
|
||||||
|
@keyframes blinkYellow {
|
||||||
|
from { background-color: #FF0; }
|
||||||
|
50% { background-color: #AA0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 0; }
|
||||||
|
to { background-color: #FF0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.led-green {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
background-color: #ABFF00;
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #304701 0 -1px 9px, #89FF00 0 2px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.led-blue {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
background-color: #24E0FF;
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #006 0 -1px 9px, #3F8CFF 0 2px 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td {
|
||||||
|
border: 1px solid #e8e8e8;
|
||||||
|
}
|
||||||
|
table th, table td {
|
||||||
|
padding: 10px 10px;
|
||||||
|
}
|
||||||
|
table td {
|
||||||
|
border: 1px solid #e8e8e8;
|
||||||
|
}
|
||||||
|
table th, table td {
|
||||||
|
padding: 10px 10px;
|
||||||
|
}
|
||||||
|
td[Attributes Style] {
|
||||||
|
text-align: -webkit-center;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
display: table-cell;
|
||||||
|
vertical-align: inherit;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
margin-bottom: 30px;
|
||||||
|
width: 800px;
|
||||||
|
text-align: left;
|
||||||
|
color: #3f3f3f;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border: 1px solid #e8e8e8;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
margin-bottom: 30px;
|
||||||
|
width: 800px;
|
||||||
|
text-align: left;
|
||||||
|
color: #3f3f3f;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border: 1px solid #e8e8e8;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: separate;
|
||||||
|
border-spacing: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#description {
|
||||||
|
margin: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
color: rgba(255, 255, 255, 1.00);
|
||||||
|
text-shadow: 2px 2px #1f1f1fb4;
|
||||||
|
}
|
||||||
|
.text-body {
|
||||||
|
color: rgba(255, 255, 255, 1.00);
|
||||||
|
text-shadow: 2px 2px #1f1f1fb4;
|
||||||
|
}
|
||||||
|
.cell-version {
|
||||||
|
padding-left: 4px;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
text-align: left;
|
||||||
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
|
color: rgba(255, 255, 255, 0.75);
|
||||||
|
text-shadow: 2px 2px #1f1f1fb4;
|
||||||
|
}
|
||||||
|
.cell-about {
|
||||||
|
padding-right: 24px;
|
||||||
|
padding-top: 0.5em;
|
||||||
|
text-align: right;
|
||||||
|
display: inline-block;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
.nav-link {
|
||||||
|
text-decoration: none;
|
||||||
|
color: rgba(255, 255, 255, 1.0);
|
||||||
|
text-shadow: 2px 2px #1f1f1fb4;
|
||||||
|
}
|
||||||
|
.nav-link2 {
|
||||||
|
text-decoration: none;
|
||||||
|
color: rgba(0, 255, 0, 1.0);
|
||||||
|
text-shadow: 2px 2px #1f1f1fb4;
|
||||||
|
}
|
||||||
|
svg {
|
||||||
|
-webkit-filter: invert(100%); /* safari 6.0 - 9.0 */
|
||||||
|
filter: invert(100%);
|
||||||
|
}
|
||||||
@@ -19,9 +19,9 @@ if (EMSCRIPTEN)
|
|||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS " \
|
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS " \
|
||||||
-s FORCE_FILESYSTEM=1 \
|
-s FORCE_FILESYSTEM=1 \
|
||||||
--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../assets/fonts@/ \
|
--preload-file ${CMAKE_CURRENT_SOURCE_DIR}/../assets/fonts@/ \
|
||||||
")
|
")
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/build_timestamp-tmpl.h ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/build_timestamp.h @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/build_timestamp-tmpl.h ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/build_timestamp.h @ONLY)
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/index-tmpl.html ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/index.html @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/index-tmpl.html ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET}/index.html @ONLY)
|
||||||
|
|||||||
@@ -115,7 +115,6 @@
|
|||||||
window.addEventListener('keydown', onkeydown, true);
|
window.addEventListener('keydown', onkeydown, true);
|
||||||
|
|
||||||
setTimeout(checkLoop, 100);
|
setTimeout(checkLoop, 100);
|
||||||
//window.requestAnimationFrame(renderFrame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function doInit() {
|
function doInit() {
|
||||||
@@ -142,10 +141,6 @@
|
|||||||
x.hidden = false;
|
x.hidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//function renderFrame() {
|
|
||||||
// window.requestAnimationFrame(renderFrame);
|
|
||||||
//}
|
|
||||||
|
|
||||||
var Module = {
|
var Module = {
|
||||||
arguments: [],
|
arguments: [],
|
||||||
preRun: [(function() {
|
preRun: [(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user