Skip to content

Commit 0e068d1

Browse files
committed
testcard2: decrease volume to standard -18.0 dBFS
Until now, whole scale was used so that the peak of the sine wave equaled exactly -0.0 dBFS, which is bad if unexepected and pass through the equipment set to normal levels. Changed to standard -18 dBFS.
1 parent f0decbd commit 0e068d1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/video_capture/testcard2.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ enum {
9696
AUDIO_BPS = 2,
9797
AUDIO_FREQUENCY = 200,
9898
AUDIO_SAMPLE_RATE = 48000,
99+
AUDIO_VOLUME_DBFS = -18,
99100
BANNER_HEIGHT = 150,
100101
BANNER_MARGIN_BOTTOM = 75,
101102
BUFFER_SEC = 1,
@@ -147,6 +148,7 @@ configure_audio(struct testcard_state2 *s)
147148
s->audio.ch_count = audio_capture_channels > 0 ? audio_capture_channels : DEFAULT_AUDIO_CAPTURE_CHANNELS;
148149
s->audio.sample_rate = AUDIO_SAMPLE_RATE;
149150

151+
double scale = pow(10.0, AUDIO_VOLUME_DBFS / 20.0) * sqrt(2.0);
150152
const size_t audio_buffer_size = (size_t) AUDIO_SAMPLE_RATE *
151153
AUDIO_BPS * s->audio.ch_count *
152154
BUFFER_SEC;
@@ -157,7 +159,7 @@ configure_audio(struct testcard_state2 *s)
157159
data[i] = data[i + 1] =
158160
(float) sin(((double) i / (double) AUDIO_FREQUENCY) * M_PI *
159161
2.) *
160-
SHRT_MAX;
162+
scale * SHRT_MAX;
161163
}
162164

163165
printf("[testcard2] playing audio\n");

0 commit comments

Comments
 (0)