321
if(gui_settings.save_all_patterns) {
322
for(i = 0, n = 0; i < 256; i++) {
323
if(!st_is_empty_pattern(&xm->patterns[i]))
327
for(i = 0, n = 0; i < 256; i++) {
328
if(xm->pattern_order_table[i] > n)
329
n = xm->pattern_order_table[i];
321
for(i = 0, n = 0; i < 256; i++) {
322
if(!st_is_empty_pattern(&xm->patterns[i]))
330
st_copy_instrument (STInstrument *src, STInstrument *dest)
336
st_clean_instrument(dest, NULL);
338
for(i = 0; i < sizeof(dest->samples) / sizeof(dest->samples[0]); i++)
339
lock[i] = dest->samples[i].sample.lock; // Preserve pointers to GMutex'es from modification
340
memcpy(dest, src, sizeof(STInstrument));
341
for(i = 0; i < sizeof(src->samples) / sizeof(src->samples[0]); i++){
342
if ((length = dest->samples[i].sample.length * sizeof(dest->samples[i].sample.data[0]))){
343
dest->samples[i].sample.data = malloc(length);
344
memcpy(dest->samples[i].sample.data, src->samples[i].sample.data, length);
346
dest->samples[i].sample.lock = lock[i];
337
351
st_clean_instrument (STInstrument *instr,
338
352
const char *name)
448
for(i = 0; i < sizeof(xm->patterns) / sizeof(xm->patterns[0]); i++)
449
if(!st_is_pattern_used_in_song(xm, i) && st_is_empty_pattern(&xm->patterns[i]))
462
for(i = 0; i < sizeof(xm->patterns) / sizeof(xm->patterns[0]); i++) {
463
if(!st_is_pattern_used_in_song(xm, i) && st_is_empty_pattern(&xm->patterns[i])) {
469
488
st_is_empty_track (XMNote *notes,
472
for(; length >= 0; length--)
491
for(; length > 0; length--, notes++) {
473
492
if(notes->note != 0 || notes->instrument != 0 || notes->volume != 0
474
|| notes->fxtype != 0 || notes->fxparam != 0)
493
|| notes->fxtype != 0 || notes->fxparam != 0) {
535
st_check_if_odd_are_not_empty (XMPattern *p)
539
for(i = 0; i < 32 && p->channels[i]; i++)
540
for(j = 1; j < p->length; j += 2)
541
if((p->channels[i][j].note && p->channels[i][j].instrument) ||
542
(p->channels[i][j].volume > 15) ||
543
p->channels[i][j].fxtype || p->channels[i][j].fxparam)
550
st_shrink_pattern (XMPattern *p)
552
int i, j, length = p->length;
554
for(i = 0; i < 32 && p->channels[i]; i++){
555
for(j = 1; j <= (length - 1) / 2; j++)
556
memcpy(&p->channels[i][j], &p->channels[i][2 * j], sizeof(XMNote));
557
for(;j < p->alloc_length; j++){/* clear the rest of the pattern */
558
p->channels[i][j].note = 0;
559
p->channels[i][j].instrument = 0;
560
p->channels[i][j].volume = 0;
561
p->channels[i][j].fxtype = 0;
562
p->channels[i][j].fxparam = 0;
566
st_set_pattern_length(p, (length - 1) / 2 + 1);
570
st_expand_pattern (XMPattern *p)
572
int i, j, length = MIN(p->length * 2, 256);
574
st_set_pattern_length(p, length);
576
for(i = 0; i < 32 && p->channels[i]; i++){
577
for(j = length / 2 - 1; j >= 0; j--){
578
/* copy to even positions and clear odd */
579
memcpy(&p->channels[i][2 * j], &p->channels[i][j], sizeof(XMNote));
580
p->channels[i][2 * j + 1].note = 0;
581
p->channels[i][2 * j + 1].instrument = 0;
582
p->channels[i][2 * j + 1].volume = 0;
583
p->channels[i][2 * j + 1].fxtype = 0;
584
p->channels[i][2 * j + 1].fxparam = 0;
514
590
st_convert_sample (void *src,