Commit c9ca3301 authored by Meg Ford's avatar Meg Ford

code cleanup

parent 5fca24e8
......@@ -214,7 +214,6 @@ const MainView = new Lang.Class({
},
setVolume: function() {
log("VOLUME VIS" + setVisibleID);
if (setVisibleID == ActiveArea.PLAY) {
log("volumeValue.play " + volumeValue[0].play);
play.setVolume(volumeValue[0].play);
......@@ -508,9 +507,8 @@ const MainView = new Lang.Class({
}));
this.activeState = play.getPipeStates();
if (this.activeState == PipelineStates.PLAYING) {
if (this.activeState == PipelineStates.PLAYING || this.activeState == PipelineStates.PAUSED) {
log("this.activeState == PipelineStates.PLAYING");
this._playListButton.set_active(false);
play.stopPlaying();
}
}
......
......@@ -83,7 +83,9 @@ const Record = new Lang.Class({
}));
this.level = Gst.ElementFactory.make("level", "level");
log(this.level);
this.pipeline.add(this.level);
this.pipeline.add(this.level);
this.volume = Gst.ElementFactory.make("volume", "volume");
this.pipeline.add(this.volume);
this.ebin = Gst.ElementFactory.make("encodebin", "ebin");
this.ebin.connect("element-added", Lang.bind(this,
function(ebin, element) {
......@@ -117,7 +119,8 @@ const Record = new Lang.Class({
}
let srcLink = this.srcElement.link(this.level);
let levelLink = this.level.link(this.ebin);
let levelLink = this.level.link(this.volume);
let volLink = this.volume.link(this.ebin);
let ebinLink = this.ebin.link(this.giosink);
if (!srcLink || !levelLink || !ebinLink) {
......@@ -166,11 +169,12 @@ const Record = new Lang.Class({
let ret = this.pipeline.set_state(Gst.State.PLAYING);
this.pipeState = PipelineStates.PLAYING;
log("return " + ret);
if (ret == Gst.StateChangeReturn.FAILURE) {
log("Unable to set the pipeline to the recording state.\n"); //create return string?
this.onEndOfStream();
} else if (ret == Gst.StateChangeReturn.SUCCESS) {
} else {
MainWindow.view.setVolume();
}
......@@ -272,8 +276,8 @@ const Record = new Lang.Class({
},
setVolume: function(value) {
let level = value;
this.srcElement.set_volume(GstAudio.StreamVolumeFormat.CUBIC, level);
this.volume.set_volume(GstAudio.StreamVolumeFormat.CUBIC, value);
log("volumefromrecord " + this.volume.get_volume(GstAudio.StreamVolumeFormat.LINEAR));
}
});
......
......@@ -51,8 +51,9 @@ const WaveForm = new Lang.Class({
_init: function(grid, file) {
this._grid = grid;
let placeHolder = -100;
for (let i = 0; i < 40; i++)
peaks.push(-100);
peaks.push(placeHolder);
if (file) {
this.waveType = WaveType.PLAY;
this.file = file;
......@@ -184,16 +185,11 @@ const WaveForm = new Lang.Class({
let i = 0;
let xAxis = 0;
let end = this.tick + 39;
log(end);
let end = this.tick + 40;
let width = this.drawing.get_allocated_width();
log("w " + width);
let waveheight = this.drawing.get_allocated_height();
log("h" + waveheight)
let length = this.nSamples;
log("length " + this.nSamples);
let pixelsPerSample = width/waveSamples;
log("pixelsPerSample " + pixelsPerSample);
let pixelsPerSample = width/waveSamples;
let gradient = new Cairo.LinearGradient(0, 0, width , waveheight);
gradient.addColorStopRGBA(0.75, 0.0, 0.72, 0.64, 0.35);
......@@ -202,61 +198,63 @@ const WaveForm = new Lang.Class({
cr.setSourceRGBA(0.0, 185, 161, 255);
for(i = this.tick; i <= end; i++) {
// Keep moving until we get to a non-null array member
if (peaks[i] < 0 || (this.tick > 39 && xAxis == 0))
cr.moveTo((xAxis * pixelsPerSample), waveheight);
if (peaks[i] < 0) { //|| (this.tick >= 40 && xAxis == 0)) {
cr.moveTo((xAxis * pixelsPerSample), (waveheight - (peaks[i] * waveheight)))
log(i);
}
// Start drawing when we reach the first non-null array member
if (peaks[i] != null && peaks[i] >= 0)
cr.lineTo((xAxis * pixelsPerSample), (waveheight - (peaks[i] * waveheight)));
if (peaks[i] != null && peaks[i] >= 0) {
let idx = i - 1;
if (this.tick >= 40 && xAxis == 0) {
cr.moveTo((xAxis * pixelsPerSample), waveheight);
}
cr.lineTo((xAxis * pixelsPerSample), (waveheight - (peaks[i] * waveheight)));
}
xAxis += 1;
}
cr.lineTo(width, waveheight);
cr.lineTo(xAxis * pixelsPerSample, waveheight);
cr.closePath();
cr.strokePreserve();
cr.setSource(gradient);
cr.fillPreserve();
cr.$dispose();
},
_drawEvent: function(playTime, recPeaks) {
let lastTime;
if (this.waveType == WaveType.PLAY) {
lastTime = this.playTime;
log("lastTime time" + lastTime);
this.playTime = playTime;
log("check peaks" + peaks.length);
log("playTime time" + this.playTime);
if (peaks.length < this.playTime) {
this.pipeline.set_state(Gst.State.PLAYING);
log("continue drawing " + peaks.length);
}
if (this.tick < this.playTime) {
this.tick += 1;
log("tick value" + this.tick);
}
if (lastTime != this.playTime) {
this.drawing.queue_draw();
log("drawing queued");
}
} else {
peaks.push(recPeaks);
lastTime = this.recordTime;
this.recordTime = playTime;
log("rec check peaks" + peaks.length);
log("recordTime time" + this.recordTime);
if (peaks.length < this.recordTime) {
log("error");
}
this.tick += 1;
log("rec tick value" + this.tick);
this.drawing.queue_draw();
}
return true;
......@@ -268,6 +266,5 @@ const WaveForm = new Lang.Class({
this.count = 0;
peaks.length = 0;
this.drawing.destroy();
//cr.$dispose();
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment