inkamusic package

Submodules

inkamusic.algorithms module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains the main algorithmic functions

class inkamusic.algorithms.InkaAlgorithms(**comp_data)

Bases: object

This is the main algorithm class

create_part(c_strct)

Creates positions (rhythm), tone heights (melody) intensities and connection_types for one part. Loops through all beats of the part. In one loop the following functions are called: self.rhythm_generator self.melody_generator

create_part_melody(c_strct)

selects the tone heights of a part for all rhythmic positions

createmelody()

This is the main algorithm for melody creation. Uses function self.walk_structure() to walk recursively along the structure of the piece.

get_bars_and_beats()

returns bars_and_beats data structure

get_instrument_range()

sets instrument range

getconnection_types()

returns connection types

getintensities()

returns intensities

getpositions()

returns positions

gettones()

returns melody tone heights

humanize_positions(pos_conn_intens)

humanizes all positions

loop_beats(rpt, harmony_constant_beats)

loops over all beats of current part

set_bar_distribution(bar_distribution)

sets bar distribution data of current composition

set_basicscale_class(basicscale_class)

set instance of BasicScale class

set_harmony_class(harmony_class)

set instance of HarmonyBasics class

set_scale(scale)

set scale of current composition

start_createmelody(harmony_track, bpm, selected_speed, global_rhythm)

Starts creating the melody (tone positions, heights, intensities and connection_types) for one instrument track calls self.createmelody(created)

walk_structure(c_strct, level)

Walks along the part structure of the composition. A part may be a CREATE or REPEAT part, in which case self.create_part() is called. Or a part may be a substructure, in which case self.walk_structure is called recursively.

inkamusic.algorithms.get_last_tones_from_melody(melody, n_th_last_tone)

gets nth last tone of current melody

inkamusic.algorithms.get_tone_from_envelope_val(envelope, instru_low, instru_high)

transforms envelope val (-1 … +1) to tone height

inkamusic.algorithms.show_bars_and_beats(txt, bars_beats)

prints bars and beats entries for debugging purposes

inkamusic.bar_distribution module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file creates the bar distribution

class inkamusic.bar_distribution.BarDistribution(inka_data, c_2)

Bases: object

keeps information about each bar of a composition

check_for_silent_bars(count_silent)

checks if any bar is silent or if to many bars play percussion only

check_non_pause_in_other_tracks(current_index_in_all_tracks, choose_bar, all_tracks)

checks if bar is not paused in another track

create_bar_distribution(bar_struct)

This functions counts for each created (i. e. not repeated) bar, how often this bar is used within the composition. Also the group in which the bar is first used is stored. This data structure will be extended with pause and harmony information in set_paused_bars and set_bar_harmony_type

do_list_type_pause(pause, track)

sets pauses in tracks depending on instruments distribution catalogs

do_percent_type_pause(pause, track, all_tracks, current_index_in_all_tracks)

sets random pauses in tracks depending on pause setting for track and depending on pauses of the same bar in other tracks

init_play_state(track)

resets the play state for all bars for one or all tracks

set_bar_harmony_type()

sets the harmony type for each bar

set_harmony_type(bar_num, harmony_type)

sets the harmony type for a specific bar

set_non_special_bars_harmony_types(harmony_list, num_of_bars_to_reach, num_of_bars_currently_assigned)

sets the harmony type for all normal bars, i. e. not the first, last and second-last bar

set_pause_for_all_tracks(all_tracks, pause)

sets random pauses in tracks depending on pause setting for track and depending on pauses of the same bar in other tracks

set_paused_bars()

sets the pause status for each bar within each track

show_bar_distribution()

prints bar distribution for debugging purposes

inkamusic.basic_rhythms module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains all pre_rhythm related functions and definitions

class inkamusic.basic_rhythms.BasicRhythm

Bases: object

BasicRhythm related functions and definitions Defines basic rhythm patterns A basic pattern consists in general of a length (in beats) and several sub patterns each associated with a specific sound type (for example Bass or Stick) Each sub pattern is defined by a list of positions and accent strength at that position An accent strength of 0 indicates a blocked position which will not be used in possible further subdivisions of a rhythm

get_basic_rhythm_by_id(r_id)

returns basic rhythm for given id

get_basic_rhythms_list()

returns list of all basic rhythms

inkamusic.basic_scales module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2019 Udo Wollschläger

This file contains all (possible) basic_scale related functions and definitions A basic_scale defines the steps of a scale but not the first note or its interpretation as c, d, …

example: the same basic_scale (7, 65) is used for c major, c minor, d major, …)
the actual first tone and its interpretation (c, d, …) are defined in the SCALES_LIST structure of module menu_entries The SCALES_LIST is accessible through the web interface
class inkamusic.basic_scales.BasicScale

Bases: object

BasicScale related functions and definitions

get_all_basic_scales()

returns list of all basic_scales

get_scale_by_index(len_indx, count_indx, pattern_starts_at, based_on_note)

returns basic_scale given by length and index all scales start at tone C unless shifted by based_on_note pattern_starts_at is the index where the scale pattern starts examples: a C-major scale uses 7 65 with pattern_starts_at=0 and based_on_note Note_C a A-minor scale uses 7 65 with pattern_starts_at=9 and based_on_note Note_A

inkamusic.const module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2019 Udo Wollschläger

This file contains all global constants

inkamusic.const.HARMONY_IDENTIFIER = 3

track number + PLAYED_IN_TRACK gives column index of column which defines if a specific bar is actually played or paused in a track

inkamusic.create_composition module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2019 Udo Wollschläger

class inkamusic.create_composition.InkaAlgorithmicMusic(**inka_data)

Bases: object

This is the Inka_Algorithmic_Music application main class.

adapt_tone_length(pos_current_tone, pos_next_tone, end_pos_limit, check_connect_type)

tries to adapt tone length using rules for different connection types

calc_num_of_bars()

calculates number of bars

calculate_tone_length(connection_type, pos_current_tone, pos_next_tone, end_pos_limit)

calculates the tone length

create_composition()

This function generates a composition

create_melody_midi(current_track, current_channel, track_id)

create midi data for melody instrument

create_midi()

creates midi data for all tracks

create_percussion_midi(current_track, perc_instrument_type, track_id)

create midi data for percussion instrument

create_track(track)

Main function called for each instrument track. generates tone positions, height values, intensities and connection_types

find_dissonance_delta(current_track_id, pos_current_tone, current_tone)

Finds distance to nearest dissonant tone in all other tracks

get_pan_value(track, is_melody_instrument)

sets pan value for a track

get_tone_length_and_connection_type(indx, track_id, is_percussion)

This functions calculates the exact tone length, avoiding dissonances or tones too short or pauses

inkamusic.create_composition.find_first_dissonance(pos, pos_current_tone, tones, current_tone)

finds first dissonance for current track

inkamusic.create_composition.set_midi_on_off(t_chord, midi_params, c_3)

creates note on and off events for a tone or chord

inkamusic.general_midi_instruments module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file defines all general midi instruments

inkamusic.harmonies module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains all harmony related functions and definitions

class inkamusic.harmonies.HarmonyBasics(all_basic_scales)

Bases: object

Harmony related functions and definitions

get_all_harmonies()

returns all harmony types

get_anchor_harmony_for_scale(selected_scale)

chooses the anchor harmony of a scale example for selected_scale: [7, 65, 0, 2, [1, 0, 2]] (SCALE_LEN, SCALE_COUNT, SCALE_START, SCALE_NOTE, harmonies)

get_harmony_steps_from_type(harmony_type)

returns harmony steps for harmony type

get_possible_harmony_type_for_scale(selected_scale, harmony_type, first_harmony, already_used)

replaces wildcard harmony types such as HARMONY_PREFER_MAJOR selects a random harmony type for a scale, using harmony_type and first_harmony flag avoids using already_used harmonies again example for selected_scale: [7, 65, 0, 0, [HARMONY_PREFER_MAJOR_VAR, HARMONY_ANY]] (SCALE_LEN, SCALE_COUNT, SCALE_START, SCALE_NOTE, harmonies)

get_random_harmony_for_scale(selected_scale, harmony_type, rndm_2)

chooses a specific harmony from a scale for given harmony type example for selected_scale: [7, 65, 0, 2, [1, 0, 2]] (SCALE_LEN, SCALE_COUNT, SCALE_START, SCALE_NOTE, harmonies)

inkamusic.harmonies.check_harmony(tone, harmony_steps, basic_scale)

checks if harmony is buildable on current tone with current scale

inkamusic.harmonies.harmony_type_check(harmony_type, loop_counter, harmony_steps, index, already_used)

checks if harmony is of selected harmony type. For the second and third call (used if no harmony was foun which can be used with the current scale) the check is less strict.

inkamusic.html_data module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains static html code used for web interface

inkamusic.html_data.get_html_source(html_id)

returns static html code used for web interface

inkamusic.menu_entries module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains all menu entries used in the web interface or, for now, as parameters to the webutilities generate function

inkamusic.menu_entries.INSTRUMENTATION_LIST = [['Piano + Bass', [['Grand Piano', 2, 2], ['Grand Piano', 2, 3], ['Grand Piano', 1, 2], ['Grand Piano', 3, 2], ['Fingered Bass', 0, 0]]], ['Classical Guitars + Bass', [['Nylon String Guitar', 2, 2], ['Nylon String Guitar', 2, 4], ['Nylon String Guitar', 1, 2], ['Nylon String Guitar', 3, 2], ['Acoustic Bass', 0, 0]]], ['Marimba + Bass', [['Marimba', 2, 2], ['Marimba', 2, 3], ['Marimba', 1, 2], ['Nylon String Guitar', 3, 2], ['Fingered Bass', 0, 0]]], ['Sax + Bass', [['Tenor Sax', 2, 2], ['Tenor Sax', 2, 4], ['Bright Grand Piano', 1, 2], ['Nylon String Guitar', 3, 2], ['Fingered Bass', 0, 0]]], [], ['Synth 1', [['Saw Wave', 2, 2], ['Warm Pad', 2, 3], ['Synth Strings 2', 3, 2], ['Synth Bass 2', 0, 0]]], ['Synth 2', [['Synth Brass 2', 2, 2], ['Square Lead', 2, 3], ['5th Sawtooth Wave', 1, 2], ['Polysynth', 1, 2], ['Synth Bass 3', 0, 0]]], [], ['Strings', [['Strings', 2, 2], ['Strings', 2, 2], ['Strings', 1, 2], ['Strings', 1, 2], ['Contrabass', 0, 0]]], ['Brass', [['Trumpet', 2, 4], ['Trumpet', 2, 2], ['Trumpet', 3, 2], ['Tuba', 0, 0]]], [], ['Random instrumentation', [[0]]]]

an instrumentation list entry defines the specific instruments, their register and role in an instrumentation

possible roles are

  • T_BASS bass instrument
  • T_CHOR chorus instrument
  • T_SOLO solo instrument
  • T_HMNY harmony instrument (generates chords)
  • T_PERC percussion instrument

possible registers are

  • R_BASS bass
  • R_LOW low
  • R_MEDI medium
  • R_HIGH high
  • R_FULL full instrument range
inkamusic.menu_entries.SCALES_LIST = [['C (maj)', [7, 65, 0, 0, [-1]]], ['C (maj+maj7)', [7, 65, 0, 0, [-1, 43]]], ['C (maj+min)', [7, 65, 0, 0, [-1, -2]]], ['F (maj+min)', [7, 65, 0, 5, [-1, -2]]], ['A (maj+min)', [7, 65, 0, 9, [-1, -2]]], [], ['A harmonic (min maj)', [7, 55, 4, 9, [-2, -1]]], ['A natural (min maj)', [7, 65, 9, 9, [-2, -1]]], ['A melodic (min maj)', [7, 64, 9, 9, [-2, -5, -4]]], ['A (min min7)', [7, 65, 9, 9, [-2, 48]]], [], ['C (minor blues)', [6, 63, 5, 0, [-6, -5, -4]]], [], ['C (minor Pentatonic)', [5, 58, 5, 0, [-2, -1]]], ['C (major Pentatonic)', [5, 58, 8, 0, [-1, -2]]], ['Japanese Pentatonic', [5, 38, 11, 0, [-5, -6, -4]]], ['Chinese Pentatonic', [5, 43, 0, 0, [-3, -5]]], ['Byzantine', [7, 54, 11, 0, [-6, -4, -4]]], [], ['6 tone (maj)', [6, 70, 3, 0, [-1]]], ['6 tone (maj min)', [6, 70, 3, 0, [-1, -2]]], ['5 tone (maj min)', [5, 51, 0, 0, [-1, -2]]], ['5 tone (min maj)', [5, 32, 4, 0, [-2, -1]]], [], ['Chromatic', [12, 0, 0, 9, [-2, -1]]]]

a scale is defined by:

  • title,
  • number of tones,
  • index of basic_scale as defined in basic_scales (example: the same basic_scale (7, 65) is used for c major, c minor, d major, …)
  • index of first tone (0 - 11) within basic_scale, this defines the start position within the scale (example: if this is set to 0 for scale (7, 65) a major scale is fixed, so c major and d major are still possible, but not c minor)
  • interpretation ( = absolute height) of first tone, i.e. c, cis, d, dis, … (if set to c in the example above the scale is now fixed as c major)
  • 1, 2, or 3 harmony IDs as defined in harmonies, first ID defines main harmony, 2nd and 3rd (if defined) are used less often
  • the first harmony must be buildable with the first tone as starting point for example, if c-major is defined as described above, the first harmony can not be minor (which is not buildable over c)

inkamusic.midiutil module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains MIDI file functions

inkamusic.midiutil.control_change_event(current_track, channel, control, value)

appends a control change event

inkamusic.midiutil.encode_midi_event(event, running_status)

encodes a midi event

inkamusic.midiutil.encode_track_header(trklen)

encodes the track header

inkamusic.midiutil.end_of_track_event(current_track)

appends an end of track event

inkamusic.midiutil.note_off_event(current_track, tick, channel, pitch)

appends a note off event

inkamusic.midiutil.note_on_event(current_track, tick, channel, pitch, velocity)

appends a note on event

inkamusic.midiutil.program_change_event(current_track, channel, data)

appends a program change of track event

inkamusic.midiutil.set_tempo_event(current_track, bpm)

appends a tempo event

inkamusic.midiutil.sys_ex_message_gm2(current_track)

appends a sys_ex message

inkamusic.midiutil.time_signature_event(current_track, numerator, denominator)

appends a time signature event

inkamusic.midiutil.write_file_header(midifile, pattern)

writes the file header

inkamusic.midiutil.write_midifile(midifile, pattern)

writes the midi file

inkamusic.midiutil.write_track(midifile, track)

writes the track into the midi file

inkamusic.midiutil.write_varlen(value)

converts value to variable length structure

inkamusic.music_parameter module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains all music generation parameter

inkamusic.rhythm_algorithms module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains the rhythm algorithmic functions

inkamusic.rhythm_algorithms.calc_rhythm_speed(track_rhythm, beats_per_minute)

calculates the number of tones played in 1 second, averaged over 1 bar

inkamusic.rhythm_algorithms.check_max_tones_per_s(track_rhythm, max_tones_per_s, bpm)

checks if rhythm is too fast for instrument const.TICKSRES is the number of MIDI units for one beat bpm is number of beats per minute => time for 1 beat = 60s / bpm => time for 1 MIDI unit = 60s / (bpm * const.TICKSRES) =: midi_unit_in_sec rhythm positions are defined in MIDI units

inkamusic.rhythm_algorithms.check_rhythm(selected_rhythm, combined_rhythm)

checks if selected rhythm is compatible with combined_rhythm

inkamusic.rhythm_algorithms.conn_type(pat_entry, comp_data)

returns connection type of a pat entry

inkamusic.rhythm_algorithms.correct_tones_per_sec(track_rhythm, track_info, bpm, rndm_2)

removes tones from rhythm until max and average number of tones per sec criterion is met

inkamusic.rhythm_algorithms.create_combined_rhythm(selected_rhythm)

combines all parts of the selected rhythm This will be the starting point for further subdivisions

inkamusic.rhythm_algorithms.create_global_rhythm(selected_rhythm, num_of_beats, min_split_length, rnd_type)

creates the main rhythm for the composition

inkamusic.rhythm_algorithms.create_part_rhythm(c_strct, comp_data, comp_data_2, bar_distribution)

creates the rhythmic components of a part, i. e. position, length and intensity of tones. The tone height will be generated in function create_part_melody

inkamusic.rhythm_algorithms.create_track_rhythm(track_info, global_rhythm, bpm, selected_speed, rndm_2)

creates individual rhythms for each track, based on global rhythm

inkamusic.rhythm_algorithms.do_track_rhythm(rule, beat_in_current_bar, current_bar_num, comp_data, comp_data_2)

create new rhythm based on variation track rhythm or original track rhythm

inkamusic.rhythm_algorithms.exists_pos(pos, rhythm)

checks if position is used in rhythm

inkamusic.rhythm_algorithms.first_bar_rhythm(beat_in_current_bar, current_bar_num, comp_data, comp_data_2)

create new rhythm starting with upbeat

inkamusic.rhythm_algorithms.get_intensity_dependency_val(track_info, rndm_2)

choose intensity_dependency_val for specific instrument type low (lowest = 1) intensity_dependency_val => position to remove is less dependent on intensity/accent high (for example 50) intensity_dependency_val => position to remove is more dependent on intensity/accent (with low intensity removed first)

inkamusic.rhythm_algorithms.get_rhythm_from_bars_and_beats(beat_indx, start_from_bar, comp_data_2)

start_from_bar is the global bar number (1 = first bar of composition) beat_indx is counted from there. All rhythm positions are relative to first bar entry in which they appear, so they need to be shifted

inkamusic.rhythm_algorithms.last_bar_rhythm(beat_in_current_bar, current_bar_num, comp_data, comp_data_2)

create new rhythm up to first accent of track_rhythm find first rhythm position which has equal or lower acc than previous position. Delete all positions starting with this position

inkamusic.rhythm_algorithms.loop_beats(rhythm_rule, rpt, bar_distribution, comp_data, c_2)

loops over all beats of current part

inkamusic.rhythm_algorithms.max_acc_of_pos(position, selected_rhythm)

finds max intensity of a position over all rhythm parts

inkamusic.rhythm_algorithms.pos_in_beat(pat_entry, beat)

checks if a given position is within a specific beat

inkamusic.rhythm_algorithms.prepare_solo_rhythm(bridge_part, comp_data, comp_data_2)

prepares special rhythm variations used for solo instruments currently these are solo normal, solo intro, solo ending, solo double

inkamusic.rhythm_algorithms.remove_one(track_rhythm, intensity_dependency_val, crit_time_diff, rndm_2)

removes one position from rhythm, with probability depending on intensity

inkamusic.rhythm_algorithms.rhythm2double(rhythm, rndm_2)

duplicates rhythm of first beat randomly to other beats

inkamusic.rhythm_algorithms.rhythm2end(rhythm, rndm_2)

ends rhythm at random position under the condition that there don’t exist stronger intensities after that position

inkamusic.rhythm_algorithms.rhythm2intro(rhythm, rndm_2)

starts rhythm at random position under the condition that there exist stronger intensities before that position

inkamusic.rhythm_algorithms.rhythm_generator(beat_indx, rhythm_rule, comp_data, comp_data_2, bar_distribution)

generates the rhythm for a beat

inkamusic.rhythm_algorithms.set_connection_types(track_info, track_rhythm, actual_num_of_tones, rndm_2)

sets the connection type of a created rhythm

inkamusic.rhythm_algorithms.set_selected_solo_rhythm(c_2, current_bar_num)

sets solo rhythm type depending on bar number and number of bars in current part

inkamusic.rhythm_algorithms.shift_to_bar(pat_entry, bar_num, comp_data_2)

shifts a pat entry to another bar

inkamusic.rhythm_algorithms.strip_blocked(selected_rhythm)

removes BLOCK_ACC entries from selected rhythm, after global rhythm has been created

inkamusic.rhythm_algorithms.subdivide_rhythm(combined_rhythm, rnd_type, min_split_length)

subdivides rhythm into next level min_split_length is the minimum length which must remain AFTER a subdivision see menu_entries.SPEED_LIST for an example

inkamusic.settings module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file defines all settings used to create a musical piece

class inkamusic.settings.Settings

Bases: object

This class defines all possible settings and menu entries

get_bridge_length()

returns the bridge_length length in bars

get_corrected_bpm(beats, length_in_seconds)

Adjust self.comp_data[‘bpm’] slightly to ensure that the number of bars is exactly a multiple of num_of_bars_multiple AND the playing time is exactly as selected in the web interface.

get_intro_ending_length()

returns the intro_ending length in bars

get_num_of_beats()

returns num of beats per bar for selected rhythm

get_rhythm_connect_tuple(rndm_2)

returns a random tuple from rhythm connect probability list depending on staccato_flag

get_selected_bpm()

returns current bpm value

get_selected_instrumentation()

returns id list of selected instrumentation

get_selected_length()

returns selected length in seconds

get_selected_percussion()

returns percussion setting

get_selected_rhythm()

returns id of selected rhythm

get_selected_rhythm_bpm()

returns bpm range of selected rhythm

get_selected_rhythm_definition()

returns basic definition for selected rhythm

get_selected_scale()

returns the currently selected scale

get_selected_speed()

returns bpm limits of selected speed

get_smallest_part_length()

returns the smallest part length in bars

get_staccato_flag()

returns the staccato_flag

replace_wildcard_harmonies_in_scale(harmony_object, rndm_2)

replaces any wildcard harmony in scale definition

reset()

resets all settings

set_intro_ending_bridge_melody_length(rndm_2, num_of_bars)

sets length of melody, intro, ending and bridge parts

set_selected_bpm(rndm_2)

sets bpm based on speed setting

set_web_interface_selections(web_settings)

set all settings from web interface

inkamusic.settings.get_instrument_by_id(instru_id)

looks up instrument definition for given id

inkamusic.settings.get_instrument_by_name_and_property(name, instru_type, instru_type_2)

selects instrument with specific properties

inkamusic.settings.get_instrument_by_property(instru_type, instru_type_2, rndm_2)

selects instrument with specific properties randomly

inkamusic.settings.get_instrument_type(instru_id)

returns instrument type (T_BASS, T_CHOR, T_SOLO, T_HMNY, T_PERC)

inkamusic.settings.get_instrumentation(txt)

returns list of ids for specific instrumentation

inkamusic.settings.get_length_min(txt='')

returns minutes options

inkamusic.settings.get_length_sec(txt='')

returns seconds options

inkamusic.settings.get_pause_probability(instrument_type, instrument_type_2, rndm_2)

returns a random probability for the instrument type to pause for a full bar Used only for percussion instruments. melody instruments define pauses individually in instrumentation_list

inkamusic.settings.get_percussion(txt)

returns percussion setting

inkamusic.settings.get_percussion_list(txt='')

returns list of percussion options

inkamusic.settings.get_rhythm(txt)

returns id of specific basic rhythm

inkamusic.settings.get_rhythm_bpm(txt)

returns bpm range of specific basic rhythm

inkamusic.settings.get_rhythm_list()

returns list of all rhythms

inkamusic.settings.get_scale(txt)

returns scale definition

inkamusic.settings.get_scales_list()

returns list of scales

inkamusic.settings.get_speed(txt)

returns bpm limits for specific speed

inkamusic.settings.get_speed_list()

returns list of all speed options

inkamusic.startup module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2019 Udo Wollschläger

inkamusic.startup.start()

inkamusic.structures module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file defines all composition structures

class inkamusic.structures.CompositionStructure(**kwargs)

Bases: object

Creates the structure of the composition, i. e. parts, repetitions, intro, ending and bridges

adapt_parts(num_of_parts, sub, parent_level, parent_level_part_length)

After a structure has been selected, the part lengths are adapted to fit the overall number of bars in the upper level. This is not always possible, in which case another structure has to be used

change_absolute(num_of_parts, sub, parent_level, ratio)

changes length of one part by an absolute amount

change_intro_or_ending_length(intro, ending, actual_length, parent_level_part_length)

try first if changes in intro or ending length are sufficient to reach parent length

change_proportional(num_of_parts, sub, parent_level, ratio)

changes length of all parts (factor is 1 / ratio)

create_bar_group(comp_struct, part_id, rpt_from_bar)

creates a new bar group, see create_bar_structure for details

create_bar_structure(comp_struct, level)

This function serialises the hierarchical structure of the composition given by comp_struct. The resulting array self.bar_struct contains a start record for each group of bars ( bar_struct[i] = [BAR_GROUP, number of first bar in group, length of group]) and then the individual bars of the group (bar_struct[i + j] = [BAR_INFO, bar index within group, [BAR_REPEATED or BAR_NOT_REPEATED, number of first bar in group], original bar number, create_type]) A bar group is identified by its first bar number.

create_composition_structure()

creates recursively the structure of the composition, using catalog entries defined in module structures

The top level (= level 0) serves as anchor and contains the total number of bars, a property array (which is unused for the top level) and an array of sub level structures.

Example: top level (level 0): comp_struct = [num_of_bars, property array, sub level array]

Level 1 divides the composition into n parts using 6 different part types:

  • Standard parts, which will contain composed music. A standard part will have approximately the length given by melody_length. If it were longer it would have been subdivided further.
  • Intro, Bridge and Ending parts, which are specialised versions of a standard part
  • Repeat parts, which are repetitions of earlier parts. Note that a repetition may be shifted in height at a later stage.
  • Sub structure parts, which serve as anchor for 1 or more parts on the next level. On levels greater than 1 the parts types Intro, Ending and Bridge are not used.

Example (cont.):

first sub level (in this example containing 2 parts)
comp_struct[SUB_INDX][0] = [length of part 0, property array part 0, sub level array of part 0] comp_struct[SUB_INDX][1] = [length of part 1, property array part 1, sub level array of part 1]
second sub level (in this example 1 part below part 1 of sub level 1)
comp_struct[SUB_INDX][1][SUB_INDX][0] = [length of part 1, property array part 0,
sub level array of part 0]
create_sub_level(**level_data)

This function is called recursively to subdivide a part for the next level Note that the parameter “parent_level” contains the level which is subdivided by this function, so the created parts will belong to “parent_level + 1”

find_subdivision_structure(creating_level_one, max_num_of_subdivisions, level_data, cr_type)

find a possible subdivision

get_bar_info(use_type, bar_indx, num_of_first_bar, rpt_from_bar)

prepares information for the BAR_INFO data structure within the bar structure

get_original_bar_num(global_bar_num)

finds global number of original (i. e. created) bar of a repetition bar

iterate_over_parts(num_of_parts, level_data)

iterate over all parts to create sublevels

set_global_bar_numbers(composition_structure, bar_offset)

sets the global bar numbers starting with 1 for each part in the structure

set_part_structs(num_of_parts, sub, form_struct, creating_level_one)

sets the different types of parts and set the preliminary lengths based on the part types (normal part = smallest_part_length, for example)

set_preliminary_lengths(num_of_parts, sub)

sets initial length to parts, depending on part type

show_bar_struct()

shows bar_struct structure for debugging purposes

inkamusic.structures.change_non_repeated_part(num_of_parts, sub, chindx, delta, parent_level)

applies length change for part which is not a repetition

inkamusic.structures.change_repeated_part(num_of_parts, sub, rpt, delta)

applies length change for part which is a repetition

inkamusic.structures.get_minimum_length(strc, min_len, melody_length)

calculates minimum num of bars needed for struct

inkamusic.structures.get_random_struct(rndm_2, max_num_of_subdivisions)

returns randomly selected struct

inkamusic.structures.get_random_struct_top(rndm_2, max_num_of_subdivisions)

returns randomly selected struct

inkamusic.structures.get_random_struct_top_short(rndm_2, max_num_of_subdivisions)

returns randomly selected struct

inkamusic.structures.init_part_data_structure(num_of_parts, sub, parent_level, upper_level_start, upper_level_end)

initialise data structure for each part if the adaption is not possible, the structure will be deleted again.

inkamusic.trackinfo_util module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains trackinfo utility functions

inkamusic.trackinfo_util.add_percussion(rhythm_definition, track_info, rndm_2)

adds percussion tracks when selected in web interface

inkamusic.trackinfo_util.create_random_instrumentation(rnd_type, rndm_2)

creates a random instrumentation

inkamusic.trackinfo_util.get_instrument_midi(track)

returns [8, 28], …

inkamusic.trackinfo_util.get_instrument_type(track)

returns const.T_SOLO, const.T_BASS, const.T_HMNY, const.T_CHOR, const.T_PERC

inkamusic.trackinfo_util.get_instrument_type_2(track)

returns ‘Bass’, ‘Low’, ‘Medium’, ‘High’, ‘Full’, ‘Stick’, ‘Accent’, ‘Bass’, ‘High’, ‘Low’, ‘Ride’, ‘Snare’

inkamusic.trackinfo_util.get_max_tones_per_sec(track)

returns max tones per second for a track based on instrument

inkamusic.trackinfo_util.get_track_connect_info(track)

returns connection type of track (LEGATO, …)

inkamusic.trackinfo_util.get_track_instrument_range(track)

returns lowest and highest tone possible for instrument (within the current register)

inkamusic.trackinfo_util.get_track_pause(track)

returns pause setting for track, only used for melody instruments (set in prepare_track_info) for percussion instruments get_pause_probability is used

inkamusic.trackinfo_util.get_track_rhythm(track)

returns track rhythm

inkamusic.trackinfo_util.is_bass_instrument(track)

returns True if bass instrument

inkamusic.trackinfo_util.is_harmony_instrument(track)

returns True if harmony instrument (which creates chords instead of single tones

inkamusic.trackinfo_util.is_melody_instrument(track)

returns True if melody instrument

inkamusic.trackinfo_util.is_solo_instrument(track)

returns True if SOLO instrument

inkamusic.trackinfo_util.prepare_track_info(track_info, menu_options, rhythm_definition, rndm_2)

creates track info for each instrument used structure of track_info is as follows:

for each track:
track_info[track_no][TRACK_INFO_MELO_OR_PERC_INDX] = melody or percussion instrument track_info[track_no][TRACK_INFO_INSTRU_DEF_INDX] = instrument definition track_info[track_no][TRACK_INFO_RHYTHM_INDX] = track rhythm (track rhythm will be added here for percussion tracks and will be added later in create_track_rhythm for melody tracks) track_info[track_no][TRACK_INFO_CONNECT_INDX] = probability tuple for connection types
inkamusic.trackinfo_util.set_track_rhythm(track, tr_rhythm)

sets rhythm for track

inkamusic.trackinfo_util.show_track_info(track_info)

prints info about all tracks

inkamusic.utilities module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains utility functions

class inkamusic.utilities.Rndm(seed)

Bases: object

Implements standard random functions independently (i. e. with separate seed values) for the following parts:

Structure Scale Harmony Instrumentation Rhythm Melody

rndm_choice(seq, weights=None)

replaces standard choice function

rndm_gauss_limit(param)

replaces standard gauss function and allows to define upper and lower limits param is [mean, delta, lower, upper]

rndm_int(lower, upper)

replaces standard randint function

rndm_random()

replaces standard random function

rndm_uniform(lower, upper)

replaces standard uniform function

inkamusic.utilities.check_tone(tone_abs_height, instrument_type, target_tone, previous_tones, c_3)

evaluates a tone

inkamusic.utilities.get_cont_in_harmony_points(tone_abs_height, prev_tone, c_3)

checks whether tone continues within the current harmony (up or down)

inkamusic.utilities.get_cont_in_scale_points(tone_abs_height, prev_tone, c_3)

checks whether tone continues within the scale (up or down)

inkamusic.utilities.get_distance_points(tone_abs_height, instrument_type, c_3)

calculates the harmonic distances of a tone against the already used tones and against the current harmony

inkamusic.utilities.get_jump_points(tone_abs_height, prev_tone)

calculates the jump height between tone and previous tone

inkamusic.utilities.get_second_last_tone_diff(tone_abs_height, previous_tones)

calculates the difference to the second last tone

inkamusic.utilities.get_up_down_equal_characteristics(rndm_local)

selects up, down or equal and tone group length

inkamusic.utilities.get_up_down_equal_points(tone_abs_height, prev_tone, c_3)

checks if up, down or equal setting is met

inkamusic.utilities.show_composition_structure(comp_struct, level)

prints composition structure for debugging purposes

inkamusic.utilities.sin_special(x_val)

this function differs from sine in that it generates more values in the range around 0 instead of extreme values near +1 and -1.

inkamusic.webutilities module

Inka Algorithmic Music Creates fully arranged algorithmic instrumental music. Copyright (C) 2018 Udo Wollschläger

This file contains webutility functions

class inkamusic.webutilities.InkaAlgorithmicMusicWebInterface

Bases: object

This is the Inka_Algorithmic_Music web interface class which generates and handles the web interface.

generate(**kwargs)

This function uses the web page settings to generate a composition

index()

This function generates the default web page used as user interface to Inka Algorithmic Music

inkamusic.webutilities.check_instrumentation_ids(instrumentation)

checks instrumentation settings

inkamusic.webutilities.create_filename()

generates file name for midid file

inkamusic.webutilities.create_rndm_classes(seed_val, instru_id_val)

creates independant random classes for different parts of the composition process

inkamusic.webutilities.get_instru_id_html()

creates instrumentation ID (seed) value html code

inkamusic.webutilities.get_menu_html()

generates web interface html code

inkamusic.webutilities.get_random_seed()

gets new seed value

inkamusic.webutilities.get_seed_html()

creates seed value html code

inkamusic.webutilities.html_select(legend, title, option_list, sel_element)

generates html code for select element

inkamusic.webutilities.html_select_length_min(legend, title, option_list, sel_element)

generates html code for minute/second select element

inkamusic.webutilities.html_select_length_sec(title, option_list, sel_element)

generates html code for minute/second select element

inkamusic.webutilities.nonbreak(original_string)

replaces spaces by non breaking spaces

Module contents

Top-level package for Inka Algorithmic Music.