@@ -468,83 +468,20 @@ static inline bool TestSectionCompression(const char* section, int width, int qu
468
468
return quant >= MIN_SECTIONS_PER_MEASURE;
469
469
}
470
470
471
- static bool GetSectionCompression (const char * section, int width, std::list<uint> quantVec , int & count, int & pitch)
471
+ static void GetSectionCompression (const char * section, int width, int & count, int & pitch)
472
472
{
473
+ count = ROWS_PER_NOTE_SECTION;
473
474
// Determines the best compression for the given section.
474
- bool error = false ;
475
- int best = ROWS_PER_NOTE_SECTION;
476
- String zeroline (width, ' 0' );
477
- std::list<uint>::iterator it;
478
- int lcm = 1 ;
479
- for (it = quantVec.begin (); it != quantVec.end (); it++)
475
+ // We actually don't care about custom snaps for this at all, since we want to save 192nds for non-standard-compressible snaps.
476
+ for (int i = 1 ; i < NUM_MEASURE_SUBDIV - 1 ; i++)
480
477
{
481
- if (*it <= 0 || *it > 192 )
482
- {
483
- // If there's a quantization error assume nothing
484
- error = true ;
485
- lcm = ROWS_PER_NOTE_SECTION;
486
- break ;
487
- }
488
- lcm = lcm * *it / gcd (lcm, *it);
489
- if (lcm > ROWS_PER_NOTE_SECTION)
478
+ if (TestSectionCompression (section, width, MEASURE_SUBDIV[i]))
490
479
{
491
- lcm = ROWS_PER_NOTE_SECTION ;
480
+ count = MEASURE_SUBDIV[i] ;
492
481
break ;
493
482
}
494
483
}
495
-
496
- // Set whole and half step measures to be quarter notes by default
497
- if (lcm <= MIN_SECTIONS_PER_MEASURE)
498
- {
499
- count = MIN_SECTIONS_PER_MEASURE;
500
- }
501
- else
502
- {
503
- // Determines the best compression for the given section.
504
- // Maybe lcm is the best factor, so just keep that.
505
- count = lcm;
506
- bool valid = false ;
507
- // The factor list is small, just check them all by hand, but only up to 96 at most since there won't be factors otherwise
508
- for (int i = 4 ; i <= lcm / 2 ; i++)
509
- {
510
- // Skip anything that isn't a lcm factor
511
- if (lcm % i > 0 ) continue ;
512
-
513
- // The first (smallest) match is always the best
514
- if (TestSectionCompression (section, width, i))
515
- {
516
- valid = true ;
517
- count = i;
518
- break ;
519
- }
520
- }
521
-
522
- // If no factor was found, double-check we won't have any data loss from our lcm guess
523
- // Why not check all factors? Saving files would be several times slower otherwise
524
- if (!valid)
525
- {
526
- valid = TestSectionCompression (section, width, lcm);
527
- }
528
- if (!valid)
529
- {
530
- // Okay, we WOULD have had data loss, so set the rows to 192 and error
531
- error = true ;
532
- count = ROWS_PER_NOTE_SECTION;
533
- }
534
- }
535
- // Is our factor a standard snap? If so, use it.
536
- // If not, save the measure as 192nds for SM5 Editor compatibility.
537
- if (ROWS_PER_NOTE_SECTION % count != 0 )
538
- {
539
- count = ROWS_PER_NOTE_SECTION;
540
- }
541
- // Yes it is weird... but we don't save 6ths even though they factor into 192 evenly.
542
- if (count == 6 )
543
- {
544
- count = 12 ;
545
- }
546
484
pitch = (ROWS_PER_NOTE_SECTION * width) / count;
547
- return error;
548
485
}
549
486
550
487
static void WriteSections (ExportData& data)
@@ -594,20 +531,17 @@ static void WriteSections(ExportData& data)
594
531
if (it->row == it->endrow )
595
532
{
596
533
section[pos] = GetNoteChar (it->type );
597
- quantVec.push_front (it->quant );
598
534
}
599
535
else
600
536
{
601
537
section[pos] = GetHoldChar (it->type );
602
- quantVec.push_front (it->quant );
603
538
auto hold = holds[it->col ];
604
539
if (hold)
605
540
{
606
541
if ((int )hold->endrow >= startRow && (int )hold->endrow < endRow)
607
542
{
608
543
int pos = ((int )hold->endrow - startRow) * numCols + (int )hold->col ;
609
544
section[pos] = ' 3' ;
610
- quantVec.push_front (holds[it->col ]->quant );
611
545
--remainingHolds;
612
546
}
613
547
}
@@ -629,7 +563,6 @@ static void WriteSections(ExportData& data)
629
563
{
630
564
int pos = (hold->endrow - startRow) * numCols + hold->col ;
631
565
section[pos] = ' 3' ;
632
- quantVec.push_front (holds[col]->quant );
633
566
holds[col] = nullptr ;
634
567
--remainingHolds;
635
568
}
@@ -641,10 +574,7 @@ static void WriteSections(ExportData& data)
641
574
int count, pitch;
642
575
const char * m = section;
643
576
quantVec.unique ();
644
- if (GetSectionCompression (m, numCols, quantVec, count, pitch))
645
- {
646
- HudError (" Bug: invalid quantization recorded in chart in measure starting at row %d" , startRow);
647
- }
577
+ GetSectionCompression (m, numCols, count, pitch);
648
578
quantVec.clear ();
649
579
if (ROWS_PER_NOTE_SECTION % count != 0 )
650
580
{
0 commit comments