This commit is contained in:
2026-02-02 19:07:00 +08:00
parent 0416a64235
commit 993ec623af
3 changed files with 85 additions and 3 deletions

View File

@@ -74,6 +74,11 @@
CGFloat x = startX + i * (self.barWidth + self.barSpacing);
CGFloat height = minHeight;
if (self.barHeightPattern.count > i) {
CGFloat base = [self.barHeightPattern[i] floatValue];
base = MIN(MAX(base, 0.15), 0.9);
height = MAX(minHeight, maxHeight * base);
}
CGFloat y = (maxHeight - height) / 2;
barLayer.frame = CGRectMake(x, y, self.barWidth, height);
@@ -141,9 +146,15 @@
CGFloat phase = (CGFloat)i / self.barLayers.count * M_PI * 2;
CGFloat wave = sin(time * 3 + phase) * 0.3 + 0.7; // 0.4 - 1.0
//
CGFloat heightFactor = rms * wave;
CGFloat height = minHeight + range * heightFactor;
CGFloat baseFactor = 0.2;
if (self.barHeightPattern.count > i) {
baseFactor = [self.barHeightPattern[i] floatValue];
baseFactor = MIN(MAX(baseFactor, 0.15), 0.9);
}
// + RMS
CGFloat dynamicFactor = rms * (0.35 + 0.15 * wave); // 0.35~0.5
CGFloat heightFactor = MIN(1.0, baseFactor + dynamicFactor * (1.0 - baseFactor));
CGFloat height = maxHeight * heightFactor;
height = MAX(minHeight, MIN(maxHeight, height));
//