[Csnd] pvstencil
Date | 2012-03-27 23:03 |
From | Oeyvind Brandtsegg |
Subject | [Csnd] pvstencil |
Hi, I am searching for an adaptive masking method, like pvstencil, but with gain modification only if the signal is *above* the threshold set in the masking table. I had thought I could do it with pvstencil, but keep failing to see how... Any ideas? I would like to use it to control the resulting amplitude when convolving two signals and they accidentally coincide on the same resonant frequencies. I'd like to leave the signal unchanged whenever the two signals contain (more or less) different spectra, and only apply filtering when the signals have somewhat similar/matching spectra. best Oeyvind |
Date | 2012-03-27 23:25 |
From | peiman khosravi |
Subject | Re: [Csnd] pvstencil |
Hi Oeyvind, I have something like this in FFTools that mimics the GRM tools contrast plug-in. It basically devides the bins into three groups according to two threshold values. You can then do what you want to to any of the groups. Here is the CSD (the magic happens in the UDO). It's a bit messy and not that straightforward. Let me know if it doesn't make sense! Best, Peiman <CsoundSynthesizer> <CsOptions> </CsOptions> <CsInstruments> sr=96000 ksmps=100 nchnls=1 0dbfs = 1 opcode thresh, 0, kkkkkkiii klowgain,kmidgain,khighgain,kthreshlow, kthreshhigh, kband, inumbins, iampout, iampinsmooth xin iclear ftgen 0, 0, inumbins, 2, 0 tablecopy iampout, iclear kcount = 0 kvol = 0 kbandfixed = kband loop: kamp table kcount, iampinsmooth kvol = kvol + kamp kcount = kcount + 1 if (kcount == kband) kgoto thresh kgoto loop thresh: kband2 = kband kband = kband + kbandfixed kvol = kvol / kbandfixed if (kvol < kthreshlow) kgoto low kgoto high low: kband3 = kband2-kbandfixed vadd iampout, klowgain, kbandfixed, kband3 kgoto contin high: ;printk2 kvol kband3 = kband2-kbandfixed if (kvol < kthreshhigh) then vadd iampout, kmidgain, kbandfixed, kband3 else vadd iampout, khighgain, kbandfixed, kband3 endif kgoto contin contin: kvol = 0 if (kcount < inumbins) kgoto loop endop instr 1 iampout ftgen 0,0,32769,2,0 iampinsmooth ftgen 0,0,32769,2,0 kfftsize init 4096 kol init 4 kwindmult init 2 kwindtype init 0 kBand init 256 kfftsize chnget "fftsize" kol chnget "ol" kwindmult chnget "window" kwindtype chnget "windtype" kBand chnget "bands" ktrig changed kfftsize,kol, kwindmult, kwindtype, kBand if ktrig = 1 then reinit pass endif pass: ifftsize = i(kfftsize) iol = i(kol) iNumBins = ifftsize/2 + 1 ihop = ifftsize/iol iwindow = ifftsize*i(kwindmult) iwindtype = i(kwindtype) ibands = i(kBand) ; if (ihop >= ifftsize) then ihop = ihop / 2 endif if (ihop < 16) then ihop = 16 endif kdepth chnget "depth" kdepth port kdepth, 0.01 kaver chnget "aver" ksmooth chnget "smooth" kthreshHigh chnget "threshH" kthreshLow chnget "threshL" khighGain chnget "gainH" khighGain port khighGain, 0.01 khighGain = khighGain+0.000000001 kmidGain chnget "gainM" kmidGain port kmidGain, 0.01 kmidGain = kmidGain+0.000000001 klowGain chnget "gainL" klowGain port klowGain, 0.01 klowGain = klowGain+0.000000001 ain1 in fsig1 pvsanal ain1, ifftsize, ihop, iwindow, iwindtype fsigblur pvsblur fsig1, ,0, 2 kflag pvsftw fsigblur, iampinsmooth if (kflag == 1) then ; only proc when frame is ready thresh klowGain,kmidGain,khighGain,kthreshLow, kthreshHigh, ibands, iNumBins, iampout, iampinsmooth pvsftr fsigblur, iampout endif fsigsmooth pvsmooth fsigblur, ksmooth, ksmooth fsigout pvsfilter fsig1, fsigsmooth, kdepth aout1 pvsynth fsigout out aout1 endin </CsInstruments> <CsScore> i1 0 36000 e </CsScore> </CsoundSynthesizer> On 27 March 2012 23:03, Oeyvind Brandtsegg <oyvind.brandtsegg@ntnu.no> wrote: Hi, |
Date | 2012-03-28 07:36 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] pvstencil |
Thanks Peiman, it looks like an interesting effect, but I can't seem to make it work properly (not having the expected effect on the audio output when adjusting the parameters) Do you have some example parameter settings? best Oeyvind 2012/3/28 peiman khosravi |
Date | 2012-03-28 08:09 | |
From | Emil Barton | |
Subject | [Csnd] What's the best legato one can achieve with Mykelson's flute? | |
|
Date | 2012-03-28 11:56 |
From | Tito Latini |
Subject | Re: [Csnd] pvstencil |
Attachments | None |
Date | 2012-03-28 21:53 |
From | peiman khosravi |
Subject | Re: [Csnd] pvstencil |
Yes it makes more sense with the max patch that controls the parameters. I'll dig out some settings for you later tonight (sorry just got home form a long day's work and must eat first!). P
On 28 March 2012 07:36, Oeyvind Brandtsegg <oyvind.brandtsegg@ntnu.no> wrote: Thanks Peiman, it looks like an interesting effect, |
Date | 2012-03-29 00:34 |
From | peiman khosravi |
Subject | Re: [Csnd] pvstencil |
Hi Oeyvind, Try these settings. I've also commented the parameters to make some sense. Best, Peiman <CsoundSynthesizer> <CsOptions> -odac </CsOptions> <CsInstruments> sr=44100 ksmps=100 nchnls=1 0dbfs = 1 opcode thresh, 0, kkkkkkiii klowgain,kmidgain,khighgain,kthreshlow, kthreshhigh, kband, inumbins, iampout, iampinsmooth xin iclear ftgen 0, 0, inumbins, 2, 0 tablecopy iampout, iclear kcount = 0 kvol = 0 kbandfixed = kband loop: kamp table kcount, iampinsmooth kvol = kvol + kamp kcount = kcount + 1 if (kcount == kband) kgoto thresh kgoto loop thresh: kband2 = kband kband = kband + kbandfixed kvol = kvol / kbandfixed if (kvol < kthreshlow) kgoto low kgoto high low: kband3 = kband2-kbandfixed vadd iampout, klowgain, kbandfixed, kband3 kgoto contin high: ;printk2 kvol kband3 = kband2-kbandfixed if (kvol < kthreshhigh) then vadd iampout, kmidgain, kbandfixed, kband3 else vadd iampout, khighgain, kbandfixed, kband3 endif kgoto contin contin: kvol = 0 if (kcount < inumbins) kgoto loop endop instr 1 Sfile = "/Applications/Max5/examples/sounds/cherokee.aif" kBand init 1 ;number of frequency bands into which the fft bins are devided. 1 means one bin per band. kdepth init 1 ;0 is 100 dry signal kaver init 0 ;time in seconds for averaging the spectral changes in the analysed signal. Gives a smoother result ksmooth init 1 ;smoothing the dynamic changes applied to the input signal kthreshHigh init .05 ;value for the upper amplitude threshold kthreshLow init .03 ;value for the lower amplitude threshold ;This setting will zero all the bins above kmidGain khighGain init 1 ;gain applied to bins whose amplitude falls above kthreshHigh kmidGain init 0 ;gain applied to bins whose amplitude falls below kthreshHigh and above kthreshLow klowGain init 0 ;gain applied to bins whose amplitude falls below kthreshLow kfftsize init 4096 kol init 4 kwindmult init 2 kwindtype init 0 kfftsize chnget "fftsize" kol chnget "ol" kwindmult chnget "window" kwindtype chnget "windtype" kBand chnget "bands" iampout ftgen 0,0,32769,2,0 iampinsmooth ftgen 0,0,32769,2,0 ktrig changed kfftsize,kol, kwindmult, kwindtype, kBand if ktrig = 1 then reinit pass endif pass: ifftsize = i(kfftsize) iol = i(kol) iNumBins = ifftsize/2 + 1 ihop = ifftsize/iol iwindow = ifftsize*i(kwindmult) iwindtype = i(kwindtype) ibands = i(kBand) ; if (ihop >= ifftsize) then ihop = ihop / 2 endif if (ihop < 16) then ihop = 16 endif ;avoide denormalisation khighGain = khighGain+0.000000001 kmidGain = kmidGain+0.000000001 klowGain = klowGain+0.000000001 ain1 diskin Sfile, 1, 0, 1 fsig1 pvsanal ain1, ifftsize, ihop, iwindow, iwindtype fsig1copy pvsmix fsig1, fsig1 ;fsigblur pvsmooth fsig1, ksmooth, ksmooth kflag pvsftw fsig1copy, iampinsmooth if (kflag == 1) then ; only proc when frame is ready thresh klowGain,kmidGain,khighGain,kthreshLow, kthreshHigh, ibands, iNumBins, iampout, iampinsmooth pvsftr fsig1copy, iampout endif fsigsmooth pvsmooth fsig1copy, ksmooth, 1 fsigout pvsfilter fsig1, fsigsmooth, kdepth aout1 pvsynth fsigout out aout1 endin </CsInstruments> <CsScore> i1 0 36000 e </CsScore> </CsoundSynthesizer> |
Date | 2012-03-30 11:26 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] pvstencil |
Thanks Peiman and Tito for the nice suggestions, I can adapt these ideas to fit my purposes. best Oeyvind 2012/3/29 peiman khosravi |
Date | 2012-03-30 11:33 |
From | Tito Latini |
Subject | Re: [Csnd] pvstencil |
Attachments | None |
Date | 2012-03-30 14:28 |
From | Oeyvind Brandtsegg |
Subject | Re: [Csnd] pvstencil |
got it, thanks :-) 2012/3/30 Tito Latini |
Date | 2012-03-31 16:39 |
From | Steven Yi |
Subject | Re: [Csnd] What's the best legato one can achieve with Mykelson's flute? |
Hi Emil, I did not look at the code in detail, but I did notice: idur = p3 If you are using tied notes for legato then you will need to change that to: idur = abs(p3) because p3 will be negative. That would certainly cause issues as idur is used as-is elsewhere in that instrument. As for flute sounds, have you looked at Lee Zakian's flute instruments? http://www.jlpublishing.com/Csound.htm The zip for Transversal Meditiation has orc/sco files. I've always enjoyed the sounds in that piece. steven On Wed, Mar 28, 2012 at 8:09 AM, Emil Barton |
Date | 2012-03-31 18:54 |
From | PMA |
Subject | Re: [Csnd] What's the best legato one can achieve with Mykelson's |
Emil, You've surely already considered this, but just in case: does your algorithm for legato notes -- i.e., the notes that are to be connected *to* -- omit the attack phase? Peter Steven Yi wrote: > Hi Emil, > > I did not look at the code in detail, but I did notice: > > idur = p3 > > If you are using tied notes for legato then you will need to change that to: > > idur = abs(p3) > > because p3 will be negative. That would certainly cause issues as > idur is used as-is elsewhere in that instrument. > > As for flute sounds, have you looked at Lee Zakian's flute instruments? > > http://www.jlpublishing.com/Csound.htm > > The zip for Transversal Meditiation has orc/sco files. I've always > enjoyed the sounds in that piece. > > steven > > > > On Wed, Mar 28, 2012 at 8:09 AM, Emil Barton |
Date | 2012-03-31 19:12 |
From | PMA |
Subject | Re: [Csnd] What's the best legato one can achieve with Mykelson's |
P.S. I suppose that's what tied notes are for, but I don't know how well they "do" legato per se. PMA wrote: > Emil, > > You've surely already considered this, but just in case: > does your algorithm for legato notes -- i.e., the notes > that are to be connected *to* -- omit the attack phase? > > Peter > > > Steven Yi wrote: >> Hi Emil, >> >> I did not look at the code in detail, but I did notice: >> >> idur = p3 >> >> If you are using tied notes for legato then you will need to change >> that to: >> >> idur = abs(p3) >> >> because p3 will be negative. That would certainly cause issues as >> idur is used as-is elsewhere in that instrument. >> >> As for flute sounds, have you looked at Lee Zakian's flute instruments? >> >> http://www.jlpublishing.com/Csound.htm >> >> The zip for Transversal Meditiation has orc/sco files. I've always >> enjoyed the sounds in that piece. >> >> steven >> >> >> >> On Wed, Mar 28, 2012 at 8:09 AM, Emil Barton |