forked from ggml-org/llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
frameforge: add PortAudio live audio capture with VAD support #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TheOriginalBytePlayer
merged 16 commits into
master
from
copilot/extend-audio-collection-capabilities
Jan 2, 2026
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fa42a51
Initial plan
Copilot a148594
Add PortAudio support for live audio capture in FrameForge SideCar
Copilot b829693
Update documentation for live audio capture feature
Copilot 11166a4
Add test for audio capture functionality
Copilot d26d75e
Address code review feedback: fix Pa_Terminate calls, add signal hand…
Copilot 910ac39
Implement VAD-based audio processing: trigger after 500ms speech + 25…
Copilot cd2d75a
Fix race conditions in VAD state management with mutex protection
Copilot 21f63f5
Update tools/frameforge/frameforge-audio.cpp
TheOriginalBytePlayer dd7d7cb
Update tools/frameforge/frameforge-audio.cpp
TheOriginalBytePlayer 6f8b9f6
Update tools/frameforge/frameforge-sidecar.cpp
TheOriginalBytePlayer 69833a9
Update tests/test-frameforge-audio.cpp
TheOriginalBytePlayer d3a5a0d
Fix multiple initialize() calls and add thread-safe PortAudio initial…
Copilot 07ab1bf
Update tools/frameforge/frameforge-sidecar.cpp
TheOriginalBytePlayer 82776be
Update tools/frameforge/frameforge-audio.cpp
TheOriginalBytePlayer 3b7e3b4
Require both PortAudio and Whisper for live audio mode at compile time
Copilot cf18ae6
Address remaining review feedback: update docs, fix signal handlers, …
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| #include "../tools/frameforge/frameforge-audio.h" | ||
|
|
||
| #include <cassert> | ||
| #include <iostream> | ||
| #include <thread> | ||
| #include <chrono> | ||
|
|
||
| using namespace frameforge; | ||
|
|
||
| static void test_audio_config() { | ||
| std::cout << "Testing audio configuration..." << std::endl; | ||
|
|
||
| AudioConfig config; | ||
| assert(config.sample_rate == 16000); | ||
| assert(config.channels == 1); | ||
| assert(config.frames_per_buffer == 512); | ||
|
|
||
| // Custom config | ||
| AudioConfig custom; | ||
| custom.sample_rate = 44100; | ||
| custom.channels = 2; | ||
| custom.frames_per_buffer = 1024; | ||
|
|
||
| assert(custom.sample_rate == 44100); | ||
| assert(custom.channels == 2); | ||
| assert(custom.frames_per_buffer == 1024); | ||
|
|
||
| std::cout << " ✓ Audio configuration passed" << std::endl; | ||
| } | ||
|
|
||
| static void test_audio_capture_initialization() { | ||
| std::cout << "Testing audio capture initialization..." << std::endl; | ||
|
|
||
| AudioConfig config; | ||
| AudioCapture capture(config); | ||
|
|
||
| // Just test that we can create an instance | ||
| assert(!capture.is_capturing()); | ||
|
|
||
| #ifdef FRAMEFORGE_PORTAUDIO_SUPPORT | ||
| std::cout << " PortAudio support is available" << std::endl; | ||
|
|
||
| // Try to initialize | ||
| bool init_result = capture.initialize(); | ||
| if (init_result) { | ||
| std::cout << " ✓ Audio capture initialization succeeded" << std::endl; | ||
|
|
||
| // Follow typical usage pattern: start capturing before testing buffer operations. | ||
| capture.start(); | ||
|
|
||
| // Test buffer operations | ||
| capture.clear_buffer(); | ||
| std::vector<float> buffer = capture.get_audio_buffer(); | ||
| assert(buffer.empty()); | ||
| std::cout << " ✓ Buffer operations work" << std::endl; | ||
|
TheOriginalBytePlayer marked this conversation as resolved.
|
||
|
|
||
| // Stop capturing to complete the typical lifecycle. | ||
| capture.stop(); | ||
| } else { | ||
| std::cout << " ! Audio capture initialization failed (this is OK if no audio device is available)" << std::endl; | ||
| } | ||
| #else | ||
| std::cout << " PortAudio support is not available" << std::endl; | ||
| std::cout << " ✓ Stub implementation works" << std::endl; | ||
| #endif | ||
| } | ||
|
|
||
| static void test_audio_callback() { | ||
| std::cout << "Testing audio callback..." << std::endl; | ||
|
|
||
| #ifdef FRAMEFORGE_PORTAUDIO_SUPPORT | ||
| AudioConfig config; | ||
| AudioCapture capture(config); | ||
|
|
||
| bool callback_called = false; | ||
| capture.set_callback([&callback_called](const std::vector<float> & data) { | ||
| callback_called = true; | ||
| std::cout << " Callback received " << data.size() << " samples" << std::endl; | ||
| }); | ||
|
|
||
| if (capture.initialize()) { | ||
| if (capture.start()) { | ||
| std::cout << " Audio capture started, waiting for callback..." << std::endl; | ||
|
|
||
| // Wait for a short time to see if we get audio data | ||
| auto start_time = std::chrono::steady_clock::now(); | ||
| while (!callback_called) { | ||
| std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
| auto elapsed = std::chrono::duration_cast<std::chrono::seconds>( | ||
| std::chrono::steady_clock::now() - start_time | ||
| ).count(); | ||
|
|
||
| if (elapsed > 2) { | ||
| std::cout << " ! No callback received after 2 seconds (no audio input?)" << std::endl; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| capture.stop(); | ||
|
|
||
| if (callback_called) { | ||
| std::cout << " ✓ Audio callback test passed" << std::endl; | ||
| } else { | ||
| std::cout << " ! Audio callback test completed (no audio detected)" << std::endl; | ||
| } | ||
| } else { | ||
| std::cout << " ! Could not start audio capture" << std::endl; | ||
| } | ||
| } else { | ||
| std::cout << " ! Could not initialize audio capture" << std::endl; | ||
| } | ||
| #else | ||
| std::cout << " PortAudio support not available, skipping callback test" << std::endl; | ||
| #endif | ||
| } | ||
|
|
||
| int main() { | ||
| std::cout << "Running FrameForge Audio Capture Tests" << std::endl; | ||
| std::cout << "======================================" << std::endl; | ||
|
|
||
| test_audio_config(); | ||
| test_audio_capture_initialization(); | ||
| test_audio_callback(); | ||
|
|
||
| std::cout << "\nAll tests completed!" << std::endl; | ||
| return 0; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.