SC’s original release included PlayBuf for normal playback, and TGrains for granulation.
In this original release, PlayBuf required (and still requires) BufRateScale to play a buffer back at its native pitch – but TGrains always used rate = 1.0 for native pitch, without BufRateScale. One could argue that this was a bad decision, but the fact is that from the beginning, there was an informal convention that, in granular UGens, rate = 1.0 means normal pitch.
Since I wasn’t completely sure if my memory was correct, I tried it:
p = Platform.userAppSupportDir +/+ "sounds/vocal-samples/VOCALS and SPOKEN WORD/male misc/absolutely_gorgeous.aif";
(
f = SoundFile.openRead(p);
f.sampleRate.postln; // 22050, definitely not matching system SR
f.close;
)
s.boot;
b = Buffer.read(s, p);
// PlayBuf rate 1
// too high
a = { PlayBuf.ar(1, b, rate: 1, doneAction: 2).dup }.play;
// PlayBuf rate BufRateScale
// correct
a = { PlayBuf.ar(1, b, rate: BufRateScale.kr(b), doneAction: 2).dup }.play;
// TGrains rate 1
// ***correct pitch***
(
a = {
var trigRate = 50, overlap = 4;
var grainDur = overlap / trigRate;
var half = grainDur * 0.5;
var bufdur = BufDur.kr(b);
var phase = Line.kr(half, bufdur - half, bufdur - grainDur, doneAction: 2);
TGrains.ar(2, Impulse.ar(trigRate), b,
rate: 1,
centerPos: phase,
dur: grainDur,
amp: 0.5
)
}.play;
)
GrainBuf was added later (2007), and follows, rather than violates, this convention. That is, the issue report makes it sound like GrainBuf is renegade, but in fact, it’s following precedent.
So if this were to be “fixed,” then all granular UGens would have to be changed. This would cause every granulator SynthDef, everywhere in the SC-verse, to change behavior. I… don’t think we’re going to do that.
I think the best solution is to update the documentation to make it absolutely clear, in all of the buffer-granulator help files, that rate
here does not follow the same rule as in PlayBuf. TGrains already says “1.0 is normal, 2.0 is one octave up” and none of the examples uses BufRateScale. GrainBuf alas doesn’t specify.
hjh