Skip to content

Commit

Permalink
Optionally use PortAudio as an audio back-end
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Jan 29, 2020
1 parent 4a2c854 commit 039e24e
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 108 deletions.
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
sudo: false
dist: xenial

language: c

addons:
apt:
packages:
- libasound2-dev
- libmp3lame-dev
- libsndfile1-dev
- libvorbis-dev
- portaudio19-dev

before_script:
- mkdir build && cd build

script:
- cmake .. && make
- cmake .. -DCMAKE_BUILD_TYPE=Debug && make
- cmake .. -DCMAKE_BUILD_TYPE=Release && make
- cmake .. -DENABLE_SNDFILE=ON -DENABLE_MP3LAME=ON -DENABLE_VORBIS=ON && make
- cmake .. -DENABLE_PORTAUDIO=ON && make
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
set(DEBUG TRUE)
endif()

if(CMAKE_SYSTEM_NAME MATCHES Linux)
option(ENABLE_PORTAUDIO "Use PortAudio as an audio back-end.")
else()
set(ENABLE_PORTAUDIO ON)
endif()

option(ENABLE_MP3LAME "Enable MP3 support.")
option(ENABLE_SNDFILE "Enable WAV support.")
option(ENABLE_VORBIS "Enable OGG support.")
Expand All @@ -40,8 +46,13 @@ target_link_libraries(svar m)
find_package(Threads REQUIRED)
target_link_libraries(svar Threads::Threads)

pkg_check_modules(ALSA REQUIRED IMPORTED_TARGET alsa)
target_link_libraries(svar PkgConfig::ALSA)
if(ENABLE_PORTAUDIO)
pkg_check_modules(PortAudio REQUIRED IMPORTED_TARGET portaudio-2.0)
target_link_libraries(svar PkgConfig::PortAudio)
else()
pkg_check_modules(ALSA REQUIRED IMPORTED_TARGET alsa)
target_link_libraries(svar PkgConfig::ALSA)
endif()

if(ENABLE_SNDFILE)
pkg_check_modules(SNDFile REQUIRED IMPORTED_TARGET sndfile)
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ SVAR - Simple Voice Activated Recorder
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
Operated Recording (VOR). When the signal level is low for longer than the fadeout time, audio
recording is paused. Capturing the audio signal is based on the
[ALSA](http://www.alsa-project.org/) technology, so it should work on all modern Linux systems.
recording is paused.

On Linux systems, capturing the audio signal is based on the [ALSA](http://www.alsa-project.org/)
technology. For all other systems, [PortAudio](http://www.portaudio.com/) library will be used.
Alternatively, it is possible to force PortAudio back-end on Linux systems by adding
`-DENABLE_PORTAUDIO=ON` to the CMake configuration step.

Currently this application supports four output formats:
- RAW (PCM 16bit interleaved)
Expand Down
2 changes: 2 additions & 0 deletions cmake/FindMp3Lame.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
find_path(LAME_INCLUDE_DIR lame/lame.h)
find_library(LAME_LIBRARIES NAMES mp3lame)

mark_as_advanced(LAME_INCLUDE_DIR)

if(LAME_INCLUDE_DIR AND LAME_LIBRARIES)

add_library(Mp3Lame::Mp3Lame INTERFACE IMPORTED)
Expand Down
15 changes: 12 additions & 3 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@
/* Define to 1 if debugging is enabled. */
#cmakedefine DEBUG 1

/* Define to 1 if MP3LAME is enabled. */
/* Define to 1 if PortAudio is enabled. */
#cmakedefine ENABLE_PORTAUDIO 1

/* Define to 1 if Mp3Lame is enabled. */
#cmakedefine ENABLE_MP3LAME 1

/* Define to 1 if SNDFILE is enabled. */
/* Define to 1 if SNDFile is enabled. */
#cmakedefine ENABLE_SNDFILE 1

/* Define to 1 if OGG is enabled. */
/* Define to 1 if Ogg Vorbis is enabled. */
#cmakedefine ENABLE_VORBIS 1

/* Define to the name of this project. */
#define PROJECT_NAME "@PROJECT_NAME@"

/* Define to the version of this project. */
#define PROJECT_VERSION "@PROJECT_VERSION@"
Loading

0 comments on commit 039e24e

Please sign in to comment.