Skip to content

Commit

Permalink
Added new footstep sound option, some general fixes to voice commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tybayn committed Jan 5, 2024
1 parent 9b8ce94 commit d76528c
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 25 deletions.
25 changes: 14 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</script>
<script src="jquery/jquery-3.6.2.min.js"></script>
<script src="scripts-v3/ghost_template-v6.js"></script>
<link rel="stylesheet" href="styles-v3/style-v15.css"/>
<link rel="stylesheet" href="styles-v3/style-v16.css"/>
<link rel="stylesheet" href="styles-v3/style-mobile-v13.css"/>
<link rel="stylesheet" href="discord-v3/discord-v4.css" >
<link rel="stylesheet" href="wiki-v3/wiki-v5.css" >
Expand Down Expand Up @@ -435,11 +435,14 @@ <h3>Data Privacy</h3>
</div>
<div class="modifier_sound_select">
<img src="imgs/footsteps.png">
<label for="modifier_sound_type" onchange="setSoundType();saveSettings();">
<input type="checkbox" name="" id="modifier_sound_type">
<div class="toggle"></div>
</label>
<img src="imgs/metronome.png">
<select id="modifier_sound_type" onchange="setSoundType();saveSettings();">
<option value=0 selected>Default</option>
<option value=1>Asphalt / Concrete</option>
<option value=2>Carpet</option>
<option value=3>Gravel / Grass</option>
<option value=4>Wood</option>
<option value=5>Metronome</option>
</select>
</div>
<div class="modifier_note">(Click <span class="sound" onclick="toggleSound(1.7,'spirit0')">&#128266;</span> on cards to hear speed)</div>
<hr>
Expand Down Expand Up @@ -555,17 +558,17 @@ <h3>Data Privacy</h3>
document.getElementById("maps_box").style.left = "-388px";
}
</script>
<script src="scripts-v3/metronome-v12.js"></script>
<script src="scripts-v3/metronome-v13.js"></script>
<script src="scripts-v3/timer-v5.js"></script>
<script src="discord-v3/discord-v7.js"></script>
<script src="wiki-v3/wiki-v4.js"></script>
<script src="scripts-v3/filter-v21.js"></script>
<script src="wiki-v3/wiki-v5.js"></script>
<script src="scripts-v3/filter-v22.js"></script>
<script src="scripts-v3/wslink-v25.js"></script>
<script src="scripts-v3/zn-v12.js"></script>
<script src="events-v3/events-v2.js"></script>
<script src="feed-v3/feed-v2.js"></script>
<script src="scripts-v3/voice_en-v12.js"></script>
<script src="scripts-v3/voice_recognition-v13.js"></script>
<script src="scripts-v3/voice_en-v13.js"></script>
<script src="scripts-v3/voice_recognition-v14.js"></script>
<script src="scripts-v3/sparkles-v1.js"></script>
<script>
$(window).on('load', function() {
Expand Down
4 changes: 2 additions & 2 deletions scripts-v3/filter-v21.js → scripts-v3/filter-v22.js
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ function saveSettings(reset = false){
user_settings['offset'] = parseInt(document.getElementById("offset_value").innerText.replace(/\d+(?:-\d+)+/g,""))
user_settings['ghost_modifier'] = parseInt(document.getElementById("ghost_modifier_speed").value)
user_settings['num_evidences'] = parseInt(document.getElementById("num_evidence").value)
user_settings['sound_type'] = document.getElementById("modifier_sound_type").checked ? 1 : 0;
user_settings['sound_type'] = document.getElementById("modifier_sound_type").value;
user_settings['speed_logic_type'] = document.getElementById("speed_logic_type").checked ? 1 : 0;
user_settings['bpm_type'] = document.getElementById("bpm_type").checked ? 1 : 0;
user_settings['bpm'] = reset ? 0 : parseInt(document.getElementById('input_bpm').innerHTML.split("<br>")[0])
Expand All @@ -1221,7 +1221,7 @@ function loadSettings(){
document.getElementById("offset_value").innerText = ` ${user_settings['offset'] ?? 0}% `
document.getElementById("ghost_modifier_speed").value = user_settings['ghost_modifier'] ?? 2
document.getElementById("num_evidence").value = user_settings['num_evidences'] ?? 3
document.getElementById("modifier_sound_type").checked = user_settings['sound_type'] ?? 0 == 1
document.getElementById("modifier_sound_type").value = user_settings['sound_type'] ?? 0
document.getElementById("speed_logic_type").checked = user_settings['speed_logic_type'] ?? 0 == 1
document.getElementById("bpm_type").checked = user_settings['bpm_type'] ?? 0 == 1
if (user_settings['domo_side'] == 1){
Expand Down
57 changes: 49 additions & 8 deletions scripts-v3/metronome-v12.js → scripts-v3/metronome-v13.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@

var snd = [new Audio('https://zero-network.net/phasmophobia/static/assets/footstep.mp3'),new Audio('assets/click.mp3')];
snd[0].preload = 'auto';
snd[1].preload = 'auto';
snd[0].load();
snd[1].load();
var snd = {
0:[new Audio('https://zero-network.net/phasmophobia/static/assets/footstep.mp3')],
1:[new Audio('https://zero-network.net/phasmophobia/static/assets/footstep_asphalt_2.mp3'),new Audio('https://zero-network.net/phasmophobia/static/assets/footstep_asphalt_3.mp3')],
2:[new Audio('https://zero-network.net/phasmophobia/static/assets/footstep_carpet_2.mp3'),new Audio('https://zero-network.net/phasmophobia/static/assets/footstep_carpet_3.mp3')],
3:[new Audio('https://zero-network.net/phasmophobia/static/assets/footstep_gravel.mp3'),new Audio('https://zero-network.net/phasmophobia/static/assets/footstep_gravel_2.mp3')],
4:[new Audio('https://zero-network.net/phasmophobia/static/assets/footstep_wood_2.mp3'),new Audio('https://zero-network.net/phasmophobia/static/assets/footstep_wood_3.mp3')],
5:[new Audio('assets/click.mp3')]
}
snd[0][0].preload = 'auto';
snd[1][0].preload = 'auto';
snd[1][1].preload = 'auto';
snd[2][0].preload = 'auto';
snd[2][1].preload = 'auto';
snd[3][0].preload = 'auto';
snd[3][1].preload = 'auto';
snd[4][0].preload = 'auto';
snd[4][1].preload = 'auto';
snd[5][0].preload = 'auto';

snd[0][0].load();
snd[1][0].load();
snd[1][1].load();
snd[2][0].load();
snd[2][1].load();
snd[3][0].load();
snd[3][1].load();
snd[4][0].load();
snd[4][1].load();
snd[5][0].load();

var speed = 1.7
var tempo = 115
Expand All @@ -12,7 +36,9 @@ var muteTimerToggle = false
var muteTimerCountdown = false
var running = false
var start = Date.now()
var step_cnt = 0
var snd_choice = 0
var prev_r = 0
var offset = 0
var additional_ghost_data = ["hantu","moroi","thaye"]
var additional_ghost_var = [0.18,0.085,0.175]
Expand Down Expand Up @@ -53,7 +79,8 @@ function toggleSound(set_tempo,id){
}

function setSoundType(){
snd_choice = document.getElementById("modifier_sound_type").checked ? 1 : 0;
snd_choice = document.getElementById("modifier_sound_type").value;
step_cnt = 0
}

function setTempo(){
Expand All @@ -75,14 +102,28 @@ function adjustOffset(v){
function startMetronome() {
running = true
var interval = 1000 / (tempo / 60)
var footstep = snd[snd_choice].cloneNode()
var r = Math.round(Math.random() * (snd[snd_choice].length-1) )
prev_r = r
var footstep = snd[snd_choice][r].cloneNode()
footstep.volume = volume
footstep.play();
setTimeout(step, interval);
function step() {
if (Date.now() - start <= 5000) {
var interval = 1000 / (tempo / 60)
var footstep = snd[snd_choice].cloneNode()
if(step_cnt > 2){
var r = Math.round(Math.random() * (snd[snd_choice].length-1) )
if (prev_r != r){
prev_r = r
step_cnt = 0
}
var footstep = snd[snd_choice][r].cloneNode()
}
else{
var footstep = snd[snd_choice][prev_r].cloneNode()
step_cnt += 1
}

footstep.volume = volume
footstep.play();
setTimeout(step, interval);
Expand Down
1 change: 1 addition & 0 deletions scripts-v3/voice_en-v12.js → scripts-v3/voice_en-v13.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const ZNLANG = {
],
"guess thaye":["guessing"],
"start":["stat"],
"timer":["i'm a","im a"],
"domo":["demo"]
},
"ghosts":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,25 @@ function parse_speech(vtext){
}

if (("webkitSpeechRecognition" in window || "speechRecognition" in window) && !navigator.userAgent.toLowerCase().match(/firefox|fxios|opr/) && !('brave' in navigator)) {
let speechRecognition = new webkitSpeechRecognition() || new speechRecognition();
let speechRecognition = new webkitSpeechRecognition() || new SpeechRecognition();
let speechRecognitionList = new webkitSpeechGrammarList() || new SpeechGrammarList();
let stop_listen = true

let ghost_grammar = `#JSGF V1.0; grammar ghosts; public <ghost> = ${all_ghosts.join(" | ")}`
let evidence_grammar = `#JSGF V1.0; grammar evidence; public <evidence> = ${all_evidence.join(" | ")}`
let speed_grammar = `#JSGF V1.0; grammar speed; pubilc <speed> = ${all_speed.join(" | ")}`
let sanity_grammar = `#JSGF V1.0; grammar sanity; public <sanity> = ${all_sanity.join(" | ")}`
let maps_grammar = `#JSGF V1.0; grammar maps; public <map> = tanglewood | edgefield | ridgeview | grafton | willow | brownstone | bleasdale | sunny meadows | sm | restricted | courtyard | male | female | wing | hospital | prison | maple lodge | woodwind | drive | road | court | farmhouse | high school | campsite | camp`
let command_grammar = `#JSGF V1.0; grammar commands; public <command> = evidence | speed | sanity | not | clear | select | remove | undo | timer | cooldown | start | stop | number | of | difficulty | monkey paw | has | line of sight | show | info | filters | tools | percent | map | maps | reset | journal | cheat sheet | stop | listening`

speechRecognitionList.addFromString(ghost_grammar,1)
speechRecognitionList.addFromString(evidence_grammar,1)
speechRecognitionList.addFromString(speed_grammar,1)
speechRecognitionList.addFromString(sanity_grammar,1)
speechRecognitionList.addFromString(maps_grammar,1)
speechRecognitionList.addFromString(command_grammar,1)

speechRecognition.grammars = speechRecognitionList

speechRecognition.continuous = false;
speechRecognition.interimResults = false;
Expand Down
17 changes: 16 additions & 1 deletion styles-v3/style-v15.css → styles-v3/style-v16.css
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,11 @@ hr{
cursor: pointer;
}

.num_evidence option{
background-color: #161615;
cursor: pointer;
}

#game_mode{
grid-column: 1;
grid-row: 2;
Expand Down Expand Up @@ -1082,7 +1087,17 @@ hr{
}

#modifier_sound_type {
display: none;
border: none;
color: #ccc;
box-shadow: inset 0 0 10px #161615;
background: rgba(0,0,0,0.25);
font-size: 11px;
cursor: pointer;
}

#modifier_sound_type option{
background-color: #161615;
cursor: pointer;
}

.speed_logic_select{
Expand Down
4 changes: 2 additions & 2 deletions wiki-v3/wiki-v4.js → wiki-v3/wiki-v5.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function startFlicker(elem){
function flickerOn(){
if (flickering){
$(obj).show()
r = Math.floor((Math.random() * (vis_max - vis_min) + vis_min) * 1000)
r = Math.round((Math.random() * (vis_max - vis_min) + vis_min) * 1000)
setTimeout(flickerOff,r,r/1000)
}
}
Expand All @@ -74,7 +74,7 @@ function startFlicker(elem){
$(obj).hide()
t_max = Math.min(flicker_max - on, invis_max)
t_min = Math.max(flicker_min - on, invis_min)
r = Math.floor((Math.random() * (t_max - t_min) + t_min) * 1000)
r = Math.round((Math.random() * (t_max - t_min) + t_min) * 1000)
setTimeout(flickerOn,r)
}
}
Expand Down

0 comments on commit d76528c

Please sign in to comment.