Skip to content

Commit

Permalink
add dBFS volume
Browse files Browse the repository at this point in the history
  • Loading branch information
pierromond committed Apr 22, 2024
1 parent f668578 commit 274f850
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/client/src/components/project/map/SoundFeature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ export const SoundFeature: FC<{ feature?: Feature; mapId: string; currentTimeKey
const noiseVariable = project.lassoVariables[`acoustic_soundlevel`];
if (properties.sound && feature.properties[currentTimeKey]) {

const volume = feature.properties[currentTimeKey].acoustic_soundlevel
const volume01 = - noiseVariable.minimumValue + feature.properties[currentTimeKey].acoustic_soundlevel/ (noiseVariable.maximumValue - noiseVariable.minimumValue );
const volumedB = -30 + 30 * (volume01);
const volume = feature.properties[currentTimeKey].acoustic_soundlevel ? Math.pow(10, volumedB / 20) : 1;

/* const volume = feature.properties[currentTimeKey].acoustic_soundlevel
? feature.properties[currentTimeKey].acoustic_soundlevel / noiseVariable.maximumValue
: 1;
: 1;*/




howler = new Howl({
src: [feature.properties[currentTimeKey].sound],
autoplay: true,
Expand All @@ -52,9 +59,12 @@ export const SoundFeature: FC<{ feature?: Feature; mapId: string; currentTimeKey

if (properties.sound) {

const volume = feature.properties.acoustic_soundlevel
? feature.properties.acoustic_soundlevel / noiseVariable.maximumValue
: 1;


const volume01 = - noiseVariable.minimumValue + feature.properties.acoustic_soundlevel/ (noiseVariable.maximumValue - noiseVariable.minimumValue );
const volumedB = -30 + 30 * (volume01);
const volume = feature.properties.acoustic_soundlevel ? Math.pow(10, volumedB / 20) : 1;

howler = new Howl({
src: [feature.properties.sound],
autoplay: true,
Expand Down

0 comments on commit 274f850

Please sign in to comment.