[COMMIT?] FFTTrigger (was Re: [Sc-devel] FFT question)
Josh Parmenter
josh at realizedsound.net
Thu Nov 8 10:22:24 PST 2007
On Nov 8, 2007, at 9:27 AM, Dan Stowell wrote:
> OK, cool. What was the issue?
>
stupidity... I was mixing up a variable.
> Small tweak to your code: better than storing m_polar "raw" and making
> a check each time, would be to calculate the coord value once and just
> drop it in, something like this in the Ctor:
>
> unit->m_coord = (IN0(2) == 1.f) ? coord_Polar : coord_Complex;
>
> Your calc func can then drop this int value in without having to do
> any decision-making about what it is.
I noticed that it only has to be sent once after I sent the email...
and the above is nicer!
Will do.
Josh
>
>
> Other than that, all looks cool
>
> Best
> Dan
>
>
> 2007/11/8, Josh Parmenter <josh at realizedsound.net>:
>> figured it out. Here is the new code:
>>
>> // if polar == 1, polar representation is used. 0.0 is complex
>>
>> FFTTrigger : PV_ChainUGen
>> {
>> *new { | buffer, hop = 0.5, polar = 0.0|
>> ^this.multiNew('control', buffer, hop, polar)
>> }
>> }
>>
>>
>>
>> void FFTTrigger_Ctor(FFTTrigger *unit)
>> {
>> World *world = unit->mWorld;
>>
>> uint32 bufnum = (uint32)IN0(0);
>> //Print("FFTBase_Ctor: bufnum is %i\n", bufnum);
>> if (bufnum >= world->mNumSndBufs) bufnum = 0;
>> SndBuf *buf = world->mSndBufs + bufnum;
>>
>> unit->m_fftsndbuf = buf;
>> unit->m_fftbufnum = bufnum;
>> unit->m_bufsize = buf->samples;
>>
>> int numSamples = unit->mWorld->mFullRate.mBufLength;
>> float dataHopSize = IN0(1);
>> int initPolar = unit->m_polar = (int)IN0(2);
>> unit->m_numPeriods = unit->m_periodsRemain = (int)((unit-
>> >m_bufsize *
>> dataHopSize) / numSamples) - 1;
>>
>> if(initPolar == 1)
>> buf->coord = coord_Polar;
>> else
>> buf->coord = coord_Complex;
>>
>> OUT0(0) = IN0(0);
>> SETCALC(FFTTrigger_next);
>> }
>>
>> void FFTTrigger_next(FFTTrigger *unit, int inNumSamples)
>> {
>> if (unit->m_periodsRemain > 0) {
>> ZOUT0(0) = -1.f;
>> unit->m_periodsRemain--;
>> } else {
>> ZOUT0(0) = unit->m_fftbufnum;
>> if(unit->m_polar == 1)
>> unit->m_fftsndbuf->coord = coord_Polar;
>> else
>> unit->m_fftsndbuf->coord = coord_Complex;
>>
>> unit->m_pos = 0;
>> unit->m_periodsRemain = unit->m_numPeriods;
>> }
>>
>> }
>> On Nov 8, 2007, at 12:56 AM, Dan Stowell wrote:
>>
>>> Josh,
>>>
>>> Don't commit it before SC 3.1.1 is out. Otherwise, I'm happy with
>>> what
>>> it looks like (haven't tried it). A couple of questions:
>>>
>>> * What's the ToComplexApx() call for in the ctor? It can't be to
>>> ensure coord is set, since you do it manually straight after, so I'm
>>> not sure.
>>> * You can get rid of the "SCComplexBuf *p" part of that line anyway,
>>> since you don't subsequently use p.
>>> * Could we please have an optional flag about whether this fills in
>>> the coord value with either coord_Complex or coord_Polar?
>>>
>>> Best
>>> Dan
>>>
>>>
>>> 2007/11/8, Josh Parmenter <josh at realizedsound.net>:
>>>> Hi all... this seems to work on my end... what do you think?
>>>>
>>>>
>>>>
>>>> FFTTrigger : PV_ChainUGen
>>>> {
>>>> *new { | buffer, hop = 0.5|
>>>> ^this.multiNew('control', buffer, hop)
>>>> }
>>>> }
>>>>
>>>>
>>>> void FFTTrigger_Ctor(FFTTrigger *unit)
>>>> {
>>>> World *world = unit->mWorld;
>>>>
>>>> uint32 bufnum = (uint32)IN0(0);
>>>> //Print("FFTBase_Ctor: bufnum is %i\n", bufnum);
>>>> if (bufnum >= world->mNumSndBufs) bufnum = 0;
>>>> SndBuf *buf = world->mSndBufs + bufnum;
>>>>
>>>>
>>>> unit->m_fftsndbuf = buf;
>>>> unit->m_fftbufnum = bufnum;
>>>> unit->m_bufsize = buf->samples;
>>>>
>>>> int numSamples = unit->mWorld->mFullRate.mBufLength;
>>>> float dataHopSize = IN0(1);
>>>> unit->m_numPeriods = unit->m_periodsRemain = (int)((unit-
>>>> >m_bufsize *
>>>> dataHopSize) / numSamples) - 1;
>>>>
>>>>
>>>> SCComplexBuf *p = ToComplexApx(buf);
>>>> buf->coord = coord_Complex;
>>>> OUT0(0) = IN0(0);
>>>> SETCALC(FFTTrigger_next);
>>>> }
>>>>
>>>> void FFTTrigger_next(FFTTrigger *unit, int inNumSamples)
>>>> {
>>>> if (unit->m_periodsRemain > 0) {
>>>> ZOUT0(0) = -1.f;
>>>> unit->m_periodsRemain--;
>>>> } else {
>>>> ZOUT0(0) = unit->m_fftbufnum;
>>>> unit->m_fftsndbuf->coord = coord_Complex;
>>>> unit->m_pos = 0;
>>>> unit->m_periodsRemain = unit->m_numPeriods;
>>>> }
>>>>
>>>>
>>>> }
>>>>
>>>> Josh
>>>>
>>>>
>>>> On Nov 7, 2007, at 6:21 PM, James Harkins wrote:
>>>>
>>>>
>>>> On Nov 7, 2007, at 4:10 PM, Dan Stowell wrote:
>>>>
>>>> CeciNestPasUnFFT
>>>>
>>>> AcceptsFinestFun? Oh wait, I'm mixing threads now.
>>>> hjh
>>>>
>>>>
>>>> : H. James Harkins
>>>> : jamshark70 at dewdrop-world.net
>>>> : http://www.dewdrop-world.net
>>>> .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
>>>>
>>>> "Come said the Muse,
>>>> Sing me a song no poet has yet chanted,
>>>> Sing me the universal." -- Whitman
>>>> _______________________________________________
>>>> Sc-devel mailing list
>>>> Sc-devel at create.ucsb.edu
>>>> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>>>>
>>>>
>>>>
>>>>
>>>> ******************************************
>>>>
>>>> /* Joshua D. Parmenter
>>>>
>>>> http://www.realizedsound.net/josh/
>>>>
>>>>
>>>>
>>>>
>>>> "Every composer ? at all times and in all cases ? gives his own
>>>> interpretation of how modern society is structured: whether
>>>> actively or
>>>> passively, consciously or unconsciously, he makes choices in this
>>>> regard. He
>>>> may be conservative or he may subject himself to continual renewal;
>>>> or he
>>>> may strive for a revolutionary, historical or social palingenesis."
>>>> - Luigi
>>>> Nono*/
>>>>
>>>> _______________________________________________
>>>> Sc-devel mailing list
>>>> Sc-devel at create.ucsb.edu
>>>> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>>>>
>>>>
>>>
>>>
>>> --
>>> http://www.mcld.co.uk
>>>
>>> _______________________________________________
>>> Sc-devel mailing list
>>> Sc-devel at create.ucsb.edu
>>> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>>
>> ******************************************
>> /* Joshua D. Parmenter
>> http://www.realizedsound.net/josh/
>>
>> "Every composer ? at all times and in all cases ? gives his own
>> interpretation of how modern society is structured: whether actively
>> or passively, consciously or unconsciously, he makes choices in this
>> regard. He may be conservative or he may subject himself to continual
>> renewal; or he may strive for a revolutionary, historical or social
>> palingenesis." - Luigi Nono
>> */
>>
>>
>> _______________________________________________
>> Sc-devel mailing list
>> Sc-devel at create.ucsb.edu
>> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
>>
>
>
> --
> http://www.mcld.co.uk
>
> _______________________________________________
> Sc-devel mailing list
> Sc-devel at create.ucsb.edu
> http://www.create.ucsb.edu/mailman/listinfo/sc-devel
******************************************
/* Joshua D. Parmenter
http://www.realizedsound.net/josh/
“Every composer – at all times and in all cases – gives his own
interpretation of how modern society is structured: whether actively
or passively, consciously or unconsciously, he makes choices in this
regard. He may be conservative or he may subject himself to continual
renewal; or he may strive for a revolutionary, historical or social
palingenesis." - Luigi Nono
*/
More information about the Sc-devel
mailing list