Hello thanks for testing it and sorry for the delay, I couldn’t post these last days.
Grain 1’s crash issue when uploading new audio while running happens on different DAWS. I’ve tried it on Reaper, Cubase and Ableton and it happens on all of them. I’ve attached a short video to show what happens and how it happens.
Then I would like to comment that I have continued to develop the other instrument that I am working on which uses the Grain 3 opcode. In a recent update I have changed the way in which the .wav audio is uploaded to the table since ftgen or fgenonce need to deliver size values to Grain3 that are the next power of 2 with respect to the size value of the sample. I have created a code that detects the appropriate value of what would be the next power of 2 to inform ftgenonce so that the table can be automatically loaded without the need to manually inform the size. For that I have used the opcodes “filelen” “filesr” and “filenchnls" in combination with Sfile and that allowed to upload mono or stereo files of different sample rates without changing the pitch. I think that it was an improvement since before it I was using a slider to manually inform the number of samples required, which I need no more. Other benefit of this update is that now the instrument track in a daw could be frozen and it will recall the samples when is unfrozen. The same happens if a project is saved, when the project is opened again now it recall the files. I have no idea why but I think it is much better than before.
The downside is that when using this new way it fails again to load samples in a problem that seems to be related to diskin and the opcodes “filelen” “filesr”,“filenchnls” which are involved here. The soundin error that used to appear no longer appears and was fixed with Build 2.9.44 now the problem is with diskin. I attach a simple example of the code I have created to upload the tables, apart from the complexities that the instrument may have to isolate the problem in this case uploading the audio to an “oscili” (but the result is the same). I’ve seen that one of the examples provided with Cabbage called “Grain3FilePlayer” by Iain McCurdy uses a similar procedure to calculate the next power of 2 of the tables. Using that example for testing, I have added to that instrument the option to save presets and the result was the same as in my instrument since it seems that although in a slightly different way he also used “filelen” “filesr” and “filenchnls” to calculate the size of the table.
@rorywalsh If you could see what happens here to find some solution when possible, especially in the second issue with diskin I will be grateful. I think that beyond helping the performance of these particular instruments fixing this type of errors could help to improve Cabbage in regards to saving presets that involve the use of audio files.
This is the code for opening tables that need power of 2:
form caption(“Sample upload”) size(400, 300), guiMode(“queue”), pluginId(“1287”), colour (0,100,0)
keyboard bounds(8, 158, 381, 95)
filebutton bounds(14, 18, 80, 40) channel(“loadfile”)
combobox bounds(220, 20, 74, 25), populate("*.snaps"), channelType(“string”) automatable(0) channel(“combo38”) value(“0”)
filebutton bounds(164, 20, 60, 25), text(“Save”, “Save”), populate("*.snaps", “test”), mode(“named preset”) channel(“filebutton39”)
filebutton bounds(164, 50, 60, 25), text(“Remove”, “Remove”), populate("*.snaps", “test”), mode(“remove preset”) channel(“filebutton40”)
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5 -m0d
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
instr 1
Sfile chnget “loadfile”
;TABLE UPLOAD
ilen filelen Sfile
isr filesr Sfile
ich filenchnls Sfile
isamp = ilen*isr
;print ilen, isr, isamp
i_ipow2 = 1
while i_ipow2 < isamp do
i_ipow2 = i_ipow2 * 2
od
printf “File name %s\n”, 1, Sfile
printf “File sample rate %d\n”, 1, isr
printf “File duration %d\n”, 1, ilen
printf “File number of samples %d\n”, 1, isamp
printf “The next power of 2 after %d samples is %d\n”, 1, isamp, i_ipow2
printf “File channels %d\n”, 1, ich
ifno1 ftgen 0, 0, i_ipow2,1, Sfile, 0, 0, 0
ibasfrq = isr / ftlen(ifno1)
ibasfrqst= ibasfrq*ich
kEnv madsr .1, .2, .6, .4
a1 oscili 1, ibasfrqst, ifno1
outs a1kEnv, a1kEnv
endin
f0 z
;---------------------------------------------------------------------------------------------------------
CONSOLE ERROR (when opening presets):
INIT ERROR in instr 1 (opcode filesr) line 29: diskinfo cannot open “C:/Users/ALE/Desktop/CSOUND FILES/TEST SAMPLES/fox 48.wav”
This is the crash issue with Grain 1: