<commit_before>module Aleatoric
# include Aleatoric

# Yes, a hack, these two methods are used to redirect error to a dummy file
#  so warnings don't show up anywhere while script is executed. Used to suppress warnings
#  in composer.rb::format(), which dynamically requires in either global_midi.rb or
#  global_csound.rb depending on format arg.  This redefines global constants, which is what
#  we *want* to happen, but that raises an error, so we wrap the call in a toggle off and on
#  of errors so no ugliness occurs in output of running script
def warnings_on
  $stderr.flush
  $stderr = STDERR
end

def warnings_off
  $stderr.flush
  $stderr = File.open('tempflush', 'w')
end


# Default format set in script invocation command line or set to :csound if no format arg passed
# TODO Make this support command-line argument or config for which is default
$FORMAT = $ARG_FORMAT || :csound
$LAST_FORMAT = $FORMAT

# TODO implement this to load both csound and midi from a config and then fill in values from the first
#  'format' statement it encounters
# TODO Add all of these consts and put them in a '' conf somewhere
REST = 0.0

# Default durations in seconds
WHL = 4.0 
HLF = 2.0
QRTR = 1.0
EITH = 0.5
SXTNTH = 0.25
THRTYSCND = 0.125
SXTYFRTH = 0.0625

# Remove MIDI consts only used by MIDI to avoid using them with CSound format
#  and silently passing bogus values to CSound that might not cause errors but
#  might not behave as intended
# Only called by set_csound_consts()
def unset_midi_consts

# These are notes in range in MIDI only
Aleatoric.send :remove_const, :Cneg1
Aleatoric.send :remove_const, :Cneg1S
Aleatoric.send :remove_const, :Dneg1F
Aleatoric.send :remove_const, :Dneg1
Aleatoric.send :remove_const, :Dneg1S
Aleatoric.send :remove_const, :Eneg1F
Aleatoric.send :remove_const, :Eneg1
Aleatoric.send :remove_const, :Fneg1
Aleatoric.send :remove_const, :Fneg1S
Aleatoric.send :remove_const, :Gneg1F
Aleatoric.send :remove_const, :Gneg1
Aleatoric.send :remove_const, :Gneg1S<commit_msg>Made REST int to be MIDI-compatible. Added global DUR_FACTOR which #TODO needs to become global tempo<commit_after>module Aleatoric
# include Aleatoric

# Yes, a hack, these two methods are used to redirect error to a dummy file
#  so warnings don't show up anywhere while script is executed. Used to suppress warnings
#  in composer.rb::format(), which dynamically requires in either global_midi.rb or
#  global_csound.rb depending on format arg.  This redefines global constants, which is what
#  we *want* to happen, but that raises an error, so we wrap the call in a toggle off and on
#  of errors so no ugliness occurs in output of running script
def warnings_on
  $stderr.flush
  $stderr = STDERR
end

def warnings_off
  $stderr.flush
  $stderr = File.open('tempflush', 'w')
end


# Default format set in script invocation command line or set to :csound if no format arg passed
# TODO Make this support command-line argument or config for which is default
$FORMAT = $ARG_FORMAT || :csound
$LAST_FORMAT = $FORMAT

# TODO implement this to load both csound and midi from a config and then fill in values from the first
#  'format' statement it encounters
# TODO Add all of these consts and put them in a '' conf somewhere
REST = 0

# Change dur_factor to change global tempo, this changes duration of all notes
#  defined using these global constants
# TODO make dur_factor configurable and rename to indicate it controls global tempo
#  and expose it in Composer language to composition scripts so user can set, and so we can set it
#  in testing so that tests that rely on actual tempo (of kw 'meter') don't break
DUR_FACTOR = 1.0 # 0.4 for 'In_C'
# Default durations in seconds
WHL = 4.0 * DUR_FACTOR
HLF = 2.0 * DUR_FACTOR
QRTR = 1.0 * DUR_FACTOR
EITH = 0.5 * DUR_FACTOR
SXTNTH = 0.25 * DUR_FACTOR
THRTYSCND = 0.125 * DUR_FACTOR
SXTYFRTH = 0.0625 * DUR_FACTOR

# Remove MIDI consts only used by MIDI to avoid using them with CSound format
#  and silently passing bogus values to CSound that might not cause errors but
#  might not behave as intended
# Only called by set_csound_consts()
def unset_midi_consts

# These are notes in range in MIDI only
Aleatoric.send :remove_const, :Cneg1
Aleatoric.send :remove_const, :Cneg1S
Aleatoric.send :remove_const, :Dneg1F
Aleatoric.send :remove_const, :Dneg1
Aleatoric.send :remove_const, :Dneg1S
Aleatoric.send :remove_const, :Eneg1F
Aleatoric.send :remove_const, :Eneg1
Aleatoric.send :remove_const, :Fneg1
Aleatoric.send :remove_const, :Fneg1S
Aleatoric.send :remove_const, :Gneg1F
Aleatoric.send :remove_const, :Gneg1
Aleatoric.send :remove_const, :Gneg1S
{'fraction_non_alphanumeric': 0.0646906101254868, 'fraction_numerical': 0.01536131544785807, 'mean_word_length': 4.610436893203883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5848938', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1464, 'n_words': 631}