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

Method printBufferSlice

hi_scripting/scripting/scriptnode/api/TestClasses.cpp:709–785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

707}
708
709String Buffer2Ascii::printBufferSlice(VariantBuffer::Ptr b, int i, int numSamplesPerLine, int numCols) const
710{
711 String s;
712 s.preallocateBytes(numCols);
713
714 int numThisTime = jmin(numSamplesPerLine, b->size - i);
715
716 auto magRange = b->buffer.findMinMax(0, i, numThisTime);
717
718
719 char SignalChar;
720
721 float delta = 0.0f;
722
723 auto ptr = b->buffer.getReadPointer(0, i);
724
725 for (int j = 1; j < numThisTime; j++)
726 delta += ptr[j] - ptr[j - 1];
727
728 float cDelta = 1.0f / ((float)numCols - 1.0f);
729
730 if (hmath::abs(delta) < cDelta * JUCE_LIVE_CONSTANT_OFF(0.25))
731 SignalChar = get(WaveformCharacters::ZeroLineChar);
732 else if (delta > 0.0)
733 SignalChar = get(WaveformCharacters::UpChar);
734 else
735 SignalChar = get(WaveformCharacters::DownChar);
736
737 auto absStart = hmath::abs(magRange.getStart());
738 auto absEnd = hmath::abs(magRange.getEnd());
739
740 float mag = 0.0f;
741
742 if (absStart > absEnd)
743 mag = magRange.getStart();
744 if (absStart < absEnd)
745 mag = magRange.getEnd();
746 if (absStart == absEnd)
747 mag = magRange.getStart() + magRange.getLength() * 0.5f;
748
749 mag = jlimit(-1.0f, 1.0f, mag);
750
751 mag = (mag + 1.0f) * 0.5f;
752
753 auto thisColIndex = roundToInt(mag * (numCols - 1));
754
755 auto halfCol = numCols / 2;
756
757 for (int i = 0; i < numCols; i++)
758 {
759 if (i == thisColIndex)
760 s << SignalChar;
761 else
762 {
763 if (i == halfCol)
764 {
765 s << get(WaveformCharacters::ZeroLineChar);
766 }

Callers

nothing calls this directly

Calls 11

jminFunction · 0.85
jlimitFunction · 0.85
roundToIntFunction · 0.85
preallocateBytesMethod · 0.80
findMinMaxMethod · 0.80
absFunction · 0.50
getFunction · 0.50
getReadPointerMethod · 0.45
getStartMethod · 0.45
getEndMethod · 0.45
getLengthMethod · 0.45

Tested by

no test coverage detected