REMI-z 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- remi_z-0.5.0/LICENSE +21 -0
- remi_z-0.5.0/PKG-INFO +31 -0
- remi_z-0.5.0/REMI_z.egg-info/PKG-INFO +31 -0
- remi_z-0.5.0/REMI_z.egg-info/SOURCES.txt +9 -0
- remi_z-0.5.0/REMI_z.egg-info/dependency_links.txt +1 -0
- remi_z-0.5.0/REMI_z.egg-info/requires.txt +4 -0
- remi_z-0.5.0/REMI_z.egg-info/top_level.txt +1 -0
- remi_z-0.5.0/setup.cfg +4 -0
- remi_z-0.5.0/setup.py +28 -0
- remi_z-0.5.0/tests/test_new.py +51 -0
- remi_z-0.5.0/tests/test_old_tokenizer.py +19 -0
remi_z-0.5.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Sonata165
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
remi_z-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: REMI-z
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Manipulate your MIDI file in bar level, and converting between MIDI and REMI-z format.
|
|
5
|
+
Home-page: https://github.com/Sonata165/REMI-z
|
|
6
|
+
Author: Longshen Ou
|
|
7
|
+
Author-email: oulongshen@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: MIDI
|
|
14
|
+
Requires-Python: >=3.7
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: miditoolkit==1.0.1
|
|
18
|
+
Requires-Dist: music21==9.3.0
|
|
19
|
+
Requires-Dist: pretty_midi==0.2.10
|
|
20
|
+
Requires-Dist: pyyaml==6.0.2
|
|
21
|
+
|
|
22
|
+
This is the official implementation of the REMI-z tokenizer in the paper [*Unlocking Potential in Pre-Trained Music Language Models for Versatile Multi-Track Music Arrangement*](https://arxiv.org/abs/2408.15176).
|
|
23
|
+
|
|
24
|
+
The core of this tokenizer is the Multitrack class as the data structure for multitrack music, which is a hierachical format. Here are the structural details:
|
|
25
|
+
- The music is represented by an Multitrack object, which is list of bars.
|
|
26
|
+
- Each Bar object represents all notes being played within one bar, is a list of Note object.
|
|
27
|
+
- Each Note object represent one note, including onset, offset, pitch, velocity information.
|
|
28
|
+
|
|
29
|
+
This Multitrack object can be create from various formats (supporting MIDI for now), and convert into various formats (e.g., MIDI, and REMI-z representation).
|
|
30
|
+
|
|
31
|
+
Music is a list of bars, or a list of instruments?
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: REMI-z
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Manipulate your MIDI file in bar level, and converting between MIDI and REMI-z format.
|
|
5
|
+
Home-page: https://github.com/Sonata165/REMI-z
|
|
6
|
+
Author: Longshen Ou
|
|
7
|
+
Author-email: oulongshen@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: MIDI
|
|
14
|
+
Requires-Python: >=3.7
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: miditoolkit==1.0.1
|
|
18
|
+
Requires-Dist: music21==9.3.0
|
|
19
|
+
Requires-Dist: pretty_midi==0.2.10
|
|
20
|
+
Requires-Dist: pyyaml==6.0.2
|
|
21
|
+
|
|
22
|
+
This is the official implementation of the REMI-z tokenizer in the paper [*Unlocking Potential in Pre-Trained Music Language Models for Versatile Multi-Track Music Arrangement*](https://arxiv.org/abs/2408.15176).
|
|
23
|
+
|
|
24
|
+
The core of this tokenizer is the Multitrack class as the data structure for multitrack music, which is a hierachical format. Here are the structural details:
|
|
25
|
+
- The music is represented by an Multitrack object, which is list of bars.
|
|
26
|
+
- Each Bar object represents all notes being played within one bar, is a list of Note object.
|
|
27
|
+
- Each Note object represent one note, including onset, offset, pitch, velocity information.
|
|
28
|
+
|
|
29
|
+
This Multitrack object can be create from various formats (supporting MIDI for now), and convert into various formats (e.g., MIDI, and REMI-z representation).
|
|
30
|
+
|
|
31
|
+
Music is a list of bars, or a list of instruments?
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
remi_z-0.5.0/setup.cfg
ADDED
remi_z-0.5.0/setup.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='REMI-z', # 项目名称
|
|
5
|
+
version='0.5.0', # 版本号
|
|
6
|
+
author='Longshen Ou', # 作者姓名
|
|
7
|
+
author_email='oulongshen@gmail.com', # 邮箱地址
|
|
8
|
+
description='Manipulate your MIDI file in bar level, and converting between MIDI and REMI-z format.',
|
|
9
|
+
long_description=open('README.md').read(), # 从 README.md 加载详细描述
|
|
10
|
+
long_description_content_type='text/markdown', # README 格式
|
|
11
|
+
url='https://github.com/Sonata165/REMI-z', # 项目主页 URL
|
|
12
|
+
packages=find_packages(), # 自动查找所有包含 `__init__.py` 的包
|
|
13
|
+
install_requires=[ # 项目的依赖项
|
|
14
|
+
'miditoolkit==1.0.1',
|
|
15
|
+
'music21==9.3.0',
|
|
16
|
+
'pretty_midi==0.2.10',
|
|
17
|
+
'pyyaml==6.0.2',
|
|
18
|
+
],
|
|
19
|
+
classifiers=[ # 分类器,描述项目的适用性
|
|
20
|
+
'Programming Language :: Python :: 3',
|
|
21
|
+
'License :: OSI Approved :: MIT License',
|
|
22
|
+
'Operating System :: OS Independent',
|
|
23
|
+
'Intended Audience :: Developers',
|
|
24
|
+
'Topic :: Multimedia :: Sound/Audio :: MIDI',
|
|
25
|
+
],
|
|
26
|
+
python_requires='>=3.7', # 支持的最低 Python 版本
|
|
27
|
+
license='MIT', # 项目许可证
|
|
28
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
dirof = os.path.dirname
|
|
4
|
+
sys.path.insert(0, dirof(dirof(__file__)))
|
|
5
|
+
|
|
6
|
+
from multitrack.core import MultiTrack
|
|
7
|
+
from multitrack.legacy_tokenizer import RemiTokenizer
|
|
8
|
+
|
|
9
|
+
def main():
|
|
10
|
+
test_key_norm()
|
|
11
|
+
|
|
12
|
+
def test_key_norm():
|
|
13
|
+
multitrack = MultiTrack.from_midi('/Users/sonata/Code/REMI-z/_misc/4bros.mid')
|
|
14
|
+
multitrack.normalize_pitch()
|
|
15
|
+
multitrack.to_midi('/Users/sonata/Code/REMI-z/_misc/4bros_norm.mid')
|
|
16
|
+
|
|
17
|
+
def test_decoding():
|
|
18
|
+
midi_fp = '/Users/sonata/Code/REMI-z/_misc/alaylm.mid'
|
|
19
|
+
multitrack = MultiTrack.from_midi(midi_fp)
|
|
20
|
+
multitrack.normalize_pitch()
|
|
21
|
+
multitrack.to_midi('/Users/sonata/Code/REMI-z/_misc/alaylm_norm.mid')
|
|
22
|
+
|
|
23
|
+
def result_comparison():
|
|
24
|
+
# Generate REMI-z for a MIDI file
|
|
25
|
+
multitrack = MultiTrack.from_midi('/Users/sonata/Code/REMI-z/_misc/butterfly_ours.mid')
|
|
26
|
+
remiz_seq = multitrack.to_remiz_seq(with_ts=True, with_tempo=True, key_norm=True)
|
|
27
|
+
multitrack.to_midi('/Users/sonata/Code/REMI-z/_misc/butterfly_ours_dec.mid')
|
|
28
|
+
multitrack[1:4]
|
|
29
|
+
|
|
30
|
+
# Generate by the legacy tokenizer (deprecated)
|
|
31
|
+
tokenizer = RemiTokenizer()
|
|
32
|
+
remi_old = tokenizer.midi_to_remi(
|
|
33
|
+
'/Users/sonata/Code/REMI-z/_misc/butterfly_ours.mid',
|
|
34
|
+
normalize_pitch=False,
|
|
35
|
+
reorder_by_inst=False,
|
|
36
|
+
include_ts=True,
|
|
37
|
+
include_tempo=True,
|
|
38
|
+
)
|
|
39
|
+
tokenizer.remi_to_midi(remi_old, '/Users/sonata/Code/REMI-z/_misc/butterfly_ours_old.mid')
|
|
40
|
+
|
|
41
|
+
same_cnt = 0
|
|
42
|
+
for i in range(len(remiz_seq)):
|
|
43
|
+
if remiz_seq[i] == remi_old[i]:
|
|
44
|
+
same_cnt += 1
|
|
45
|
+
percent = same_cnt / len(remiz_seq) * 100
|
|
46
|
+
print(f"Same count: {same_cnt}/{len(remiz_seq)}")
|
|
47
|
+
print(f"Same percent: {percent}%")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if __name__ == '__main__':
|
|
51
|
+
main()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from multitrack.legacy_tokenizer import RemiTokenizer
|
|
2
|
+
|
|
3
|
+
def test_old_tokenizer():
|
|
4
|
+
pass
|
|
5
|
+
|
|
6
|
+
import unittest
|
|
7
|
+
|
|
8
|
+
class TestCoreFunctions(unittest.TestCase):
|
|
9
|
+
|
|
10
|
+
def test_add(self):
|
|
11
|
+
tk = RemiTokenizer()
|
|
12
|
+
|
|
13
|
+
# Testing add function
|
|
14
|
+
self.assertEqual(add(2, 3), 5) # Expected result: 2 + 3 = 5
|
|
15
|
+
self.assertEqual(add(-1, 1), 0) # Expected result: -1 + 1 = 0
|
|
16
|
+
self.assertEqual(add(0, 0), 0) # Expected result: 0 + 0 = 0
|
|
17
|
+
|
|
18
|
+
if __name__ == '__main__':
|
|
19
|
+
unittest.main()
|