Skip to content

Commit

Permalink
Merge branch 'release/0.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
roszcz committed Aug 30, 2024
2 parents dfac3c6 + 0a61c0e commit d7a0a59
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.3.1] - 2024-08-28
### Added
- possible to write midi to a buffer

## [0.3.0] - 2024-08-28
### Changed
- remove pianofor.ai helper code
Expand Down
12 changes: 10 additions & 2 deletions fortepyan/midi/structures.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import json
import math
import pathlib
import functools
import collections
from heapq import merge
from warnings import showwarning
from dataclasses import field, dataclass

import six
import mido
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -926,6 +928,7 @@ def write(self, filename: str):
filename (str): Path to write .mid file to.
"""
# TODO argument has to also allow passing an io.Bytes so we can write in-memory

def event_compare(event1, event2):
"""
Expand Down Expand Up @@ -1112,8 +1115,13 @@ def event_compare(event1, event2):
event.time -= tick
tick += event.time

# Write it out to a file,
mid.save(filename=filename)
# Write it out
if isinstance(filename, six.string_types) or isinstance(filename, pathlib.PurePath):
# If a string or path was given, pass it as the filename
mid.save(filename=filename)
else:
# Otherwise, try passing it in as a file pointer
mid.save(file=filename)


def __repr__(self):
Expand Down

0 comments on commit d7a0a59

Please sign in to comment.