Csound Csound-dev Csound-tekno Search About

[Cs-dev] next-pow-of-two in orchestra

Date2010-05-16 21:45
FromOeyvind Brandtsegg
Subject[Cs-dev] next-pow-of-two in orchestra
In connection to the request from Josh regarding looping with skiptime,
we don't need a "loopskip" opcode,
but what *could* be a proposition for a new opcode (or operator) is a
next-pow-of-two method.
Something like @ that exists as a score operator.

With this we would not need to do

findpow2:
if ipowsize > ilength goto done
ipowsize	= ipowsize * 2
goto findpow2
done:

Not terribly important, but next-pow-of-two could be considered a
commonly needed low level building block

best
Oeyvind

------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-05-16 22:54
Fromjoachim heintz
SubjectRe: [Cs-dev] next-pow-of-two in orchestra
Isn't it 2 ^ ceil(log(ival) / log(2))?
For instance:


-nm0


instr 1
ival	 =	 2
loop:
inextpowof2	=	 2 ^ ceil(log(ival) / log(2))
prints	 "%d\t%d%n", ival, inextpowof2
loop_lt	ival, 1, 1026, loop
endin


i 1 0 0
e



Or did I misunderstand you?
(I took this formula from a code of Jacob, I think.)

Best -

	joachim


Am 16.05.2010 um 22:45 schrieb Oeyvind Brandtsegg:

> In connection to the request from Josh regarding looping with  
> skiptime,
> we don't need a "loopskip" opcode,
> but what *could* be a proposition for a new opcode (or operator) is a
> next-pow-of-two method.
> Something like @ that exists as a score operator.
>
> With this we would not need to do
>
> findpow2:
> if ipowsize > ilength goto done
> ipowsize	= ipowsize * 2
> goto findpow2
> done:
>
> Not terribly important, but next-pow-of-two could be considered a
> commonly needed low level building block
>
> best
> Oeyvind
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>


------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2010-05-16 22:56
FromSteven Yi
SubjectRe: [Cs-dev] next-pow-of-two in orchestra
Hi Oeyvind,

I wrote a small UDO that takes in time in seconds and finds out the
pow-of-two value to use. It's on the UDO database at:

http://www.csounds.com/udo

and is called findPowerOfTwo.

Thanks,
Steven

On 5/16/10, Oeyvind Brandtsegg  wrote:
> In connection to the request from Josh regarding looping with skiptime,
> we don't need a "loopskip" opcode,
> but what *could* be a proposition for a new opcode (or operator) is a
> next-pow-of-two method.
> Something like @ that exists as a score operator.
>
> With this we would not need to do
>
> findpow2:
> if ipowsize > ilength goto done
> ipowsize	= ipowsize * 2
> goto findpow2
> done:
>
> Not terribly important, but next-pow-of-two could be considered a
> commonly needed low level building block
>
> best
> Oeyvind
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

-- 
Sent from my mobile device

------------------------------------------------------------------------------

_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net