Csound Csound-dev Csound-tekno Search About

[Csnd] recursive filtering

Date2014-05-25 15:59
FromAnders Genell
Subject[Csnd] recursive filtering
Dear all!

I am trying to take a wav-file containing a recording of an electrical engine and supress everything except some narrow bands corresponding to harmonics of the engine rpm. I have the harmonics factors and a set of rpm values (samples at 100Hz - it is a vehicle CAN bus) in two text files that I import to tables.

If I do just one harmonic, things sound fine, but if I try to loop through more harmonics, sound becomes distorted.

Any hints?

Regards,
Anders

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
kr = 100
nchnls = 2
0dbfs  = 1

girpm ftgen 0, 0, 0, -23, $INRPM
giharm ftgen 0, 0, 0, -23, $INHARM

turnon 1

instr 1
ilen filelen $INWAV

asigl init 0
asigr init 0
afiltl init 0
afiltr init 0

krpm init 0

awavl, awavr diskin2 $INWAV, 1

tabplay  1, ftlen(girpm), girpm, krpm

icnt = ftlen(giharm)
;icnt = 1
kindex = 0

loop:

 khrm table kindex, giharm
 kcf = krpm*khrm

 afiltl resonx  awavl, kcf, kcf/10, 4
 afiltr resonx  awavr, kcf, kcf/10, 4
 aśigl = asigl + afiltl
 asigr = asigr + afiltr

 kindex = kindex + 1

 if (kindex < icnt) kgoto loop

asigl   balance asigl, awavl
asigr   balance asigr, awavr
        outs    asigl, asigr

ktime timek
if (ktime>=ftlen(girpm)) then
        event "e", 0, 0, 0.1
endif

endin
</CsInstruments>
<CsScore>
</CsScore>
</CsoundSynthesizer>