Fast multiplication and DSP

Discussions about programming and implementing Coyote-1 effect modules

Fast multiplication and DSP

Postby sammay » Tue Mar 16, 2010 12:17 pm

To begin implementing some serious signal processing, we'll need some fast multiplication routines.

My ultimate goal is to implement a biquad filter within a microframe. This requires a maximum of 5 multiplications. That would open up all of this good stuff: bandpass, lowpass, peaking EQ filters, shelving filters. Certain biquad filters (e.g. a peaking EQ filter for a graphic equalizer) can be done with less multiplications because some coefficients are the same.

Here is a signed 16-bit multiplication routine that runs in 36 instructions. It's perfect for multiplying a signed 16-bit sample by a positive coefficient smaller than 1.

Code: Select all
'------------------------------------
'Signed multiply                                   
'''------------------------------------
''' Multiply integer part of 16.16 fixed point in m1 (31..16) by the fractional
''' part of 16.16 fixed point in m2 (15..0).
'''
''' On exit, 16.16 fixed point product in m2.
'''
''' m1 may be signed. m2 CANNOT be signed.
'''
''' Takes 36 instructions, 30% faster than the stock _mult.   
'''------------------------------------
_mults
      andn   m1,WORD_MASK
       and   m2,WORD_MASK
      sar   m2,#1   wc '1st bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '2nd bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '3rd bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '4th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '5th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '6th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '7th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '8th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '9th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '10th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '11th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '12th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '13th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '14th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '15th bit
   if_c   adds   m2,m1
      sar   m2,#1   wc '16th bit
   if_c   adds   m2,m1
      sar   m2,#1   'shift final result into place
_mults_ret   ret

m1                       long    $00000000
m2                       long    $00000000


In one microframe we can execute 20MIPS/44kHz = 450 instructions. At a conservative estimate we can then execute 10 of the above multiplications. I'm confident that with careful attention to overflows and fixed point shifts, it will be possible to execute several biquad filters in one microframe.

TL,DR; A THREE OR FOUR BAND EQ SHOULD BE POSSIBLE. ALSO SOPHISTICATED WAH EFFECTS.
sammay
 
Posts: 10
Joined: Fri Feb 12, 2010 5:02 am

Return to Effect Module Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron