HardwareHeaven.com

HardwareHeaven.com

Looking for the skin chooser?
 
 
  • Home

  • Hardware reviews

  • Articles

  • News

  • Tools

  • Gaming at HardwareHeaven

  • Forums

 

Go Back   HardwareHeaven.com > Forums > Hardware and Related Topics > kX Project Audio Driver Support Forum > Effects and the DSP


Reply
 
Thread Tools
Old Jan 1, 2003, 03:25 PM   #1
DriverHeaven Newbie
 
Join Date: Jan 2003
Location: Greece
Posts: 4
Rep Power: 0
Gasm is on a distinguished road

Static filter implementation on dane

Hellos to ya all and a happy and creative (or non-"Creative" ) 2003!!!!

Well, my issue is on the implementation of matlab designed static filters on the emu10kx with dane assembler. More specificly the problem is that although the design in matlab seems to be stable when i'm trying to implement the designed filter in dane assembler the results are rather dissapointing . Well actually filtering is occuring but completely different than the specifications!!! For example in the example below i designed a quantised 2nd order lowpass filter with cutoff at 200 Hz in matlab but when i'm trying to implement it using the below code i get something like a highpass but not even the opposite from the one i designed!!!

Here is the matlab filter information

Fs = 48 KHz
Cutoff = 200 Hz
Passband attenuation = 0 db
Stopband attenuation = -40 db

------- Section 1 -------
Numerator
QuantizedCoefficients{1}{1}
(1) 0.3210358396172524
(2) -0.6207185396924615
(3) 0.3210358396172524
Denominator
QuantizedCoefficients{1}{2}
(1) 0.5000000000000000
(2) -0.9855409921146929
(3) 0.4859153456054628

FilterStructure = df1t
ScaleValues = [1]
NumberOfSections = 1
StatesPerSection = [4]
CoefficientFormat = quantizer('fixed', 'round', 'saturate', [32 31])
InputFormat = quantizer('fixed', 'floor', 'saturate', [32 31])
OutputFormat = quantizer('fixed', 'floor', 'saturate', [32 31])
MultiplicandFormat = quantizer('fixed', 'floor', 'saturate', [32 31])
ProductFormat = quantizer('fixed', 'floor', 'saturate', [64 62])
SumFormat = quantizer('fixed', 'floor', 'saturate', [64 62])



And this is the dane code:

input in;
output out;
control level=0;
static b0=0.3210358396172524 , b1=-0.6207185396924615;
static b2=0.3210358396172524 , a0=0.5;
static a1=0.9855409921146929 , a2=-0.4859153456054628;
static x1=0 , x2=0 , y1=0 , y2=0;
temp t1 , t2 , t3;

; code

macs 0 , 0 , 0 , 0;
macmv x2 , x1 , x2 , b2;
macmv x1 , in , x1 , b1;
macmv t1 , t1 , in , b0;
macs t2 , accum , 0 , 0;
macs 0 , 0 , 0 , 0;
macmv y2 , y1 , y2 , a2;
macmv y1 , t2 , y1 , a1;
macmv t1 , t1 , t2 , a0;
macs t3 , accum , 0 , 0;
macs out , 0 , level , t3;

end

At first i thought that the problem was the quantizing but i don't thing that the changes due to quantizing would be so drastic!!!
So please help me with that since being not a student somewhere and studying dsp all alone it's very difficult to finger out something that i may be doing wrong!

Thx for your time and again happy 2003!
__________________
/George B. B.
Gasm is offline   Reply With Quote


Old Jan 3, 2003, 03:24 PM   #2
h/h member-shmember
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,639
Rep Power: 69
Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!

it looks for me that the whole feedback ('denominator') path is implemented incorrectly (sound does not goes through it at all), also i'd recommend you to think of the following stuff:

1. 32bit fixed-point coefficients are really large enough to not care about quantization at all... (just try to compare filters after/before quantization)

2. Think of implementing filter as "Direct-Form II Transpose", it is really better for real applications (especially in terms of required DSP resources)

3. MACMV is very usefull when doing large order FIR filters, but something like "MACS R, accum, X, Y" can produce much more better code for simple second-order IIR.

4. Check the frequency response of the filter you designed once more... Is 30dB boost at 200Hz what you exactly want?
__________________

Last edited by Max M.; Jan 4, 2003 at 02:45 PM.
Max M. is offline   Reply With Quote
Old Jan 6, 2003, 06:42 PM Threadstarter Thread Starter   #3
DriverHeaven Newbie
 
Join Date: Jan 2003
Location: Greece
Posts: 4
Rep Power: 0
Gasm is on a distinguished road

hi max and thx for your answer!

Actually the wrong thing about the implementation is that the "feedback" section is actually a feedforward one in cascade with the first!. But on the other side i think that the signal is passing through it via the t2 register where the accum of the first section in been assigned (please correct me where i'm wrong).

1. Yes you're absolutely right. 32bit fixed-point with a minor "step" of 2^-31 is really enough! (Btw with FDA tool in matlab filter design is being very quick and comparison is done automaticly so no prob there).

2. Well yes ti surely is better; it only needs the half delay registers than direct form I in a biquad (although it is more sensible to overflows but that's not a problem for short static filters), but i'm just trying to know dane better and to learn how to control the signal flow.

3. Yes i think you're right. It'll give better flow control for start.
And i suppose that the missing move instruction is done with a
macs t1 , t2 , 0 , 0 right ?

btw i was checking the biquad filters that come with the package.
are they implemented in direct form I normal or transposed?
(i think it's normal but i'm not sure).
__________________
/George B. B.
Gasm is offline   Reply With Quote
Old Jan 6, 2003, 07:57 PM   #4
kX Project DSP Engineer
 
Join Date: Dec 2002
Location: Denmark
Posts: 94
Rep Power: 0
Soeren_B is on a distinguished road

The filters (peaking, lp,hp,notch,bp and shelvings) are implemented in a direct form I biquad.

'The missing' a0 coef is normalized into the other coefs (all other coefs are divided by a0). The a1 and a2 gets multiplied by -1 before they are transfered to the DSP. Furthermore the values are divided by a scalar value which is needed to keep the values between -1 and 1. This is 'undone' with the 'sca' value in the DSP code.

The overall formula then looks like this (without the scalar):

y[n] = (b0/a0)*x[n] + (b1/a0)*x[n-1] + (b2/a0)*x[n-2]
- (a1/a0)*y[n-1] - (a2/a0)*y[n-2]

.. which rougly translates into to the 5 macmv lines (without the /a0 part).

Scaling and normalizing are done in the GUI/control c++ code (see the developer package).

HTH
Soeren
Soeren_B is offline   Reply With Quote
Old Jan 7, 2003, 02:19 PM   #5
h/h member-shmember
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,639
Rep Power: 69
Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!

>But on the other side i think that the signal is passing through it via the t2 register where the accum of the first section in been assigned (please correct me where i'm wrong).

Yes, but t2 is just immidiately multiplied by a0 and goes to output and never riches a1, a2 and never goes back.
__________________
Max M. is offline   Reply With Quote
Reply

Thread Tools