sublibs package

Submodules

parts module

Miscellaneous Functions.

dB2gain(value)[ソース]

Convert dB-like value to gain.

パラメータ:

value (int) -- dB-like value

戻り値:

gain

戻り値の型:

float

gain2dB(value)[ソース]

Convert gain to dB-like value.

パラメータ:

value (float) -- gain

戻り値:

dB-like value

戻り値の型:

int

paramsmid module

Analyze MIDI files according to SMF (Standard MIDI File) format.

reference:

MIDI1.0規格書(日本語版98.1) ISBN4-8456-0348-9 C3055 http://www.amei.or.jp/

    1. MIDI 1.0

    1. スタンダードMIDIファイル1.0

Todo:

Compile automatically.

class StandardMidiFile

ベースクラス: object

StandardMidiFile analyzes SMF(Standard MIDI File).

パラメータ:

midifile (pathlib.Path) -- target SMF(Standard MIDI File)

channels_preset()

Get a list of preset numbers for each of the 16 channels.

戻り値:

list of prest numbers

instruments()

Get a list of instrument names for each of the 16 channels.

戻り値:

instruments

lyrics()

Get lyrics list.

戻り値:

lyrics

title()

Get Title.

戻り値:

title

total_tick()

Count ticks.

戻り値:

total ticks

csv2mid module

Generate a MID(Standard MIDI File) file from a CSV file.

Format of CSV file

<Format> = <Track Name>, <Bar Number>, <Tick Number>, <Event List>, <Value List>

  1. Track Name

    Track Name.

    • example: "Sequencer"

    • example: "Main Melody"

    • example: "Sub Melody"

  2. Bar Number

    Indicates the order of appearance of the measures.

    • example: 0

    • example: 1

  3. Tick Number

    Indicates the timing of event occurrence within a bar in terms of Tick conversion. However, the length of a quarter note is 480 ticks.

    • example: 0

    • example: 480

    • example: 960

  4. Event List

    Event.

    • example: "Meta Event","Set Tempo"

    • example: "Midi Event","Note On"

    • example: "Midi Event","Control Change","Channel Volume"

  5. Value List

    Event Value.

    • example: 500000

    • example: 0,69,0x40,200

    • example: 0,0x60

restrictions
  1. Only "GM System Level 1".

  2. Tempo changes and odd time signatures are not supported.

  3. The division is fixed at 480.

exception SmfError(*args)[ソース]

ベースクラス: Exception

Exceptions sent out from errcheck func.

パラメータ:

args (object) --

戻り値の型:

None

class AllNotesOff(track, bar='0', tick='0', n='0')[ソース]

ベースクラス: _ChannelMode

AllNoteOff is "all notes off message".

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

class ChannelPressure(track, bar='0', tick='0', n='0', vv='100')[ソース]

ベースクラス: _MidiEvent

ChannelPressure is ***.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

  • vv (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

n: str = '0'

channle

Type:

str

vv: str = '100'

threshold

Type:

int

class ChannelVolume(track, bar='0', tick='0', n='0', vv='0x70')[ソース]

ベースクラス: _ControlChange

ChannelVolume is "Channel Volume".

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

  • vv (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

vv: str = '0x70'

value

Type:

str

class CopyrightNotice(track, bar='0', tick='0', text='')[ソース]

ベースクラス: _MetaEvnet

CopyrightNotice is class.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • text (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

text: str = ''

Copyright Notice

Type:

str

class EndOfTrack(track, bar='0', tick='0')[ソース]

ベースクラス: _MetaEvnet

end of track

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

classmethod name()[ソース]
戻り値の型:

list[str]

track: str

"track" is a name that identifies a track.

Type:

str

class Expression(track, bar='0', tick='0', n='0', vv='0x70')[ソース]

ベースクラス: _ControlChange

Expresson is "Expression".

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

  • vv (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

vv: str = '0x70'

value

Type:

str

class GmSystemOn(track, bar='0', tick='0')[ソース]

ベースクラス: _SystemExclusiveEvent

GM System Level 1.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

classmethod name()[ソース]
戻り値の型:

list[str]

track: str

"track" is a name that identifies a track.

Type:

str

class HeaderChunk(format=1, ntrks=1, division=480)[ソース]

ベースクラス: object

HeaderChunk is a class that generates "Header chunks".

パラメータ:
  • format (int) --

  • ntrks (int) --

  • division (int) --

division: int = 480

"division" specifies the meaning of the delta-times. ticks per quarter-note.

Type:

int

format: int = 1

"format" specifies the overall organisation of the file.

Type:

int

ntrks: int = 1

"ntrks" is the number of track chunks in the file.

Type:

int

class InstrumentName(track, bar='0', tick='0', text='')[ソース]

ベースクラス: _MetaEvnet

InstrumentName is class.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • text (str) --

classmethod name()[ソース]
text: str = ''

Instrument Name

Type:

str

class KeySignature(track, bar='0', tick='0', sf='0', mi='0')[ソース]

ベースクラス: _MetaEvnet

KeySignature is expressed as four numbers.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • sf (str) --

  • mi (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

mi: str = '0'

0 is major, 1 is minor

Type:

str

sf: str = '0'

0 is C, +1 ~ +7 is #, -1 ~ -7 is b

Type:

str

class Lyric(track, bar='0', tick='0', text='')[ソース]

ベースクラス: _MetaEvnet

Lyric is class.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • text (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

text: str = ''

Lyric

Type:

str

class ModulationWheel(track, bar='0', tick='0', n='0', vv='0')[ソース]

ベースクラス: _ControlChange

ModulationWeel is "Modulation Wheel".

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

  • vv (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

vv: str = '0'

value

Type:

str

class NoteOffAfterOn(track, bar='0', tick='0', n='0', kk='60', vv='0x20')[ソース]

ベースクラス: _MidiEvent

NoteOffAfterOn is "Note off".

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

  • kk (str) --

  • vv (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

kk: str = '60'

key number

Type:

str

n: str = '0'

channel

Type:

str

vv: str = '0x20'

velocity

Type:

str

class NoteOn(track, bar='0', tick='0', n='0', kk='60', vv='0x40', dr='100')[ソース]

ベースクラス: _MidiEvent

NoteOn is "Note On".

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

  • kk (str) --

  • vv (str) --

  • dr (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

dr: str = '100'

duration

Type:

str

kk: str = '60'

key number

Type:

str

n: str = '0'

channel

Type:

str

vv: str = '0x40'

velocity

Type:

str

class Pan(track, bar='0', tick='0', n='0', vv='0x40')[ソース]

ベースクラス: _ControlChange

Pan is "Pan".

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

  • vv (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

vv: str = '0x40'

str:

class PitchWheelChange(track, bar='0', tick='0', n='0', ll='0', mm='0x40')[ソース]

ベースクラス: _MidiEvent

PitchWheelChange is ***.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

  • ll (str) --

  • mm (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

ll: str = '0'

LSB, centre(non-effect) is 0x00

Type:

str

mm: str = '0x40'

MSB, centre(non-effect) is 0x40

Type:

str

n: str = '0'

channel

Type:

str

class ProgramChange(track, bar='0', tick='0', n='0', vv='0')[ソース]

ベースクラス: _MidiEvent

ProgramChange is ***.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

  • vv (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

n: str = '0'

channle

Type:

str

vv: str = '0'

preset number

Type:

str

class ResetAllControllers(track, bar='0', tick='0', n='0')[ソース]

ベースクラス: _ChannelMode

ResetAllControllers is ***.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

class SequencerTrackName(track, bar='0', tick='0', text='')[ソース]

ベースクラス: _MetaEvnet

SequenceTrackName is class.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • text (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

text: str = ''

Sequencer / Track Name

Type:

str

class SetTempo(track, bar='0', tick='0', value='500000')[ソース]

ベースクラス: _MetaEvnet

Quarter note microsecond unit time.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • value (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

value: str = '500000'

Quarter note microsecond unit time

Type:

str

class SustainOff(track, bar='0', tick='0', n='0')[ソース]

ベースクラス: _ControlChange

SustaionOff is ***.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

class SustainOn(track, bar='0', tick='0', n='0')[ソース]

ベースクラス: _ControlChange

SustaionOn is ***.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • n (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

class TextEvent(track, bar='0', tick='0', text='')[ソース]

ベースクラス: _MetaEvnet

TextEvent is class.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • text (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

text: str = ''

text event

Type:

str

class TimeSignature(track, bar='0', tick='0', nn='4', dd='2', cc='24', bb='8')[ソース]

ベースクラス: _MetaEvnet

TimeSignature is expressed as four numbers.

パラメータ:
  • track (str) --

  • bar (dataclasses.InitVar[str]) --

  • tick (dataclasses.InitVar[str]) --

  • nn (str) --

  • dd (str) --

  • cc (str) --

  • bb (str) --

classmethod name()[ソース]
戻り値の型:

list[str]

bb: str = '8'

str:

cc: str = '24'

str:

dd: str = '2'

power to two, rhythm notevalue

Type:

str

nn: str = '4'

rhythm beat

Type:

str

event_classes()[ソース]

Return a set of event classes.

戻り値:

event classes

戻り値の型:

set

event_data(params)[ソース]

Convert CSV data list to event data object.

パラメータ:

params (list) -- csv data list

戻り値:

event data object

戻り値の型:

object

generate(csvfile, midifile)[ソース]

Generate a MID file from a CSV file.

パラメータ:
  • csvfile (str) -- CSV filename to be converted.

  • midifile (str) -- MID filename to be created.

戻り値の型:

None

Module contents

Packages of support modules

parts: Gain control for MIDI devices

csv2mid: Generate a MID(Standard MIDI File) file from a CSV file.

paramsmid: Parsing SMF(Standard MIDI File) files