musical_games package

Submodules

musical_games.base module

class musical_games.base.Bar(lilypond_code, alternatives=None)[source]

Bases: object

Single bar for a single instrument / hand.

Parameters:
  • lilypond_code (str) – the lilypond code for this single bar
  • alternatives (list of Bar) – list of alternative bars (used for repeats, like in part 1, repeat, part 2).
class musical_games.base.KeySignature(note, major_minor)[source]

Bases: object

The key signature for a single tract.

Parameters:
  • note (str) – the base note of this key, for example ‘g’
  • major_minor (str) – either ‘major’ or ‘minor’
class musical_games.base.MidiOptions(instrument=None, min_volume=None, max_volume=None)[source]

Bases: object

Container for the midi options

Parameters:
  • instrument (str) – the lilypond midi instrument type
  • min_volume (float) – the minimum volume of a staff
  • max_volume (float) – the maximum volume of a staff
class musical_games.base.TempoIndication(beat_value, mm_tempo)[source]

Bases: object

The time signature for a single tract.

Parameters:
  • beat_value (int) – the beat that we indicate the tempo for. Example: (2, 4, 8, ...)
  • mm_tempo (int) – the Metzels Metronome value (for example: 120)
class musical_games.base.TimeSignature(nmr_beats, beat_value)[source]

Bases: object

The time signature for a single tract.

Parameters:
  • nmr_beats (int) – the number of beats in one measure
  • beat_value (int) – the note value which is to be given one beat

musical_games.shell_utils module

musical_games.shell_utils.get_argparse_extension_checker(choices)[source]

musical_games.utils module

class musical_games.utils.ConvertLilypondResults(typeset_results, concatenated_png, wav_list, mp3_list, ogg_list)[source]

Bases: object

The output object from converting a lilypond file to the most common outputs.

Parameters:
  • typeset_results (TypesetResults) – the original typeset results
  • concatenated_png (str) – the location of the concatenated png file
  • wav_list (list of str) – the location of the wav files
  • mp3_list (list of str) – the location of the mp3 files
  • ogg_list (list of str) – the location of the ogg files
midi_list
pdf_list
png_list
ps_list
class musical_games.utils.PNGConcatenation[source]

Bases: object

concatenate(png_list, output_fname)[source]

Concatenate the images.

This will do some minor preprocessing to the output images. It will trim the whitespace and remove the page numbers from the pngs.

Parameters:
  • png_list (list of str) – the list of pngs to concatenate
  • output_fname (str) – the name of the output file
musical_games.utils.auto_convert_lilypond_file(lilypond_filename, sound_font=None, output_prefix=None, pdf=True, png=True, ps=False, mp3=True, ogg=True, png_concatenation=None, midi_gain=None)[source]

Converts a lilypond file to pdf, png, midi, wav, mp3 and ogg.

The idea is that given a lilypond file you want to have some standard output. This wrapper function will give you the common output files.

Parameters:
  • lilypond_filename (str) – the lilypond file name
  • sound_font (str) – the path to the soundfont to use. If not given we will not convert to wav, mp3 and ogg.
  • output_prefix (str) – path + file prefix. If None we use the dir and basename of the lilypond file.
  • pdf (str) – if we want pdf output
  • png (boolean) – if we want png output
  • ps (boolean) – if we want postscript output
  • mp3 (boolean) – if we want mp3 output, only applicable if the lilypond has midi output defined
  • ogg (boolean) – if we want ogg output, only applicable if the lilypond has midi output defined
  • png_concatenation (PNGConcatenation) – the concatenation routine to use for concatenating the PNGs
  • midi_gain (float) – the gain for use during the midi to wav conversion
Returns:

information about the file names that were outputted

Return type:

LilypondConvertOutput

musical_games.utils.correct_indent(string, nmr_spaces)[source]

Dedents the string first, then indents by the given number of spaces.

Parameters:
  • string (str) – the string to correct the indentation
  • nmr_spaces (int) – the number of spaces to indent by.
Returns:

the same string with the indent set to the nmr of spaces given.

Return type:

string

musical_games.utils.write_lilypond_book(filename, lilypond_book)[source]

Write the given lilypond string to the given file.

Parameters:
  • filename (str) – the full path and name of the file to write
  • lilypond_book (LilypondBook) – the book with the lilypond content.

Module contents