def write_Bar(file, bar, bpm = 120, repeat = 0):
	"""Writes a mingus.Bar to a midi file. Both the key and the \
meter are written to the file as well."""
	m = MidiFile()
	t = MidiTrack(bpm)
	m.tracks = [t]
	while repeat >= 0:
		t.play_Bar(bar)
		repeat -= 1
	return m.write_file(file)
def write_Track(file, track, bpm = 120, repeat = 0):
	"""Writes a mingus.Track to a midi file. Writes the name to \
the file and sets the instrument if the instrument has the attribute \
instrument_nr, which represents the MIDI instrument number. The class \
MidiInstrument in mingus.containers.Instrument has this attribute by \
default."""
	m = MidiFile()
	t = MidiTrack(bpm)
	m.tracks = [t]
	while repeat >= 0:
		t.play_Track(track)
		repeat -= 1
	return m.write_file(file)
def write_NoteContainer(file, notecontainer, bpm = 120, repeat = 0):
	"""Writes a mingus.NoteContainer to a midi file."""
	m = MidiFile()
	t = MidiTrack(bpm)
	m.tracks = [t]
	while repeat >= 0:
		t.set_deltatime("\x00")
		t.play_NoteContainer(notecontainer)
		t.set_deltatime("\x48")
		t.stop_NoteContainer(notecontainer)
		repeat -= 1
	return m.write_file(file)
Esempio n. 4
0
def write_Bar(
    file,
    bar,
    bpm=120,
    repeat=0,
    verbose=False,
):
    """Writes a mingus.Bar to a midi file. Both the key and the meter are written \
to the file as well."""

    m = MidiFile()
    t = MidiTrack(bpm)
    m.tracks = [t]
    while repeat >= 0:
        t.play_Bar(bar)
        repeat -= 1
    return m.write_file(file, verbose)
def write_Note(file, note, bpm = 120, repeat = 0):
	"""Expects a Note object from mingus.containers and \
saves it into a midi file, specified in file. You can set the \
velocity and channel in Note.velocity and Note.channel."""
	m = MidiFile()
	t = MidiTrack(bpm)
	m.tracks = [t]
	while repeat >= 0:
		t.set_deltatime("\x00")
		t.play_Note(note)
		t.set_deltatime("\x48")
		t.stop_Note(note)
		repeat -= 1
	return m.write_file(file)
Esempio n. 6
0
def write_Track(
    file,
    track,
    bpm=120,
    repeat=0,
    verbose=False,
):
    """Writes a mingus.Track to a midi file. Writes the name to the file and sets \
the instrument if the instrument has the attribute instrument_nr, which \
represents the MIDI instrument number. The class MidiInstrument in \
mingus.containers.Instrument has this attribute by default."""

    m = MidiFile()
    t = MidiTrack(bpm)
    m.tracks = [t]
    while repeat >= 0:
        t.play_Track(track)
        repeat -= 1
    return m.write_file(file, verbose)
Esempio n. 7
0
def write_NoteContainer(
    file,
    notecontainer,
    bpm=120,
    repeat=0,
    verbose=False,
):
    """Writes a mingus.NoteContainer to a midi file."""

    m = MidiFile()
    t = MidiTrack(bpm)
    m.tracks = [t]
    while repeat >= 0:
        t.set_deltatime('\x00')
        t.play_NoteContainer(notecontainer)
        t.set_deltatime("\x48")
        t.stop_NoteContainer(notecontainer)
        repeat -= 1
    return m.write_file(file, verbose)
Esempio n. 8
0
def write_Note(
    file,
    note,
    bpm=120,
    repeat=0,
    verbose=False,
):
    """Expects a Note object from mingus.containers and saves it into a midi file, \
specified in file. You can set the velocity and channel in Note.velocity and \
Note.channel."""

    m = MidiFile()
    t = MidiTrack(bpm)
    m.tracks = [t]
    while repeat >= 0:
        t.set_deltatime('\x00')
        t.play_Note(note)
        t.set_deltatime("\x48")
        t.stop_Note(note)
        repeat -= 1
    return m.write_file(file, verbose)
Esempio n. 9
0
def write_Composition(
    file,
    composition,
    bpm=120,
    repeat=0,
    verbose=False,
):
    """Writes a mingus.Composition to a midi file."""

    m = MidiFile()
    t = []
    for x in range(len(composition.tracks)):
        t += [MidiTrack(bpm)]
    m.tracks = t
    while repeat >= 0:
        for i in range(len(composition.tracks)):
            m.tracks[i].play_Track(composition.tracks[i])
        repeat -= 1
    return m.write_file(file, verbose)