Hi Oleg, That all looks good to me - cool new operator!
Ideas for xxx: sidebands trigexpand trig_harmonics We were really looking for this kind of thing back in the 70s! Cheers, - Julius On Tue, Nov 14, 2023 at 10:53 AM Oleg Nesterov <o...@redhat.com> wrote: > On 08/21, Oleg Nesterov wrote: > > > > On 08/20, Julius Smith wrote: > > > > > > Pretty fun! This looks closely related Andy Moorer's technique: > > > > > > @ARTICLE{MoorerDSF75, > > > AUTHOR = "James A. Moorer", > > > TITLE = "The Synthesis of Complex Audio Spectra by Means of > > > Discrete Summation Formulae", > > > JOURNAL = JAES, > > > VOLUME = 24, > > > PAGES = {717--727}, > > > MONTH = dec, > > > NOTE = "Also available as CCRMA Report no. > > > \htmladdnormallink{STAN-M-5}{ > https://ccrma.stanford.edu/STANM/stanms/stanm5/ > > > }", > > > YEAR = 1975 > > > } > > > > Thanks! At first glance I don't think this is very closely related > > but interesting. > > So yes, this is another thing, I'll try to make another PR, I already > have the code. Let's finish this discussion first. > > > > I vote in favor of the addition provided its well documented in its > > > comments -> MarkDown extraction. > > OK. Please see the (same) code with the docs below. > > Is the documentation good enough for PR? > > And of course, how should I name xxx and yyy ? ;) > > Oleg. > > > > //-----------------------------`(os.)xxx`-------------------------------------- > // adds harmonics to quad oscillator. > // > // #### Usage > // > // ``` > // cos(x),sin(x) : xxx(vs) : _,_ > // ``` > // > // Where: > // > // * `vs` : list of amplitudes > // > // #### Example test program > // > // ``` > // cos(x),sin(x) : xxx((10,20,30)) > // ``` > // > // outputs > // > // 10*cos(x) + 20*cos(2*x) + 30*cos(3*x), > // 10*sin(x) + 20*sin(2*x) + 30*sin(3*x); > // > // ``` > // process = os.quadosc(F) : xxx((10,20,30)) > // ``` > // > // is (modulo floating point issues) the same as > // > // c = os.quadosc : _,!; > // s = os.quadosc : !,_; > // process = > // 10*c(F) + 20*c(2*F) + 30*c(F), > // 10*s(F) + 20*s(2*F) + 30*s(F); > // > // but much more efficient. > // > // #### Implementation Notes > // > // This is based on the trivial trigonometric identities: > // > // cos((n + 1) x) = 2 cos(x) cos(n x) - cos((n - 1) x) > // sin((n + 1) x) = 2 cos(x) sin(n x) - sin((n - 1) x) > // > // note that the calculation of the cosine/sine parts do not depend > // on each other, so if you only need the sine part you can do > // > // process = os.quadosc(F) : xxx(vs) : !,_; > // > // and compiler will discard the half of the calculations. > > //----------------------------------------------------------------------------- > xxx(vs, c0,s0) > = c0*vn(0),s0*vn(0), 1,c0, 0,s0 > : seq(n, outputs(vs)-1, add(vn(n+1))) > : _,_, !,!, !,! > with { > // ba.take(n+1, vs) > vn(n) = vs : route(outputs(vs),1, n+1,1); > > add(vn, co,so, cn_2,cn_1, sn_2,sn_1) = > co+cn*vn, so+sn*vn, cn_1,cn, sn_1,sn > with { > cn = 2*c0*cn_1 - cn_2; > sn = 2*c0*sn_1 - sn_2; > }; > }; > > > //-----------------------------`(os.)yyy`-------------------------------------- > // creates the list of complex harmonics from quad oscillator. > // > // Similar to `xxx` but doesn't sum the harmonics, so it is more > // generic but less convenient for immediate usage. > // > // #### Usage > // > // ``` > // cos(x),sin(x) : yyy(N) : si.bus(2*N) > // ``` > // > // Where: > // > // * `N` : number of harmonics, compile time constant > 1 > // > // #### Example test program > // > // ``` > // cos(x),sin(x) : yyy(3) > // ``` > // > // outputs > // > // cos(x),sin(x), cos(2*x),sin(2*x), cos(3*x),sin(3*x); > // > // ``` > // process = os.quadosc(F) : yyy(3) > // ``` > // > // is (modulo floating point issues) the same as > // > // process = os.quadosc(F), os.quadosc(2*F), os.quadosc(3*F); > // > // but much more efficient. > > //----------------------------------------------------------------------------- > yyy(N, c0,s0) > = c0,s0, 1,c0, 0,s0 > : seq(n, N-1, si.bus(2*(n+1)), add) > : si.bus(2*N), !,!, !,! > with { > add(cn_2,cn_1, sn_2,sn_1) = > cn,sn, cn_1,cn, sn_1,sn > with { > cn = 2*c0*cn_1 - cn_2; > sn = 2*c0*sn_1 - sn_2; > }; > }; > > -- "Anything that can be automated should optionally be"
_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users