Skip to content

Commit

Permalink
Merge pull request magenta#37 from wilzh40/main
Browse files Browse the repository at this point in the history
Added Github actions for both cmake and clang-format, formatted code.
  • Loading branch information
nikhilbhanu authored Feb 24, 2023
2 parents 4e33765 + 8cdf2e4 commit cf5d3c8
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/cmake.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
clang-format-version: '13'
check-path: 'src'
8 changes: 4 additions & 4 deletions src/audio/tflite/InferencePipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> (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<int> (sampleRate * kModelHopSize / kModelSampleRate_Hz);

DBG ("User Sample Rate: " << sampleRate);
DBG ("User Frame Size: " << userFrameSize);
DBG ("User Hop Size: " << userHopSize);
Expand Down

0 comments on commit cf5d3c8

Please sign in to comment.