How were one-shot samples traditionally pitched?

Discussions about anything related to samplers and sampling techniques.

How were one-shot samples traditionally pitched?

Postby joeboy » Sat Dec 24, 2016 8:06 am

Specifically older models that didn't have much computational power at their disposal. Since my machine isn't so hot either.

It's winter and I'm writing a boring little program to serve as a drum machine in a pinch. I'd like the option to offset any sample by a given number of semitones. I'm doing that by changing the rate at which I read through the PCM file's array.

Of course anything other than a full octave jump upwards results in a non-integer iterator value, meaning that a single index of the PCM can't be referenced. The quick and easy solution is to round the iterator to the nearest integer, which indeed produces a clean signal that certainly sounds higher/lower, but I'm told this is inaccurate.

When I try linear interpolation, supposedly more pitch accurate than simple rounding, the resulting waveform is recognizable but horribly noisy--all sorts of audio distortions that the rounding method didn't have. This is the code I'm using:

(wav file is single-channel 16-bit at 48000Hz, stored internally as an unsigned short array. each interpolated sample is split into two 8-bit unsigned chars before being written to the DSP.)

Code: Select all
unsigned short linter(int n, double k, unsigned short *s) {
        return round(((1 - k) * s[n]) + (k * s[n + 1]));
}


where N is the integer section of the iterator, K is its fractional remainder, and S is the sample array. If the next desired sample existed at S[27.75], then N would be 27 and K would be 0.75. The return value would be a weighted average of S[27] and S[28] in favor of S[28].

It's an implementation of the linear interpolation formula described here:
http://www.electronics.dit.ie/staff/tsc ... etable.htm

__

Should audible noisiness be expected with a simple linear interpolation, or have I most likely erred somewhere along the way? Is the rounding method generally considered "good enough" for one-shot samples? How inaccurate is it really? How did early samplers handle this?
User avatar
joeboy
Junior Member
Junior Member
 
Posts: 102
Joined: Tue Jul 17, 2012 1:22 am
Location: 熊本
Gear: ax-80, jx-8p, v-synth, monotribe, ПИФ, tx81z, sy35, tg77

Re: How were one-shot samples traditionally pitched?

Postby Rasputin » Sat Dec 24, 2016 8:42 am

Variable clock is the only way I know of which can avoid interpolation. But that's not really an option in most circumstances now, so you're likely stuck with some form of interpolation.

I think early Akai used 8-point windowed sinc interpolation, and later used linear. I'd be willing to guess that majority of vintage samplers used linear.

Keep in mind that a lot of traditional (read: vintage) stuff had a lot of artifacts. I mean, the SP1200 is chock full, so maybe trying old, CPU light methods and hoping not to get artifacts isn't something that goes hand-in-hand.
Rasputin
Active Member
Active Member
 
Posts: 681
Joined: Thu Jul 21, 2016 4:52 am

Re: How were one-shot samples traditionally pitched?

Postby joeboy » Sat Dec 24, 2016 8:58 am

Thanks for the quick reply.

fwiw making a system call and setting a new sample rate that reflects the desired pitch also produces a clean signal, but it also seemed to gum up performance and I gather that it's frowned upon in general. Don't think it's even possible in OpenBSD (target platform) once the sound device has been initialized at a certain rate.

Maybe I'll look into alternative algorithms. It could be that my fears over latency are exaggerated. I just need something that will guarantee real-time performance on a netbook with an Intel Atom processor and a gig of ram.

I'm still confused why the linear interpolation is legitimately noisy compared to the rounding though. According to my computer music textbooks it should be the other way around. Makes me wonder if I'm just introducing some kind of error in bit diddling.
User avatar
joeboy
Junior Member
Junior Member
 
Posts: 102
Joined: Tue Jul 17, 2012 1:22 am
Location: 熊本
Gear: ax-80, jx-8p, v-synth, monotribe, ПИФ, tx81z, sy35, tg77

Re: How were one-shot samples traditionally pitched?

Postby Rasputin » Sat Dec 24, 2016 9:31 am

I think it's semi-assumed that one will use a low-pass filter with the interpolation. I'm not sure if that's a factor in your design.
Rasputin
Active Member
Active Member
 
Posts: 681
Joined: Thu Jul 21, 2016 4:52 am

Re: How were one-shot samples traditionally pitched?

Postby joeboy » Sat Dec 24, 2016 9:35 am

I wasn't aware of that. I'm kind of stumbling through all this blindly. Maybe that's the next direction I should head in, thanks.
User avatar
joeboy
Junior Member
Junior Member
 
Posts: 102
Joined: Tue Jul 17, 2012 1:22 am
Location: 熊本
Gear: ax-80, jx-8p, v-synth, monotribe, ПИФ, tx81z, sy35, tg77

Re: How were one-shot samples traditionally pitched?

Postby Rasputin » Sat Dec 24, 2016 9:49 am

I think this is fairly to the point and not overly complex or under illuminating:

https://www.utdallas.edu/~cpb021000/EE% ... lation.pdf
Rasputin
Active Member
Active Member
 
Posts: 681
Joined: Thu Jul 21, 2016 4:52 am

Re: How were one-shot samples traditionally pitched?

Postby joeboy » Sat Dec 24, 2016 10:20 am

Thanks for the info.

I imagine I'll get into filters soon enough as I'm planning on doing lots of audio programming over the break, but I've found out why my pitch-shifting was so noisy: a sign error! The PCM should have been read, manipulated, and written as signed rather than unsigned.

So I'm afraid there aren't even any sexy DSP intricacies at play here. Just a really stupid C syntax mistake :)

Oh well. A chance to learn.
User avatar
joeboy
Junior Member
Junior Member
 
Posts: 102
Joined: Tue Jul 17, 2012 1:22 am
Location: 熊本
Gear: ax-80, jx-8p, v-synth, monotribe, ПИФ, tx81z, sy35, tg77


Return to Samplers

Who is online

Users browsing this forum: No registered users and 3 guests