Skip to content

Commit 5eb8760

Browse files
author
Bradley Varol
committed
Added optional boolean to getWaveformData() that allows only positive phase values to be included in the channel arrays
1 parent b9322cb commit 5eb8760

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Waveform.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function getWaveform($filename, $width, $height)
155155
return imagepng($img, $filename);
156156
}
157157

158-
public function getWaveformData($width)
158+
public function getWaveformData($width, $positivePhaseOnly = false)
159159
{
160160
// Calculating parameters
161161
$needChannels = $this->getChannels() > 1 ? 2 : 1;
@@ -196,10 +196,14 @@ public function getWaveformData($width)
196196
$channel1 []= $sample;
197197
}
198198
}
199-
$lines1 []= min($channel1);
199+
if (!$positivePhaseOnly) {
200+
$lines1 []= min($channel1);
201+
}
200202
$lines1 []= max($channel1);
201203
if ($needChannels === 2) {
202-
$lines2 []= min($channel2);
204+
if (!$positivePhaseOnly) {
205+
$lines2 [] = min($channel2);
206+
}
203207
$lines2 []= max($channel2);
204208
}
205209
}

0 commit comments

Comments
 (0)