[PD] converting decimal to binary

adam armfield adamairmailed at yahoo.com
Tue Jun 27 15:16:05 CEST 2006


<pre>What type of output are you looking for?  Because
beyond 6 digits,
Pd's floating point numbers look funny, and 6 digits
only covers 63 in
binary.  Do you want a character string?
I don't know what kind of format you can work with. 
Pd could,
alternatively, output 1's and 0's sequentially as a
series of floats.

at the moment i'm still working on that bit, the
formula that Federico gave me
outputs 1&0's to seperate outlets, which i think would
drive a set of toggles quite well (though when i tried
it pd crashed, i think because the number i input was
too big, & the expr object i made ran out of digits


[nbx]
|
[expr $f1>>0&1;
$f1>>1&1;
$f1>>2&1;
$f1>>3&1;
...
]

and so on...
depending on how many bits you want to display

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

i want to make a sequencer which generates rhythms
according to the fibonacci sequence, there's been some
talk of it on another forum, i've done some cut and
paste and present the main details here (it looks
pretty interesting)

original thread is:
http://www.dogsonacid.com/showthread.php?s=5ab52100bff93bb30ced93458a7e9529&threadid=409342&perpage=20&pagenumber=2

all the best
adam
-----------------------------------
i'm not sure if mean - "why do i think fibonacci
sequences will yield rhythms that sound good?" or "how
do i do it?". i guess i'll try to answer both...

harmonics have such an integral role in so many things
- i just can't believe that they don't come into play
in rhythm sequences. surely - there is some sort of
"rule" that determines which patterns "sit" well with
each other, and which don't. clearly - simply placing
drum hits in at random sounds like ass, whereas
certain intervals seem to produce a pleasant interplay
in the beat. i've always figured this must have
something to do with the properties of the fibonacci
sequence, since harmonic relationships are the
deciding factor in so many appliactions dealing with
interplay and relationships between things, from which
atromic orbitals will react with one another - so
which tones sound good when played together - to the
proportion of objects in visual arts.

i'm a bit hesitant to just spill the beans so soon -
but what the hell, i've always thought that
information/knowledge should be "open-source". so what
the hell; basically the method goes like this:

you always have some fundamental resolution - most of
us use 1/8th notes or 1/16th notes. so the measure can
be represented as a string of discrete bits, or a
binary word, where each bit in the word represents a
unique position in the measure.

i'll use the housebeat with 1/8th note rez. for an
example because it has lots of clean harmonics. note
that the least significant digit is used to denote the
first position - so we've got a big/little-endian
switch going on...

kick:
01010101

this binary word evaluates to 85

so if we take 85 to be our "base" (i.e. the first
element in the series) - and continue in the fibonacci
sequence, we get 85*(1+1) = 170 which, in binary is:

101010

^ the open highhat pattern

continuing on the next element is 21*(2+1) = 255

11111111

^ commonly used for closed highhats


basically - for breakbeats - i take 1 or 2 elements
which i want to draw by hand. in the midi file above i
used:

00100001 (kick)
and
01000100 (snare)

and added them together. then i took each row, and
recursively added the current word to the previous
word to produce the next word.

the method is still a work in progress - i'm still
experimenting with "clipping" - in this case meaning
continuing the sums, and clipping off any bits higher
than the "all 1s" word. (in this case > 255).
alternatively, you could just increase the res i
suppose to get some really complicated breaks with
16,32,or even 64 bit resolution.

this doesn't have to be used just for durms - you
could use it to generate the rhythm sequences for
anything. the possibilities are quite mind-boggling.

so there ya go dogs - if there's a number theorist in
the house who'd like to collab with me in developing
applications of this method - hit me up.

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

least significant means "smallest numerical value".
each digit in a binary word, read from right to left,
indicates another power of 2.

e.g: the rightmost position is bit*2^0, ("bit"
referring to whether that digit either 1 or 0) the
next is bit*2^1, the next is bit*2^2, and so on.

so the first (i.e. rightmost) bit coincides with the
first note/event in the measure. if you were to order
the bits the other way around, you'd always roll over
your word's maximum value in every operation. it's a
minor point, but one that is definitely necessary.
just think of it like this: the smaller "time values"
of the events go with the smaller (or less
significant) digits of the number.

the fibonacci sequence goes like this, let "e" denote
event, and i denote which event it is in the sequence.
so e_i refeers to an arbitrary event; e_i+1 refers to
the one that comes next, and e_i-1 refers to the one
that came before it.

so the fibonacci sequence is:

e_i+1 = e_i+e_i-1

in the example i posted earlier, our "base" is 85.
meaning we multiply each element of the fibonacci
sequence by 85, so instead of 1,2,3,5,8 - you would
get 85,170,255,425,680 = 85*(1,2,3,5,8).

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

if you can find it - you should check out "the
schillinger method of musical composition" - it uses
wave analysis to generate melodies and rhythms. i
actually have a copy of volume 1 i got many years ago
- which is where i got started thinking this way. it's
really interesting stuff - but a heavy read.

to do what i want to do tho' using wave analysis, i'd
have to break out my old differential equations notes
& remember how to do a fourier analysis . like that's
gonna happen

----------

Everyone has their own way (use single hits and
sampling for me) but using the fibonacci sequence for
making beats sounds interesting!!! Here's another way
to describe, even though I don't use this sequence to
make beats, just happen to know it:

Bases:Fsub1=1, Fsub2=1
Recursive rule: FsubN=FsubN-1+FsubN-2, N greater than
or equal to 3... so F3=F2+F1. And you can move up to
any number in the sequence using this format.



</pre>


		
___________________________________________________________ 
Does your mail provider give you FREE antivirus protection? 
Get Yahoo! Mail http://uk.mail.yahoo.com




More information about the Pd-list mailing list