Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
Expand Down Expand Up @@ -193,7 +197,7 @@ jobs:

- uses: subosito/flutter-action@v2
with:
flutter-version: 3.0.0
flutter-version: 3.10.0
cache: true

- run: flutter pub get
Expand All @@ -217,14 +221,15 @@ jobs:
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
if: ${{ matrix.platform == 'apk' }}
with:
java-version: "11"
distribution: 'temurin'
java-version: '11'

- uses: subosito/flutter-action@v2
with:
flutter-version: 3.0.0
flutter-version: 3.10.0
cache: true

- run: flutter pub get
Expand Down
22 changes: 16 additions & 6 deletions cxx/AudioFrameObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,23 @@ bool AudioFrameObserver::onPlaybackAudioFrameBeforeMixing(

bool AudioFrameObserver::onRecordAudioFrame(const char *channelId,
AudioFrame &audioFrame) {
auto *buffer = (char *) audioFrame.buffer;
for (int i = 0; i < audioFrame.bytesPerSample * audioFrame.channels
* audioFrame.samplesPerChannel;
i += audioFrame.bytesPerSample) {
// set the audio frame to noise, if you set the audio frame to silence, you can remove this if statement
if (i % 2 == 0) { buffer[i] = 0; }
static std::random_device rd;
static std::mt19937 gen(rd());

auto *buffer = static_cast<int16_t *>(audioFrame.buffer);
int totalSamples = audioFrame.channels * audioFrame.samplesPerChannel;

// Generate white noise: fill audio buffer with random values
// Noise amplitude can be adjusted via noiseAmplitude (0.0 - 1.0)
constexpr float noiseAmplitude = 0.3f;
std::uniform_int_distribution<int16_t> dist(
static_cast<int16_t>(-32768 * noiseAmplitude),
static_cast<int16_t>(32767 * noiseAmplitude));

for (int i = 0; i < totalSamples; ++i) {
buffer[i] = dist(gen);
}

return true;
}

Expand Down
Loading