Skip to content

Commit

Permalink
Merge branch 'nocturnal-filter'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattk70 committed Feb 12, 2024
2 parents b8bf7e3 + a5abde2 commit 204ed7b
Show file tree
Hide file tree
Showing 13 changed files with 10,399 additions and 3,646 deletions.
8 changes: 6 additions & 2 deletions Help/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@
</td>
</tr>
<tr>
<td colspan="2" class="text-center text-bg-light"><h5>Audio Export Preferences</h5></td>
<td colspan="2" class="text-center text-bg-light"><h5>Audio Preferences</h5></td>
</tr>
<tr>
<td><b>Gain Adjustment</b></td>
<td>If your recordings are very quiet, you can increase the loudness of the audio by adding gain. The volume of audio can be increased by up to 50 decibels.</td>
</tr>
<tr>
<td><b>Format and Bitrate</b></td>
Expand Down Expand Up @@ -151,7 +155,7 @@
</tr>

<tr>
<td colspan="2" class="text-center text-bg-warning"><h5>Experimental Features</h5></td>
<td colspan="2" class="text-center text-bg-warning"><h5>Advanced Features</h5></td>
</tr>
<tr>
<th>Context Mode</th>
Expand Down
1 change: 0 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ input[type="range"].vertical {
line-height: 20px;
float: right;
text-decoration: none; /* Remove underline from <a> tags */
display: inline-block;
transition: transform 0.2s; /* Add transition for smooth scaling */
}

Expand Down
File renamed without changes
1,231 changes: 634 additions & 597 deletions index.html

Large diffs are not rendered by default.

13 changes: 3 additions & 10 deletions js/BirdNet2.4.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,7 @@ onmessage = async (e) => {
})
DEBUG && console.log(`model received load instruction. Using list: ${list}, batch size ${batch}`);

tf.setBackend(backend).then(async () => {
if (backend === "webgl") {
tf.env().set("WEBGL_FORCE_F16_TEXTURES", true);
tf.env().set("WEBGL_PACK", true);
tf.env().set("WEBGL_EXP_CONV", true);
tf.env().set("TOPK_K_CPU_HANDOFF_THRESHOLD", 128);
tf.env().set("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD", 0);
}
tf.setBackend('tensorflow').then(async () => {
tf.enableProdMode();
if (DEBUG) {
console.log(tf.env());
Expand Down Expand Up @@ -327,9 +320,9 @@ class Model {
const finalPrediction = newPrediction || prediction;

const { indices, values } = tf.topk(finalPrediction, 5, true);
const topIndices = await indices.array();
const topIndices = indices.arraySync();
indices.dispose();
const topValues = await values.array();
const topValues = values.arraySync();
values.dispose();
// end new
// const array_of_predictions = finalPrediction.arraySync()
Expand Down
46 changes: 46 additions & 0 deletions js/audio_normalizer_processor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// This needs some refinement!

class AudioNormalizerProcessor extends AudioWorkletProcessor {
static get parameterDescriptors() {
return [{ name: 'peakLoudness', defaultValue: -3 }];
}

process(inputs, outputs, parameters) {
const input = inputs[0];
const output = outputs[0];

const peakLoudness = parameters.peakLoudness[0];

for (let channel = 0; channel < input.length; ++channel) {
const inputData = input[channel];
const outputData = output[channel];

// Increase buffer size
const bufferSize = 1024; // Adjust as needed

for (let sample = 0; sample < inputData.length; sample += bufferSize) {
let maxAbsValue = 0;
const endSample = Math.min(sample + bufferSize, inputData.length);

for (let s = sample; s < endSample; ++s) {
const absValue = Math.abs(inputData[s]);
if (absValue > maxAbsValue) {
maxAbsValue = absValue;
}
}

const desiredPeak = Math.pow(10, peakLoudness / 20); // Convert dB to linear scale
const scaleFactor = desiredPeak / (maxAbsValue + 1e-5); // Handle division by zero

for (let s = sample; s < endSample; ++s) {
outputData[s] = inputData[s] * scaleFactor;
}
}
}

return true;
}
}

registerProcessor('audio-normalizer-processor', AudioNormalizerProcessor);

231 changes: 139 additions & 92 deletions js/listWorker.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions js/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class State {
this.filteredOffset = {}, // Current species start number for filtered results
this.selection = false,
this.blocked = [],
this.audio = { format: 'mp3', bitrate: 128, padding: false, fade: false, downmix: false, quality: 5 },
this.audio = { gain: 0, format: 'mp3', bitrate: 128, padding: false, fade: false, downmix: false, quality: 5 },
this.filters = { active: false, highPassFrequency: 0, lowShelfFrequency: 0, lowShelfAttenuation: 0, SNR: 0 },
this.detect = { nocmig: false, contextAware: false, confidence: 450 },
this.chart = { range: { start: undefined, end: undefined }, species: undefined },
Expand All @@ -29,7 +29,8 @@ export class State {
this.speciesThreshold = undefined,
this.useWeek = false,
this.week = -1,
this.list = 'everything'
this.list = 'everything',
this.local = true
}


Expand Down
Loading

0 comments on commit 204ed7b

Please sign in to comment.