float ModulatorSamplerSound::getGainValueForVelocityXFade(int velocity) { if (upperVeloXFadeValue == 0 && lowerVeloXFadeValue == 0) return 1.0f; Range<int> upperRange = Range<int>(velocityRange.getHighestBit() - upperVeloXFadeValue, velocityRange.getHighestBit()); Range<int> lowerRange = Range<int>(velocityRange.findNextSetBit(0), velocityRange.findNextSetBit(0) + lowerVeloXFadeValue); float delta = 1.0f; if (upperRange.contains(velocity)) { delta = (float)(velocity - upperRange.getStart()) / (upperRange.getLength()); return Interpolator::interpolateLinear(1.0f, 0.0f, delta); } else if (lowerRange.contains(velocity)) { delta = (float)(velocity - lowerRange.getStart()) / (lowerRange.getLength()); return Interpolator::interpolateLinear(0.0f, 1.0f, delta); } else { return 1.0f; } }
void TimelineComponent::updateClip (TimelineClip* clip) { jassert (clip); ClipRange<double> time; clip->getClipRange (time); const Range<int> hrange (trackHeight (clip->trackIndex())); clip->setBounds (timeToX (time.getStart(), clip->getTimeUnit()), hrange.getStart(), timeToWidth (time, clip->getTimeUnit()), hrange.getLength()); }
int main() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); int n; cin >> n; vector<Range> v; v.resize(n); for (int i = 0; i < n; ++i) { int x; int y; cin >> x >> y; v[i] = Range(x, y); } std::sort(v.begin(), v.end()); Range current = v[0]; int max = current.getLength(); for (int i = 1; i < n; ++i) { if (current.isIntersect(v[i])) current = current.getUnion(v[i]); else current = v[i]; if (current.getLength() > max) max = current.getLength(); } cout << max << endl; return 0; }
void Image::createSolidAreaMask (RectangleList& result, const float alphaThreshold) const { if (hasAlphaChannel()) { const uint8 threshold = (uint8) jlimit (0, 255, roundToInt (alphaThreshold * 255.0f)); SparseSet<int> pixelsOnRow; const BitmapData srcData (*this, 0, 0, getWidth(), getHeight()); for (int y = 0; y < srcData.height; ++y) { pixelsOnRow.clear(); const uint8* lineData = srcData.getLinePointer (y); if (isARGB()) { for (int x = 0; x < srcData.width; ++x) { if (((const PixelARGB*) lineData)->getAlpha() >= threshold) pixelsOnRow.addRange (Range<int> (x, x + 1)); lineData += srcData.pixelStride; } } else { for (int x = 0; x < srcData.width; ++x) { if (*lineData >= threshold) pixelsOnRow.addRange (Range<int> (x, x + 1)); lineData += srcData.pixelStride; } } for (int i = 0; i < pixelsOnRow.getNumRanges(); ++i) { const Range<int> range (pixelsOnRow.getRange (i)); result.add (Rectangle<int> (range.getStart(), y, range.getLength(), 1)); } result.consolidate(); } } else { result.add (0, 0, getWidth(), getHeight()); } }
void TextLayout::recalculateWidth() { if (lines.size() > 0) { Range<float> range (lines.getFirst()->getLineBoundsX()); int i; for (i = lines.size(); --i > 0;) range = range.getUnionWith (lines.getUnchecked(i)->getLineBoundsX()); for (i = lines.size(); --i >= 0;) lines.getUnchecked(i)->lineOrigin.x -= range.getStart(); width = range.getLength(); } }
void timerCallback() override { if (canMoveTransport()) updateCursorPosition(); else setRange (visibleRange.movedToStartAt (transportSource.getCurrentPosition() - (visibleRange.getLength() / 2.0))); }
double xToTime (const float x) const { return (x / getWidth()) * (visibleRange.getLength()) + visibleRange.getStart(); }
float timeToX (const double time) const { return getWidth() * (float) ((time - visibleRange.getStart()) / (visibleRange.getLength())); }
bool operator==(const Range &A, const Range &B) { return A.getOffset() == B.getOffset() && A.getLength() == B.getLength(); }