Hi Jeanette. As you know I’ve been tinkering with the slightly unpredictable world of physical modeling (noise is random!).
In this case I found using the noise opcode beneficial due to the ability to constrain it with the built in lpf (kbeta). It helps even out amplitudes; without a lpf I find higher notes are much louder.
-odac -m2
; -o wguide1_dur_48000.wav
sr = 48000
ksmps = 32
nchnls = 2
0dbfs = 1
gkCnt init 0
seed 0
instr trig
kNote[] fillarray 33, 40, 45, 52, 57, 64, 69
kLen = lenarray(kNote)
kTrig = metro(.2)
kFreq = mtof(kNote[gkCnt])
schedkwhen kTrig, 0, 0, 2, 0, 5, kFreq
if kTrig == 1 then
gkCnt += 1
endif
if gkCnt == kLen then
gkCnt = 0
endif
endin
instr 2
aEnv = expseg:a(1, .1, .0001)
aSig = noise(2 * aEnv, 0.99)
kFreq = p4
; kDur affects general duration of notes
; by exponentially raising cutoff relative
; to note frequency
; in this case, when the highest note (A440)
; is played, the cutoff is 22kHz
iDur = 50 ; affects general duration
kCut = p4 * iDur ; filter cutoff freq.
print p4 ; prints note freq.
print p4 * iDur ; prints cutoff freq.
; kRtio = duration of lower vs higher freq
; ex. value of .5 will increase dur. of high notes vs low
; value of .01 will decrease dur. of higher notes vs low
iRtio = .5
; prints feedback value
print .992 + (.006 - (.6/p4 * iRtio))
kFbk = 0.992 + (.006 - (.6/kFreq * iRtio))
aWg1 = wguide1(aSig, kFreq, kCut, kFbk)
aOut = dcblock2(aWg1)
outs aOut, aOut
endin
i"trig" 0 70
e
Here there are 2 primary factors at work in the code. As the note pitch rises, the cutoff freq increases exponentially & the feedback level increases as well.
For example, with a note at 55 Hz the wguide filter cutoff will be 2750 & the feedback .993
At A440 the cutoff is 22kHz and the feedback .997
I think it creates “plausibly similar” note lengths. To increase overall note lengths you can raise the initial kFbk level above .992
The iRtio value affects the duration ratio of high vs low notes (see comments).
I noticed that notes higher than 440, however, start dropping dramatically in duration. For ex., using an orc sr of 48000, A880 will raise the wguide cutoff to 44kHz but the note has essentially no sustain. However, if the sr is raised to 96000 it’s duration increases substantially (although the timbre of all the notes now sounds brighter to me, I don’t find it particularly appealing…) so clearly the sr of the orc would appear to be a factor.
This does pose another issue though as higher notes again start rising in amplitude. I’m not sure adjusting the noise kbeta would help, I haven’t yet tried it. Perhaps raising the kbeta in relation to the note/cutoff freq. might help.
I think therein lies a possible problem with finding a “simple” formula. There seems to be a relationship between the exciter freq. (and the duration of it), the wguide cutoff freq., the feedback level, the osc sr and the resulting amplitude of each note relating to the exc. freq & wguide cutoff.
Perhaps someone can offer a better mathematical solution (it’s definitely not a strength of mine) as these are only my personal anecdotal experiences. I wonder how practical any formula might be as changes to the exciter source would possibly prevent any method from being precise unless possibly applied in an opcode. And of course noise itself is a random exciter, although that seems beneficial for some models as it inherently creates constant variation.
I hope to see some other responses, I find this a really interesting method of synthesis and there are certainly those here with much more knowledge than myself in this area.
I uploaded two files here for convenience, one at sr 48000 & the other at 96000:
https://github.com/ST-Music/csound-examples/tree/main/physical_modeling/wguide1
Not sure this really answers your question but perhaps offers one perspective.
Best,
Scott