-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
audio_BPM_detection_portable.html
125 lines (100 loc) · 3.2 KB
/
audio_BPM_detection_portable.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<html>
<head>
<script src="js/audio_BPM_detection_portable.js"></script>
<script>
// For debug START
var DEBUG_count = 0
var DEBUG_timerID
var DEBUG_always_visible
var DEBUG_hide_sec = 0
var DEBUG_last_display_time = 0
function DEBUG_show(msg, hide_sec, always_visible) {
if (always_visible)
DEBUG_always_visible = true
//DEBUG_always_visible = true
if (DEBUG_timerID || DEBUG_always_visible)
msg = Ldebug.innerText + " | " + msg// + '(' + DEBUG_hide_sec + ')'
var time = Date.now()
if (Ldebug.style.visibility != "inherit") {
DEBUG_hide_sec = 0
DEBUG_last_display_time = time
}
if (DEBUG_timerID) {
clearTimeout(DEBUG_timerID)
DEBUG_timerID = null
if (hide_sec && (msg != null) && !DEBUG_always_visible) {
DEBUG_hide_sec += hide_sec
if (DEBUG_hide_sec > hide_sec + 1)
DEBUG_hide_sec -= 1
var time_diff = parseInt(DEBUG_hide_sec - (time - DEBUG_last_display_time)/1000)
if (time_diff < hide_sec)
time_diff = hide_sec
hide_sec = time_diff
}
}
if (msg != null) {
Ldebug.innerText = msg
if (!self.use_Silverlight || !self.SL_DEBUG_show || self.SL_windowless || !self.SL_loaded)
Ldebug.style.visibility = "inherit"
if (hide_sec && !DEBUG_always_visible) {
DEBUG_timerID = setTimeout('DEBUG_timerID=null; DEBUG_show()', hide_sec*1000)
}
}
else {
DEBUG_always_visible = false
Ldebug.style.visibility = "hidden"
}
// Silverlight START
if (self.SL_DEBUG_show)
SL_DEBUG_show(msg)
}
// For debug END
function toFileProtocol(url) {
return "file:///" + url.replace(/^(\w)\:/, "$1|").replace(/\\/g, "/").replace(/ /g, "%20").replace(/\&/g, "%26");
}
/*
// for standalone testing
require('electron').ipcRenderer.on('audio_BPM_detection_finished', function (event, message) {
alert(message)
});
*/
onload = function () {
if (/file\=([^\&]+)/.test(self.location.search)) {
const path = toFileProtocol(decodeURIComponent(RegExp.$1))
//"C:\\Users\\user\\Desktop\\Youthful Days' Graffiti (Extended Mix).mp3"
const BPM_by_id3 = (/BPM_by_id3\=([^\&]+)/.test(self.location.search)) ? parseFloat(RegExp.$1) : 0
//alert(BPM_by_id3)
const window_id = (/window_id\=([^\&]+)/.test(self.location.search)) ? parseInt(RegExp.$1) : -1
Audio_BPM_detection_portable(path, {BPM_by_id3:BPM_by_id3}, function (data) {
const data_all = { data:data, window_id:window_id }
try{
const e_remote = require('electron').remote || require('@electron/remote');
e_remote.getGlobal("mainWindow_postMessage")("audio_BPM_detection_finished", JSON.stringify(data_all))
setTimeout(function () { self.close() }, 500)
}
catch (err) {
DEBUG_show(err,0,1)
setTimeout(function () { self.close() }, 10*1000)
}
});
}
else {
DEBUG_show("ERROR: No file specified")
}
}
</script>
<style>
body {
margin: 0px;
overflow:hidden;
font-family: Segoe UI;
background-color:transparent;
}
</style>
</head>
<body>
<div style="position:absolute; top:0px; left:0px; width:300px">
<div id="Ldebug" style="position:absolute; top:0px; left:0px; color:black; font-size:xx-small; visibility:hidden; background-color:white; padding:3px; border-color:black; border-width:1px; border-style:solid; z-index:99"></div>
</div>
</body>
</html>