Skip to content

Commit

Permalink
Continuous integration using GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Aug 12, 2021
1 parent 662bf3d commit a875519
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 33 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/cmakebuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI - Build and Test
on:
push:
pull_request:
branches: [ master ]
jobs:
build:
strategy:
matrix:
build-type: [ Debug, Release ]
port-audio: [ ENABLE_PORTAUDIO=ON, ENABLE_PORTAUDIO=OFF ]
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
run: |
sudo apt update
sudo apt install --yes --quiet --no-install-recommends \
libasound2-dev \
libmp3lame-dev \
libogg-dev \
libsndfile1-dev \
libvorbis-dev \
portaudio19-dev
- uses: actions/checkout@v2
- name: Create Build Environment
run: cmake -E make_directory ${{ github.workspace }}/build
- name: Configure CMake
working-directory: ${{ github.workspace }}/build
# Note the current convention is to use the -S and -B options here to
# specify source and build directories, but this is only available with
# CMake 3.13 and higher. The CMake binaries on the Github Actions
# machines are (as of this writing) 3.12
run: >
cmake $GITHUB_WORKSPACE
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
-D${{ matrix.port-audio }}
-DENABLE_MP3LAME=ON
-DENABLE_SNDFILE=ON
-DENABLE_VORBIS=ON
- name: Build
working-directory: ${{ github.workspace }}/build
run: cmake --build . --config ${{ matrix.build-type }}
- name: Test
working-directory: ${{ github.workspace }}/build
run: ctest -C ${{ matrix.build-type }}
54 changes: 54 additions & 0 deletions .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CodeQL Analysis
on:
push:
pull_request:
branches: [ master ]
jobs:
analyze:
permissions:
actions: read
contents: read
security-events: write
strategy:
matrix:
build-type: [ Release ]
language: [ cpp ]
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
run: |
sudo apt update
sudo apt install --yes --quiet --no-install-recommends \
libasound2-dev \
libmp3lame-dev \
libogg-dev \
libsndfile1-dev \
libvorbis-dev \
portaudio19-dev
- uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
queries: security-and-quality
- name: Create Build Environment
run: cmake -E make_directory ${{ github.workspace }}/build
- name: Configure CMake
working-directory: ${{ github.workspace }}/build
# Note the current convention is to use the -S and -B options here to
# specify source and build directories, but this is only available with
# CMake 3.13 and higher. The CMake binaries on the Github Actions
# machines are (as of this writing) 3.12
run: >
cmake $GITHUB_WORKSPACE
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
-DENABLE_PORTAUDIO=ON
-DENABLE_MP3LAME=ON
-DENABLE_SNDFILE=ON
-DENABLE_VORBIS=ON
- name: Build
working-directory: ${{ github.workspace }}/build
run: cmake --build . --config ${{ matrix.build-type }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2010-2020 Arkadiusz Bokowy <[email protected]>
Copyright (c) 2010-2021 Arkadiusz Bokowy <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SVAR - Simple Voice Activated Recorder
======================================
# SVAR - Simple Voice Activated Recorder

[![Build Status](https://github.com/Arkq/svar/actions/workflows/cmakebuild.yaml/badge.svg)](https://github.com/Arkq/svar/actions/workflows/cmakebuild.yaml)

It is a simple console application (low memory footprint and CPU usage) designed for recording
audio when a specified signal level is exceeded. It is commonly known solution called Voice
Expand All @@ -12,6 +13,7 @@ Alternatively, it is possible to force PortAudio back-end on Linux systems by ad
`-DENABLE_PORTAUDIO=ON` to the CMake configuration step.

Currently this application supports four output formats:

- RAW (PCM 16bit interleaved)
- WAV ([libsndfile](http://www.mega-nerd.com/libsndfile/))
- MP3 ([mp3lame](http://lame.sourceforge.net/))
Expand All @@ -30,9 +32,10 @@ For the fine adjustment of the activation condition (the signal level), one can
the RMS is displayed. Activation threshold is based on the maximal peak value in the signal
packed (time of tenth of the second).

Installation
------------
## Installation

$ mkdir build && cd build
$ cmake .. -DENABLE_SNDFILE=ON -DENABLE_MP3LAME=ON -DENABLE_VORBIS=ON
$ make && make install
```sh
mkdir build && cd build
cmake .. -DENABLE_SNDFILE=ON -DENABLE_MP3LAME=ON -DENABLE_VORBIS=ON
make && make install
```
14 changes: 12 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SVAR - main.c
* Copyright (c) 2010-2020 Arkadiusz Bokowy
* Copyright (c) 2010-2021 Arkadiusz Bokowy
*
* This file is a part of SVAR.
*
Expand Down Expand Up @@ -49,9 +49,15 @@

enum output_format {
FORMAT_RAW = 0,
#if ENABLE_SNDFILE
FORMAT_WAV,
#endif
#if ENABLE_MP3LAME
FORMAT_MP3,
#endif
#if ENABLE_VORBIS
FORMAT_OGG,
#endif
};

/* available output formats */
Expand Down Expand Up @@ -225,15 +231,19 @@ static void print_audio_info(void) {
if (!appconfig.signal_meter)
printf("Output file format: %s\n",
get_output_format_name(appconfig.output_format));
#if ENABLE_MP3LAME
if (appconfig.output_format == FORMAT_MP3)
printf("Output bit rate [min, max]: %d, %d kbit/s\n",
appconfig.bitrate_min / 1000,
appconfig.bitrate_max / 1000);
#endif
#if ENABLE_VORBIS
if (appconfig.output_format == FORMAT_OGG)
printf("Output bit rate [min, nominal, max]: %d, %d, %d kbit/s\n",
appconfig.bitrate_min / 1000,
appconfig.bitrate_nom / 1000,
appconfig.bitrate_max / 1000);
#endif
}

#if ENABLE_PORTAUDIO
Expand Down Expand Up @@ -272,7 +282,7 @@ static void peak_check_S16_LE(const int16_t *buffer, size_t frames, int channels
sum2 += abslvl * abslvl;
}

*rms = sqrt((double)sum2 / frames);
*rms = ceil(sqrt((double)sum2 / frames));
}

/* Process incoming audio frames. */
Expand Down

0 comments on commit a875519

Please sign in to comment.