sudo: required
language: generic
dist: xenial 

addons:
  apt:
    packages:
      libc6-i386
      libspeexdsp-dev
      libsamplerate0-dev
      sox
      git
      octave-common octave gnuplot octave-signal
      
install:
    - export CODEC2DIR=${PWD}/codec2
    - export LPCNETDIR=${PWD}
    - export BUILDDIR=${PWD}/build_linux

script:
    # First build and install vanilla codec2 as we need -lcodec2 to build LPCNet
    - git clone https://github.com/drowe67/codec2.git
    - cd codec2
    - mkdir build_linux && cd build_linux && cmake .. && make
    # OK, build and test LPCNet
    - cd $LPCNETDIR && mkdir -p $BUILDDIR && cd $BUILDDIR 
    - cmake -DCODEC2_BUILD_DIR=$CODEC2DIR/build_linux .. && make
    # simple sanity check
    - cd src && sox ../../wav/wia.wav -t raw -r 16000 - | ./lpcnet_enc -s | ./lpcnet_dec -s > /dev/null
    # some LPCNet ctests
    - ls -l
    - cd $BUILDDIR && ctest --output-on-failure
    # Re-build codec2 with LPCNet and test FreeDV 2020 support
    - cd $CODEC2DIR/build_linux
    - make clean
    - cmake -DLPCNET_BUILD_DIR=$BUILDDIR ..
    - make
    - cd src
    # sanity check
    - ./freedv_tx 2020 $LPCNETDIR/wav/wia.wav - | ./freedv_rx 2020 - /dev/null
