Cabbage Logo
Back to Cabbage Site

Random speed for counter

Hello :))

I am writing a program that triggers notes from several arrays using iNoteCount += 1. Besides using Markov, is there a simpler way to randomize the counter speed so that the notes get played randomly? It looks like I cannot just directly assign a random value to iNoteCount using random opcode as Csound crushes.

Thank you!

All the best,
Chen Liu.

I’m afraid you’ll need to give us a little more info. Maybe you can post a simple example of how you are doing it? There are many many ways of doing this, but I would need to see how you are approaching it before I can help…

No problem~ Below is how I did for the random events. Basically, the counter runs steadily and triggers numbers randomly from three groups of arrays in order. The numbers represent three types of key scales.

instr generate
seed       2
iArr1[] fillarray 220, 246, 261, 329, 349, 440
iArr2[] fillarray 220, 246, 277, 293, 329, 348.9, 415
iArr3[] fillarray 220, 261, 293, 329, 392, 440 
iNoteCount =          0
until iNoteCount == 150 do

if iNoteCount < 50 then
	indx random 0, 6
	ifreq = iArr1[indx]
	iNoteCount +=  0.5
	event_i   "i", "play", iNoteCount, 2, ifreq
endif
if iNoteCount < 100 && iNoteCount >= 50 then
	indx random 0, 7
	ifreq = iArr2[indx]
	iNoteCount += 0.5
	event_i   "i", "play", iNoteCount, 2, ifreq
	endif
if iNoteCount < 150 && iNoteCount >= 100 then
	indx random 0, 6
	ifreq = iArr3[indx]
	iNoteCount += 0.5
	event_i   "i", "play", iNoteCount, 2, ifreq
endif
 enduntil

endin 

Let me know if there is anything needed to clarify. Thanks again for your help and patience!

You can just use random number for the start time of each new note? Something like:

event_i "i", "play", iNoteCount+rnd(10), 2, ifreq

This will add a random value to each starting time.

1 Like