Skip to content

Commit adc46a8

Browse files
marcantt2468
authored andcommitted
Requests: SetVolume: allow volumes > 1.0
Allow volumes > 1.0 / > 0dB, which is legal in OBS (you can do this in Advanced Audio Properties). OBS allows up to +26dB gain, so we do the same. This corresponds to approximately 20x linear gain (actually 19.9526231497, but 20 is easier to explain and OBS doesn't care).
1 parent a93c4df commit adc46a8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/WSRequestHandler_Sources.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ RpcResponse WSRequestHandler::GetSourceTypesList(const RpcRequest& request)
231231
* @param {boolean (optional)} `useDecibel` Output volume in decibels of attenuation instead of amplitude/mul.
232232
*
233233
* @return {String} `name` Source name.
234-
* @return {double} `volume` Volume of the source. Between `0.0` and `1.0` if using mul, under `0.0` if using dB (since it is attenuating).
234+
* @return {double} `volume` Volume of the source. Between `0.0` and `20.0` if using mul, under `26.0` if using dB.
235235
* @return {boolean} `muted` Indicates whether the source is muted.
236236
*
237237
* @api requests
@@ -277,7 +277,7 @@ RpcResponse WSRequestHandler::GetVolume(const RpcRequest& request)
277277
* Set the volume of the specified source. Default request format uses mul, NOT SLIDER PERCENTAGE.
278278
*
279279
* @param {String} `source` Source name.
280-
* @param {double} `volume` Desired volume. Must be between `0.0` and `1.0` for mul, and under 0.0 for dB. Note: OBS will interpret dB values under -100.0 as Inf.
280+
* @param {double} `volume` Desired volume. Must be between `0.0` and `20.0` for mul, and under 26.0 for dB. OBS will interpret dB values under -100.0 as Inf. Note: The OBS volume sliders only reach a maximum of 1.0mul/0.0dB, however OBS actually supports larger values.
281281
* @param {boolean (optional)} `useDecibel` Interperet `volume` data as decibels instead of amplitude/mul.
282282
*
283283
* @api requests
@@ -296,8 +296,8 @@ RpcResponse WSRequestHandler::SetVolume(const RpcRequest& request)
296296
QString sourceName = obs_data_get_string(request.parameters(), "source");
297297
float sourceVolume = obs_data_get_double(request.parameters(), "volume");
298298

299-
bool isNotValidDecibel = (useDecibel && sourceVolume > 0.0);
300-
bool isNotValidMul = (!useDecibel && (sourceVolume < 0.0 || sourceVolume > 1.0));
299+
bool isNotValidDecibel = (useDecibel && sourceVolume > 26.0);
300+
bool isNotValidMul = (!useDecibel && (sourceVolume < 0.0 || sourceVolume > 20.0));
301301
if (sourceName.isEmpty() || isNotValidDecibel || isNotValidMul) {
302302
return request.failed("invalid request parameters");
303303
}

0 commit comments

Comments
 (0)