//==========================================================================
// Name:            fdmdv2_defines.h
// Purpose:         Definitions used by plots derived from fdmdv2_plot class.
// Created:         August 27, 2012
// Authors:         David Rowe, David Witten
// 
// License:
//
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License version 2.1,
//  as published by the Free Software Foundation.  This program 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 this program; if not, see <http://www.gnu.org/licenses/>.
//
//==========================================================================
#ifndef __FDMDV2_DEFINES__
#define __FDMDV2_DEFINES__

#include "wx/wx.h"
#include "codec2_fdmdv.h"

// Spectrogram and Waterfall

#define MIN_MAG_DB        -40.0     // min of spectrogram/waterfall magnitude axis
#define MAX_MAG_DB          0.0     // max of spectrogram/waterfall magnitude axis
#define STEP_MAG_DB         5.0     // magnitude axis step
#define BETA                0.95    // constant for time averaging spectrum data
#define MIN_F_HZ            0       // min freq on Waterfall and Spectrum
#define MAX_F_HZ            3000    // max freq on Waterfall and Spectrum
#define STEP_F_HZ           500     // major (e.g. text legend) freq step on Waterfall and Spectrum graticule
#define STEP_MINOR_F_HZ     100     // minor (ticks) freq step on Waterfall and Spectrum graticule
#define WATERFALL_SECS_Y    30      // number of seconds respresented by y axis of waterfall
#define WATERFALL_SECS_STEP 5       // graticule y axis steps of waterfall
#define DT                  0.1     // time between real time graphing updates
#define FS                  8000    // FDMDV modem sample rate

// Scatter diagram 

#define SCATTER_MEM_SECS    2
// (symbols/frame)/(graphics update period) = symbols/s sent to scatter memory
// memory (symbols) = secs of memory * symbols/sec
#define SCATTER_MEM_SYMS_MAX    ((int)(SCATTER_MEM_SECS*((FDMDV_NC_MAX+1)/DT)))

// Waveform plotting constants

#define WAVEFORM_PLOT_FS    400                            // sample rate (points/s) of waveform plotted to screen
#define WAVEFORM_PLOT_TIME  5                              // length or entire waveform on screen
#define WAVEFORM_PLOT_BUF   ((int)(DT*WAVEFORM_PLOT_FS))   // number of new samples we plot per DT

// sample rate I/O & conversion constants

#define MAX_FPB             8096                           // maximum value of portAudio framesPerBuffer
#define PA_FPB              1024                           // nominal value of portAudio framesPerBuffer
#define SAMPLE_RATE         48000                          // 48 kHz sampling rate rec. as we can trust accuracy of sound card
#define N8                  FDMDV_NOM_SAMPLES_PER_FRAME    // processing buffer size at 8 kHz
#define MEM8                (FDMDV_OS_TAPS/FDMDV_OS)
#define N48                 (N8*FDMDV_OS)                  // processing buffer size at 48 kHz
#define NUM_CHANNELS        2                              // I think most sound cards prefer stereo we will convert to mono

#define MAX_BITS_PER_CODEC_FRAME 64                            // 1600 bit/s mode
#define MAX_BYTES_PER_CODEC_FRAME (MAX_BITS_PER_CODEC_FRAME/8)
#define MAX_BITS_PER_FDMDV_FRAME 40                            // 2000 bit/s mode

// Squelch
#define SQ_DEFAULT_SNR      1.5

// Level Gauge
#define FROM_RADIO_MAX       0.8
#define FROM_MIC_MAX         0.8
#define LEVEL_BETA           0.99

// SNR
#define SNRSLOW_BETA        0.5                           // time constant for slow SNR for display

// Data
#define MAX_CALLSIGN         80

enum
{
    ID_ROTATE_LEFT = wxID_HIGHEST + 1,
    ID_ROTATE_RIGHT,
    ID_RESIZE,
    ID_PAINT_BG
};

// Codec 2 LPC Post Filter defaults, from codec-dev/src/quantise.c

#define CODEC2_LPC_PF_GAMMA 0.5
#define CODEC2_LPC_PF_BETA  0.2

// FreeDV modes

#define MODE_1400_V0_91  0   // Legacy 1400 from Dec 2012 V0.91 release with incorrect QPSK mapping
#define MODE_1400        1   // 1400 bit/s codec, no FEC
#define MODE_1600        2   // 1300 bit/s codec, + 300 bit/s FEC
#define MODE_2000        3   // 1400 bit/s codec, 600 bit/s FEC on most sensitive bits, 2000 bit/s total
#define MODE_1600_WIDE   4   // As per 2 but wide carrier spacing

#define FSEP_WIDE      125

#endif  //__FDMDV2_DEFINES__
