Hi Michael. Thanks for looking at this.
Yes, a good approach/suggestion, anytime I have these types of issues I use an audio editing program (I’ve posted many images here :)). That’s how I was able to determine the exact time clicks were occuring.
First, I apologize, I probably should have written a better “solved” post. As mentioned in another post, the issue with the initial code is that unlike linseg, linsegr is not properly recognized by tablew inside the same instr.
So when you were testing I’m assuming the clicks were caused due to the fact notes were being triggered two times per sec and the env release time was 3 sec (I purposely made it unnecessarily long). However, as tablew seemingly doesn’t recognize the release time there is no overlap from release time, the amplitude shifts instantly from one note to another causing a click.
The solution was moving the tablew to a seperate instrument & sending the audio to it. In that case, for whatever reason, the release time is then properly recognized. This approach seems to solve the problem(no clicks, linsegr release times recognized):
-odac
; -o/sdcard/click_test.wav
sr = 44100
ksmps = 10
nchnls = 2
0dbfs = 1
gaNdx init 0
giFt ftgen 0, 0, -3*sr, 2, 0
gaSend init
instr trig
iNote[] fillarray 60, 67
gaNdx = phasor(1/3)
kTrig = metro(2)
kNote = int(trandom(kTrig, 0, 1.99))
schedkwhen kTrig, 0, .1, “preplay”, 0, .3, iNote[kNote]
endin
instr preplay
aEnv = linsegr:a(0, .002, .6, p3, .6, 1, 0)
aSig = wgpluck2(.7, 1, cpsmidinn(p4), .2, .3)
gaSend += aSig * aEnv
endin
instr write
aNdx = phasor(1/3)
tablew(gaSend, aNdx, giFt, 1)
clear gaSend
endin
instr read, play
aNdx = phasor(1/3)
aSig = table3:a(aNdx, giFt, 1)
outs aSig, aSig
endin
i"trig" 0 8.1
i"write" 0 9.4
i"read" .1 9.4
I shortened the start time of instr “read” but in the finished instr there had to be a full 3 sec delay in start times, that was the whole put in bothering to write to tables. Hopefully I can post an audio example of that later tonight that makes it clear why.
A quick note to others who may read: I have seen examples of people using a-rate env with functional syntax (myself included), presumably to avoid k-rate clicks. However the rules when using function(al) syntax are different.
This does not work:
aEnv = linsegr(0, .002, .6, p3, .6, 1, 0)
This will produce clicks (although depending on the osc/audio may not always be distinct), the env is still operating at k-rate.
https://www.dropbox.com/s/mel0ao51vzjhel1/click.jpg?dl=0
Running an a-rate env this way appears to be useless.
This will work:
aEnv = linsegr:a(0, .002, .6, p3, .6, 1, 0)
or without functional syntax:
aEnv linsegr 0, .002, .6, p3, .6, 1, 0
I mention this as I’ve learned the hard way, it occasionally plagued me till yesterday. It may have been obvious to all but me, but just in case. I know ambiguities are mentioned in the short Function Syntax section of the Canonical but the particulars weren’t clear to myself.
Best,
Scott
ST Music
https://soundcloud.com/st-csound
https://soundcloud.com/stoons-1
https://youtube.com/channel/UCGhwmkS1uWmX6mhTIQ0IDsg