MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / GrabSample

Method GrabSample

Source/ModularSynth.cpp:2699–2725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2697}
2698
2699void ModularSynth::GrabSample(ChannelBuffer* data, std::string name, bool window, int numBars)
2700{
2701 delete mHeldSample;
2702 mHeldSample = new Sample();
2703 mHeldSample->Create(data);
2704 mHeldSample->SetName(name);
2705 mHeldSample->SetNumBars(numBars);
2706
2707 //window sample to avoid clicks
2708 if (window)
2709 {
2710 int length = data->BufferSize();
2711 const int fadeSamples = 15;
2712 if (length > fadeSamples * 2) //only window if there's enough space
2713 {
2714 for (int i = 0; i < fadeSamples; ++i)
2715 {
2716 for (int ch = 0; ch < mHeldSample->NumChannels(); ++ch)
2717 {
2718 float fade = float(i) / fadeSamples;
2719 mHeldSample->Data()->GetChannel(ch)[i] *= fade;
2720 mHeldSample->Data()->GetChannel(ch)[length - 1 - i] *= fade;
2721 }
2722 }
2723 }
2724 }
2725}
2726
2727void ModularSynth::GrabSample(std::string filePath)
2728{

Callers

nothing calls this directly

Calls 8

BufferSizeMethod · 0.80
GetChannelMethod · 0.80
DataMethod · 0.80
CreateMethod · 0.45
SetNameMethod · 0.45
SetNumBarsMethod · 0.45
NumChannelsMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected