Finished VAD VAD impl

canary
WolverinDEV 2018-03-08 15:40:31 +01:00
parent 1ff845f896
commit 0140846d1b
8 changed files with 403 additions and 200 deletions

View File

@ -3,10 +3,13 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="978d055d-27d3-431a-bd34-e5e79bb273b3" name="Default" comment=""> <list default="true" id="978d055d-27d3-431a-bd34-e5e79bb273b3" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/css/ts/chat.css" afterPath="$PROJECT_DIR$/css/ts/chat.css" /> <change beforePath="$PROJECT_DIR$/css/general.css" afterPath="$PROJECT_DIR$/css/general.css" />
<change beforePath="$PROJECT_DIR$/js/InfoBar.js" afterPath="$PROJECT_DIR$/js/InfoBar.js" /> <change beforePath="$PROJECT_DIR$/index.html" afterPath="$PROJECT_DIR$/index.html" />
<change beforePath="$PROJECT_DIR$/js/InfoBar.js.map" afterPath="$PROJECT_DIR$/js/InfoBar.js.map" /> <change beforePath="$PROJECT_DIR$/js/ui/modal/ModalSettings.ts" afterPath="$PROJECT_DIR$/js/ui/modal/ModalSettings.ts" />
<change beforePath="$PROJECT_DIR$/js/InfoBar.ts" afterPath="$PROJECT_DIR$/js/InfoBar.ts" /> <change beforePath="$PROJECT_DIR$/js/utils/modal.js" afterPath="$PROJECT_DIR$/js/utils/modal.js" />
<change beforePath="$PROJECT_DIR$/js/utils/modal.js.map" afterPath="$PROJECT_DIR$/js/utils/modal.js.map" />
<change beforePath="$PROJECT_DIR$/js/utils/modal.ts" afterPath="$PROJECT_DIR$/js/utils/modal.ts" />
<change beforePath="$PROJECT_DIR$/js/voice/VoiceRecorder.ts" afterPath="$PROJECT_DIR$/js/voice/VoiceRecorder.ts" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" /> <option name="TRACKING_ENABLED" value="true" />
@ -29,100 +32,90 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="client.ts" pinned="false" current-in-tab="false"> <file leaf-file-name="AudioController.ts" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/client.ts"> <entry file="file://$PROJECT_DIR$/js/voice/AudioController.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="442"> <state relative-caret-position="424">
<caret line="120" column="42" lean-forward="false" selection-start-line="120" selection-start-column="42" selection-end-line="120" selection-end-column="42" /> <caret line="99" column="5" lean-forward="true" selection-start-line="99" selection-start-column="5" selection-end-line="99" selection-end-column="5" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="chat.css" pinned="false" current-in-tab="true"> <file leaf-file-name="VoiceRecorder.ts" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/css/ts/chat.css"> <entry file="file://$PROJECT_DIR$/js/voice/VoiceRecorder.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="834"> <state relative-caret-position="424">
<caret line="101" column="21" lean-forward="false" selection-start-line="101" selection-start-column="21" selection-end-line="101" selection-end-column="21" /> <caret line="109" column="9" lean-forward="true" selection-start-line="109" selection-start-column="9" selection-end-line="109" selection-end-column="9" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="client.css" pinned="false" current-in-tab="false"> <file leaf-file-name="ModalSettings.ts" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/css/ts/client.css"> <entry file="file://$PROJECT_DIR$/js/ui/modal/ModalSettings.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="414"> <state relative-caret-position="352">
<caret line="23" column="51" lean-forward="false" selection-start-line="23" selection-start-column="51" selection-end-line="23" selection-end-column="51" /> <caret line="43" column="27" lean-forward="false" selection-start-line="43" selection-start-column="27" selection-end-line="43" selection-end-column="27" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="index.d.ts" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/node_modules/@types/jquery/index.d.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="290">
<caret line="608" column="4" lean-forward="false" selection-start-line="608" selection-start-column="4" selection-end-line="608" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="modal.ts" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/utils/modal.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="524">
<caret line="105" column="23" lean-forward="true" selection-start-line="105" selection-start-column="23" selection-end-line="105" selection-end-column="23" />
<folding>
<marker date="1520516687898" expanded="true" signature="2648:2655" ph="×" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="index.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="215">
<caret line="193" column="101" lean-forward="false" selection-start-line="193" selection-start-column="81" selection-end-line="193" selection-end-column="101" />
<folding>
<element signature="n#style#0;n#div#0;n#div#0;n#div#1;n#div#3;n#div#0;n#div#2;n#div#0;n#x-content#0;n#x-entry#1;n#x-tab#0;n#template#2;n#body#0;n#html#0;n#!!top" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="general.css" pinned="false" current-in-tab="false"> <file leaf-file-name="general.css" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/css/general.css"> <entry file="file://$PROJECT_DIR$/css/general.css">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1854"> <state relative-caret-position="614">
<caret line="103" column="0" lean-forward="true" selection-start-line="103" selection-start-column="0" selection-end-line="103" selection-end-column="0" /> <caret line="274" column="1" lean-forward="false" selection-start-line="274" selection-start-column="1" selection-end-line="274" selection-end-column="1" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="tab.css" pinned="false" current-in-tab="false"> <file leaf-file-name="lib.es6.d.ts" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/css/ts/tab.css"> <entry file="file://$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external/lib.es6.d.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="666"> <state relative-caret-position="290">
<caret line="37" column="14" lean-forward="true" selection-start-line="37" selection-start-column="14" selection-end-line="37" selection-end-column="14" /> <caret line="7199" column="4" lean-forward="false" selection-start-line="7199" selection-start-column="4" selection-end-line="7199" selection-end-column="4" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="connection.ts" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/connection.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="182">
<caret line="480" column="30" lean-forward="false" selection-start-line="480" selection-start-column="30" selection-end-line="480" selection-end-column="30" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="InfoBar.ts" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/InfoBar.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="532">
<caret line="83" column="52" lean-forward="false" selection-start-line="83" selection-start-column="52" selection-end-line="83" selection-end-column="52" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="view.ts" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/ui/view.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="298">
<caret line="154" column="4" lean-forward="false" selection-start-line="154" selection-start-column="4" selection-end-line="154" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="chat.ts" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/chat.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="308">
<caret line="181" column="36" lean-forward="false" selection-start-line="181" selection-start-column="36" selection-end-line="181" selection-end-column="36" />
<folding>
<marker date="1520448117338" expanded="true" signature="1900:1910" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
</leaf> </leaf>
</component> </component>
<component name="FileTemplateManagerImpl"> <component name="FileTemplateManagerImpl">
@ -146,6 +139,7 @@
<find>update</find> <find>update</find>
<find>on_data</find> <find>on_data</find>
<find>on_connected</find> <find>on_connected</find>
<find>vad_vad_bar_filler</find>
</findStrings> </findStrings>
</component> </component>
<component name="Git.Settings"> <component name="Git.Settings">
@ -161,12 +155,9 @@
<option value="$PROJECT_DIR$/js/voice/AudioResampler.ts" /> <option value="$PROJECT_DIR$/js/voice/AudioResampler.ts" />
<option value="$PROJECT_DIR$/js/voice/VoiceRecoder.ts" /> <option value="$PROJECT_DIR$/js/voice/VoiceRecoder.ts" />
<option value="$PROJECT_DIR$/js/main.ts" /> <option value="$PROJECT_DIR$/js/main.ts" />
<option value="$PROJECT_DIR$/js/utils/modal.ts" />
<option value="$PROJECT_DIR$/css/ts/tab.css" /> <option value="$PROJECT_DIR$/css/ts/tab.css" />
<option value="$PROJECT_DIR$/js/ui/modal/ModalSettings.ts" />
<option value="$PROJECT_DIR$/css/ts/client.css" /> <option value="$PROJECT_DIR$/css/ts/client.css" />
<option value="$PROJECT_DIR$/js/ui/ControlBar.ts" /> <option value="$PROJECT_DIR$/js/ui/ControlBar.ts" />
<option value="$PROJECT_DIR$/js/voice/VoiceRecorder.ts" />
<option value="$PROJECT_DIR$/js/ui/server.ts" /> <option value="$PROJECT_DIR$/js/ui/server.ts" />
<option value="$PROJECT_DIR$/js/ui/view.ts" /> <option value="$PROJECT_DIR$/js/ui/view.ts" />
<option value="$PROJECT_DIR$/js/settings.ts" /> <option value="$PROJECT_DIR$/js/settings.ts" />
@ -177,8 +168,6 @@
<option value="$PROJECT_DIR$/css/ts/icons.css" /> <option value="$PROJECT_DIR$/css/ts/icons.css" />
<option value="$PROJECT_DIR$/js/FileManager.ts" /> <option value="$PROJECT_DIR$/js/FileManager.ts" />
<option value="$PROJECT_DIR$/js/ui/modal/ModalCreateChannel.ts" /> <option value="$PROJECT_DIR$/js/ui/modal/ModalCreateChannel.ts" />
<option value="$PROJECT_DIR$/css/general.css" />
<option value="$PROJECT_DIR$/index.html" />
<option value="$PROJECT_DIR$/js/codec/Codec.ts" /> <option value="$PROJECT_DIR$/js/codec/Codec.ts" />
<option value="$PROJECT_DIR$/js/voice/VoiceHandler.ts" /> <option value="$PROJECT_DIR$/js/voice/VoiceHandler.ts" />
<option value="$PROJECT_DIR$/js/voice/AudioController.ts" /> <option value="$PROJECT_DIR$/js/voice/AudioController.ts" />
@ -187,6 +176,12 @@
<option value="$PROJECT_DIR$/js/client.ts" /> <option value="$PROJECT_DIR$/js/client.ts" />
<option value="$PROJECT_DIR$/js/InfoBar.ts" /> <option value="$PROJECT_DIR$/js/InfoBar.ts" />
<option value="$PROJECT_DIR$/css/ts/chat.css" /> <option value="$PROJECT_DIR$/css/ts/chat.css" />
<option value="$PROJECT_DIR$/js/utils/modal.ts" />
<option value="$PROJECT_DIR$/css/general.css" />
<option value="$PROJECT_DIR$/index.html" />
<option value="$PROJECT_DIR$/js/voice/VoiceRecorder.js" />
<option value="$PROJECT_DIR$/js/voice/VoiceRecorder.ts" />
<option value="$PROJECT_DIR$/js/ui/modal/ModalSettings.ts" />
</list> </list>
</option> </option>
</component> </component>
@ -352,7 +347,7 @@
<updated>1519749313999</updated> <updated>1519749313999</updated>
<workItem from="1519749316100" duration="9698000" /> <workItem from="1519749316100" duration="9698000" />
<workItem from="1520012895408" duration="13944000" /> <workItem from="1520012895408" duration="13944000" />
<workItem from="1520175420796" duration="57014000" /> <workItem from="1520175420796" duration="67767000" />
</task> </task>
<task id="LOCAL-00001" summary="A lot of updates :)"> <task id="LOCAL-00001" summary="A lot of updates :)">
<created>1520446012318</created> <created>1520446012318</created>
@ -368,14 +363,22 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1520450076160</updated> <updated>1520450076160</updated>
</task> </task>
<option name="localTasksCounter" value="3" /> <task id="LOCAL-00003" summary="Fixed another stuff">
<created>1520452384034</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1520452384034</updated>
</task>
<option name="localTasksCounter" value="4" />
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="80656000" /> <option name="totallyTimeSpent" value="91409000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="65" y="-4" width="1215" height="1028" extended-state="6" /> <frame x="65" y="-4" width="1215" height="1028" extended-state="6" />
<editor active="true" />
<layout> <layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
@ -384,8 +387,8 @@
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TypeScript" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.2483731" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="TypeScript" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.2483731" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23045267" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23045267" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.14320987" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.16049382" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Inspection Results" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.329718" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" /> <window_info id="Inspection Results" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.329718" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
@ -464,7 +467,8 @@
<option name="CHECK_NEW_TODO" value="false" /> <option name="CHECK_NEW_TODO" value="false" />
<MESSAGE value="A lot of updates :)" /> <MESSAGE value="A lot of updates :)" />
<MESSAGE value="Fixing some stuff" /> <MESSAGE value="Fixing some stuff" />
<option name="LAST_COMMIT_MESSAGE" value="Fixing some stuff" /> <MESSAGE value="Fixed another stuff" />
<option name="LAST_COMMIT_MESSAGE" value="Fixed another stuff" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
@ -473,14 +477,6 @@
<watches-manager /> <watches-manager />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/node_modules/@types/emscripten/index.d.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1764">
<caret line="103" column="13" lean-forward="false" selection-start-line="103" selection-start-column="13" selection-end-line="103" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external/lib.es6.d.ts"> <entry file="file://$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external/lib.es6.d.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="35856"> <state relative-caret-position="35856">
@ -578,22 +574,6 @@
<state /> <state />
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/js/voice/AudioResampler.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="378">
<caret line="21" column="1" lean-forward="false" selection-start-line="21" selection-start-column="1" selection-end-line="21" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/node_modules/@types/jquery/index.d.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="34" column="20" lean-forward="false" selection-start-line="34" selection-start-column="14" selection-end-line="34" selection-end-column="20" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/contextMenu.ts"> <entry file="file://$PROJECT_DIR$/js/contextMenu.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="188"> <state relative-caret-position="188">
@ -602,14 +582,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external/lib.es6.d.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="269">
<caret line="7190" column="10" lean-forward="false" selection-start-line="7190" selection-start-column="10" selection-end-line="7190" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ui/server.ts"> <entry file="file://$PROJECT_DIR$/js/ui/server.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="341"> <state relative-caret-position="341">
@ -666,16 +638,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/js/utils/modal.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="108">
<caret line="6" column="21" lean-forward="false" selection-start-line="6" selection-start-column="21" selection-end-line="6" selection-end-column="21" />
<folding>
<marker date="1520348245429" expanded="true" signature="2079:2086" ph="×" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/img/client_icon_sprite.svg"> <entry file="file://$PROJECT_DIR$/img/client_icon_sprite.svg">
<provider selected="true" editor-type-id="images"> <provider selected="true" editor-type-id="images">
<state /> <state />
@ -729,14 +691,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/js/ui/modal/ModalSettings.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-198">
<caret line="12" column="31" lean-forward="false" selection-start-line="12" selection-start-column="23" selection-end-line="12" selection-end-column="31" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ui/channel.ts"> <entry file="file://$PROJECT_DIR$/js/ui/channel.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="263"> <state relative-caret-position="263">
@ -748,19 +702,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-90">
<caret line="28" column="87" lean-forward="true" selection-start-line="28" selection-start-column="87" selection-end-line="28" selection-end-column="87" />
<folding>
<element signature="n#style#0;n#div#0;n#body#0;n#html#0;n#!!top" expanded="true" />
<element signature="n#style#0;n#div#1;n#div#0;n#div#1;n#div#0;n#body#0;n#html#0;n#!!top" expanded="true" />
<element signature="n#style#0;n#div#0;n#x-content#0;n#x-entry#0;n#x-tab#0;n#template#0;n#body#0;n#html#0;n#!!top" expanded="true" />
<element signature="n#style#0;n#div#0;n#div#0;n#x-content#0;n#x-entry#0;n#x-tab#0;n#template#0;n#body#0;n#html#0;n#!!top" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/codec/Codec.ts"> <entry file="file://$PROJECT_DIR$/js/codec/Codec.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="501"> <state relative-caret-position="501">
@ -777,22 +718,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/js/voice/VoiceRecorder.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="192">
<caret line="15" column="11" lean-forward="false" selection-start-line="15" selection-start-column="4" selection-end-line="15" selection-end-column="11" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/voice/AudioController.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="496">
<caret line="99" column="5" lean-forward="true" selection-start-line="99" selection-start-column="5" selection-end-line="99" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ui/ControlBar.ts"> <entry file="file://$PROJECT_DIR$/js/ui/ControlBar.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="298"> <state relative-caret-position="298">
@ -819,14 +744,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/css/general.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1854">
<caret line="103" column="0" lean-forward="true" selection-start-line="103" selection-start-column="0" selection-end-line="103" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/css/ts/client.css"> <entry file="file://$PROJECT_DIR$/css/ts/client.css">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="414"> <state relative-caret-position="414">
@ -835,16 +752,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/js/voice/VoiceHandler.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="140" column="44" lean-forward="false" selection-start-line="140" selection-start-column="44" selection-end-line="140" selection-end-column="44" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/client.ts"> <entry file="file://$PROJECT_DIR$/js/client.ts">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="442"> <state relative-caret-position="442">
@ -887,5 +794,99 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/js/voice/AudioResampler.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="378">
<caret line="21" column="1" lean-forward="false" selection-start-line="21" selection-start-column="1" selection-end-line="21" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/voice/AudioController.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="424">
<caret line="99" column="5" lean-forward="true" selection-start-line="99" selection-start-column="5" selection-end-line="99" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/voice/VoiceHandler.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="140" column="44" lean-forward="false" selection-start-line="140" selection-start-column="44" selection-end-line="140" selection-end-column="44" />
<folding>
<element signature="n#!!doc" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/utils/modal.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="524">
<caret line="105" column="23" lean-forward="true" selection-start-line="105" selection-start-column="23" selection-end-line="105" selection-end-column="23" />
<folding>
<marker date="1520516687898" expanded="true" signature="2648:2655" ph="×" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/css/general.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="614">
<caret line="274" column="1" lean-forward="false" selection-start-line="274" selection-start-column="1" selection-end-line="274" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="215">
<caret line="193" column="101" lean-forward="false" selection-start-line="193" selection-start-column="81" selection-end-line="193" selection-end-column="101" />
<folding>
<element signature="n#style#0;n#div#0;n#div#0;n#div#1;n#div#3;n#div#0;n#div#2;n#div#0;n#x-content#0;n#x-entry#1;n#x-tab#0;n#template#2;n#body#0;n#html#0;n#!!top" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/node_modules/@types/jquery/index.d.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="290">
<caret line="608" column="4" lean-forward="false" selection-start-line="608" selection-start-column="4" selection-end-line="608" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$APPLICATION_HOME_DIR$/plugins/JavaScriptLanguage/jsLanguageServicesImpl/external/lib.es6.d.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="290">
<caret line="7199" column="4" lean-forward="false" selection-start-line="7199" selection-start-column="4" selection-end-line="7199" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/voice/VoiceRecorder.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="290">
<caret line="85" column="8" lean-forward="false" selection-start-line="85" selection-start-column="8" selection-end-line="85" selection-end-column="8" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/voice/VoiceRecorder.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="424">
<caret line="109" column="9" lean-forward="true" selection-start-line="109" selection-start-column="9" selection-end-line="109" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/ui/modal/ModalSettings.ts">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="352">
<caret line="43" column="27" lean-forward="false" selection-start-line="43" selection-start-column="27" selection-end-line="43" selection-end-column="27" />
<folding />
</state>
</provider>
</entry>
</component> </component>
</project> </project>

View File

@ -246,4 +246,47 @@ html {
border: gray solid; border: gray solid;
border-width: 2px; border-width: 2px;
border-radius: 0px 6px 6px 6px; border-radius: 0px 6px 6px 6px;
}
.vad_vad_bar {
position: relative;
width: 100%;
height: 20px;
}
.vad_vad_bar .vad_vad_bar_filler {
background-color: green;
width: 50%;
height: 100%;
}
/* The slider itself */
.vad_vad_slider {
margin: 0px;
background-color: gray;
-webkit-appearance: none; /* Override default CSS styles */
appearance: none;
width: 100%;
height: 100%;
outline: none;
opacity: 0.7; /* Set transparency (for mouse-over effects on hover) */
-webkit-transition: .2s; /* 0.2 seconds transition on hover */
transition: opacity .2s;
}
/* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */
.vad_vad_slider::-webkit-slider-thumb {
-webkit-appearance: none; /* Override default look */
appearance: none;
width: 2px; /* Set a specific slider handle width */
height: 20px; /* Slider handle height */
background: #000000; /* Green background */
cursor: pointer; /* Cursor on hover */
}
.vad_vad_slider::-moz-range-thumb {
width: 2px; /* Set a specific slider handle width */
height: 100%; /* Slider handle height */
background: #000000; /* Green background */
cursor: pointer; /* Cursor on hover */
} }

View File

@ -191,9 +191,14 @@
<button class="vat_ppt_key">Uninitialised</button> <button class="vat_ppt_key">Uninitialised</button>
</div> </div>
<div class="vad_type_settings vad_type_vad"> <div class="vad_type_settings vad_type_vad">
<a>Voice activity threshold</a> <div>Voice activity threshold (<a class="vad_vad_slider_value">20</a>%)</div>
<div class="vad_threshold_selector"> <div class="vad_vad_threshold_selector">
<input type="range" min="0" max="100" value="50" class="vad_slider"> <div class="vad_vad_bar">
<div style="width: 100%; height: 100%; position: absolute">
<div class="vad_vad_bar_filler"></div>
</div>
<input type="range" min="0" max="100" value="50" class="vad_vad_slider">
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,12 +4,13 @@
namespace Modals { namespace Modals {
export function spawnSettingsModal() { export function spawnSettingsModal() {
const modal = createModal({ let modal;
modal = createModal({
header: "Settings", header: "Settings",
body: () => { body: () => {
let template = $("#tmpl_settings").tmpl(); let template = $("#tmpl_settings").tmpl();
template = $.spawn("div").append(template); template = $.spawn("div").append(template);
initialiseSettingListeners(template = template.tabify()); initialiseSettingListeners(modal,template = template.tabify());
return template; return template;
}, },
footer: () => { footer: () => {
@ -31,16 +32,15 @@ namespace Modals {
modal.open(); modal.open();
} }
function initialiseSettingListeners(tag: JQuery) { function initialiseSettingListeners(modal: Modal, tag: JQuery) {
//Voice //Voice
initialiseVoiceListeners(tag.find(".settings_voice")); initialiseVoiceListeners(modal, tag.find(".settings_voice"));
} }
function initialiseVoiceListeners(tag: JQuery) { function initialiseVoiceListeners(modal: Modal, tag: JQuery) {
let currentVAD = globalClient.settings.global("vad_type"); let currentVAD = globalClient.settings.global("vad_type");
tag.find("input[type=radio][name=\"vad_type\"]").change(function (this: HTMLButtonElement) { tag.find("input[type=radio][name=\"vad_type\"]").change(function (this: HTMLButtonElement) {
console.log(this.value + " => " + $(this).attr("display"));
tag.find(".vad_settings .vad_type").text($(this).attr("display")); tag.find(".vad_settings .vad_type").text($(this).attr("display"));
tag.find(".vad_settings .vad_type_settings").hide(); tag.find(".vad_settings .vad_type_settings").hide();
tag.find(".vad_settings .vad_type_" + this.value).show(); tag.find(".vad_settings .vad_type_" + this.value).show();
@ -51,6 +51,17 @@ namespace Modals {
case "ppt": case "ppt":
let keyCode: number = Number.parseInt(globalClient.settings.global("vad_ppt_key", Key.T.toString())); let keyCode: number = Number.parseInt(globalClient.settings.global("vad_ppt_key", Key.T.toString()));
tag.find(".vat_ppt_key").text(String.fromCharCode(keyCode)); tag.find(".vat_ppt_key").text(String.fromCharCode(keyCode));
break;
case "vad":
let slider = tag.find(".vad_vad_slider");
let vad: VoiceActivityDetectorVAD = globalClient.voiceConnection.voiceRecorder.getVADHandler() as VoiceActivityDetectorVAD;
slider.val(vad.percentageThreshold);
slider.trigger("change");
vad.percentage_listener = per => {
tag.find(".vad_vad_bar_filler")
.css("width", per + "%");
};
break;
} }
}); });
@ -58,7 +69,6 @@ namespace Modals {
currentVAD = "ppt"; currentVAD = "ppt";
let elm = tag.find("input[type=radio][name=\"vad_type\"][value=\"" + currentVAD + "\"]"); let elm = tag.find("input[type=radio][name=\"vad_type\"][value=\"" + currentVAD + "\"]");
elm.attr("checked", "true"); elm.attr("checked", "true");
elm.trigger("change");
tag.find(".vat_ppt_key").click(function () { tag.find(".vat_ppt_key").click(function () {
@ -68,7 +78,6 @@ namespace Modals {
let head = $.spawn("div"); let head = $.spawn("div");
head.text("Type the key you wish"); head.text("Type the key you wish");
head.css("background-color", "blue"); head.css("background-color", "blue");
console.log("SPAWNED!");
return head; return head;
}, },
footer: "" footer: ""
@ -82,5 +91,26 @@ namespace Modals {
}); });
modal.open(); modal.open();
}); });
//VAD VAD
let slider = tag.find(".vad_vad_slider");
slider.on("input change", () => {
globalClient.settings.changeGlobal("vad_threshold", slider.val().toString());
let vad = globalClient.voiceConnection.voiceRecorder.getVADHandler();
if(vad instanceof VoiceActivityDetectorVAD)
vad.percentageThreshold = slider.val() as number;
tag.find(".vad_vad_slider_value").text(slider.val().toString());
});
modal.properties.registerCloseListener(() => {
let vad = globalClient.voiceConnection.voiceRecorder.getVADHandler();
if(vad instanceof VoiceActivityDetectorVAD)
vad.percentage_listener = undefined;
});
//Trigger radio button select for VAD setting setup
elm.trigger("change");
} }
} }

View File

@ -44,13 +44,32 @@ class ModalProperties {
this.hight = "auto"; this.hight = "auto";
this.closeable = true; this.closeable = true;
} }
registerCloseListener(listener) {
if (this.closeListener) {
if ($.isArray(this.closeListener))
this.closeListener.push(listener);
else
this.closeListener = [this.closeListener, listener];
}
else
this.closeListener = listener;
return this;
}
triggerClose() {
if ($.isArray(this.closeListener))
for (let listener of this.closeListener)
listener();
else
this.closeListener();
}
} }
class Modal { class Modal {
constructor(props) { constructor(props) {
this.properties = props; this.properties = props;
this._create();
} }
_create() { _create() {
if (this.htmlTag)
return;
let modal = $.spawn("div"); let modal = $.spawn("div");
modal.addClass("modal"); modal.addClass("modal");
let content = $.spawn("div"); let content = $.spawn("div");
@ -72,6 +91,7 @@ class Modal {
this.htmlTag = modal; this.htmlTag = modal;
} }
open() { open() {
this._create();
this.htmlTag.appendTo($("body")); this.htmlTag.appendTo($("body"));
this.htmlTag.show(); this.htmlTag.show();
} }
@ -80,7 +100,7 @@ class Modal {
this.htmlTag.animate({ opacity: 0 }, () => { this.htmlTag.animate({ opacity: 0 }, () => {
_this.htmlTag.detach(); _this.htmlTag.detach();
}); });
this.properties.closeListener(); this.properties.triggerClose();
} }
} }
function createModal(data) { function createModal(data) {

File diff suppressed because one or more lines are too long

View File

@ -41,12 +41,28 @@ class ModalProperties {
body: BodyCreator = () => "BODY"; body: BodyCreator = () => "BODY";
footer: BodyCreator = () => "FOOTER"; footer: BodyCreator = () => "FOOTER";
closeListener: () => void = () => {}; closeListener: (() => void) | (() => void)[] = () => {};
registerCloseListener(listener: () => void) : this {
if(this.closeListener) {
if($.isArray(this.closeListener))
this.closeListener.push(listener);
else
this.closeListener = [this.closeListener, listener];
} else this.closeListener = listener;
return this;
}
width: number | string = "60%"; width: number | string = "60%";
hight: number | string = "auto"; hight: number | string = "auto";
closeable: boolean = true; closeable: boolean = true;
triggerClose(){
if($.isArray(this.closeListener))
for(let listener of this.closeListener)
listener();
else
this.closeListener();
}
} }
class Modal { class Modal {
@ -55,10 +71,10 @@ class Modal {
constructor(props: ModalProperties) { constructor(props: ModalProperties) {
this.properties = props; this.properties = props;
this._create();
} }
private _create() { private _create() {
if(this.htmlTag) return;
let modal = $.spawn("div"); let modal = $.spawn("div");
modal.addClass("modal"); modal.addClass("modal");
@ -87,6 +103,7 @@ class Modal {
} }
open() { open() {
this._create();
this.htmlTag.appendTo($("body")); this.htmlTag.appendTo($("body"));
this.htmlTag.show(); this.htmlTag.show();
} }
@ -96,7 +113,7 @@ class Modal {
this.htmlTag.animate({opacity: 0}, () => { this.htmlTag.animate({opacity: 0}, () => {
_this.htmlTag.detach(); _this.htmlTag.detach();
}); });
this.properties.closeListener(); this.properties.triggerClose();
} }
} }

View File

@ -2,9 +2,19 @@
/// <reference path="../utils/modal.ts" /> /// <reference path="../utils/modal.ts" />
abstract class VoiceActivityDetector { abstract class VoiceActivityDetector {
protected handle: VoiceRecorder;
abstract shouldRecord(buffer: AudioBuffer) : boolean; abstract shouldRecord(buffer: AudioBuffer) : boolean;
initialise(handle: VoiceRecorder) {} initialise() {}
finalize() {} finalize() {}
initialiseNewStream(old: MediaStreamAudioSourceNode, _new: MediaStreamAudioSourceNode) : void {}
changeHandle(handle: VoiceRecorder, triggerNewStream: boolean) {
const oldStream = !this.handle ? undefined : this.handle.getMicrophoneStream();
this.handle = handle;
if(triggerNewStream) this.initialiseNewStream(oldStream, !handle ? undefined : handle.getMicrophoneStream());
}
} }
class VoiceRecorder { class VoiceRecorder {
@ -24,7 +34,7 @@ class VoiceRecorder {
private audioContext: AudioContext; private audioContext: AudioContext;
private processor: any; private processor: any;
private mute: any; private mute: GainNode;
private vadHandler: VoiceActivityDetector; private vadHandler: VoiceActivityDetector;
private _chunkCount: number = 0; private _chunkCount: number = 0;
@ -33,7 +43,7 @@ class VoiceRecorder {
this.handle = handle; this.handle = handle;
this.userMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; this.userMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
this.audioContext = new AudioContext(); this.audioContext = AudioController.globalContext;
this.processor = this.audioContext.createScriptProcessor(VoiceRecorder.BUFFER_SIZE, VoiceRecorder.CHANNELS, VoiceRecorder.CHANNELS); this.processor = this.audioContext.createScriptProcessor(VoiceRecorder.BUFFER_SIZE, VoiceRecorder.CHANNELS, VoiceRecorder.CHANNELS);
const _this = this; const _this = this;
@ -43,11 +53,12 @@ class VoiceRecorder {
else { else {
if(this._chunkCount != 0) this.on_end(); if(this._chunkCount != 0) this.on_end();
this._chunkCount = 0 this._chunkCount = 0
}; }
}); });
//Not needed but make sure we have data for the preprocessor //Not needed but make sure we have data for the preprocessor
this.mute = this.audioContext.createGain(); this.mute = this.audioContext.createGain();
this.mute.gain.setValueAtTime(0, 0);
this.processor.connect(this.mute); this.processor.connect(this.mute);
this.mute.connect(this.audioContext.destination); this.mute.connect(this.audioContext.destination);
@ -60,6 +71,18 @@ class VoiceRecorder {
return !!this.userMedia; return !!this.userMedia;
} }
getMediaStream() : MediaStream {
return this.mediaStream;
}
getDestinationContext() : AudioNode {
return this.mute;
}
getMicrophoneStream() : MediaStreamAudioSourceNode {
return this.microphoneStream;
}
reinizaliszeVAD() { reinizaliszeVAD() {
let type = this.handle.client.settings.global("vad_type", "ppt"); let type = this.handle.client.settings.global("vad_type", "ppt");
if(type == "ppt") { if(type == "ppt") {
@ -70,15 +93,25 @@ class VoiceRecorder {
} else if(type == "pt") { } else if(type == "pt") {
if(!(this.getVADHandler() instanceof PassThroughVAD)) if(!(this.getVADHandler() instanceof PassThroughVAD))
this.setVADHander(new PassThroughVAD()); this.setVADHander(new PassThroughVAD());
} else if(type == "vad") {
if(!(this.getVADHandler() instanceof VoiceActivityDetectorVAD))
this.setVADHander(new VoiceActivityDetectorVAD());
let threshold = Number.parseInt(globalClient.settings.global("vad_threshold", "50"));
(this.getVADHandler() as VoiceActivityDetectorVAD).percentageThreshold = threshold;
} else { } else {
console.warn("Invalid VAD handler! (" + type + ")"); console.warn("Invalid VAD handler! (" + type + ")");
} }
} }
setVADHander(handler: VoiceActivityDetector) { setVADHander(handler: VoiceActivityDetector) {
if(this.vadHandler) this.vadHandler.finalize(); if(this.vadHandler) {
this.vadHandler.changeHandle(null, true);
this.vadHandler.finalize();
}
this.vadHandler = handler; this.vadHandler = handler;
this.vadHandler.initialise(this); this.vadHandler.changeHandle(this, false);
this.vadHandler.initialise();
this.vadHandler.initialiseNewStream(undefined, this.microphoneStream);
} }
getVADHandler() : VoiceActivityDetector { getVADHandler() : VoiceActivityDetector {
@ -125,8 +158,10 @@ class VoiceRecorder {
console.log("Start recording!"); console.log("Start recording!");
this.mediaStream = stream as MediaStream; this.mediaStream = stream as MediaStream;
const oldStream = this.microphoneStream;
this.microphoneStream = this.audioContext.createMediaStreamSource(stream); this.microphoneStream = this.audioContext.createMediaStreamSource(stream);
this.microphoneStream.connect(this.processor); this.microphoneStream.connect(this.processor);
this.vadHandler.initialiseNewStream(oldStream, this.microphoneStream);
} }
} }
@ -142,6 +177,58 @@ class PassThroughVAD extends VoiceActivityDetector {
} }
} }
class VoiceActivityDetectorVAD extends VoiceActivityDetector {
analyzer: AnalyserNode;
buffer: Uint8Array;
continuesCount: number = 0;
maxContinuesCount: number = 12;
percentageThreshold: number = 50;
percentage_listener: (per: number) => void = ($) => {};
initialise() {
this.analyzer = AudioController.globalContext.createAnalyser();
this.analyzer.smoothingTimeConstant = 1; //TODO test
this.buffer = new Uint8Array(this.analyzer.fftSize);
return super.initialise();
}
initialiseNewStream(old: MediaStreamAudioSourceNode, _new: MediaStreamAudioSourceNode): void {
if(this.analyzer)
this.analyzer.disconnect();
if(_new)
_new.connect(this.analyzer);
}
shouldRecord(buffer: AudioBuffer): boolean {
let usage = this.calculateUsage();
if($.isFunction(this.percentage_listener)) this.percentage_listener(usage);
if(usage >= this.percentageThreshold) {
this.continuesCount = 0;
} else this.continuesCount++;
return this.continuesCount < this.maxContinuesCount;
}
calculateUsage() : number {
let total = 0
,float
,rms;
this.analyzer.getByteTimeDomainData(this.buffer);
for(let index = 0; index < this.analyzer.fftSize; index++) {
float = ( this.buffer[index++] / 0x7f ) - 1;
total += (float * float);
}
rms = Math.sqrt(total / this.analyzer.fftSize);
let db = 20 * ( Math.log(rms) / Math.log(10) );
// sanity check
db = Math.max(-192, Math.min(db, 0));
let percentage = 100 + ( db * 1.92 );
return percentage;
}
}
class PushToTalkVAD extends VoiceActivityDetector { class PushToTalkVAD extends VoiceActivityDetector {
private _key: number; private _key: number;
private _pushed: boolean = false; private _pushed: boolean = false;
@ -162,10 +249,10 @@ class PushToTalkVAD extends VoiceActivityDetector {
} }
initialise(handle: VoiceRecorder) { initialise() {
document.addEventListener("keydown", this._evListenerDown); document.addEventListener("keydown", this._evListenerDown);
document.addEventListener("keyup", this._evListenerUp); document.addEventListener("keyup", this._evListenerUp);
return super.initialise(handle); return super.initialise();
} }
finalize() { finalize() {