From feed95c490d09ba3cc984cc9e8ae53607c3903b5 Mon Sep 17 00:00:00 2001 From: miranda Date: Thu, 25 Jun 2026 00:52:07 +0300 Subject: [PATCH] fix AY freq-to-tone calculation --- source/AYUGens/sc/AY.sc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/AYUGens/sc/AY.sc b/source/AYUGens/sc/AY.sc index 93eb0f50a8..31401ef00c 100644 --- a/source/AYUGens/sc/AY.sc +++ b/source/AYUGens/sc/AY.sc @@ -16,9 +16,11 @@ AY : UGen { *categories { ^ #["UGens>Oscillators"] } - *freqtotone { |freq| - // Approximate empirical... - //^(109300 / (freq - 3.70727)) - ^(110300 / (freq - 0.5)) + *freqtotone { |freq, s=nil| + var chipTactsPerOutCount; + s = s ?? { Server.default }; + // this mirrors ayemu's internal calculation of ChipTacts_per_outcount + chipTactsPerOutCount = 1773400.div(Server.default.sampleRate).div(8); + ^(s.sampleRate * chipTactsPerOutCount / (2 * freq)).round } }