Cabbage Logo
Back to Cabbage Site

Event_i p2, 2-D Arrays

Hey everyone,

I am trying to simulate random guitar-like strumming patterns. Currently, I’m using a random number (ichord) which will decide which set of event_i commands to execute. Each set of these event_i commands has a different strumming pattern, which I primarily realised through using different combinations of p2 delays.

I would like to randomise these p2 values for each set of event_i’s. If you look in the file, I have labelled these patterns. However, these patterns are unique only to the randomised ‘ichord’. I want to be able to use any strumming pattern for any chord.

Maybe defining a 2-D array could work? Here is a pseudo-pseudocode :smile:

istrum 1, 5

if istrum = 1 then
iarr[0][0] ; strumming pattern 1, first note
iarr[0][1] ; second note
iarr[0][2] ; third note
iarr[0][3]; fourth note
iarr[0][4] ; fifth note
else if irand ==2 then
iarr[1][0] ; strumming pattern 2, first note
iarr[1][1] ; second note
iarr[1][2] ; third note
iarr[1][3] ; fourth note
iarr[1][4] ; fifth note

…etc., and then I would just use these array values in the p2 statement in the event_i commands.

Any feedback/suggestions would be appreciated.

FM only.csd (12.3 KB)


FM only2.csd (11.5 KB)

This is a more organised version of the code, since the first file is pretty unorganised.

Like this?

event_i "i", "fm", random(1, 5), p3, 1, cpspch(7.01)*itrnpose,int(irandenv)

The code posted by @hdale94 should do the trick. The nice thing about sending events like this is that the parameter can be derived at performance time, even though the p-fields themselves are i-rate.