<?xml version="1.0"?>
<!--
  Copyright (C) 2016-2017 Free Software Foundation, Inc. 

  This file is part of GNU Radio.

  GNU Radio is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3, or (at your option)
  any later version.
  
  GNU Radio is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with GNU Radio; see the file COPYING.  If not, write to
  the Free Software Foundation, Inc., 51 Franklin Street,
  Boston, MA 02110-1301, USA.
 -->

<block>
    <name>Symbol Sync</name>
    <key>digital_symbol_sync_xx</key>
    <category>[Core]/Synchronizers</category>
    <import>from gnuradio import digital</import>
    <import>from gnuradio import filter</import>
    <make>digital.symbol_sync_$(type)($ted_type, $sps, $loop_bw, $damping, $ted_gain, $max_dev, $osps, $constellation, $resamp_type, $nfilters, $pfb_mf_taps)</make>

    <callback>set_loop_bandwidth($loop_bw)</callback>
    <callback>set_damping_factor($damping)</callback>
    <callback>set_ted_gain($ted_gain)</callback>

    <param>
        <name>I/O Type</name>
        <key>type</key>
        <type>enum</type>
        <option>
            <name>Complex</name>
            <key>cc</key>
            <opt>input:complex</opt>
            <opt>output:complex</opt>
        </option>
        <option>
            <name>Float</name>
            <key>ff</key>
            <opt>input:float</opt>
            <opt>output:float</opt>
        </option>
    </param>
    <param>
        <name>Timing Error Detector</name>
        <key>ted_type</key>
        <type>enum</type>
        <option>
            <name>Mueller and Müller</name>
            <key>digital.TED_MUELLER_AND_MULLER</key>
            <opt>hide_constellation:part</opt>
        </option>
        <option>
            <name>Modified Mueller and Müller</name>
            <key>digital.TED_MOD_MUELLER_AND_MULLER</key>
            <opt>hide_constellation:part</opt>
        </option>
        <option>
            <name>Zero Crossing</name>
            <key>digital.TED_ZERO_CROSSING</key>
            <opt>hide_constellation:part</opt>
        </option>
        <option>
            <name>Gardner</name>
            <key>digital.TED_GARDNER</key>
            <opt>hide_constellation:all</opt>
        </option>
        <option>
            <name>Early-Late</name>
            <key>digital.TED_EARLY_LATE</key>
            <opt>hide_constellation:all</opt>
        </option>
        <option>
            <name>D'Andrea and Mengali Gen MSK</name>
            <key>digital.TED_DANDREA_AND_MENGALI_GEN_MSK</key>
            <opt>hide_constellation:all</opt>
        </option>
        <option>
            <name>Mengali and D'Andrea GMSK</name>
            <key>digital.TED_MENGALI_AND_DANDREA_GMSK</key>
            <opt>hide_constellation:all</opt>
        </option>
        <option>
            <name>y[n]y'[n] Maximum Likelihood</name>
            <key>digital.TED_SIGNAL_TIMES_SLOPE_ML</key>
            <opt>hide_constellation:all</opt>
        </option>
        <option>
            <name>sgn(y[n])y'[n] Maximum Likelihood</name>
            <key>digital.TED_SIGNUM_TIMES_SLOPE_ML</key>
            <opt>hide_constellation:all</opt>
        </option>
    </param>
    <param>
        <name>TED Slicer Constellation</name>
        <key>constellation</key>
        <value>digital.constellation_bpsk().base()</value>
        <type>raw</type>
        <hide>$ted_type.hide_constellation</hide>
    </param>
    <param>
        <name>Samples per Symbol</name>
        <key>sps</key>
        <value>sps</value>
        <type>real</type>
    </param>
    <param>
        <name>Expected TED Gain</name>
        <key>ted_gain</key>
        <value>1.0</value>
        <type>real</type>
    </param>
    <param>
        <name>Loop Bandwidth</name>
        <key>loop_bw</key>
        <value>0.045</value>
        <type>real</type>
    </param>
    <param>
        <name>Damping Factor</name>
        <key>damping</key>
        <value>1.0</value>
        <type>real</type>
    </param>
    <param>
        <name>Maximum Deviation</name>
        <key>max_dev</key>
        <value>1.5</value>
        <type>real</type>
    </param>
    <param>
        <name>Output Samples/Symbol</name>
        <key>osps</key>
        <value>1</value>
        <type>int</type>
    </param>
    <param>
        <name>Interpolating Resampler</name>
        <key>resamp_type</key>
        <type>enum</type>
        <option>
            <name>MMSE, 8 tap FIR</name>
            <key>digital.IR_MMSE_8TAP</key>
            <opt>hide_nfilters:all</opt>
            <opt>hide_pfb_mf_taps:all</opt>
        </option>
        <option>
            <name>Polyphase Filterbank, MMSE</name>
            <key>digital.IR_PFB_NO_MF</key>
            <opt>hide_nfilters:</opt>
            <opt>hide_pfb_mf_taps:all</opt>
        </option>
        <option>
            <name>Polyphase Filterbank, MF</name>
            <key>digital.IR_PFB_MF</key>
            <opt>hide_nfilters:</opt>
            <opt>hide_pfb_mf_taps:</opt>
        </option>
    </param>
    <param>
        <name>Filterbank Arms</name>
        <key>nfilters</key>
        <value>128</value>
        <type>int</type>
        <hide>$resamp_type.hide_nfilters</hide>
    </param>
    <param>
        <name>PFB MF Taps</name>
        <key>pfb_mf_taps</key>
        <value>[]</value>
        <type>real_vector</type>
        <hide>$resamp_type.hide_pfb_mf_taps</hide>
    </param>

    <sink>
        <name>in</name>
        <type>$type.input</type>
    </sink>

    <source>
        <name>out</name>
        <type>$type.output</type>
    </source>
    <source>
        <name>error</name>
        <type>float</type>
        <optional>1</optional>
    </source>
    <source>
        <name>T_inst</name>
        <type>float</type>
        <optional>1</optional>
    </source>
    <source>
        <name>T_avg</name>
        <type>float</type>
        <optional>1</optional>
    </source>
</block>
