Skip to content

Commit

Permalink
Add decibel selection to audio condition
Browse files Browse the repository at this point in the history
  • Loading branch information
WarmUpTill committed Feb 17, 2024
1 parent b5ef92c commit 825af55
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 67 deletions.
2 changes: 1 addition & 1 deletion data/locale/de-DE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ AdvSceneSwitcher.condition.audio.type.volume="Konfigurierter Lautstärkepegel"
AdvSceneSwitcher.condition.audio.type.syncOffset="Sync-Offset"
AdvSceneSwitcher.condition.audio.type.monitor="Audio-Monitoring"
AdvSceneSwitcher.condition.audio.type.balance="Audio-Balance"
AdvSceneSwitcher.condition.audio.entry="{{checkType}} von {{audioSources}} ist {{condition}}{{volume}}{{syncOffset}}{{monitorTypes}}"
AdvSceneSwitcher.condition.audio.entry="{{checkType}}von{{audioSources}}ist{{condition}}{{volume}}{{volumeDB}}{{percentDBToggle}}{{syncOffset}}{{monitorTypes}}"
AdvSceneSwitcher.condition.cursor="Cursor"
AdvSceneSwitcher.condition.cursor.type.region="ist in der Region"
AdvSceneSwitcher.condition.cursor.type.moving="bewegt sich"
Expand Down
2 changes: 1 addition & 1 deletion data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ AdvSceneSwitcher.condition.audio.type.volume="Configured volume level"
AdvSceneSwitcher.condition.audio.type.syncOffset="Sync offset"
AdvSceneSwitcher.condition.audio.type.monitor="Audio monitoring"
AdvSceneSwitcher.condition.audio.type.balance="Audio balance"
AdvSceneSwitcher.condition.audio.entry="{{checkType}}of{{audioSources}}is{{condition}}{{volume}}{{syncOffset}}{{monitorTypes}}"
AdvSceneSwitcher.condition.audio.entry="{{checkType}}of{{audioSources}}is{{condition}}{{volume}}{{volumeDB}}{{percentDBToggle}}{{syncOffset}}{{monitorTypes}}"
AdvSceneSwitcher.condition.cursor="Cursor"
AdvSceneSwitcher.condition.cursor.type.region="is in region"
AdvSceneSwitcher.condition.cursor.type.moving="is moving"
Expand Down
2 changes: 1 addition & 1 deletion data/locale/es-ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ AdvSceneSwitcher.condition.audio.state.mute="silenciado"
AdvSceneSwitcher.condition.audio.state.unmute="no silenciado"
AdvSceneSwitcher.condition.audio.type.output="Volumen de salida"
AdvSceneSwitcher.condition.audio.type.volume="Nivel de volumen configurado"
AdvSceneSwitcher.condition.audio.entry="{{checkType}} de {{audioSources}} es {{condition}}{{volume}}{{syncOffset}}{{monitorTypes}}"
AdvSceneSwitcher.condition.audio.entry="{{checkType}}de{{audioSources}}es{{condition}}{{volume}}{{volumeDB}}{{percentDBToggle}}{{syncOffset}}{{monitorTypes}}"
AdvSceneSwitcher.condition.cursor="Cursor"
AdvSceneSwitcher.condition.cursor.type.region="está en la región"
AdvSceneSwitcher.condition.cursor.type.moving="se está moviendo"
Expand Down
2 changes: 1 addition & 1 deletion data/locale/fr-FR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ AdvSceneSwitcher.condition.audio.type.volume="Niveau de volume configuré"
AdvSceneSwitcher.condition.audio.type.syncOffset="Décalage de synchronisation"
AdvSceneSwitcher.condition.audio.type.monitor="Surveillance audio"
AdvSceneSwitcher.condition.audio.type.balance="Équilibre audio"
AdvSceneSwitcher.condition.audio.entry="{{checkType}}de{{audioSources}}est{{condition}}{{volume}}{{syncOffset}}{{monitorTypes}}"
AdvSceneSwitcher.condition.audio.entry="{{checkType}}de{{audioSources}}est{{condition}}{{volume}}{{volumeDB}}{{percentDBToggle}}{{syncOffset}}{{monitorTypes}}"
AdvSceneSwitcher.condition.cursor="Curseur"
AdvSceneSwitcher.condition.cursor.type.region="est dans la région"
AdvSceneSwitcher.condition.cursor.type.moving="est en mouvement"
Expand Down
2 changes: 1 addition & 1 deletion data/locale/zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ AdvSceneSwitcher.condition.audio.type.volume="配置音量级别"
AdvSceneSwitcher.condition.audio.type.syncOffset="同步偏移"
AdvSceneSwitcher.condition.audio.type.monitor="音频监控"
AdvSceneSwitcher.condition.audio.type.balance="音频平衡"
AdvSceneSwitcher.condition.audio.entry="{{checkType}}{{audioSources}}{{condition}}{{volume}}{{syncOffset}}{{monitorTypes}}"
AdvSceneSwitcher.condition.audio.entry="{{checkType}}{{audioSources}}{{condition}}{{volume}}{{volumeDB}}{{percentDBToggle}}{{syncOffset}}{{monitorTypes}}"
AdvSceneSwitcher.condition.cursor="屏幕区域"
AdvSceneSwitcher.condition.cursor.type.region="当前位置"
AdvSceneSwitcher.condition.cursor.type.moving="正在移动"
Expand Down
11 changes: 2 additions & 9 deletions plugins/base/macro-action-audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "macro-helpers.hpp"
#include "selection-helpers.hpp"

#include <cmath>

namespace advss {

constexpr int64_t nsPerMs = 1000000;
Expand Down Expand Up @@ -45,19 +43,14 @@ struct FadeInfo {
std::atomic_bool active = {false};
std::atomic_int id = {0};
};
}
} // namespace

static FadeInfo masterAudioFade;
static std::unordered_map<std::string, FadeInfo> audioFades;

constexpr auto fadeInterval = std::chrono::milliseconds(100);
constexpr float minFade = 0.000001f;

static float decibelToPercent(float db)
{
return pow(10, (db / 20));
}

// For backwards compatibility
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(29, 0, 0)
static float get_master_volume()
Expand Down Expand Up @@ -114,7 +107,7 @@ std::atomic_int *MacroActionAudio::GetFadeIdPtr() const

float MacroActionAudio::GetVolume() const
{
return _useDb ? decibelToPercent(_volumeDB) : (float)_volume / 100.0f;
return _useDb ? DecibelToPercent(_volumeDB) : (float)_volume / 100.0f;
}

void MacroActionAudio::SetVolume(float vol) const
Expand Down
Loading

0 comments on commit 825af55

Please sign in to comment.