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

Method GetCueSampleData

Source/SamplePlayer.cpp:809–840  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

807}
808
809ChannelBuffer* SamplePlayer::GetCueSampleData(int cueIndex)
810{
811 float startSeconds, lengthSeconds, speed;
812 bool stopOnNoteOff;
813 GetPlayInfoForPitch(cueIndex, startSeconds, lengthSeconds, speed, stopOnNoteOff);
814 if (lengthSeconds <= 0)
815 lengthSeconds = 1;
816 int startSamples = startSeconds * gSampleRate * mSample->GetSampleRateRatio();
817 int lengthSamplesSrc = lengthSeconds * gSampleRate * mSample->GetSampleRateRatio();
818 if (startSamples >= mSample->Data()->BufferSize())
819 startSamples = mSample->Data()->BufferSize() - 1;
820 if (startSamples + lengthSamplesSrc >= mSample->Data()->BufferSize())
821 lengthSamplesSrc = mSample->Data()->BufferSize() - 1 - startSamples;
822 int lengthSamplesDest = lengthSamplesSrc / speed / mSample->GetSampleRateRatio();
823 ChannelBuffer* data = new ChannelBuffer(lengthSamplesDest);
824 data->SetNumActiveChannels(mSample->Data()->NumActiveChannels());
825 /*for (int ch = 0; ch < data->NumActiveChannels(); ++ch)
826 {
827 BufferCopy(data->GetChannel(ch), mSample->Data()->GetChannel(ch) + startSamples, lengthSamplesSrc);
828 }*/
829
830 for (int ch = 0; ch < data->NumActiveChannels(); ++ch)
831 {
832 for (int i = 0; i < lengthSamplesDest; ++i)
833 {
834 float offset = i * speed * mSample->GetSampleRateRatio();
835 data->GetChannel(ch)[i] = GetInterpolatedSample(offset, mSample->Data()->GetChannel(ch) + startSamples, lengthSamplesSrc);
836 }
837 }
838
839 return data;
840}
841
842bool SamplePlayer::MouseMoved(float x, float y)
843{

Callers 1

ImportSampleCuePointMethod · 0.80

Calls 7

GetInterpolatedSampleFunction · 0.85
BufferSizeMethod · 0.80
DataMethod · 0.80
SetNumActiveChannelsMethod · 0.80
NumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
GetSampleRateRatioMethod · 0.45

Tested by

no test coverage detected