Add TXTP "loop_mode = auto" to simplify looping last segment

This commit is contained in:
bnnm 2019-12-05 22:41:29 +01:00
parent 1a7891828f
commit 337e2d3922
2 changed files with 21 additions and 2 deletions

View File

@ -38,6 +38,16 @@ loop_start_segment = 2 # 2nd file start
loop_end_segment = 2 # optional, default is last loop_end_segment = 2 # optional, default is last
mode = segments # optional, default is segments mode = segments # optional, default is segments
``` ```
You can also set looping to the last segment like this:
```
BGM01_BEGIN.VAG
BGM01_LOOPED.VAG
# equivalent to loop_start_segment = 2, loop_end_segment = 2
# (only for multiple segments, to repeat a single file use #E)
loop_mode = auto
```
If your loop segment has proper loops you want to keep, you can use: If your loop segment has proper loops you want to keep, you can use:
``` ```
@ -166,7 +176,7 @@ loop_mode = keep
## TXTP COMMANDS ## TXTP COMMANDS
You can set file commands by adding multiple `#(command)` after the name. `# (anything)` is considered a comment and ignored, as well as any command not understood. You can set file commands by adding multiple `#(command)` after the name. `#(space)(anything)` is considered a comment and ignored, as well as any command not understood.
### Subsong selection for bank formats ### Subsong selection for bank formats
**`#(number)` or `#s(number)`**: set subsong (number) **`#(number)` or `#s(number)`**: set subsong (number)

View File

@ -123,6 +123,7 @@ typedef struct {
uint32_t loop_start_segment; uint32_t loop_start_segment;
uint32_t loop_end_segment; uint32_t loop_end_segment;
int is_loop_keep; int is_loop_keep;
int is_loop_auto;
txtp_entry default_entry; txtp_entry default_entry;
int default_entry_set; int default_entry_set;
@ -313,8 +314,13 @@ static int make_group_segment(txtp_header* txtp, int position, int count) {
/* loop settings only make sense if this group becomes final vgmstream */ /* loop settings only make sense if this group becomes final vgmstream */
if (position == 0 && txtp->vgmstream_count == count) { if (position == 0 && txtp->vgmstream_count == count) {
if (txtp->loop_start_segment && !txtp->loop_end_segment) if (txtp->loop_start_segment && !txtp->loop_end_segment) {
txtp->loop_end_segment = count; txtp->loop_end_segment = count;
}
else if (txtp->is_loop_auto) { /* auto set to last segment */
txtp->loop_start_segment = count;
txtp->loop_end_segment = count;
}
loop_flag = (txtp->loop_start_segment > 0 && txtp->loop_start_segment <= count); loop_flag = (txtp->loop_start_segment > 0 && txtp->loop_start_segment <= count);
} }
@ -1389,6 +1395,9 @@ static int parse_keyval(txtp_header * txtp, const char * key, const char * val)
if (is_substring(val,"keep")) { if (is_substring(val,"keep")) {
txtp->is_loop_keep = 1; txtp->is_loop_keep = 1;
} }
else if (is_substring(val,"auto")) {
txtp->is_loop_auto = 1;
}
else { else {
goto fail; goto fail;
} }