Changeset 253

Show
Ignore:
Timestamp:
06/09/06 13:26:17 (18 years ago)
Author:
pieterpalmers
Message:

- trying to fix problems with file locations introcuded earlier

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libfreebob-2.0/src/bebob_light/bebob_light_avdevice.cpp

    r242 r253  
    17861786         
    17871787        } 
     1788 
     1789    // FIXME: do this the proper way! 
     1790    m_transmitProcessor->syncmaster=m_receiveProcessor; 
    17881791 
    17891792        if (!addPlugToProcessor(*inputPlug,m_transmitProcessor,  
  • branches/libfreebob-2.0/src/debugmodule/debugmodule.cpp

    r242 r253  
    9393    va_list arg; 
    9494    va_start( arg, format ); 
    95     DebugModuleManager::instance()->print( "%s (%s)[%d] %s: ", getPreSequence( level ), 
     95    DebugModuleManager::instance()->print( "%s (%s)[%4d] %s: ", getPreSequence( level ), 
    9696                 file,  line,  function ); 
    9797    DebugModuleManager::instance()->va_print( format, arg ); 
  • branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.cpp

    r249 r253  
    4343// this is one milisecond of processing delay 
    4444#define TICKS_PER_SECOND 24576000 
    45 #define RECEIVE_PROCESSING_DELAY (TICKS_PER_SECOND / 500) 
     45#define RECEIVE_PROCESSING_DELAY (TICKS_PER_SECOND * 1/1000) 
    4646 
    4747namespace FreebobStreaming { 
     
    5353/* transmit */ 
    5454AmdtpTransmitStreamProcessor::AmdtpTransmitStreamProcessor(int port, int framerate, int dimension) 
    55         : TransmitStreamProcessor(port, framerate), m_dimension(dimension)
     55        : TransmitStreamProcessor(port, framerate), m_dimension(dimension), m_last_timestamp(0)
    5656 
    5757 
     
    106106                *tag = IEC61883_TAG_WITH_CIP; 
    107107                *sy = 0; 
     108                m_last_timestamp=9000.0 + cycle * 3072.0; 
    108109                return RAW1394_ISO_OK; 
    109110        } 
     
    116117                 
    117118        // construct the packet cip 
    118         int nevents = iec61883_cip_fill_header (getNodeId(), &m_cip_status, packet); 
    119  
     119        // FIXME: this should be done differently: 
     120        // first we should determine the timestamp of the first sample in this block 
     121        // this can be done by reading the rate of the compagnion receiver 
     122        // this rate will give us the ticks per sample used by the device 
     123        // then we should take the previous timestamp, and add m_syt_interval * ticks_per_sample 
     124        // to this timestamp (only if we are sending events). This gives us the timestamp 
     125        // of the first sample in this packet. 
     126        // we should define a transfer delay and add it to this timestamp and then send it to 
     127        // the device. 
     128         
     129        // NOTE: this will even work when we're only transmitting (no receive stream): 
     130        //       the ticks_per_sample value is initialized by the receive streamprocessor 
     131        //       to the nominal value. We will then transmit at our own pace, being at nominal 
     132        //       rate compared to the cycle counter. 
     133 
     134    // NOTE: this scheme might even work when sync'ing on the sync streams of the device 
     135    //       they are AMDTP streams with SYT timestamps, therefore a decent estimate of 
     136    //       ticks_per_frame can be found, and we are synced when using it. 
     137         
     138//      <<compile error here>> 
     139         
     140        int nevents = iec61883_cip_fill_header (getNodeId(), &m_cip_status, packet); 
     141         
     142         
     143        unsigned int timestamp_ticks=m_last_timestamp; // fixed transfer delay 
     144        timestamp_ticks += 9000; 
     145        unsigned int timestamp=(((timestamp_ticks/3072) << 12) & 0xF000); 
     146        timestamp |= ((timestamp_ticks % 3072)) & 0xFFF; 
     147         
     148        timestamp = htons(timestamp); 
     149         
     150        m_last_timestamp += nevents*syncmaster->getTicksPerFrame(); 
     151   
     152    if (nevents==0) { 
     153        timestamp=0xFFFF; 
     154    } 
     155     
    120156        enum raw1394_iso_disposition retval = RAW1394_ISO_OK; 
    121157 
     
    142178         
    143179        // signal underrun 
    144         m_xruns++; 
     180//         m_xruns++; 
    145181 
    146182        retval=RAW1394_ISO_DEFER; 
     
    159195        } 
    160196         
    161         if (packet->syt != 0xFFFF) { 
    162              unsigned int m_last_timestamp=ntohs(packet->syt); 
    163              // reconstruct the top part of the timestamp using the current cycle number 
    164               m_last_timestamp |= ((cycle << 12) & 0x01FF0000); 
    165               
    166              debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Sent packet with SYT for cycle %2d: %5u ticks (%2u cycles + %04u ticks)\n", 
    167              cycle, 
    168              CYCLE_COUNTER_TO_TICKS(m_last_timestamp), 
    169              CYCLE_COUNTER_GET_CYCLES(m_last_timestamp), 
    170              CYCLE_COUNTER_GET_TICKS(m_last_timestamp) 
    171              ); 
    172         } 
     197        unsigned int timestamp2=ntohs(timestamp); 
     198         debugOutput(DEBUG_LEVEL_VERBOSE,"XMIT %d EVENTS, SYT %04X (was: %04X) for cycle %2d: %5u ticks (%2u cycles + %04u ticks)\n", 
     199         nevents, timestamp, packet->syt, cycle, 
     200         CYCLE_COUNTER_TO_TICKS(timestamp2), 
     201         CYCLE_COUNTER_GET_CYCLES(timestamp2), 
     202         CYCLE_COUNTER_GET_TICKS(timestamp2) 
     203         ); 
    173204    } 
    174205     
    175206    *tag = IEC61883_TAG_WITH_CIP; 
    176207    *sy = 0; 
     208     
     209    // FIXME: do this directly 
     210    packet->syt=timestamp; 
    177211     
    178212    // update the frame counter 
     
    205239    // and we should also provide enough prefill for the 
    206240    // SYT processing delay 
    207 /*    if(!transferSilence((m_framerate * RECEIVE_PROCESSING_DELAY)/TICKS_PER_SECOND)) { 
    208         debugFatal("Could not prefill transmit stream\n"); 
    209         return false; 
    210     }*/ 
     241//     if(!transferSilence((m_framerate * RECEIVE_PROCESSING_DELAY)/TICKS_PER_SECOND)) { 
     242//         debugFatal("Could not prefill transmit stream\n"); 
     243//         return false; 
     244//     } 
    211245     
    212246    // the framecounter should be pulled back to 
     
    772806 
    773807AmdtpReceiveStreamProcessor::AmdtpReceiveStreamProcessor(int port, int framerate, int dimension) 
    774     : ReceiveStreamProcessor(port, framerate), m_dimension(dimension), m_last_timestamp(0)
     808    : ReceiveStreamProcessor(port, framerate), m_dimension(dimension), m_last_timestamp(0), m_last_timestamp2(0)
    775809 
    776810 
     
    844878            // actual presentation time later 
    845879            if (packet->syt != 0xFFFF) { 
    846                   
    847                 m_last_timestamp=ntohs(packet->syt); 
     880                 
     881                m_last_timestamp2=m_last_timestamp; 
     882                 
     883                unsigned int syt_timestamp=ntohs(packet->syt); 
    848884                 // reconstruct the top part of the timestamp using the current cycle number 
    849 //                  m_last_timestamp |= ((cycle << 12) & 0x01FF0000); 
    850                 unsigned int syt_cycles=CYCLE_COUNTER_GET_CYCLES(m_last_timestamp); 
    851                 int new_cycles=cycle+(syt_cycles-(cycle & 0xF)); 
    852 //                 m_last_timestamp &= 0xFFF; // keep only the offset 
    853 //                 m_last_timestamp |= ((new_cycles << 12) & 0x01FFF000); // add the right cycle info 
    854                   
     885                unsigned int now_cycle_masked=cycle & 0xF; 
     886                unsigned int syt_cycle=CYCLE_COUNTER_GET_CYCLES(syt_timestamp); 
     887                 
     888                // if this is true, wraparound has occurred, undo this wraparound 
     889                if(syt_cycle<now_cycle_masked) syt_cycle += 0xF; 
     890                 
     891                unsigned int delta_cycles=syt_cycle-now_cycle_masked; 
     892                 
     893                // reconstruct the cycle part of the timestamp 
     894                unsigned int new_cycles=cycle + delta_cycles; 
     895                 
     896                if(new_cycles>7999) new_cycles-=8000; // wrap around 
     897                 
     898                m_last_timestamp = (new_cycles) << 12; 
     899                 
     900                // now add the offset part on top of that 
     901                m_last_timestamp |= (syt_timestamp & 0xFFF); 
     902                 
     903                // m_last_timestamp timestamp now contains all info, 
     904                // including cycle number 
     905                 
     906                if (m_last_timestamp & m_last_timestamp2) { 
     907                    // try and estimate the frame rate from the device: 
     908                    int timestamp_difference=CYCLE_COUNTER_TO_TICKS(m_last_timestamp) 
     909                                             -CYCLE_COUNTER_TO_TICKS(m_last_timestamp2); 
     910                                              
     911                    // handle wrap around of the cycle variable 
     912                    if (new_cycles==0) timestamp_difference+=TICKS_PER_SECOND; 
     913                     
     914                    // implement a 1st order DLL to estimate the framerate 
     915                    // this is the number of ticks between two samples 
     916                    double f=timestamp_difference; 
     917                    double err = timestamp_difference / m_syt_interval; 
     918                    // now it contains the error between our estimate 
     919                    // and the current measurement 
     920                    err=err-m_ticks_per_frame; 
     921                     
     922                    // integrate the error 
     923                    m_ticks_per_frame += 0.000001*err; 
     924                } 
     925                 
    855926                 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"R-SYT for cycle (%2d %2d)=>%2d: %5uT (%04uC + %04uT) %04X %04X %d\n", 
    856                  cycle,cycle & 0xF,new_cycles, 
     927                 cycle,now_cycle_masked,delta_cycles, 
    857928                 CYCLE_COUNTER_TO_TICKS(m_last_timestamp), 
    858929                 CYCLE_COUNTER_GET_CYCLES(m_last_timestamp), 
     
    860931                 ntohs(packet->syt),m_last_timestamp&0xFFFF, dropped 
    861932                 ); 
     933                  
     934#ifdef DEBUG 
     935                if(m_last_timestamp<m_last_timestamp2) { 
     936                    if(new_cycles==0) { 
     937                        debugWarning("timestamp not sequential, but it's wraparound. %08X %08X %08X\n",syt_timestamp, m_last_timestamp, m_last_timestamp2);                    
     938                    } else { 
     939                        debugFatal("timestamp not sequential! %08X %08X %08X\n",syt_timestamp, m_last_timestamp, m_last_timestamp2); 
     940                        return RAW1394_ISO_STOP; 
     941                    } 
     942                } 
     943#endif 
     944 
    862945            } 
    863946        } 
     
    892975// this uses SYT to determine if one period is ready 
    893976bool AmdtpReceiveStreamProcessor::isOnePeriodReady() {  
    894 #if 0 // this code is not ready yet 
     977#define DO_SYT_SYNC 
     978#ifdef DO_SYT_SYNC 
     979 // this code is not ready yet 
    895980 
    896981    // one sample will take a number off cycle counter ticks: 
     
    9371022        // FIXME: if we are sure, make ideal_presentation_time an unsigned int 
    9381023//         assert(ideal_presentation_time>=0); 
    939          
    940          
    941 /*        if(ideal_presentation_time) { 
    942             debugOutput(DEBUG_LEVEL_VERBOSE, "Presentation time < 0 : %d\n", ideal_presentation_time); 
    943         }*/ 
     1024#ifdef DEBUG 
     1025        if(ideal_presentation_time<0) { 
     1026            debugWarning("ideal_presentation_time time is negative!\n"); 
     1027        } 
     1028#endif 
    9441029         
    9451030        unsigned int current_time=m_handler->getCycleCounter() & 0x1FFFFFF; 
     
    9491034        // so add one second 
    9501035//         if (current_time_ticks < m_previous_signal_ticks) current_time_ticks += 24576000; 
    951         debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Periods: %d\n",m_PeriodStat.m_count); 
     1036        debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Periods: %d, remote framerate %f\n",m_PeriodStat.m_count, m_ticks_per_frame); 
    9521037        debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Timestamp : %10u ticks (%3u secs + %4u cycles + %04u ticks)\n", 
    9531038            m_last_timestamp_ticks, 
     
    9781063         
    9791064        if(tmp<0) { 
    980             debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"SYT passed (%d ticks too late)\n",-tmp); 
     1065            debugOutput(DEBUG_LEVEL_VERBOSE,"SYT passed (%d ticks too late)\n",-tmp); 
     1066            debugOutput(DEBUG_LEVEL_VERBOSE,"Periods: %d, remote ticks/frame: %f, remote framerate = %f\n",m_PeriodStat.m_count, m_ticks_per_frame, 24576000.0/m_ticks_per_frame); 
    9811067            if (-tmp>1000000) debugWarning("SYT VERY LATE: %d!\n",-tmp); 
    982             return true; 
     1068//                 return true; 
    9831069        } else { 
    9841070            debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Too early wait %d ticks\n",tmp); 
    985             return false; 
     1071//             return false; 
    9861072        } 
    987     } else return false; 
    988 #endif 
     1073     }  
     1074//      else return false; 
     1075// #else 
    9891076    if(m_framecounter > (int)m_period) { 
    9901077     return true; 
    9911078    } else return false; 
    992  
     1079#endif 
    9931080} 
    9941081 
     
    10141101    m_WakeupStat.reset(); 
    10151102 
     1103    // reset the framerate estimate 
     1104     m_ticks_per_frame = (TICKS_PER_SECOND*1.0) / m_framerate; 
     1105 
     1106     debugOutput(DEBUG_LEVEL_VERBOSE,"Initializing remote ticks/frame to %f\n",m_ticks_per_frame); 
     1107         
     1108        //reset the timestamps 
     1109        m_last_timestamp=0; 
     1110        m_last_timestamp2=0; 
     1111         
    10161112         
    10171113        // reset all non-device specific stuff 
     
    10621158                break; 
    10631159        } 
     1160 
     1161    // prepare the framerate estimate 
     1162    m_ticks_per_frame = (TICKS_PER_SECOND*1.0) / m_framerate; 
     1163 
     1164    debugOutput(DEBUG_LEVEL_VERBOSE,"Initializing remote ticks/frame to %f\n",m_ticks_per_frame); 
    10641165 
    10651166    // allocate the event buffer 
  • branches/libfreebob-2.0/src/libstreaming/AmdtpStreamProcessor.h

    r244 r253  
    5959class AmdtpAudioPort; 
    6060class AmdtpMidiPort; 
     61class AmdtpReceiveStreamProcessor; 
    6162 
    6263/*! 
     
    101102        unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);};  
    102103 
     104    // FIXME: do this the proper way! 
     105    AmdtpReceiveStreamProcessor *syncmaster; 
     106 
    103107protected: 
    104108 
     
    127131        int encodeSilencePortToMBLAEvents(AmdtpAudioPort *, quadlet_t *data, 
    128132                                   unsigned int offset, unsigned int nevents); 
     133 
     134    double m_last_timestamp; 
     135 
    129136 
    130137    DECLARE_DEBUG_MODULE; 
     
    173180        unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);};  
    174181 
     182    double getTicksPerFrame() {return m_ticks_per_frame;}; 
     183     
    175184protected: 
    176185 
     
    186195     
    187196    unsigned int m_last_timestamp; 
     197    unsigned int m_last_timestamp2; 
     198     
     199    double m_ticks_per_frame; 
    188200     
    189201    DECLARE_DEBUG_MODULE; 
  • branches/libfreebob-2.0/src/libstreaming/MotuStreamProcessor.cpp

    r249 r253  
    2727 * 
    2828 */ 
     29 
    2930 
    3031#include "MotuStreamProcessor.h" 
  • branches/libfreebob-2.0/src/libstreaming/MotuStreamProcessor.h

    r246 r253  
    2828#ifndef __FREEBOB_MOTUSTREAMPROCESSOR__ 
    2929#define __FREEBOB_MOTUSTREAMPROCESSOR__ 
     30#include <assert.h> 
    3031 
    3132#include "../debugmodule/debugmodule.h" 
  • branches/libfreebob-2.0/src/libstreaming/Port.h

    r249 r253  
    2828#ifndef __FREEBOB_PORT__ 
    2929#define __FREEBOB_PORT__ 
     30 
     31#include <stdint.h> 
    3032 
    3133#include "../debugmodule/debugmodule.h" 
  • branches/libfreebob-2.0/src/libstreaming/StreamProcessorManager.cpp

    r250 r253  
    157157        } 
    158158         
    159         m_streamingThread->setVerboseLevel(getDebugLevel()); 
    160  
    161159        m_isoManager=new IsoHandlerManager(); 
    162160         
     
    667665 
    668666        if (m_isoManager) m_isoManager->setVerboseLevel(l); 
    669         if (m_streamingThread) m_streamingThread->setVerboseLevel(l); 
    670667 
    671668        debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n"); 
  • branches/libfreebob-2.0/src/libutil/DelayLockedLoop.cpp

    r250 r253  
    2929#include "DelayLockedLoop.h" 
    3030 
    31 namespace FreeBobUtil { 
    32  
    33 IMPL_DEBUG_MODULE( DelayLockedLoop, DelayLockedLoop, DEBUG_LEVEL_NORMAL ); 
    34  
     31namespace FreebobUtil { 
     32 
     33/** 
     34 * Creates a new Delay Locked Loop with a predefined order and 
     35 * a predefined set of coefficients. 
     36 * 
     37 * Make sure coeffs is a float array containing order+1 coefficients. 
     38 * 
     39 * @pre order > 0 
     40 * @param order order of the DLL 
     41 * @param coeffs coefficients to use 
     42 */ 
     43DelayLockedLoop::DelayLockedLoop(unsigned int order, float *coeffs)  
     44
     45    unsigned int i; 
     46     
     47    m_order=order; 
     48    if (m_order==0) m_order=1; 
     49     
     50    m_coeffs=new float[order]; 
     51    m_nodes=new float[order]; 
     52     
     53    for (i=0;i<order;i++) { 
     54        m_coeffs[i]=coeffs[i]; 
     55        m_nodes[i]=0.0; 
     56    } 
     57 
     58
     59 
     60/** 
     61 * Creates a new Delay Locked Loop with a predefined order. 
     62 * All coefficients are set to 0. 
     63 * 
     64 * @pre order > 0 
     65 * @param order order of the DLL 
     66 */ 
     67DelayLockedLoop::DelayLockedLoop(unsigned int order) 
     68
     69    unsigned int i; 
     70     
     71    m_order=order; 
     72    if (m_order==0) m_order=1; 
     73     
     74    m_coeffs=new float[order]; 
     75    m_nodes=new float[order]; 
     76     
     77    for (i=0;i<order;i++) { 
     78        m_coeffs[i]=0.0; 
     79        m_nodes[i]=0.0; 
     80    } 
     81
     82 
     83/** 
     84 * Creates a new first order Delay Locked Loop. 
     85 * The coefficient is set to 0. 
     86 * 
     87 */ 
    3588DelayLockedLoop::DelayLockedLoop() { 
    36  
     89    m_order=1; 
     90     
     91    m_coeffs=new float[1]; 
     92    m_coeffs[0]=0.0; 
     93     
     94    m_nodes=new float[1]; 
     95    m_nodes[0]=0.0; 
    3796} 
    3897 
    3998DelayLockedLoop::~DelayLockedLoop() { 
    40  
     99    if(m_coeffs) delete[] m_coeffs; 
     100    if(m_nodes) delete[] m_nodes; 
     101     
     102
     103     
     104/** 
     105 * Returns the coefficient with index i 
     106 * 
     107 * i should be smaller than the DLL order 
     108 * 
     109 * @param i index of the coefficient 
     110 * @return value of the coefficient 
     111 */ 
     112float  
     113DelayLockedLoop::getCoefficient(unsigned int i) { 
     114     
     115    unsigned int x; 
     116    if (x<m_order) { 
     117        return m_coeffs[x]; 
     118    } else { 
     119        return 0.0; 
     120    } 
     121
     122/** 
     123 * Sets the value of the coefficient with index i 
     124 * 
     125 * i should be smaller than the DLL order 
     126 *  
     127 * @param i index of the coefficient 
     128 * @param c value of the coefficient 
     129 */ 
     130void 
     131DelayLockedLoop::setCoefficient(unsigned int i, float c) { 
     132     
     133    unsigned int x; 
     134    if (x<m_order) { 
     135        m_coeffs[x]=c; 
     136    } 
     137
     138 
     139/** 
     140 * Sets the value of the integrator output with index i. 
     141 * This allows to set the inital values 
     142 * 
     143 * i should be smaller than the DLL order 
     144 *  
     145 * 
     146 * @param i index of the integrator 
     147 * @param c value of the integrator output 
     148 */ 
     149void 
     150DelayLockedLoop::setIntegrator(unsigned int i, float c) { 
     151     
     152    unsigned int x; 
     153    if (x<m_order) { 
     154        m_nodes[x]=c; 
     155    } 
     156
     157 
     158/** 
     159 * Clears the internal state of the DLL,  
     160 * meaning that it will set all internal nodes to 0.0 
     161 */ 
     162void  
     163DelayLockedLoop::reset() { 
     164     
     165    unsigned int i; 
     166    for (i=0;i<m_order;i++) { 
     167        m_nodes[i]=0.0; 
     168    } 
     169     
     170
     171 
     172/** 
     173 * Returns the order of the DLL 
     174 * @return DLL order 
     175 */ 
     176unsigned int  
     177DelayLockedLoop::getOrder() { 
     178    return m_order; 
     179
     180 
     181/** 
     182 * Set the order of the DLL 
     183 * with setting of new coefficients 
     184 * 
     185 * Make sure coeffs is a float array containing 'order' coefficients. 
     186 * 
     187 * resets the DLL before changing the order 
     188 * 
     189 * @pre order > 0 
     190 * @param order new order for the DLL 
     191 * @param coeffs coefficients to use 
     192 */ 
     193void  
     194DelayLockedLoop::setOrder(unsigned int order, float* coeffs) { 
     195    unsigned int i; 
     196     
     197    reset(); 
     198     
     199    m_order=order; 
     200    if (m_order==0) m_order=1; 
     201     
     202    if(m_coeffs) delete[] m_coeffs; 
     203    m_coeffs=new float[order]; 
     204     
     205    if(m_nodes) delete[] m_nodes; 
     206    m_nodes=new float[order]; 
     207     
     208    for (i=0;i<order;i++) { 
     209        m_coeffs[i]=coeffs[i]; 
     210        m_nodes[i]=0.0; 
     211    } 
     212 
     213
     214 
     215/** 
     216 * Set the order of the DLL, 
     217 * the coefficients are set to 0 
     218 * 
     219 * resets the DLL before changing the order 
     220 * 
     221 * @pre order > 0 
     222 * @param order new order for the DLL 
     223 */ 
     224void  
     225DelayLockedLoop::setOrder(unsigned int order) { 
     226    unsigned int i; 
     227     
     228    reset(); 
     229     
     230    m_order=order; 
     231     
     232    if (m_order==0) m_order=1; 
     233     
     234    if(m_coeffs) delete[] m_coeffs; 
     235    m_coeffs=new float[order]; 
     236     
     237    if(m_nodes) delete[] m_nodes; 
     238    m_nodes=new float[order]; 
     239     
     240    for (i=0;i<order;i++) { 
     241        m_coeffs[i]=0.0; 
     242        m_nodes[i]=0.0; 
     243    } 
     244 
     245
     246     
     247/** 
     248 * Put a new value in the loop, updating all internal nodes and 
     249 * the output value. 
     250 * 
     251 * @param v new value 
     252 */ 
     253void  
     254DelayLockedLoop::put(float v) { 
     255 
     256    // we write the calculation out 
     257    // to make use of pipeline-ing and out of order execution 
     258    // except for very high order loops, then we do it looped 
     259     
     260    // error = newval - output 
     261    m_error=v-m_nodes[0]; 
     262 
     263    // update the output value 
     264    m_nodes[0]+=m_error*m_coeffs[0]; 
     265     
     266    if(m_order==1) return; // we are done 
     267     
     268    // add the output of the second integrator 
     269    m_nodes[0]+=m_nodes[1]; 
     270     
     271    // update the second integrator 
     272    m_nodes[1]+=m_error*m_coeffs[1]; 
     273     
     274    if(m_order==2) return; // we are done 
     275     
     276    // if the order is even higher, we are using a loop 
     277    unsigned int i; 
     278    for (i=2; i < m_order;i++) { 
     279        // add the i-th integrator value 
     280        m_nodes[i-1] += m_nodes[i]; 
     281         
     282        // update the i-th integrator 
     283        m_nodes[i] = m_coeffs[i] * m_error; 
     284    } 
     285     
     286    return; 
     287
     288 
     289/** 
     290 * Get the output value of the DLL  
     291 * 
     292 * @return current output value 
     293 */ 
     294float  
     295DelayLockedLoop::get() { 
     296    return m_nodes[0]; 
     297
     298 
     299/** 
     300 * Get the current error signal value 
     301 * 
     302 * @return current error signal value 
     303 */ 
     304float  
     305DelayLockedLoop::getError() { 
     306    return m_error; 
    41307} 
    42308 
  • branches/libfreebob-2.0/src/libutil/DelayLockedLoop.h

    r250 r253  
    2929#define __FREEBOB_DELAYLOCKEDLOOP__ 
    3030 
    31 #include "../debugmodule/debugmodule.h" 
    32  
    33 namespace FreeBobUtil { 
     31namespace FreebobUtil { 
    3432 
    3533class DelayLockedLoop { 
     
    3735public: 
    3836 
     37        DelayLockedLoop(unsigned int order, float *coeffs); 
     38        DelayLockedLoop(unsigned int order); 
    3939        DelayLockedLoop(); 
     40         
    4041        virtual ~DelayLockedLoop(); 
     42     
     43    float getCoefficient(unsigned int i); 
     44    void setCoefficient(unsigned int i, float c); 
     45     
     46    void setIntegrator(unsigned int i, float c); 
     47     
     48    void reset(); 
     49     
     50    unsigned int getOrder(); 
     51    void setOrder(unsigned int i); 
     52    void setOrder(unsigned int order, float* coeffs); 
     53     
     54    void put(float v); 
     55    float get(); 
     56    float getError(); 
     57     
     58protected: 
    4159 
    42 protected: 
    43     DECLARE_DEBUG_MODULE; 
     60    unsigned int m_order; 
    4461 
     62    float *m_coeffs; 
     63    float *m_nodes; 
     64    float m_error; 
    4565}; 
    4666 
  • branches/libfreebob-2.0/src/libutil/Makefile.am

    r250 r253  
    2525 
    2626MAINTAINERCLEANFILES = Makefile.in 
     27noinst_PROGRAMS = test-dll 
     28test_dll_SOURCES = test-dll.cpp 
     29test_dll_LDADD = libutil.la