Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove star-imports #19

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ pip install miditoolkit
## Example Usage

```python
import miditoolkit
path_midi = miditoolkit.midi.utils.example_midi_file()
midi_obj = miditoolkit.midi.parser.MidiFile(path_midi)
from miditoolkit import MidiFile
from miditoolkit.midi.utils import example_midi_file

path_midi = example_midi_file()
midi_obj = MidiFile(path_midi)

print(midi_obj)
```

"""
Output:

```
ticks per beat: 480
max tick: 72002
tempo changes: 68
Expand All @@ -67,8 +70,6 @@ key sig: 0
markers: 71
lyrics: False
instruments: 2

"""
```
A. [Parse and create MIDI files](examples/parse_and_create_MIDI_files.ipynb)
B. [Piano-roll Manipulation](examples/pinoroll_manipulation.ipynb)
Expand Down
33 changes: 30 additions & 3 deletions miditoolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,34 @@
Update date: 2020.06.23
"""

from .midi import *
akx marked this conversation as resolved.
Show resolved Hide resolved
from .pianoroll import *

__version__ = "1.0.1"

# Convenience exports for commonly used classes.

from miditoolkit.midi.parser import MidiFile
from miditoolkit.midi.containers import (
ControlChange,
Instrument,
KeySignature,
Lyric,
Marker,
Note,
Pedal,
PitchBend,
TempoChange,
TimeSignature,
)

__all__ = [
"ControlChange",
"Instrument",
"KeySignature",
"Lyric",
"Marker",
"MidiFile",
"Note",
"Pedal",
"PitchBend",
"TempoChange",
"TimeSignature",
]
5 changes: 0 additions & 5 deletions miditoolkit/midi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
from .containers import *
akx marked this conversation as resolved.
Show resolved Hide resolved
from .parser import *
akx marked this conversation as resolved.
Show resolved Hide resolved
from .utils import *

__all__ = [_ for _ in dir() if not _.startswith("_")]
11 changes: 7 additions & 4 deletions miditoolkit/pianoroll/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from .parser import *
from .utils import *
from .vis import *
from .parser import notes2pianoroll, pianoroll2notes

__all__ = [_ for _ in dir() if not _.startswith("_")]
# Convenience re-exports

__all__ = [
"notes2pianoroll",
"pianoroll2notes",
]
4 changes: 3 additions & 1 deletion tests/test_pianoroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

from pathlib import Path

from miditoolkit import MidiFile, notes2pianoroll, pianoroll2notes
from miditoolkit import MidiFile
from miditoolkit.constants import PITCH_RANGE
from tqdm import tqdm

from miditoolkit.pianoroll import notes2pianoroll, pianoroll2notes


def test_pianoroll():
midi_paths = list(Path("tests", "testcases").glob("**/*.mid"))
Expand Down