<commit_before># Generate a MIDI file using a tone row, repeated 3 times using random rhythms
#
# NOTE: this blindly overwrites any existing MTK-tone_row_melody.mid file, unless an argument is provided

require 'mtk'
require 'mtk/midi/file'
include MTK
include PitchClasses

file = ARGV[0] || 'MTK-tone_row_melody.mid'

row = PitchClassSet(Db, G, Ab, F, Eb, E, D, C, B, Gb, A, Bb)
pitch_pattern = Pattern.PitchCycle *row
rhythm_pattern = Pattern.RhythmCycle(Pattern.Choice 0.25, 0.5, 0.75, 1) # choose between sixteenth, eighth, dotted eighth, and quarter

sequencer = Sequencer::RhythmicSequencer.new [pitch_pattern, rhythm_pattern], :max_steps => 36
timeline = sequencer.to_timeline

MIDI_File(file).write timeline
<commit_msg>udpated tone_row_melody example to use Durations constants<commit_after># Generate a MIDI file using a tone row, repeated 3 times using random rhythms
#
# NOTE: this blindly overwrites any existing MTK-tone_row_melody.mid file, unless an argument is provided

require 'mtk'
require 'mtk/midi/file'
include MTK
include PitchClasses
include Durations

file = ARGV[0] || 'MTK-tone_row_melody.mid'

row = PitchClassSet(Db, G, Ab, F, Eb, E, D, C, B, Gb, A, Bb)
pitch_pattern = Pattern.PitchCycle *row
rhythm_pattern = Pattern.RhythmCycle(Pattern.Choice s, e, e+s, q) # choose between sixteenth, eighth, dotted eighth, and quarter

sequencer = Sequencer::RhythmicSequencer.new [pitch_pattern, rhythm_pattern], :max_steps => 36
timeline = sequencer.to_timeline

MIDI_File(file).write timeline

{'fraction_non_alphanumeric': 0.09636963696369637, 'fraction_numerical': 0.011221122112211221, 'mean_word_length': 5.707964601769912, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4122030', 'n_tokens_mistral': 559, 'n_tokens_neox': 518, 'n_words': 166}