Cabbage Logo
Back to Cabbage Site

Grains on fly (granular synthesis)

I appreciate you including the English text, as it gives context to the piece. But I know I"m missing out on something by not being able to read the original. But it takes little away from my enjoyment of the piece. It makes me want to start composing again!

Composing can be an enjoyable activity. If you have visions, realize them! But in this historical epoch there would be more need for a great computer “luthier” and I think you have the qualities and you have taken the right path.
A collaboration between computer engineers and musician-performers and composers would be fruitful.
Stradivari did not compose, Cristofori did not compose. Despite this they have a positive place in History.
The universals of music have been identified in “jeu de règles, jeu sensori-moteur, jeu symbolique” (F. Delalande).
It is possible to make interesting music with only one of these games, but the music in its maximum vitality probably remains the complete one of all “jeux”.
Probably, Computer music should take “sensori-moteur” play into greater consideration, it should find a way to make environment, body’s energy and electrical energy work well together.
This could perhaps be achieved with common computers, without resorting to particularly sophisticated and expensive tools.

3 Likes

Hi Rory,
I added a “gentable” to display the envelope of the recorded source. There are some drawbacks that maybe you can easily solve:

  1. (the most important). When I change the value of “tab size” combobox, the system crashes. If at system startup I set value(1) or value(2), or value(3) in “combobox”, it’s ok, but if I wanted to change it on running, I would not know how to do it with “gentable”.
  2. (less important) I wrote “ftfree 1, 0” to clean all the previous rec, but it’s not work.
  3. (less important) Now it appears this Warning in console (I use windows 10): The following identifiers are not camelCase: “rescale”(Line:122)".
    I’m attaching the new version of the file.GrainOnFly_prova8.csd (9.1 KB)

Thanks @strapparts, I’ll check this out when I get a chance and see if I can find a fix :+1:

[edit] I just tested this here and I’m not getting any crash? Do you get a crash in the main Cabbage IDE, or only when running as a plugin, or both?

[edit2] sorry, I can also get it to crash, but only when I start recording. Either way, it’s something I can work with…

A possible workaround here until I fix this is the great one large table just for displaying the actual tables. So create a second table that has the maximum table size samples. Each time you record a sample, use one of the quick table copy opcodes to update table 2 with the contents of table 1, and then set the view range with sampleRange().

In the meantime I will try to solve the crash. I generally wouldn’t recommend changing table sizes on the fly, but in this case it should be Ok, because it will probably won’t be done that often.

I just took a deeper look at the my gentable code and I’m not sure we can actually resize a gentable after it has been created. Check this thread. So the option above should work, another option would be to generate the waveform on the fly using an SVG element. Hmm, this sounds like a fun challenge. I might give it a go if I get a spare moment.

This would be an excellent solution, but I have the impression that sampleRange, in gentable, doesn’t work.
I did a test by adding this instrument:
instr 20
kmetro metro 2
cabbageSet kmetro, “gentable1”, “alpha”, random:k(0, 1)
cabbageSet kmetro, “gentable1”, “sampleRange”, 0, random:k(100, 20000)
endin
I see “alpha” variations, but I don’t see end point variations.

Now that you mention it, I think it’s for soundfiler, which in this case would also work. On the other hand, it’s in the gentable docs, so I better take a look :slight_smile:

Seems to work Ok when you pass the arguments to the channel as a string using sprintfk() as seen below. I’ll take a look at see why it fails the other way.

<Cabbage>
form caption("Gentable Sample Range") size(400, 300), guiMode("queue") pluginId("def1"), colour(0,0,0)
gentable bounds(0, 0, 400, 200), channel("table1"), tableNumber(1)
hrange bounds(4, 208, 392, 40) channel("min", "max") max(1) min(0) range(0, 1, 0:1, 1, 0.001)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1


instr 1
    iLen ftlen 1
    kMin, kTrig1 cabbageGet "min"
    kMax, kTrig2 cabbageGet "max"
    cabbageSet kTrig1+kTrig2, "table1", sprintfk("sampleRange(%d, %d)", kMin*iLen, kMax*iLen) 
endin

</CsInstruments>
<CsScore>
f1 0 1024 10 1
;causes Csound to run for about 7000 years...
f0 z
;starts instrument 1 and runs it for a week
i1 0 [60*60*24*7] 
</CsScore>
</CsoundSynthesizer>

This example is fantastic!
Ok, I learn that I have to be careful of formats (string or number) when I pass values ​​with cabbageSet. I also see that with tabsize of 32768 the example works, but with higher tabsizes (for example 131072 etc.) it doesn’t work.

as soon as I can, I will try with ‘sounfiler’

Tables with a sizes greater than 44100 can’t be updated on the fly. It’s just way too slow. That’s why the soundfiler widget exists. It uses much faster drawing routines. I should probably print some kind of warning to the console when this happens.

In this thread: svgTable example Rory came up with an ingenious solution. Thanks, Rory! I’m attaching the new version of GrainOnFly with his solution GrainOnFly_prova12.csd (10.3 KB) .
I also entered this line:
cabbageSet “table1”, “svgElement”, “0”
to reset the image when you change size tab.
It works, don’t ask me why. I am not very familiar with svg.

Interesting. It works because it’s not valid SVG text so it clears the image. Nice trick :slight_smile:

With this request I’m cheeky, I know: could you also write valid SVG text to draw a horizontal line in the center here, instead of leaving the image completely blank? :slightly_smiling_face:

Just add another point at the end, which cause a line to be drawn right back at the start of the:

 SPath strcat SPath, sprintf({{
        L%d %d L0 %d" style="fill:none;stroke:lime;stroke-width:2;stroke-linejoin:round;"/>
        }}, iBounds[2], iBounds[3]/2, iBounds[3]/2) 

Notice the extra L0 % in the format specifiers. You can drop this line in as a replacement for the one that is there. :+1:

Great! I was missing this horizontal line. Thank you! I attach the new csd. GrainOnFly_prova13.csd (11.3 KB) I also added the automatic recording stop when the table ends.

Thanks for posting the update :+1: I’m glad the SVG approach worked out.