Professional Web Applications Themes

Info on Altivec convolution function (conv) in vDSP.h - Mac Programming

Anyone have experience using the 'conv' function described in vDSP.h? I can sort of get it to work, but can't figure out how the output is aligned in the result array (or be sure how it should be aligned in the input arrays - is there FFT style swapping of segments?). I get a convolved signal out but I seem to lose more at the ends than I'd expect. An excerpt from vDSP.h is given below. The vDSP pdf guide gives almost no information on how to use this function. Any insights on arrangement of data in input and output ...

  1. #1

    Default Info on Altivec convolution function (conv) in vDSP.h


    Anyone have experience using the 'conv' function described in vDSP.h? I
    can sort of get it to work, but can't figure out how the output is
    aligned in the result array (or be sure how it should be aligned in the
    input arrays - is there FFT style swapping of segments?). I get a
    convolved signal out but I seem to lose more at the ends than I'd expect.

    An excerpt from vDSP.h is given below. The vDSP pdf guide gives almost
    no information on how to use this function. Any insights on arrangement
    of data in input and output arrays would be hugely appreciated...

    ER




    /*
    ?????????????????????????????????????????????????? ?????????????????????????????
    Function conv
    convD

    Floating Point Convolution and Correlation in Single and Double
    Precision

    Criteria to invoke PowerPC vector code:
    1. signal and result must have relative alignement.
    2. 4 <= lenFilter <= 256
    3. lenResult > 36
    4. signalStride = 1
    5. strideResult = 1

    If any of the above criteria are not satisfied, the PowerPC scalar
    code
    implementation will be used. strideFilter can be positive for
    correlation or negative for convolution.
    ?????????????????????????????????????????????????? ?????????????????????????????
    */
    /*
    * conv()
    *
    * Availability:
    * Mac OS X: in version 10.0 and later in vecLib.framework
    * CarbonLib: not in Carbon, but vecLib is compatible with
    Carbon
    * Non-Carbon CFM: in vecLib 1.0 and later
    */
    extern void
    conv(
    const float signal[],
    SInt32 signalStride,
    const float filter[],
    SInt32 strideFilter,
    float result[],
    SInt32 strideResult,
    SInt32 lenResult,
    SInt32 lenFilter) AVAILABLE_
    MAC_OS_X_VERSION_10_0_AND_LATER;


    Eric Raas Guest

  2. #2

    Default Re: Info on Altivec convolution function (conv) in vDSP.h

    > Anyone have experience using the 'conv' function described in vDSP.h?
    > I can sort of get it to work, but can't figure out how the output is
    > aligned in the result array (or be sure how it should be aligned in
    > the input arrays - is there FFT style swapping of segments?). I get
    > a convolved signal out but I seem to lose more at the ends than I'd
    > expect.
    > ...
    Got it - here's what worked in the end:

    1) pick a filter length (must be between 4 and 26 floats)
    2) pick the length of the convolution result (must be more than 36
    floats)
    3) the length of the *input* signal must then be at least the sum of
    the
    lengths of the filter and the output minus one (the ends will not be
    valid).

    In my case I wanted the output result to be the same length as the input
    vector, and to be correctly aligned with the input so I could replace a
    signal with a smoothed copy of itself. Zero padding at the beginning
    and end of the signal with half the length of the filter at each end (
    for a total number of zeros equal to the length of the filter) produced
    the desired result. For example:

    length of original signal = 64 floats
    filter length = 16 floats
    desired result length = 64 floats
    signal length to pass to conv() = 80 floats (minimum would be 79)

    signal is zero padded at each end before passing to conv:

    0 0 0 0 0 0 0 0 (64 floats) 0 0 0 0 0 0 0 0

    I guess this is a fairly standard arrangement for convolution, but I
    wish Apple provided more doentation for these useful functions!



    Eric Raas Guest

  3. #3

    Default Re: Info on Altivec convolution function (conv) in vDSP.h

    Another weird thing, that is mentioned in the pdf file for conv(), is
    that if you want convolution (as opposed to correlation) you must set
    filterStride to -1 and pass a pointer to the *last* element in the
    filter array.
    Eric Raas Guest

Similar Threads

  1. Sending a javascript function with collected info
    By Online_in_Oregon in forum Macromedia Flash Data Integration
    Replies: 1
    Last Post: February 8th, 10:00 PM
  2. Split complex vectors and AltiVec FFT's
    By Eric Raas in forum Mac Programming
    Replies: 4
    Last Post: September 21st, 05:18 PM
  3. note 33962 deleted from function.gd-info by alindeman
    By alindeman@php.net in forum PHP Notes
    Replies: 0
    Last Post: July 12th, 01:05 AM
  4. note 33962 added to function.gd-info
    By Ron@rack1.php.net in forum PHP Notes
    Replies: 0
    Last Post: July 12th, 12:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139