MCPcopy Create free account
hub / github.com/christophhart/HISE / getResizedBuffer

Method getResizedBuffer

hi_scripting/scripting/api/ScriptingApiObjects.cpp:1693–1736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1691
1692
1693var ScriptingObjects::ScriptRingBuffer::getResizedBuffer(int numDestSamples, int resampleMode)
1694{
1695 if (numDestSamples > 0)
1696 {
1697 auto& rb = getRingBuffer()->getReadBuffer();
1698
1699 if (rb.getNumSamples() == numDestSamples)
1700 return getReadBuffer();
1701
1702 VariantBuffer::Ptr b = new VariantBuffer(numDestSamples);
1703
1704 float stride = (float)rb.getNumSamples() / (float)numDestSamples;
1705
1706 int dstIndex = 0;
1707
1708 if (stride < 2.0)
1709 {
1710 for (float i = 0.0f; i < (float)rb.getNumSamples(); i += stride)
1711 {
1712 auto idx = (int)i;
1713 auto c = rb.getSample(0, idx);
1714 b->setSample(dstIndex++, c);
1715 }
1716 }
1717 else
1718 {
1719 for (float i = 0.0f; i < (float)rb.getNumSamples(); i += stride)
1720 {
1721 auto idx = (int)i;
1722 auto numThisTime = jmin(rb.getNumSamples() - idx, roundToInt(stride));
1723 auto v = FloatVectorOperations::findMinAndMax(rb.getReadPointer(0, idx), numThisTime);
1724
1725 auto c = v.getStart() + v.getLength() * 0.5f;
1726 b->setSample(dstIndex++, c);
1727 }
1728 }
1729
1730
1731
1732 return var(b.get());
1733 }
1734 else
1735 return var(new VariantBuffer(0));
1736}
1737
1738var ScriptingObjects::ScriptRingBuffer::createPath(var dstArea, var sourceRange, var startValue)
1739{

Callers

nothing calls this directly

Calls 12

jminFunction · 0.85
roundToIntFunction · 0.85
findMinAndMaxFunction · 0.85
varFunction · 0.85
getReadBufferMethod · 0.80
getNumSamplesMethod · 0.45
getSampleMethod · 0.45
setSampleMethod · 0.45
getReadPointerMethod · 0.45
getStartMethod · 0.45
getLengthMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected