| I'm trying to use arrays to modify pvs amp data,
but it seems I'm not getting what I expect.
Could I be doing something wrong, or is something not working as it should?
In the example below, I (expect to) find the bin with the strongest
amplitude and reduce that amplitude by a factor, then do the same
operation again (100 times).
I resynthesize the unmodified and the modified signal to the right and
left channels respectively.
If I comment out the line
kArr2[kMaxIndx] = kMax*0.01
then I would expect the unmodified and "modified" signals to be the
same but they are not.
sr = 44100
ksmps = 128
nchnls = 2
0dbfs=1
giSine ftgen 0, 0, 65537, 10, 1
; pvs ftables
gifftsize = 512
giFftTabSize = (gifftsize / 2) + 1
gifna ftgen 0 ,0 ,giFftTabSize, 7, 1, giFftTabSize, 1
; make ftable for pvs analysis
gifnf ftgen 0 ,0 ,giFftTabSize, 7, 1, giFftTabSize, 1
; make ftable for pvs analysis
gifnaMod ftgen 0 ,0 ,giFftTabSize, 7, 1, giFftTabSize, 1
; make ftable for modified pvs data
instr 99
; test tone
kscal line 1, p3, 2
a1 oscili 0.1, 220*kscal, giSine
a2 oscili 0.2, 330*kscal, giSine
a3 oscili 0.1, 440*kscal, giSine
a4 oscili 0.5, 1550*kscal, giSine
ain = (a1+a2+a3+a4) * 0.1
iwtype = 0
fsin pvsanal ain, gifftsize, gifftsize/4, gifftsize, iwtype
kflag pvsftw fsin,gifna,gifnf ; export amps
and freqs to table,
; copy pvs data from table to array
; modify amplitude of single bin
; repeat the above N number of times
; transfer array to pvs data
if kflag > 0 then
; copy pvs data from table to array
kArr2[] init giFftTabSize-1
copyf2array kArr2, gifna
kcount = 0
if kcount < 100 then
kMax ,kMaxIndx maxarray kArr2
kArr2[kMaxIndx] = kMax*0.01
kcount = kcount + 1
endif
copya2ftab kArr2, gifnaMod
endif
; resynth unmodified
aout1 pvsynth fsin
; modify and resynth
pvsftr fsin, gifnaMod, gifnf
aout pvsynth fsin
outch 1, aout, 2, aout1
endin
i99 0 10
e
--
Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205
http://flyndresang.no/
http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://soundcloud.com/t-emp
|