From 8cdf2e426a8a733341517161b9b42a56091b4751 Mon Sep 17 00:00:00 2001 From: wilzh40 Date: Mon, 20 Feb 2023 17:06:39 -0800 Subject: [PATCH] Added Github actions for both cmake and clang-format, formatted code. --- .github/workflows/cmake.yaml | 46 ++++++++++++++++++++++++++ .github/workflows/format.yaml | 13 ++++++++ src/audio/tflite/InferencePipeline.cpp | 8 ++--- 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/cmake.yaml create mode 100644 .github/workflows/format.yaml diff --git a/.github/workflows/cmake.yaml b/.github/workflows/cmake.yaml new file mode 100644 index 0000000..b5cad3a --- /dev/null +++ b/.github/workflows/cmake.yaml @@ -0,0 +1,46 @@ +name: CI + +on: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + + workflow_dispatch: + +jobs: + build_and_test: + name: Test plugin on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false # show all errors for each platform (vs. cancel jobs on error) + matrix: + os: [macOS-latest] # TODO: enable other OSes [ubuntu-latest, windows-2019, macOS-latest] + + steps: + - name: Get latest CMake + uses: lukka/get-cmake@latest + + - name: Get latest Ninja + uses: seanmiddleditch/gha-setup-ninja@v3 + + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Init repo + shell: bash + run: ./repo-init.sh + + - name: Configure Build (Ninja) + shell: bash + run: cmake -B build-ninja -S . -G Ninja + + - name: Build CMake (Ninja) + shell: bash + run: cmake --build build-ninja \ No newline at end of file diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml new file mode 100644 index 0000000..949a5a6 --- /dev/null +++ b/.github/workflows/format.yaml @@ -0,0 +1,13 @@ +name: Check clang-format +on: [push, pull_request] +jobs: + formatting-check: + name: Formatting Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run clang-format style check for C/C++/Protobuf programs. + uses: jidicula/clang-format-action@v4.10.2 + with: + clang-format-version: '13' + check-path: 'src' \ No newline at end of file diff --git a/src/audio/tflite/InferencePipeline.cpp b/src/audio/tflite/InferencePipeline.cpp index 9dba192..5d0e593 100644 --- a/src/audio/tflite/InferencePipeline.cpp +++ b/src/audio/tflite/InferencePipeline.cpp @@ -35,21 +35,21 @@ InferencePipeline::~InferencePipeline() {} void InferencePipeline::prepareToPlay (double sr, int samplesPerBlock) { sampleRate = sr; - + // Calculate the hopsize and framesize of the model at the // user's sample rate in order to load the holding input buffer. - + // The frame size is the amount that is copied for downsampling and is // independent of the amount that is removed from the buffer after processing (hopsize). // Use ceil to ensure there are enough samples to correctly perform downsampling later. userFrameSize = static_cast (ceil (sampleRate * kModelFrameSize / kModelSampleRate_Hz)); - + // If the hopsize of the model does not convert evenly to the user's sample rate, logic // must be written to handle this when advancing the pointer in the holding input buffer. // E.g. 44100 * 320 / 16000 = 882 // As is, this works with standard sample rates of 44.1k, 48k, 88.2k, 96k, 176.4k and 192k. userHopSize = static_cast (sampleRate * kModelHopSize / kModelSampleRate_Hz); - + DBG ("User Sample Rate: " << sampleRate); DBG ("User Frame Size: " << userFrameSize); DBG ("User Hop Size: " << userHopSize);