Closed rualark closed 7 years ago
Window-scan generation can finish when:
Other causes:
Cause of this bug is always "last variant in first window"
Found out that cc was not returned to minimum in ScanLeft. Fixing this does not resolve bug.
Ideas for debugging:
Species 4: 2runs.log Reseed 0: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 83 84
In second run second to last scan does not approve note 83: Reseed 1: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 83 91
This melody:
Reseed 8: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 79 76
Reseed 8: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 76 76
Reseed 8: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 83 76 <--
Reseed 8: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 77 76
Reseed 8: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 96 76
Does not reach this code: LogCantus("Rpenalty", rpenalty_cur, flags); SaveBestRejected(acc[cpv]);
MatchVectors also did not trigger. I moved it higher in code.
Configuration file does not allow skip_flags, so cause of this behaviour is unknown:
rules_file = rules.csv # Specify which file contains all rules
hsp_file = harm.csv # Harmonic sequence penalties
rule_set = 1 # Specify which set of rules to use (see rules.xlsx)
# Currently window-scan method is not working
#method = window-scan # This method is fastest random generator with s_len=1, accept_reseed=1, random_seed=1
method = swa # This method is mainly used for testing (same algorithm used as in CA1)
accept_reseed = 1 # After accepting first result reseed (if random_seed) and choose new range (if random_range)
random_seed = 1 # Seed melody with random numbers. This ensures giving different results if generation is very slow.
random_range = 0 # Limit scanning to one of possible fast-scan ranges (automatically enabled for RSWA)
late_require = 1 # Allow not-last scan window to have no needed flags or strict when strict=0 (blocked flags are always disallowed). This calculation usually requires more time
s_len = 1 # Maximum number of measures to full scan. Higher values are slow to compute
t_cnt = 1000 # Maximum number of steps generated
shuffle = 0 # If you want to shuffle all canti after generation (can shuffle up to 32000 canti)
# Main parameters
c_len = 13 # Number of measures in each cantus. Usually 9 to 11 for cantus
key = Am # Music key to use for generation
first_note = A5 # Starting note of each cantus
last_note = A5 # Ending note of each cantus
random_key = 0 # Allow generator to select random key
tempo = 100-130 # Tempo range
cantus_high = 1 # Set to 1 to consider cantus to be higher voice
transpose_back = 1 # Set to 1 to transpose generated melody closer to initial first note
# Random SWA
approximations = 500 # Maximum number of approximations to run if rpenalty decreases
swa_steps = 2 # Size of Sliding Window Approximation algorithm window in steps
correct_range = 12 # Maximum interval allowed between each source and corrected note
rpenalty_accepted = 0 # Maximum accepted rule penalty for RandomSWA
# Rule parameters
fill_steps_mul = 2 # Multiply number of notes between leap notes to get steps for filling (+2)
first_steps_tonic = 3 # Number of first steps, which must contain tonic note (will increase by one if cantus is longer than 10 notes)
# Technical parameters
midifile_out_mul = 2 # All notes length is multiplied by this number before exporting
show_severity = 1 # =1 to show severity and flag id in square brackets in comments to notes (also when exporting to MIDI file)
calculate_correlation = 0 # Enables correlation calculation algorithm. Slows down generation. Outputs to cf1-cor.csv
calculate_blocking = 1 # Enables blocking flags calculation algorithm. Slows down generation.
calculate_stat = 0 # Enables flag statistics calculation algorithm. Slows down generation.
calculate_ssf = 0 # Enables SWA stuck flags statistics calculation algorithm.
best_rejected = 0 # Show best rejected results if rejecting more than X ms. Requires blocking or stat to work. Set to 0 to disable. Slows down generation
midifile_export_marks = 0 # Set to export marks (harmony) to midifile lyrics
midifile_export_comments = 1 # Set to export comments (violations) to midifile lyrics
Midi_file = midi\good-cf-min.mid # Path and file name of imported midi file
method = window-scan
cantus_id = 14
cantus_high = 0
species = 4
Reseed 17: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 79 83
Rpenalty 0: 0 0 0 1 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Flags analysis: 8 => '2', + Leap back <=6th 21 => '1', + Culmination late 3 43 => '1', + 50 => '1', - Last note (not C) 54 => '1', 58 => '1', 80 => '1', 81 => '1', 83 => '1', 86 => '3', 101 => '3', 108 => '1', 116 => '1', 121 => '2', 160 => '1', 182 => '1', 189 => '1', 207 => '1', 225 => '10',
Reseed 19: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 91 92
Reseed 19: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 77 92
Reseed 19: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 78 92
Reseed 19: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 83 92 <--
Reseed 19: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 80 92
Reseed 19: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 84 92
Reseed 19: 81 81 86 83 83 81 81 80 80 78 78 83 83 81 81 86 86 84 89 88 88 92 92 81 92
When debugging I also confirmed that ep2 == c_len and FailLastIntervals() skips melody when skip_flags==1
This means that ep2 is wrongly set to c_len, while only penultimate note is being evaluated. Last note is stable in scans, while penultimate note is changing.
I found out that ep2 is set wrongly to c_len after BackWindow from ep2 == c_len scan:
ep2 is set in this code:
FillCantus(cc_id, sp1, sp2, 0);
FillCantus(cc, sp1, sp2, cc_rand);
// If this is not first window, go to previous window
if (wid > 0) wid--;
sp1 = wpos1[wid];
sp2 = wpos2[wid];
// End of evaluation window
ep1 = max(0, sp1 - 1);
ep2 = sp2;
// Add last note if this is last window
if (ep2 == c_len - 1) ep2 = c_len;
// Go to rightmost element
p = sp2 - 1;
Problem is obviously with this line: if (ep2 == c_len - 1) ep2 = c_len;
This line was used when scanning took place only inside melody without scanning border notes. So, when I was scanning penultimate note, last note was always fixed to correct one and ep2 was fully equal to c_len. Today we scan all notes, so this is wrong line of code.
Solution: removed this line