MCPcopy Create free account
hub / github.com/LMMS/lmms / nextStringSample

Method nextStringSample

plugins/bit_invader/bit_invader.cpp:89–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87
88
89sample_t bSynth::nextStringSample()
90{
91 float sample_step =
92 static_cast<float>( sample_length / ( sample_rate / nph->frequency() ) );
93
94
95 // check overflow
96 while (sample_realindex >= sample_length) {
97 sample_realindex -= sample_length;
98 }
99
100 sample_t sample;
101
102 if (interpolation) {
103
104 // find position in shape
105 int a = static_cast<int>(sample_realindex);
106 int b;
107 if (a < (sample_length-1)) {
108 b = static_cast<int>(sample_realindex+1);
109 } else {
110 b = 0;
111 }
112
113 // Nachkommaanteil
114 const float frac = fraction( sample_realindex );
115
116 sample = linearInterpolate( sample_shape[a], sample_shape[b], frac );
117
118 } else {
119 // No interpolation
120 sample_index = static_cast<int>(sample_realindex);
121 sample = sample_shape[sample_index];
122 }
123
124 // progress in shape
125 sample_realindex += sample_step;
126
127 return sample;
128}
129
130/***********************************************************************
131*

Callers 1

playNoteMethod · 0.80

Calls 3

fractionFunction · 0.85
linearInterpolateFunction · 0.85
frequencyMethod · 0.80

Tested by

no test coverage detected