Sieves? https://www.kvraudio.com/forum/viewtop ... 0#p7309910
Architect: Does anyone have a * macro/script
- KVRian
- 698 posts since 7 Dec, 2009 from GWB
-
- KVRer
- 23 posts since 25 Oct, 2021
Thanks for the link! it is great but I have a variation of the sieve method in mind and not sure if building on the linked patch and fragments would be possible.cturner wrote: ↑Thu Nov 04, 2021 12:27 pm Sieves? https://www.kvraudio.com/forum/viewtop ... 0#p7309910
if i ever manage to make it work, i'll post it here
- KVRian
- 698 posts since 7 Dec, 2009 from GWB
I see for some reason I never posted my Lua script that encapsulated the Architect objects. I should remember not to reply to posts before breakfast is over. The script below should be a bit more illustrative of the approach insofar as it's readable.
Reviewing your earlier posts, I think your difficulty is trying to model your algorithm as something that manipulates MIDI format data. The sieve demo I wrote uses TRUE/FALSE entries for an array size equivalent to the number "ticks" (beats) in a chosen loop of 48 ticks. This could also be the number of intervals in an octave or some such if you were dealing with pitch. With all the arrays the same size, containing T/F data, you then get all the logic elements for free--and I guess in your case--no need to sort data.
The example patch enables different sized "loops" or "octaves" on the fly, so you're not chained to some fixed notion of measure or interval.
Anyway, my suggestion is to model your algorithm simply as a data structure, and then figure out what you need to do to convert that data to usable MIDI. Separate things into a domain hierarchy.
HTH
Code: Select all
function sieve(extent, modulo, shift)
sarray = arc.array.new()
for i = 0, extent-1 do
if (i % modulo) == shift then
sarray:insert(true)
else
sarray:insert(false)
end
end
return sarray
end
function V(a, b)
tmp = arc.array.new()
for i in pairs(a) do
tmp:insert(a[i] and b[i])
end
return tmp
end
function U(a, b)
tmp = arc.array.new()
for i in pairs(a) do
tmp:insert(a[i] or b[i])
end
return tmp
end
function NOT(a)
tmp = arc.array.new()
for i in pairs(a) do
tmp:insert(not a[i])
end
return tmp
end
function arc.module.setup()
-- sieves in parentheses, mostly unions
p80u81u87 = U(U(sieve(40, 8, 0), sieve(40, 8, 1)), sieve(40, 8, 7))
p51u53 = U(sieve(40, 5, 1), sieve(40, 5, 3))
p80u81u82 = U(U(sieve(40, 8, 0), sieve(40, 8, 1)), sieve(40, 8, 2))
p83 = sieve(40, 8, 3)
p84 = sieve(40, 8, 4)
p85u86 = U(sieve(40, 8, 5), sieve(40, 8, 6))
p52u53u54 = U(U(sieve(40, 5, 2), sieve(40, 5, 3)), sieve(40, 5, 4))
p81v52 = V(sieve(40, 8, 1), sieve(40, 5, 2))
p86v51 = V(sieve(40, 8, 6), sieve(40, 5, 1))
-- intersections
p80u81u87vp51u53 = V(p80u81u87, p51u53)
p80u81u82n50 = V(p80u81u82, sieve(40, 5, 0))
p85u86v52u53u54 = V(p85u86, p52u53u54)
psappha = U(U(U(U(U(U(p80u81u87vp51u53, p80u81u82n50), p83), p84), p85u86v52u53u54), p81v52), p86v51)
arc.module.outlets[1]:send(psappha)
end
-
- KVRer
- 23 posts since 25 Oct, 2021
Thank you, your effort is greatly appreciated! I have 0 prior experience with programming languages and i've only been reading the Programming in Lua book for a few days now.
While i aim towards understanding the code you shared i am regretfully not there yet.
Unlike the code, i understand the logical and musical aspect of things and your post will help me push towards my goal-thanks again!
While i aim towards understanding the code you shared i am regretfully not there yet.
Unlike the code, i understand the logical and musical aspect of things and your post will help me push towards my goal-thanks again!
- KVRian
- 698 posts since 7 Dec, 2009 from GWB
So how does your current idea/project differ from Xenakis’ use of Sieves?
-
- KVRer
- 23 posts since 25 Oct, 2021
the goal is very similar-achieve music through algorithms and stochastics.
i'd like to build a modular(fragment collection with panel view) environment in Architect that allows you to generate "synchronized" (broadly speaking) music in real time with control over things like arrangement/orchestration (via cc & midi channels) as well as tempo, rhythm, phrasing and pitch.
Sieves(approximation) would be one of many methods of generating arrays that will be the main source of data that is further manipulated (probabilities, distribution etc) and used to control pretty much every available aspect of music through your daw.
Also, i'd like do be able to have a variable degree of control via live midi note input-i've had some success with things like autoarrangers so far.
Thanks again for the Lua script-i understand it now but i'm still nowhere near a point where I could do something like that from scratch.
- KVRian
- 698 posts since 7 Dec, 2009 from GWB
You might want to look at Christopher Ariza's Athena CL composition environment. It's one of the few that incorporates Sieves, and with Athena written in Python, the makeup of the program is eminently readable. You can see how he's broken things into various domains, which I think will be quite important to your effort.
http://www.flexatone.org/article/athenaCLMain
As you said previously, you wanted to use Sieves for both pitch and rhythm, which are both very different domains. The argument is that you'd want to have your Sieves code be abstract enough to work in both domains, otherwise any change forces rewrites in two or more areas of your code, with attendant confusion.
HTH
-
- KVRer
- 23 posts since 25 Oct, 2021
thank you for your effort, but since i have 0 experience with programming and computer lingo, the athenaCL is utterly incomprehensible.
i have a vague idea of what "libath" is & what it's supposed to be used for but have no clue where it is, what does "assume we are in package dir" mean and how i'm supposed to check. things like "sys.stdout.write" could as well be written in ancient greek xD
I'd rather not loose focus and learn Architect & slowly work towards understanding lua. Judging by what i've already patched, I think Architect is capable of doing everything I described before-for instance, I've made arrays(and sieves) work with pitch and time already, ie you can use the same array(or as many different ones you want) to generate rhythm and/or notes. Have not yet built a macro that "freezes" a random sequence of array values but i think i know how and hope to do it once i fix the issues i've encountered.
My main problem at this moment is not understanding the rules governing triggering and why do i need to trigger certain macros multiple times to work properly even though it is connected in a way that a single trigger should do the job. Obviously not, but it seems that way to me lol
I'll rebuild everything and check every step, hopefully i find the culprit and what to change.
i have a vague idea of what "libath" is & what it's supposed to be used for but have no clue where it is, what does "assume we are in package dir" mean and how i'm supposed to check. things like "sys.stdout.write" could as well be written in ancient greek xD
I'd rather not loose focus and learn Architect & slowly work towards understanding lua. Judging by what i've already patched, I think Architect is capable of doing everything I described before-for instance, I've made arrays(and sieves) work with pitch and time already, ie you can use the same array(or as many different ones you want) to generate rhythm and/or notes. Have not yet built a macro that "freezes" a random sequence of array values but i think i know how and hope to do it once i fix the issues i've encountered.
My main problem at this moment is not understanding the rules governing triggering and why do i need to trigger certain macros multiple times to work properly even though it is connected in a way that a single trigger should do the job. Obviously not, but it seems that way to me lol
I'll rebuild everything and check every step, hopefully i find the culprit and what to change.
-
- KVRAF
- Topic Starter
- 2691 posts since 25 Aug, 2003 from Bournemouth, UK
Could you send me this part of your patch, and I'll see if I can work out where it is going wrong? Thanks. Either PM it, attach it to a reply (if you don't mind it being public), or email it directly to colin (at) loomer.co.uk.tom plese wrote: ↑Sat Nov 06, 2021 10:02 am My main problem at this moment is not understanding the rules governing triggering and why do i need to trigger certain macros multiple times to work properly even though it is connected in a way that a single trigger should do the job. Obviously not, but it seems that way to me lol
Architect, the modular MIDI toolkit, beta now available for macOS, Windows, and Linux.
-
- KVRer
- 23 posts since 25 Oct, 2021
thanks, that would be great! ofc i don't mind making it public, but the public might xDcolin@loomer wrote: ↑Wed Nov 10, 2021 9:54 am Could you send me this part of your patch, and I'll see if I can work out where it is going wrong? Thanks. Either PM it, attach it to a reply (if you don't mind it being public), or email it directly to colin (at) loomer.co.uk.
i know i made many egregious errors(just don't know where they are) so if you deem the patch unfixable or have a working solution for the "sort two ordered arrays" problem be quick with your judgement and abandon the patch.
Thanks for your time and effort!
You do not have the required permissions to view the files attached to this post.
-
- KVRian
- 679 posts since 15 Feb, 2012 from France
I’d love to have a look too once it’s finished !
Last edited by nilhartman on Thu Nov 11, 2021 10:08 pm, edited 1 time in total.
- KVRian
- 698 posts since 7 Dec, 2009 from GWB
In your example patch, you don't say what happens to elements present in both arrays. 10 appears in both arrays. Are they both kept, or is one of the elements dropped?
The process is really "merging two sorted arrays", correct? IOW: "joining two arrays and then sorting".
EDIT: Looks like table.sort() works in Lua, so why don't you try that? For more information on table.sort(), see page 196 of _Programming in Lua_ 3rd edition.
HTH
You do not have the required permissions to view the files attached to this post.
-
- KVRer
- 23 posts since 25 Oct, 2021
Both elements are dropped, but I know there must be a dozen better ways to do it.
This is how I put it together: since the arrays that are being merged (thanks for the correct term) are in order, the shared values always "wait for each other"-if there's a 10 in both but arrA has 2, 4, 6, 8 before and arrB has 0 and 5 it will take lowest values in correct order (0,2,4,5,6,8) so arrB will hold 10 until it shows up in arrA.
If both arrays have the same value during the "shift macro", then both are truncated since the declared "minimum" value of their shifted elements equals both values.
Thank you very much for your help, will test the table.sort() today-I'm going through the Lua book but am nowhere near page 196 yet xD
Thank you all for being patient and helpful, I'll do my best to learn the correct language as quickly as possible so I can properly communicate. In hindsight, I probably should've done that before trying to patch stuff.
Thanks again!
This is how I put it together: since the arrays that are being merged (thanks for the correct term) are in order, the shared values always "wait for each other"-if there's a 10 in both but arrA has 2, 4, 6, 8 before and arrB has 0 and 5 it will take lowest values in correct order (0,2,4,5,6,8) so arrB will hold 10 until it shows up in arrA.
If both arrays have the same value during the "shift macro", then both are truncated since the declared "minimum" value of their shifted elements equals both values.
Thank you very much for your help, will test the table.sort() today-I'm going through the Lua book but am nowhere near page 196 yet xD
Thank you all for being patient and helpful, I'll do my best to learn the correct language as quickly as possible so I can properly communicate. In hindsight, I probably should've done that before trying to patch stuff.
Thanks again!
- KVRian
- 698 posts since 7 Dec, 2009 from GWB
This sounds like you're talking procedurally, not in terms of what you want as a result of your algorithm. You're not suggesting that
[0, 1, 4, 5, 7, 13, 15, 16, 19, 22, 25, 28]
should be the output, are you?
I'd think that
[0, 1, 4, 5, 7, 10, 13, 15, 16, 19, 22, 25, 28]
is what you'd want, correct?
The book isn't sequential in its presentation, there's no penalty for "dropping in" where the exposition touches on a topic of interest.I'm going through the Lua book but am nowhere near page 196 yet
I'm sure I don't use terms with sufficient precision either, but "correct language" will help with internet searches and more importantly, thinking clearly about algorithm design.I'll do my best to learn the correct language as quickly as possible so I can properly communicate. In hindsight, I probably should've done that before trying to patch stuff.
- KVRian
- 698 posts since 7 Dec, 2009 from GWB
Given that the Sieves objects I posted gets the OP about 95% of the way toward his preset working, I don't see this as a great use of Colin's time.