Skip to content

Commit

Permalink
remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
pfalstad committed Jun 17, 2019
1 parent 10bac5b commit 349dd7d
Showing 1 changed file with 6 additions and 36 deletions.
42 changes: 6 additions & 36 deletions src/com/lushprojects/circuitjs1/client/AudioInputElm.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, AudioFileEntry> audioFileMap = new HashMap<Integer, AudioFileEntry>();

Expand Down Expand Up @@ -96,7 +97,7 @@ String getRailText() {
return fileName == null ? "No file" : fileName;
}

void setSampleRate(int sr) {
void setSamplingRate(int sr) {
samplingRate = sr;
}

Expand Down Expand Up @@ -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());
}
});
Expand All @@ -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);
[email protected]::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)();
[email protected]::setSampleRate(I)(context.sampleRate);
[email protected]::setSamplingRate(I)(context.sampleRate);
if (oFiles.length >= 1) {
var reader = new FileReader();
reader.onload = function(e) {
Expand All @@ -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);
[email protected]::gotAudioData(*)(data);
},
function(e){ console.log("Error with decoding audio data" + e.err); });
}-*/;

void gotAudioData(JsArrayNumber d) {
data = d;
lastSamplingRate = samplingRate;
Expand Down

0 comments on commit 349dd7d

Please sign in to comment.