From 349dd7d33d2ebfaf2490056c3de8eae34254dd2a Mon Sep 17 00:00:00 2001 From: pf Date: Mon, 17 Jun 2019 16:11:26 -0700 Subject: [PATCH] remove dead code --- .../circuitjs1/client/AudioInputElm.java | 42 +++---------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/src/com/lushprojects/circuitjs1/client/AudioInputElm.java b/src/com/lushprojects/circuitjs1/client/AudioInputElm.java index 195f234e..645ccf07 100644 --- a/src/com/lushprojects/circuitjs1/client/AudioInputElm.java +++ b/src/com/lushprojects/circuitjs1/client/AudioInputElm.java @@ -44,6 +44,7 @@ class AudioInputElm extends RailElm { static int lastSamplingRate; + // cache to preserve audio data when doing cut/paste, or undo/redo static int fileNumCounter = 1; static HashMap audioFileMap = new HashMap(); @@ -96,7 +97,7 @@ String getRailText() { return fileName == null ? "No file" : fileName; } - void setSampleRate(int sr) { + void setSamplingRate(int sr) { samplingRate = sr; } @@ -129,7 +130,6 @@ public EditInfo getEditInfo(int n) { file.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { fileName = file.getFilename().replaceAll("^.*\\\\", "").replaceAll("\\.[^.]*$", ""); -// AudioInputElm.fetchAudio(thisElm, file.getFilename()); AudioInputElm.fetchLoadFileData(thisElm, file.getElement()); } }); @@ -149,31 +149,11 @@ public void setEditValue(int n, EditInfo ei) { startPosition = ei.value; } - static native boolean oldfetchAudio(AudioInputElm elm, String file) /*-{ - var context = new (window.AudioContext || window.webkitAudioContext)(); - var url = file; - var request = new XMLHttpRequest(); - request.open("GET", url, true); - request.responseType = "arraybuffer"; - var loader = this; - request.onload = function() { - // Asynchronously decode the audio file data in request.response - var audioData = request.response; - - context.decodeAudioData(audioData, function(buffer) { - var data = buffer.getChannelData(0); - elm.@com.lushprojects.circuitjs1.client.AudioInputElm::gotAudioData(*)(data); - }, - function(e){ console.log("Error with decoding audio data" + e.err); }); - } - request.send(); - }-*/; - - - static native String fetchLoadFileData(AudioInputElm elm, Element element) /*-{ - var oFiles = element.files; + // fetch audio data for a selected file + static native String fetchLoadFileData(AudioInputElm elm, Element uploadElement) /*-{ + var oFiles = uploadElement.files; var context = new (window.AudioContext || window.webkitAudioContext)(); - elm.@com.lushprojects.circuitjs1.client.AudioInputElm::setSampleRate(I)(context.sampleRate); + elm.@com.lushprojects.circuitjs1.client.AudioInputElm::setSamplingRate(I)(context.sampleRate); if (oFiles.length >= 1) { var reader = new FileReader(); reader.onload = function(e) { @@ -188,16 +168,6 @@ static native String fetchLoadFileData(AudioInputElm elm, Element element) /*-{ } }-*/; - static native boolean fetchAudio(AudioInputElm elm, String audioData) /*-{ - var context = new (window.AudioContext || window.webkitAudioContext)(); - var url = file; - context.decodeAudioData(audioData, function(buffer) { - var data = buffer.getChannelData(0); - elm.@com.lushprojects.circuitjs1.client.AudioInputElm::gotAudioData(*)(data); - }, - function(e){ console.log("Error with decoding audio data" + e.err); }); - }-*/; - void gotAudioData(JsArrayNumber d) { data = d; lastSamplingRate = samplingRate;