diff --git a/.github/workflows/c-demos.yml b/.github/workflows/c-demos.yml index d0f117fe6..211672c47 100644 --- a/.github/workflows/c-demos.yml +++ b/.github/workflows/c-demos.yml @@ -48,6 +48,13 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] + include: + - os: ubuntu-latest + pv_recorder_platform: "linux" + - os: windows-latest + pv_recorder_platform: "windows-amd64" + - os: macos-latest + pv_recorder_platform: "mac-arm64" steps: - uses: actions/checkout@v3 @@ -55,7 +62,7 @@ jobs: submodules: recursive - name: Create build directory - run: cmake -B ./build + run: cmake -B ./build -DPV_RECORDER_PLATFORM="${{ matrix.pv_recorder_platform }}" - name: Build micdemo run: cmake --build ./build --target rhino_demo_mic @@ -65,18 +72,33 @@ jobs: strategy: matrix: - machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64] - make_file: ["Unix Makefiles"] + machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64] include: + - machine: rpi3-32 + make_file: "Unix Makefiles" + pv_recorder_platform: "raspberry-pi3" + - machine: rpi3-64 + make_file: "Unix Makefiles" + pv_recorder_platform: "raspberry-pi3-64" + - machine: rpi4-32 + make_file: "Unix Makefiles" + pv_recorder_platform: "raspberry-pi4" + - machine: rpi4-64 + make_file: "Unix Makefiles" + pv_recorder_platform: "raspberry-pi4-64" + - machine: rpi5-64 + make_file: "Unix Makefiles" + pv_recorder_platform: "raspberry-pi5-64" - machine: pv-windows-arm64 make_file: "MinGW Makefiles" + pv_recorder_platform: "windows-arm64" steps: - uses: actions/checkout@v3 with: submodules: recursive - name: Create build directory - run: cmake -G "${{ matrix.make_file }}" -B ./build + run: cmake -G "${{ matrix.make_file }}" -B ./build -DPV_RECORDER_PLATFORM="${{ matrix.pv_recorder_platform }}" - name: Build micdemo run: cmake --build ./build --target rhino_demo_mic @@ -91,12 +113,15 @@ jobs: - os: ubuntu-latest platform: linux arch: x86_64 + pv_recorder_platform: "linux" - os: windows-latest platform: windows arch: amd64 + pv_recorder_platform: "windows-amd64" - os: macos-latest platform: mac arch: arm64 + pv_recorder_platform: "mac-arm64" steps: - uses: actions/checkout@v3 @@ -109,7 +134,7 @@ jobs: python-version: '3.10' - name: Create build directory - run: cmake -B ./build + run: cmake -B ./build -DPV_RECORDER_PLATFORM="${{ matrix.pv_recorder_platform }}" - name: Build filedemo run: cmake --build ./build --target rhino_demo_file @@ -125,28 +150,38 @@ jobs: strategy: matrix: - machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64] - make_file: ["Unix Makefiles"] + machine: [rpi3-32, rpi3-64, rpi4-32, rpi4-64, rpi5-64, pv-windows-arm64] include: - machine: rpi3-32 platform: raspberry-pi arch: cortex-a53 + make_file: "Unix Makefiles" + pv_recorder_platform: "raspberry-pi3" - machine: rpi3-64 platform: raspberry-pi arch: cortex-a53-aarch64 + make_file: "Unix Makefiles" + pv_recorder_platform: "raspberry-pi3-64" - machine: rpi4-32 platform: raspberry-pi arch: cortex-a72 + make_file: "Unix Makefiles" + pv_recorder_platform: "raspberry-pi4" - machine: rpi4-64 platform: raspberry-pi arch: cortex-a72-aarch64 + make_file: "Unix Makefiles" + pv_recorder_platform: "raspberry-pi4-64" - machine: rpi5-64 platform: raspberry-pi arch: cortex-a76-aarch64 + make_file: "Unix Makefiles" + pv_recorder_platform: "raspberry-pi5-64" - machine: pv-windows-arm64 platform: windows arch: arm64 make_file: "MinGW Makefiles" + pv_recorder_platform: "windows-arm64" steps: - uses: actions/checkout@v3 @@ -154,7 +189,7 @@ jobs: submodules: recursive - name: Create build directory - run: cmake -G "${{ matrix.make_file }}" -B ./build + run: cmake -G "${{ matrix.make_file }}" -B ./build -DPV_RECORDER_PLATFORM="${{ matrix.pv_recorder_platform }}" - name: Build filedemo run: cmake --build ./build --target rhino_demo_file diff --git a/demo/c/CMakeLists.txt b/demo/c/CMakeLists.txt index 6d09c3105..2fb87d410 100644 --- a/demo/c/CMakeLists.txt +++ b/demo/c/CMakeLists.txt @@ -3,7 +3,7 @@ project(rhino_demo_c) set(CMAKE_C_STANDARD 99) set(CMAKE_BUILD_TYPE Release) -add_subdirectory(pvrecorder) +add_subdirectory(pvrecorder/project) set(COMMON_LIBS dl) set(MIC_LIBS pthread m) @@ -14,7 +14,7 @@ add_executable( rhino_demo_mic rhino_demo_mic.c $) -target_include_directories(rhino_demo_mic PRIVATE pvrecorder/include) +target_include_directories(rhino_demo_mic PRIVATE pvrecorder/project/include) add_executable( rhino_demo_file diff --git a/demo/c/README.md b/demo/c/README.md index 4a77a74ff..4010d08b2 100644 --- a/demo/c/README.md +++ b/demo/c/README.md @@ -5,6 +5,7 @@ You need a C99-compatible compiler to build these demos. ## Requirements + - The demo requires [CMake](https://cmake.org/) version 3.13 or higher. - **For Windows Only**: [MinGW](https://www.mingw-w64.org/) is required to build the demo. @@ -17,15 +18,21 @@ Signup or Login to [Picovoice Console](https://console.picovoice.ai/) to get you ## Build Linux/MacOS ```console -cmake -S demo/c/. -B demo/c/build && cmake --build demo/c/build --target rhino_demo_mic +cmake -S demo/c/. -B demo/c/build -DPV_RECORDER_PLATFORM={PV_RECORDER_PLATFORM} +cmake --build demo/c/build --target rhino_demo_mic ``` +The {PV_RECORDER_PLATFORM} variable will set the compilation flags for the given platform. Exclude this variable to get a list of possible values. + ## Build Windows ```console -cmake -S demo/c/. -B demo/c/build -G "MinGW Makefiles" && cmake --build demo/c/build --target rhino_demo_mic +cmake -S demo/c/. -B demo/c/build -DPV_RECORDER_PLATFORM={PV_RECORDER_PLATFORM} -G "MinGW Makefiles" +cmake --build demo/c/build --target rhino_demo_mic ``` +The {PV_RECORDER_PLATFORM} variable will set the compilation flags for the given platform. Exclude this variable to get a list of possible values. + ## Run ### Usage @@ -120,9 +127,12 @@ If understood correctly, the following prints to the console: ## Build ```console -cmake -S demo/c/. -B demo/c/build && cmake --build demo/c/build --target rhino_demo_file +cmake -S demo/c/. -B demo/c/build -DPV_RECORDER_PLATFORM={PV_RECORDER_PLATFORM} +cmake --build demo/c/build --target rhino_demo_file ``` +The {PV_RECORDER_PLATFORM} variable will set the compilation flags for the given platform. Exclude this variable to get a list of possible values. + ## Run ### Usage diff --git a/demo/c/pvrecorder b/demo/c/pvrecorder index 7faea93bd..22195152c 160000 --- a/demo/c/pvrecorder +++ b/demo/c/pvrecorder @@ -1 +1 @@ -Subproject commit 7faea93bd80873083ce94f372a2af74c8269d611 +Subproject commit 22195152c41e62effae0fbf9dc20fa88ac37f570 diff --git a/demo/c/rhino_demo_mic.c b/demo/c/rhino_demo_mic.c index 253a8763a..5cb8a5d2d 100644 --- a/demo/c/rhino_demo_mic.c +++ b/demo/c/rhino_demo_mic.c @@ -1,5 +1,5 @@ /* - Copyright 2018-2023 Picovoice Inc. + Copyright 2018-2025 Picovoice Inc. You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. @@ -112,7 +112,7 @@ void show_audio_devices(void) { char **devices = NULL; int32_t count = 0; - pv_recorder_status_t status = pv_recorder_get_audio_devices(&count, &devices); + pv_recorder_status_t status = pv_recorder_get_available_devices(&count, &devices); if (status != PV_RECORDER_STATUS_SUCCESS) { fprintf(stderr, "Failed to get audio devices with: %s.\n", pv_recorder_status_to_string(status)); exit(1); @@ -123,7 +123,7 @@ void show_audio_devices(void) { fprintf(stdout, "index: %d, name: %s\n", i, devices[i]); } - pv_recorder_free_device_list(count, devices); + pv_recorder_free_available_devices(count, devices); } void print_error_message(char **message_stack, int32_t message_stack_depth) { @@ -323,7 +323,7 @@ int picovoice_main(int argc, char *argv[]) { const int32_t frame_length = pv_rhino_frame_length_func(); pv_recorder_t *recorder = NULL; - pv_recorder_status_t recorder_status = pv_recorder_init(device_index, frame_length, 100, true, true, &recorder); + pv_recorder_status_t recorder_status = pv_recorder_init(frame_length, device_index, 100, &recorder); if (recorder_status != PV_RECORDER_STATUS_SUCCESS) { fprintf(stderr, "Failed to initialize device with %s.\n", pv_recorder_status_to_string(recorder_status)); exit(1);