hcube: hypercube calculator using 4 layers of nested clones and a dynamic [expr]
hcube: hypercube calculator using 4 layers of nested clones and a dynamic [expr]
Preface:
Mainly I did this for two reasons, 1) to see what it would look like to have a 4-d "tree" of clone objects and 2) I think it's funny (in a pure data sense).
As to practical purposes...I leave that up to the user.
Though, being (sort of) 4-d, I think it lends itself to audio sequencers, samplers, and esp. GEM projects.
requires: iemguts
(See hcube-help.pd for more detailed info.)
hcube is a series of four nested clones: cube, table, row, col(umn), with col holding a dynamically generated [expr] object.
It is created using arguments for the number of cubes, tables/cube, rows/table, and columns/table plus an expr, in [expr] notation where $f1 is the variable, $f2 is cube index, $f3 table, etc.
It reports the calculated result, i.e. sends [send]s, in the format [r #-#-#-#] where the numbers represent the (1-indexed) index of the object, ex. [r 1-1-1-1] is the first cube, first table, first row, and first column result.
It can take messages in the format [cubeidx tableidx rowidx columnidx variable formula]. Where if idx=0 then the messages is sent to [all ( clones and if >0 the message is sent to that (index=N-1) item.
The abstraction lends itself to changing the variable, locations, and (esp.) [expr] formulas on the fly, i.e. over time. So sending the variable down the chain and getting a cascade of values. (There is an example of this in the help file.)
I hope it may give you either 1) some use or 2) a giggle.
Now more than ever: Peace and Love through sharing.
Stay safe.
-S
p.s. it's my guess iemmatrix may already do this, but from a logic standpoint, using the clones like this, I think makes a lot of sense and is easy to follow.
Where can i find a list of messages that edits settings of Pure Data temporarily?
@4ZZ4 And you can look inside the tcl folder for scripts called "something dialog" or "dialog something".
If you search inside them for "pdsend" you will see the messages that can be sent directly to pd.
E.g in dialog_audio.tcl you will see......
pdsend "pd audio-dialog \
$audio_indev1 \
$audio_indev2 \
$audio_indev3 \
$audio_indev4 \
[expr $audio_inchan1 * ( $audio_inenable1 ? 1 : -1 ) ]\
[expr $audio_inchan2 * ( $audio_inenable2 ? 1 : -1 ) ]\
[expr $audio_inchan3 * ( $audio_inenable3 ? 1 : -1 ) ]\
[expr $audio_inchan4 * ( $audio_inenable4 ? 1 : -1 ) ]\
$audio_outdev1 \
$audio_outdev2 \
$audio_outdev3 \
$audio_outdev4 \
[expr $audio_outchan1 * ( $audio_outenable1 ? 1 : -1 ) ]\
[expr $audio_outchan2 * ( $audio_outenable2 ? 1 : -1 ) ]\
[expr $audio_outchan3 * ( $audio_outenable3 ? 1 : -1 ) ]\
[expr $audio_outchan4 * ( $audio_outenable4 ? 1 : -1 ) ]\
$audio_sr \
$audio_advance \
$audio_callback \
$audio_blocksize"
Which lets you do this....... set_audio_parameters.pd The rhs for Vanilla is the [audio-dialog( part.
You have to open the dialog to get the settings in Vanilla...... but you can set them on the fly with no dialog.
David.
expr if($f1 < 50 && $f1 > 60, 0, 1)
@casper You ask for a zero if the input is below 50 and above 60 which is never true, so you only get a one.
What you probably want is [expr if($f1 > 50 && $f1 < 60, 1, 0)] or [expr if($f1 >= 50 && $f1 <= 60, 1, 0)].
You can also use "or" which is ||, so: [expr if($f1 < 50 || $f1 > 60, 0, 1)] or [expr if($f1 <= 50 || $f1 >= 60, 0, 1)].
[pink~] from iemlib not working
@liamorourke There was a thread here 4 months ago....... https://forum.pdpatchrepo.info/topic/12460/brown-noise-generator
and @il-pleut is rummaging around in [fexpr~] at this very moment...... https://forum.pdpatchrepo.info/topic/12651/expr-expr-fexpr-gallerie
Probably the right time to ask him for the whole [noise~] rainbow while he is inspired.......
But maybe it is trying to open [cyclone/pink~] .........???...... and not finding the abstraction [iemlib/pink~].
David.
Why are webpages about pure data often down?
I have had many problems with opening pure data webpages, recently i couldn't open the Expr Manual http://yadegari.org/expr/expr.html
do anybody here have another link to a copy or a similar page to the Expr Manual? i'd very much like to read it.
Converting audio signals to binary with no externals ?
@Boran Robert i think & and | do work with expr~ and ^ is XOR, see this example for & and | in use: bitshift_sound.pd
here is a list with all operators:
http://yadegari.org/expr/expr.html
and here is a tutorial: https://nightmachines.tv/downloads/Bytebeats_Beginners_Guide_TTNM_v1-5.pdf
Converting audio signals to binary with no externals ?
@seb-harmonik.ar , @whale-av Many thanks for help. So what i want to do is this :
i want to have 2 oscillators (both sine waves. one a carry oscillator and the other one a modulator) with different frequency. And i want their audio signal to be processed in [expr~ ] using bitwise XOR modulation. This is different from [+~] , [-~] , [*~] , [/~]. This paper describes this in detail.
Here is a plot of the waveform result using bitwise XOR (from the paper above) :
Here is a schematic view of the oscillator structure :
So to control both oscillators i need to control the theta (phase) , f (frequency) and A (linear amplitude). Also S1 is unipolar. So the idea is that i can use the basic operations on the audio signals like (addition,multiplication,bitwise OR,bitwise AND) or i can use something different (bitwise XOR). So i tried to make somehow the bitwise XOR using a formula : bitwise XOR equivalent <- (S1 | S2) - (S1 & S2) (not working). The bitwise operations like "&" and "|" works for [expr] not [expr~].
Also i just found this about [expr~ ] object so maybe i am missing something or i am wrong
What is this operator "^" it is bitwise XOR ? or exponential ? or something else ?
Thanks to all a lot for the help. I also tried what @alexandros was talking about and it is almost working. But the waveform is really off so i need to learn more about this idea.
Converting audio signals to binary with no externals ?
@alexandros Thank you very much. I need to further test this ideas. So more precisely i want to make bitwise XOR modulation on two sine waves. The problem is i don't now what i am missing. Another problem with "&" and "|" operations are that i need them as inputs to be already in binary form. So this operations "&" and "|" don't work with [expr~] only [expr]. But yes i would like to use [expr~] because converting the signals to binary form and then back to signal is not easy. Also for the carry oscillator i was thinking to use unipolar signal instead of bipolar.
[osc~ 300] <- carry [osc~ 100] <- modulator
| |
[expr~ here i need to make bitwise XOR,AND,OR]
|
[dac~ 1 2]
so actually i try to make bitwise XOR like this :
[osc~ 300] [osc~ 100]
| |
[expr~ (($v1 | $v2) - ($v1 & $v2))] XOR = (A OR B) - (A AND B)
|
[dac~ 1 2]
This idea works for binary numbers :
[0110] [1111]
| |
[expr $f1 & $f2]
|
[output]
[0110] [1111]
| |
[expr (($f1 | $f2) - ($f1 & $f2))]
|
[output]
[0110] [1111]
| |
[expr $f1 | $f2]
|
[output]
Converting audio signals to binary with no externals ?
[snapshot~] will only give you the last value of the previous sample block, not good for any operation on all samples. Why don't you try [expr~]. For XOR you can do this [expr~ $v1^$v2]
If you want a specific number of bits (say 8-bit), add 1 to a bipolar signal and multiply it by half the resolution. For example for 8-bit do this:
[osc~]
|
[+~ 1]
|
[*~ 127.5]
|
[expr~ int($v1)^int($v2)]
or do everything in [expr~] like this:
[osc~]
|
[expr~ int(($v1+1)*127.5)^int(($v2+1)*127.5)]
That should work