Commit 2172c9cc authored by Meg Ford's avatar Meg Ford

play.js, record.js, waveform.js: unbreak the build

parent 7a2f4c08
...@@ -187,16 +187,18 @@ const _TENTH_SEC = 100000000; ...@@ -187,16 +187,18 @@ const _TENTH_SEC = 100000000;
this.view.setLabel(0); this.view.setLabel(0);
} }
let clockTime = this.clock.get_time(); this.absoluteTime = this.clock.get_time();
let baseTime = this.pipeline.get_base_time();
let runningTime = clockTime - baseTime; if (this.baseTime == 0)
log("clock time " + clockTime); this.baseTime = this.absoluteTime;
log("base time " + baseTime); log("base time " + this.baseTime);
log("running time " + runningTime);
let approxTime = Math.round(runningTime / _TENTH_SEC);
let runTime = this.absoluteTime- this.baseTime;
log(runTime);
log("current clocktime " + this.absoluteTime);
let approxTime = Math.round(runTime/_TENTH_SEC);
log("approx" + approxTime); log("approx" + approxTime);
MainWindow.wave._drawEvent(approxTime, this.peak); MainWindow.wave._drawEvent(approxTime);
return true; return true;
}, },
......
...@@ -48,6 +48,7 @@ const Record = new Lang.Class({ ...@@ -48,6 +48,7 @@ const Record = new Lang.Class({
Name: "Record", Name: "Record",
_recordPipeline: function() { _recordPipeline: function() {
this.baseTime = 0;
this._view = MainWindow.view; this._view = MainWindow.view;
this._buildFileName = new BuildFileName(); this._buildFileName = new BuildFileName();
this.initialFileName = this._buildFileName.buildInitialFilename(); this.initialFileName = this._buildFileName.buildInitialFilename();
...@@ -131,8 +132,9 @@ const Record = new Lang.Class({ ...@@ -131,8 +132,9 @@ const Record = new Lang.Class({
_updateTime: function() { _updateTime: function() {
let time = this.pipeline.query_position(Gst.Format.TIME, null)[1]/Gst.SECOND; let time = this.pipeline.query_position(Gst.Format.TIME, null)[1]/Gst.SECOND;
if (time >= 0) if (time >= 0) {
this._view.setLabel(time, 0); this._view.setLabel(time, 0);
}
return true; return true;
}, },
...@@ -229,26 +231,29 @@ const Record = new Lang.Class({ ...@@ -229,26 +231,29 @@ const Record = new Lang.Class({
if (peakVal) { if (peakVal) {
let val = peakVal.get_nth(0); let val = peakVal.get_nth(0);
log("val" + val); log("val" + val);
log("profile!" + this.profile);
if (val > 0) if (val > 0)
val = 0; val = 0;
let value = Math.pow(10, val/20); let value = Math.pow(10, val/20);
log(value); this.peak = value;
this.peak = value;
let clockTime = this.clock.get_time(); this.absoluteTime = this.clock.get_time();
let baseTime = this.pipeline.get_base_time();
let runningTime = clockTime - baseTime; if (this.baseTime == 0)
log("clock time " + clockTime); this.baseTime = this.absoluteTime;
log("base time " + baseTime); log("base time " + this.baseTime);
log("running time " + runningTime);
let approxTime = Math.round(runningTime / _TENTH_SEC);
this.runTime = this.absoluteTime- this.baseTime;
log(this.runTime);
log("current clocktime " + this.absoluteTime);
let approxTime = Math.round(this.runTime/_TENTH_SEC);
log("approx" + approxTime); log("approx" + approxTime);
MainWindow.wave._drawEvent(approxTime, this.peak); log("peakruntime" + this.peak);
} MainWindow.wave._drawEvent(approxTime, this.peak);
}
}
} }
}
break; break;
case Gst.MessageType.EOS: case Gst.MessageType.EOS:
......
...@@ -131,13 +131,16 @@ const WaveForm = new Lang.Class({ ...@@ -131,13 +131,16 @@ const WaveForm = new Lang.Class({
if (peakVal) { if (peakVal) {
let val = peakVal.get_nth(0); let val = peakVal.get_nth(0);
log("val" + val); log("val" + val);
if (val > 0)
val = 0;
let value = Math.pow(10, val/20); let value = Math.pow(10, val/20);
log(value); log(value);
this.peak = value;
if (value <= 0)
peaknumber = 0;
else if (value >= 1)
peaknumber = 1;
else
peaknumber = value;
peaks.push(peaknumber); peaks.push(peaknumber);
log("wave height" + peaknumber); log("wave height" + peaknumber);
} }
...@@ -172,7 +175,7 @@ const WaveForm = new Lang.Class({ ...@@ -172,7 +175,7 @@ const WaveForm = new Lang.Class({
}, },
fillSurface: function(drawing, cr) { fillSurface: function(drawing, cr) {
let start = 0; let start = 0;
if (this.waveType == WaveType.PLAY) { if (this.waveType == WaveType.PLAY) {
if (peaks.length != this.playTime) { if (peaks.length != this.playTime) {
this.pipeline.set_state(Gst.State.PLAYING); this.pipeline.set_state(Gst.State.PLAYING);
...@@ -181,14 +184,13 @@ const WaveForm = new Lang.Class({ ...@@ -181,14 +184,13 @@ const WaveForm = new Lang.Class({
} }
} else { } else {
if (this.recordTime >= 0) if (this.recordTime >= 0)
start = Math.floor(this.recordTime); start = this.recordTime;
} }
let i = 0; let i = 0;
let xAxis = 0; let xAxis = 0;
let end = start + 40; let end = start + 40;
log(start + "start");
log(end + "end");
let width = this.drawing.get_allocated_width(); let width = this.drawing.get_allocated_width();
let waveheight = this.drawing.get_allocated_height(); let waveheight = this.drawing.get_allocated_height();
let length = this.nSamples; let length = this.nSamples;
...@@ -203,7 +205,7 @@ const WaveForm = new Lang.Class({ ...@@ -203,7 +205,7 @@ const WaveForm = new Lang.Class({
for(i = start; i <= end; i++) { for(i = start; i <= end; i++) {
// Keep moving until we get to a non-null array member // Keep moving until we get to a non-null array member
if (peaks[i] < 0) { if (peaks[i] < 0) { //|| (this.tick >= 40 && xAxis == 0)) {
cr.moveTo((xAxis * pixelsPerSample), (waveheight - (peaks[i] * waveheight))) cr.moveTo((xAxis * pixelsPerSample), (waveheight - (peaks[i] * waveheight)))
log(i); log(i);
} }
...@@ -252,8 +254,7 @@ const WaveForm = new Lang.Class({ ...@@ -252,8 +254,7 @@ const WaveForm = new Lang.Class({
if (peaks.length < this.recordTime) { if (peaks.length < this.recordTime) {
log("error"); log("error");
} }
log(peaks.length);
log("draw event");
this.drawing.queue_draw(); this.drawing.queue_draw();
} }
return true; return true;
......
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