Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
a4a7deee
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a4a7deee
编写于
10月 08, 2017
作者:
C
cg2121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
UI: Implement stereo balancing
上级
92d7c810
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
134 addition
and
25 deletion
+134
-25
UI/adv-audio-control.cpp
UI/adv-audio-control.cpp
+45
-20
UI/adv-audio-control.hpp
UI/adv-audio-control.hpp
+3
-3
UI/data/locale/en-US.ini
UI/data/locale/en-US.ini
+1
-1
UI/window-basic-adv-audio.cpp
UI/window-basic-adv-audio.cpp
+1
-1
libobs/obs-internal.h
libobs/obs-internal.h
+1
-0
libobs/obs-source.c
libobs/obs-source.c
+62
-0
libobs/obs-source.h
libobs/obs-source.h
+5
-0
libobs/obs.c
libobs/obs.c
+7
-0
libobs/obs.h
libobs/obs.h
+9
-0
未找到文件。
UI/adv-audio-control.cpp
浏览文件 @
a4a7deee
...
...
@@ -8,6 +8,7 @@
#include "qt-wrappers.hpp"
#include "obs-app.hpp"
#include "adv-audio-control.hpp"
#include "window-basic-main.hpp"
#ifndef NSEC_PER_MSEC
#define NSEC_PER_MSEC 1000000
...
...
@@ -25,13 +26,13 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
forceMonoContainer
=
new
QWidget
();
mixerContainer
=
new
QWidget
();
panning
Container
=
new
QWidget
();
balance
Container
=
new
QWidget
();
labelL
=
new
QLabel
();
labelR
=
new
QLabel
();
nameLabel
=
new
QLabel
();
volume
=
new
QSpinBox
();
forceMono
=
new
QCheckBox
();
panning
=
new
QSlider
(
Qt
::
Horizontal
);
balance
=
new
QSlider
(
Qt
::
Horizontal
);
#if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO
monitoringType
=
new
QComboBox
();
#endif
...
...
@@ -60,8 +61,8 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
mixerContainer
->
setLayout
(
hlayout
);
hlayout
=
new
QHBoxLayout
();
hlayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
panning
Container
->
setLayout
(
hlayout
);
panning
Container
->
setMinimumWidth
(
100
);
balance
Container
->
setLayout
(
hlayout
);
balance
Container
->
setMinimumWidth
(
100
);
labelL
->
setText
(
"L"
);
...
...
@@ -81,11 +82,23 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
forceMonoContainer
->
layout
()
->
setAlignment
(
forceMono
,
Qt
::
AlignHCenter
|
Qt
::
AlignVCenter
);
panning
->
setMinimum
(
0
);
panning
->
setMaximum
(
100
);
panning
->
setTickPosition
(
QSlider
::
TicksAbove
);
panning
->
setEnabled
(
false
);
panning
->
setValue
(
50
);
/* XXX */
balance
->
setMinimum
(
0
);
balance
->
setMaximum
(
100
);
balance
->
setTickPosition
(
QSlider
::
TicksAbove
);
balance
->
setTickInterval
(
50
);
OBSBasic
*
main
=
reinterpret_cast
<
OBSBasic
*>
(
App
()
->
GetMainWindow
());
const
char
*
speakers
=
config_get_string
(
main
->
Config
(),
"Audio"
,
"ChannelSetup"
);
if
(
strcmp
(
speakers
,
"Mono"
)
==
0
)
balance
->
setEnabled
(
false
);
else
balance
->
setEnabled
(
true
);
float
bal
=
obs_source_get_balance_value
(
source
)
*
100.0
f
;
balance
->
setValue
((
int
)
bal
);
int64_t
cur_sync
=
obs_source_get_sync_offset
(
source
);
syncOffset
->
setMinimum
(
-
20000
);
...
...
@@ -118,10 +131,14 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
mixer6
->
setText
(
"6"
);
mixer6
->
setChecked
(
mixers
&
(
1
<<
5
));
panningContainer
->
layout
()
->
addWidget
(
labelL
);
panningContainer
->
layout
()
->
addWidget
(
panning
);
panningContainer
->
layout
()
->
addWidget
(
labelR
);
panningContainer
->
setMaximumWidth
(
170
);
speaker_layout
sl
=
obs_source_get_speaker_layout
(
source
);
if
(
sl
==
SPEAKERS_STEREO
)
{
balanceContainer
->
layout
()
->
addWidget
(
labelL
);
balanceContainer
->
layout
()
->
addWidget
(
balance
);
balanceContainer
->
layout
()
->
addWidget
(
labelR
);
balanceContainer
->
setMaximumWidth
(
170
);
}
mixerContainer
->
layout
()
->
addWidget
(
mixer1
);
mixerContainer
->
layout
()
->
addWidget
(
mixer2
);
...
...
@@ -134,8 +151,8 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
this
,
SLOT
(
volumeChanged
(
int
)));
QWidget
::
connect
(
forceMono
,
SIGNAL
(
clicked
(
bool
)),
this
,
SLOT
(
downmixMonoChanged
(
bool
)));
QWidget
::
connect
(
panning
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
panning
Changed
(
int
)));
QWidget
::
connect
(
balance
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
balance
Changed
(
int
)));
QWidget
::
connect
(
syncOffset
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
syncOffsetChanged
(
int
)));
#if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO
...
...
@@ -163,7 +180,7 @@ OBSAdvAudioCtrl::~OBSAdvAudioCtrl()
nameLabel
->
deleteLater
();
volume
->
deleteLater
();
forceMonoContainer
->
deleteLater
();
panning
Container
->
deleteLater
();
balance
Container
->
deleteLater
();
syncOffset
->
deleteLater
();
#if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO
monitoringType
->
deleteLater
();
...
...
@@ -179,7 +196,7 @@ void OBSAdvAudioCtrl::ShowAudioControl(QGridLayout *layout)
layout
->
addWidget
(
nameLabel
,
lastRow
,
idx
++
);
layout
->
addWidget
(
volume
,
lastRow
,
idx
++
);
layout
->
addWidget
(
forceMonoContainer
,
lastRow
,
idx
++
);
layout
->
addWidget
(
panning
Container
,
lastRow
,
idx
++
);
layout
->
addWidget
(
balance
Container
,
lastRow
,
idx
++
);
layout
->
addWidget
(
syncOffset
,
lastRow
,
idx
++
);
#if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO
layout
->
addWidget
(
monitoringType
,
lastRow
,
idx
++
);
...
...
@@ -283,10 +300,18 @@ void OBSAdvAudioCtrl::downmixMonoChanged(bool checked)
}
}
void
OBSAdvAudioCtrl
::
panning
Changed
(
int
val
)
void
OBSAdvAudioCtrl
::
balance
Changed
(
int
val
)
{
/* TODO */
UNUSED_PARAMETER
(
val
);
float
bal
=
(
float
)
val
/
100.0
f
;
if
(
abs
(
50
-
val
)
<
10
)
{
balance
->
blockSignals
(
true
);
balance
->
setValue
(
50
);
bal
=
0.5
f
;
balance
->
blockSignals
(
false
);
}
obs_source_set_balance_value
(
source
,
bal
);
}
void
OBSAdvAudioCtrl
::
syncOffsetChanged
(
int
milliseconds
)
...
...
UI/adv-audio-control.hpp
浏览文件 @
a4a7deee
...
...
@@ -19,12 +19,12 @@ private:
QPointer
<
QWidget
>
forceMonoContainer
;
QPointer
<
QWidget
>
mixerContainer
;
QPointer
<
QWidget
>
panning
Container
;
QPointer
<
QWidget
>
balance
Container
;
QPointer
<
QLabel
>
nameLabel
;
QPointer
<
QSpinBox
>
volume
;
QPointer
<
QCheckBox
>
forceMono
;
QPointer
<
QSlider
>
panning
;
QPointer
<
QSlider
>
balance
;
QPointer
<
QLabel
>
labelL
;
QPointer
<
QLabel
>
labelR
;
QPointer
<
QSpinBox
>
syncOffset
;
...
...
@@ -61,7 +61,7 @@ public slots:
void
volumeChanged
(
int
percentage
);
void
downmixMonoChanged
(
bool
checked
);
void
panning
Changed
(
int
val
);
void
balance
Changed
(
int
val
);
void
syncOffsetChanged
(
int
milliseconds
);
void
monitoringTypeChanged
(
int
index
);
void
mixer1Changed
(
bool
checked
);
...
...
UI/data/locale/en-US.ini
浏览文件 @
a4a7deee
...
...
@@ -768,7 +768,7 @@ Basic.AdvAudio="Advanced Audio Properties"
Basic.AdvAudio.Name
=
"Name"
Basic.AdvAudio.Volume
=
"Volume (%)"
Basic.AdvAudio.Mono
=
"Downmix to Mono"
Basic.AdvAudio.
Panning
=
"Panning
"
Basic.AdvAudio.
Balance
=
"Balance
"
Basic.AdvAudio.SyncOffset
=
"Sync Offset (ms)"
Basic.AdvAudio.Monitoring
=
"Audio Monitoring"
Basic.AdvAudio.Monitoring.None
=
"Monitor Off"
...
...
UI/window-basic-adv-audio.cpp
浏览文件 @
a4a7deee
...
...
@@ -37,7 +37,7 @@ OBSBasicAdvAudio::OBSBasicAdvAudio(QWidget *parent)
label
=
new
QLabel
(
QTStr
(
"Basic.AdvAudio.Mono"
));
label
->
setAlignment
(
Qt
::
AlignHCenter
);
mainLayout
->
addWidget
(
label
,
0
,
idx
++
);
label
=
new
QLabel
(
QTStr
(
"Basic.AdvAudio.
Panning
"
));
label
=
new
QLabel
(
QTStr
(
"Basic.AdvAudio.
Balance
"
));
label
->
setAlignment
(
Qt
::
AlignHCenter
);
mainLayout
->
addWidget
(
label
,
0
,
idx
++
);
label
=
new
QLabel
(
QTStr
(
"Basic.AdvAudio.SyncOffset"
));
...
...
libobs/obs-internal.h
浏览文件 @
a4a7deee
...
...
@@ -608,6 +608,7 @@ struct obs_source {
float
volume
;
int64_t
sync_offset
;
int64_t
last_sync_offset
;
float
balance
;
/* async video data */
gs_texture_t
*
async_texture
;
...
...
libobs/obs-source.c
浏览文件 @
a4a7deee
...
...
@@ -16,6 +16,7 @@
******************************************************************************/
#include <inttypes.h>
#include <math.h>
#include "media-io/format-conversion.h"
#include "media-io/video-frame.h"
...
...
@@ -140,6 +141,7 @@ bool obs_source_init(struct obs_source *source)
source
->
user_volume
=
1
.
0
f
;
source
->
volume
=
1
.
0
f
;
source
->
sync_offset
=
0
;
source
->
balance
=
0
.
5
f
;
pthread_mutex_init_value
(
&
source
->
filter_mutex
);
pthread_mutex_init_value
(
&
source
->
async_mutex
);
pthread_mutex_init_value
(
&
source
->
audio_mutex
);
...
...
@@ -2589,6 +2591,37 @@ static void downmix_to_mono_planar(struct obs_source *source, uint32_t frames)
}
}
static
void
process_audio_balancing
(
struct
obs_source
*
source
,
uint32_t
frames
,
float
balance
,
enum
obs_balance_type
type
)
{
float
**
data
=
(
float
**
)
source
->
audio_data
.
data
;
switch
(
type
)
{
case
OBS_BALANCE_TYPE_SINE_LAW
:
for
(
uint32_t
frame
=
0
;
frame
<
frames
;
frame
++
)
{
data
[
0
][
frame
]
=
data
[
0
][
frame
]
*
sinf
((
1
.
0
f
-
balance
)
*
(
M_PI
/
2
.
0
f
));
data
[
1
][
frame
]
=
data
[
1
][
frame
]
*
sinf
(
balance
*
(
M_PI
/
2
.
0
f
));
}
break
;
case
OBS_BALANCE_TYPE_SQUARE_LAW
:
for
(
uint32_t
frame
=
0
;
frame
<
frames
;
frame
++
)
{
data
[
0
][
frame
]
=
data
[
0
][
frame
]
*
sqrtf
(
1
.
0
f
-
balance
);
data
[
1
][
frame
]
=
data
[
1
][
frame
]
*
sqrtf
(
balance
);
}
break
;
case
OBS_BALANCE_TYPE_LINEAR
:
for
(
uint32_t
frame
=
0
;
frame
<
frames
;
frame
++
)
{
data
[
0
][
frame
]
=
data
[
0
][
frame
]
*
(
1
.
0
f
-
balance
);
data
[
1
][
frame
]
=
data
[
1
][
frame
]
*
balance
;
}
break
;
default:
break
;
}
}
/* resamples/remixes new audio to the designated main audio output format */
static
void
process_audio
(
obs_source_t
*
source
,
const
struct
obs_source_audio
*
audio
)
...
...
@@ -2622,6 +2655,13 @@ static void process_audio(obs_source_t *source,
mono_output
=
audio_output_get_channels
(
obs
->
audio
.
audio
)
==
1
;
if
((
!
mono_output
&&
source
->
sample_info
.
speakers
==
SPEAKERS_STEREO
)
||
!
(
source
->
balance
<=
0
.
51
f
&&
source
->
balance
>=
0
.
49
f
))
{
process_audio_balancing
(
source
,
frames
,
source
->
balance
,
OBS_BALANCE_TYPE_SINE_LAW
);
}
if
(
!
mono_output
&&
(
source
->
flags
&
OBS_SOURCE_FLAG_FORCE_MONO
)
!=
0
)
downmix_to_mono_planar
(
source
,
frames
);
}
...
...
@@ -4165,3 +4205,25 @@ EXPORT void obs_enable_source_type(const char *name, bool enable)
else
info
->
output_flags
|=
OBS_SOURCE_CAP_DISABLED
;
}
enum
speaker_layout
obs_source_get_speaker_layout
(
obs_source_t
*
source
)
{
if
(
!
obs_source_valid
(
source
,
"obs_source_get_audio_channels"
))
return
SPEAKERS_UNKNOWN
;
return
source
->
sample_info
.
speakers
;
}
void
obs_source_set_balance_value
(
obs_source_t
*
source
,
float
balance
)
{
if
(
!
obs_source_valid
(
source
,
"obs_source_set_balance_value"
))
return
;
source
->
balance
=
balance
;
}
float
obs_source_get_balance_value
(
const
obs_source_t
*
source
)
{
return
obs_source_valid
(
source
,
"obs_source_get_balance_value"
)
?
source
->
balance
:
0
.
5
f
;
}
libobs/obs-source.h
浏览文件 @
a4a7deee
...
...
@@ -38,6 +38,11 @@ enum obs_source_type {
OBS_SOURCE_TYPE_SCENE
,
};
enum
obs_balance_type
{
OBS_BALANCE_TYPE_SINE_LAW
,
OBS_BALANCE_TYPE_SQUARE_LAW
,
OBS_BALANCE_TYPE_LINEAR
,
};
/**
* @name Source output flags
...
...
libobs/obs.c
浏览文件 @
a4a7deee
...
...
@@ -1563,6 +1563,7 @@ static obs_source_t *obs_load_source_type(obs_data_t *source_data)
obs_data_t
*
settings
=
obs_data_get_obj
(
source_data
,
"settings"
);
obs_data_t
*
hotkeys
=
obs_data_get_obj
(
source_data
,
"hotkeys"
);
double
volume
;
double
balance
;
int64_t
sync
;
uint32_t
flags
;
uint32_t
mixers
;
...
...
@@ -1578,6 +1579,10 @@ static obs_source_t *obs_load_source_type(obs_data_t *source_data)
volume
=
obs_data_get_double
(
source_data
,
"volume"
);
obs_source_set_volume
(
source
,
(
float
)
volume
);
obs_data_set_default_double
(
source_data
,
"balance"
,
0
.
5
);
balance
=
obs_data_get_double
(
source_data
,
"balance"
);
obs_source_set_balance_value
(
source
,
(
float
)
balance
);
sync
=
obs_data_get_int
(
source_data
,
"sync"
);
obs_source_set_sync_offset
(
source
,
sync
);
...
...
@@ -1716,6 +1721,7 @@ obs_data_t *obs_save_source(obs_source_t *source)
obs_data_t
*
hotkey_data
=
source
->
context
.
hotkey_data
;
obs_data_t
*
hotkeys
;
float
volume
=
obs_source_get_volume
(
source
);
float
balance
=
obs_source_get_balance_value
(
source
);
uint32_t
mixers
=
obs_source_get_audio_mixers
(
source
);
int64_t
sync
=
obs_source_get_sync_offset
(
source
);
uint32_t
flags
=
obs_source_get_flags
(
source
);
...
...
@@ -1748,6 +1754,7 @@ obs_data_t *obs_save_source(obs_source_t *source)
obs_data_set_int
(
source_data
,
"sync"
,
sync
);
obs_data_set_int
(
source_data
,
"flags"
,
flags
);
obs_data_set_double
(
source_data
,
"volume"
,
volume
);
obs_data_set_double
(
source_data
,
"balance"
,
balance
);
obs_data_set_bool
(
source_data
,
"enabled"
,
enabled
);
obs_data_set_bool
(
source_data
,
"muted"
,
muted
);
obs_data_set_bool
(
source_data
,
"push-to-mute"
,
push_to_mute
);
...
...
libobs/obs.h
浏览文件 @
a4a7deee
...
...
@@ -893,6 +893,15 @@ EXPORT void obs_source_set_volume(obs_source_t *source, float volume);
/** Gets the user volume for a source that has audio output */
EXPORT
float
obs_source_get_volume
(
const
obs_source_t
*
source
);
/* Gets speaker layout of a source */
EXPORT
enum
speaker_layout
obs_source_get_speaker_layout
(
obs_source_t
*
source
);
/** Sets the balance value for a stereo audio source */
EXPORT
void
obs_source_set_balance_value
(
obs_source_t
*
source
,
float
balance
);
/** Gets the balance value for a stereo audio source */
EXPORT
float
obs_source_get_balance_value
(
const
obs_source_t
*
source
);
/** Sets the audio sync offset (in nanoseconds) for a source */
EXPORT
void
obs_source_set_sync_offset
(
obs_source_t
*
source
,
int64_t
offset
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录