mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 01:30:49 +01:00
Add #v alias and fix dB decimals
This commit is contained in:
parent
8a1430e0b1
commit
395c2d38dc
@ -612,6 +612,7 @@ Loop anchors have priority over `loop_start_segment`, and are ignored in layered
|
||||
Manually setting values gets old, so TXTP supports a bunch of simple macros. They automate some of the above commands (analyzing the file), and may be combined, so order still matters.
|
||||
- `volume N (channels)`: sets volume V to selected channels. N.N = percent or NdB = decibels.
|
||||
- `1.0` or `0dB` = base volume, `2.0` or `6dB` = double volume, `0.5` or `-6dB` = half volume
|
||||
- `#v N` also works
|
||||
- `track (channels)`: makes a file of selected channels
|
||||
- `layer-v N (channels)`: mixes selected channels to N channels with default volume (for layered vocals). If N is 0 (or ommited), automatically sets highest channel count among all layers.
|
||||
- `layer-b N (channels)`: same, but adjusts volume depending on layers (for layered bgm)
|
||||
|
@ -894,13 +894,12 @@ static int get_position(const char* params, double* value_f, char* value_type) {
|
||||
static int get_volume(const char* params, double *value, int *is_set) {
|
||||
int n, m;
|
||||
double temp_f;
|
||||
int temp_i;
|
||||
char temp_c1, temp_c2;
|
||||
|
||||
if (is_set) *is_set = 0;
|
||||
|
||||
/* test if format is NdB (decibels) */
|
||||
m = sscanf(params, " %i%c%c%n", &temp_i, &temp_c1, &temp_c2, &n);
|
||||
m = sscanf(params, " %lf%c%c%n", &temp_f, &temp_c1, &temp_c2, &n);
|
||||
if (m == 3 && temp_c1 == 'd' && (temp_c2 == 'B' || temp_c2 == 'b')) {
|
||||
/* dB 101:
|
||||
* - logaritmic scale
|
||||
@ -916,7 +915,7 @@ static int get_volume(const char* params, double *value, int *is_set) {
|
||||
*/
|
||||
|
||||
if (is_set) *is_set = 1;
|
||||
*value = pow(10, temp_i / 20.0); /* dB to % where 1.0 = max */
|
||||
*value = pow(10, temp_f / 20.0); /* dB to % where 1.0 = max */
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -1466,7 +1465,7 @@ static void parse_params(txtp_entry* entry, char* params) {
|
||||
|
||||
//todo cleanup
|
||||
/* macros */
|
||||
else if (strcmp(command,"@volume") == 0) {
|
||||
else if (is_match(command,"v") || is_match(command,"@volume")) {
|
||||
txtp_mix_data mix = {0};
|
||||
|
||||
nm = get_volume(params, &mix.vol, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user