In regards to the 432hz Player, someone wrote to me with the idea of rounding the frequency scaling to the nearest fraction.

So I tried it. It does seem to give a noticeable quality improvement! Clearer sound. At the cost of very slightly off pitch and speed.

`// C#`

private void AdjustTempo(double speed, double rate, double pitch)

{

if (BassActive)

{

// In BASS, 2x speed is 100 (+100%), whereas our Speed property is 2. Need to convert.

// speed 1=0, 2=100, 3=200, 4=300, .5=-100, .25=-300

var freqSrc = ManagedBass.Bass.ChannelGetAttribute(_chan, ChannelAttribute.TempoFrequency);

var freqDst = _chanInfo.Frequency * pitch * rate;

if (true)

{

var freqRatio = freqDst / freqSrc;

var freqFraction = GetFraction(freqRatio, 0.0001);

freqDst = freqSrc * freqFraction.Key / freqFraction.Value;

}

ManagedBass.Bass.ChannelSetAttribute(_chan, ChannelAttribute.Tempo, (1.0 / pitch * speed - 1.0) * 100.0);

ManagedBass.Bass.ChannelSetAttribute(_chan, ChannelAttribute.TempoFrequency, freqDst);

}

}

private KeyValuePair<int, int> GetFraction(double value, double tolerance = 0.02)

{

var f0 = 1 / value;

var f1 = 1 / (f0 - Math.Truncate(f0));

var aT = (int)Math.Truncate(f0);

var aR = (int)Math.Round(f0);

var bT = (int)Math.Truncate(f1);

var bR = (int)Math.Round(f1);

var c = (int)Math.Round(1 / (f1 - Math.Truncate(f1)));

if (Math.Abs(1.0 / aR - value) <= tolerance)

return new KeyValuePair<int, int>(1, aR);

else if (Math.Abs(bR / (aT * bR + 1.0) - value) <= tolerance)

return new KeyValuePair<int, int>(bR, aT * bR + 1);

else

return new KeyValuePair<int, int>(c * bT + 1, c * aT * bT + aT + c);

}

I altered TempoFrequency. Now my question is: what should I do with Tempo? Should I round it too in the same way? Or use it to compensate for the speed alteration?

Would love some input from experts here.

Edit: I'm thinking, there are actually 2 samplerate conversions. One for pitch-shifting, and one for the output.

Let's take a sample song at 441.9hz

freqSrc = 44100

freqDst = 43111.909705760583

freqRatio = 0.977594324393664

freqFraction = 87 / 89

new freqDst = 43108.988764044945

Then, we need to resample from 43108.988764044945 to 48000 for playback. And there's also Tempo to take into the equation.

For resampling to 48000, I see 2 options.

A) Ignore it and let the system handle it

B) Find fraction rounding that work for both conversions

For Tempo, I see 2 options.

A) Compensate for speed shift

B) Round it to a fraction

Are Tempo and TempoFrequency inter-connected in a way that needs to be taken into account?

Writing this, I'm thinking the best may be to

1. Find fraction rounding that work for both sample rate conversions

2. Adjust tempo to cancel the speed difference

3. Round tempo to a fraction (optional, if slight speed shift is acceptable)

Does this whole idea make sense, or is there something I'm missing?