rosabeats 0.1.3__py3-none-any.whl
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.
- docs/beatrecipe_docs.txt +80 -0
- rosabeats/__init__.py +23 -0
- rosabeats/beatrecipe_processor.py +523 -0
- rosabeats/beatswitch.py +256 -0
- rosabeats/rosabeats.py +996 -0
- rosabeats/rosabeats_shell.py +387 -0
- rosabeats/segment_song.py +181 -0
- rosabeats-0.1.3.dist-info/METADATA +158 -0
- rosabeats-0.1.3.dist-info/RECORD +16 -0
- rosabeats-0.1.3.dist-info/WHEEL +5 -0
- rosabeats-0.1.3.dist-info/entry_points.txt +5 -0
- rosabeats-0.1.3.dist-info/licenses/LICENSE.md +7 -0
- rosabeats-0.1.3.dist-info/top_level.txt +3 -0
- scripts/reverse_beats_in_bars_rosa.py +48 -0
- scripts/shuffle_bars_rosa.py +35 -0
- scripts/shuffle_beats_rosa.py +29 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rosabeats
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Audio beat detection, segmentation, and remixing library using librosa
|
|
5
|
+
Author: John Fleming
|
|
6
|
+
License-Expression: ISC
|
|
7
|
+
Project-URL: Homepage, https://github.com/jbff/rosabeats
|
|
8
|
+
Project-URL: Repository, https://github.com/jbff/rosabeats
|
|
9
|
+
Keywords: audio,beat,detection,segmentation,remixing,librosa,music
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
|
|
18
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Conversion
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE.md
|
|
22
|
+
Requires-Dist: librosa<1.0,>=0.11.0
|
|
23
|
+
Requires-Dist: soundfile<1.0,>=0.13.0
|
|
24
|
+
Requires-Dist: sounddevice<1.0,>=0.5.0
|
|
25
|
+
Requires-Dist: numpy<3.0,>=2.0
|
|
26
|
+
Requires-Dist: scipy<2.0,>=1.15
|
|
27
|
+
Requires-Dist: scikit-learn<2.0,>=1.5
|
|
28
|
+
Provides-Extra: ffms2
|
|
29
|
+
Requires-Dist: ffms2; extra == "ffms2"
|
|
30
|
+
Provides-Extra: vamp
|
|
31
|
+
Requires-Dist: vamp; extra == "vamp"
|
|
32
|
+
Provides-Extra: all
|
|
33
|
+
Requires-Dist: ffms2; extra == "all"
|
|
34
|
+
Requires-Dist: vamp; extra == "all"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# rosabeats
|
|
38
|
+
|
|
39
|
+
This repository contains the rosabeats Python library that allows for audio beat detection, segmentation, and remixing. It leverages the power of librosa and other audio processing libraries to enable precise beat tracking, song segmentation, and creative audio manipulation. This repository contains the core library code and various tools including scripts to segment songs, create and play/save beat "recipes", and a command line interpreter for interactive beat manipulation.
|
|
40
|
+
|
|
41
|
+
I wrote this because for some reason I was too dense to figure out how to use [Amen](https://github.com/algorithmic-music-exploration/amen) to replicate in Python something like the Infinite Jukebox. That was the initial impetus, anyway. This code is not elegant. If I was too dense to figure out how to use amen, even with the code and examples in front of me, you can bet that I did not write elegant code. But it does work and I have enjoyed playing with it.
|
|
42
|
+
|
|
43
|
+
A short mp3 that is in the public domain is included and an example beat recipe that references it. The track used for this example was obtained from [Free Music Archive](https://freemusicarchive.org/music/play-house/single/random-drop/) - "Random Drop" by Play House - and is distributed under the Creative Commons Public Domain License (CC0), which allows for unrestricted use, modification, and distribution without any copyright restrictions. Many thanks to the creator.
|
|
44
|
+
|
|
45
|
+
I wrote most of this code in 2018-2019 and made some additions through 2021. I created this public repo to hold the most useful bits on April 12, 2025. I intend to improve the code. It almost certainly contains bugs that I don't ever hit. It was cobbled together a feature at a time and thus, looks and probably acts that way.
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- **Beat Detection**: Automatically detect beats and tempo in audio files
|
|
50
|
+
- **Bar Analysis**: Group beats into bars with configurable beats-per-bar
|
|
51
|
+
- **Audio Segmentation**: Segment songs into structural parts using:
|
|
52
|
+
- Laplacian segmentation (powered by librosa)
|
|
53
|
+
- Segmentino (using Vamp plugins)
|
|
54
|
+
- **Audio Remixing**: Create remixes by manipulating beats and bars:
|
|
55
|
+
- Play individual beats or ranges of beats
|
|
56
|
+
- Play entire bars or ranges of bars
|
|
57
|
+
- Shuffle beats or bars randomly
|
|
58
|
+
- Reverse the order of beats within bars
|
|
59
|
+
- Create precise rests with beat-accurate timing
|
|
60
|
+
- **Beat Recipe Files**: Save and load beat patterns as reusable recipes
|
|
61
|
+
- **Interactive Shell**: Command-line interface for experimenting with beat patterns
|
|
62
|
+
- **Segment Analysis**: Identify structurally similar sections in songs
|
|
63
|
+
- **Output Options**: Play remixes in real-time, save to files, or generate beat recipes
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
### Prerequisites
|
|
68
|
+
|
|
69
|
+
- Python 3.9+ (Tested most recently with Python 3.11.12 and 3.13.2)
|
|
70
|
+
- ffms2 libraries (On Fedora: `dnf install ffms2`; tested most recently with ffms-5.0)
|
|
71
|
+
|
|
72
|
+
### Installing from PyPI
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Basic install
|
|
76
|
+
pip install rosabeats
|
|
77
|
+
|
|
78
|
+
# With optional dependencies
|
|
79
|
+
pip install rosabeats[all]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or with [uv](https://docs.astral.sh/uv/):
|
|
83
|
+
```bash
|
|
84
|
+
uv pip install rosabeats
|
|
85
|
+
uv pip install rosabeats[all]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Installing from Source
|
|
89
|
+
|
|
90
|
+
1. Clone the repository:
|
|
91
|
+
```bash
|
|
92
|
+
git clone https://github.com/jbff/rosabeats.git
|
|
93
|
+
cd rosabeats
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
2. Install the package:
|
|
97
|
+
```bash
|
|
98
|
+
pip install .
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Or for development (editable install):
|
|
102
|
+
```bash
|
|
103
|
+
pip install -e .
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
3. Installing optional dependencies:
|
|
107
|
+
|
|
108
|
+
rosabeats has optional dependencies that can be installed based on your needs:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Install with Vamp plugin support
|
|
112
|
+
pip install .[vamp]
|
|
113
|
+
|
|
114
|
+
# Install with ffms2 support for additional audio formats
|
|
115
|
+
pip install .[ffms2]
|
|
116
|
+
|
|
117
|
+
# Install with all optional dependencies
|
|
118
|
+
pip install .[all]
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This will install the package and its dependencies, and make the following command-line tools available:
|
|
122
|
+
- `beatrecipe-processor`: Process beat recipes
|
|
123
|
+
- `segment-song`: Segment songs using librosa's Laplacian segmentation
|
|
124
|
+
- `beatswitch`: Generate beat recipes with alternating patterns
|
|
125
|
+
- `rosabeats-shell`: Interactive shell for beat manipulation
|
|
126
|
+
|
|
127
|
+
### Optional: Vamp Plugins for Segmentino
|
|
128
|
+
|
|
129
|
+
If you want to use the Segmentino-based segmentation:
|
|
130
|
+
|
|
131
|
+
1. Download and install the Vamp plugin SDK
|
|
132
|
+
2. Install the Segmentino plugin
|
|
133
|
+
|
|
134
|
+
### Using rosabeats
|
|
135
|
+
|
|
136
|
+
The package can be imported in Python as:
|
|
137
|
+
```python
|
|
138
|
+
import rosabeats
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Documentation for beat recipes can be found in the `docs/` directory of the package. The main tools (`beatrecipe_processor.py` and `segment_song.py`) have been tested and are functional. Additional scripts in the `scripts/` directory may be of interest but have not been recently tested.
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
## ISC License
|
|
146
|
+
|
|
147
|
+
Copyright © 2025 [John Fleming](https://github.com/jbff)
|
|
148
|
+
|
|
149
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
150
|
+
|
|
151
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
152
|
+
|
|
153
|
+
## Acknowledgments
|
|
154
|
+
|
|
155
|
+
- [librosa](https://librosa.org/) for audio analysis
|
|
156
|
+
- [Vamp plugins](https://www.vamp-plugins.org/) for audio segmentation
|
|
157
|
+
- [Amen](https://github.com/algorithmic-music-exploration/amen) was the original inspiration
|
|
158
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
docs/beatrecipe_docs.txt,sha256=2WOPDt_8Av27vKV5Sq2yYK0PhByJH4nU6JS6rnlD4PM,3355
|
|
2
|
+
rosabeats/__init__.py,sha256=egpPGyTlEcFz8g4Fxlmzx3R2ntFXoVUc0ttzFOyPOFs,841
|
|
3
|
+
rosabeats/beatrecipe_processor.py,sha256=fAMJugNVfYvEza2U3C4s488d9KT4LejvglAlBBTBjJk,16230
|
|
4
|
+
rosabeats/beatswitch.py,sha256=VOO00lHM8TYrPHBL-a0SkJ5jvFtSUq6LpyID3WhZfZ8,8483
|
|
5
|
+
rosabeats/rosabeats.py,sha256=BHYD01biiw3z-vtoGGs9gK-ZURk9velt6Or0_-Qom1c,36264
|
|
6
|
+
rosabeats/rosabeats_shell.py,sha256=Giq1sdHw96TOK86ze5QUfnOuyKsFzddfWP5fTztJt4w,10718
|
|
7
|
+
rosabeats/segment_song.py,sha256=VJ4poSXVfXZGFLkn8HP92M3bCjk-wMxeumBwAh2svec,6703
|
|
8
|
+
rosabeats-0.1.3.dist-info/licenses/LICENSE.md,sha256=aPJeloE50MoONg47hPe8CtvglnNcGO3tsS-S5os4WiA,771
|
|
9
|
+
scripts/reverse_beats_in_bars_rosa.py,sha256=g1fRRTTko7BrDnmGQOhIq_rMsVYQznUwgTolRSXFDpI,1167
|
|
10
|
+
scripts/shuffle_bars_rosa.py,sha256=m3zLkQ8A0tgApeVUni6calh6xwHLwzJlkG_qdbyJ3bU,799
|
|
11
|
+
scripts/shuffle_beats_rosa.py,sha256=USaHpWgv7B8rQKVAOXqoia91FLBYyn1N03dIQOcpyBM,683
|
|
12
|
+
rosabeats-0.1.3.dist-info/METADATA,sha256=L8ztM95XsgvMYKD5Ae-Zevize47RmoHpmkzQzDMIe5U,6987
|
|
13
|
+
rosabeats-0.1.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
14
|
+
rosabeats-0.1.3.dist-info/entry_points.txt,sha256=4psFMIAY5kogJyT8RMdFeTpAnRHmZpaFPnlwI3tntuk,208
|
|
15
|
+
rosabeats-0.1.3.dist-info/top_level.txt,sha256=XbOrAF6RZpVfzXdkX9tFRtJFB3RUGXodl7RzoYIfz7A,23
|
|
16
|
+
rosabeats-0.1.3.dist-info/RECORD,,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# ISC License
|
|
2
|
+
|
|
3
|
+
Copyright © 2025 [John Fleming](https://github.com/jbff)
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# shuffle bars in a song with rosabeats
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from rosabeats import rosabeats
|
|
7
|
+
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
try:
|
|
10
|
+
infile = str(sys.argv[1])
|
|
11
|
+
except:
|
|
12
|
+
print("must specify input and output file", flush=True)
|
|
13
|
+
sys.exit(1)
|
|
14
|
+
try:
|
|
15
|
+
outfile = str(sys.argv[2])
|
|
16
|
+
except:
|
|
17
|
+
print("must specify input and output file", flush=True)
|
|
18
|
+
sys.exit(1)
|
|
19
|
+
try:
|
|
20
|
+
first_bar = int(sys.argv[3])
|
|
21
|
+
except:
|
|
22
|
+
first_bar = 0
|
|
23
|
+
try:
|
|
24
|
+
beats_per = int(sys.argv[4])
|
|
25
|
+
except:
|
|
26
|
+
beats_per = 8
|
|
27
|
+
|
|
28
|
+
song = rosabeats(infile, debug=True)
|
|
29
|
+
song.divide_bars()
|
|
30
|
+
song.track_beats()
|
|
31
|
+
|
|
32
|
+
bar_count = int(song.total_beats / beats_per)
|
|
33
|
+
|
|
34
|
+
barlist = [x for x in range(bar_count + 1)]
|
|
35
|
+
|
|
36
|
+
song.enable_output_play()
|
|
37
|
+
song.setup_playback()
|
|
38
|
+
|
|
39
|
+
song.enable_output_save(outfile)
|
|
40
|
+
song.reset_remix()
|
|
41
|
+
|
|
42
|
+
song.play_beats([x for x in range(first_bar)])
|
|
43
|
+
for count, bar in enumerate(barlist):
|
|
44
|
+
first_b = (count * 8) + first_bar
|
|
45
|
+
beatlist = [x for x in range(first_b, first_b + beats_per)]
|
|
46
|
+
beatlist.reverse()
|
|
47
|
+
song.play_beats(beatlist)
|
|
48
|
+
song.save_remix()
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# shuffle bars in a song with rosabeats
|
|
3
|
+
|
|
4
|
+
import sys, random
|
|
5
|
+
from rosabeats import rosabeats
|
|
6
|
+
|
|
7
|
+
if __name__ == "__main__":
|
|
8
|
+
if len(sys.argv) < 2:
|
|
9
|
+
print("require one argument that is a file containing music", flush=True)
|
|
10
|
+
sys.exit(1)
|
|
11
|
+
|
|
12
|
+
infile = sys.argv[1]
|
|
13
|
+
outfile = infile[0:-4] + "_barshuf.wav"
|
|
14
|
+
|
|
15
|
+
song = rosabeats(infile, debug=True)
|
|
16
|
+
song.divide_bars(8, 2)
|
|
17
|
+
song.track_beats()
|
|
18
|
+
|
|
19
|
+
bar_count = int(song.total_beats / 8)
|
|
20
|
+
|
|
21
|
+
barlist = [x for x in range(1, bar_count)]
|
|
22
|
+
|
|
23
|
+
random.shuffle(barlist)
|
|
24
|
+
|
|
25
|
+
song.enable_output_play()
|
|
26
|
+
song.setup_playback()
|
|
27
|
+
|
|
28
|
+
song.enable_output_save(outfile)
|
|
29
|
+
song.reset_remix()
|
|
30
|
+
|
|
31
|
+
song.play_beats([0, 1])
|
|
32
|
+
song.play_bar(0)
|
|
33
|
+
song.play_bars(barlist)
|
|
34
|
+
song.play_bar(bar_count)
|
|
35
|
+
song.save_remix()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# shuffle beats in a song with rosabeats
|
|
3
|
+
|
|
4
|
+
import sys, random
|
|
5
|
+
from rosabeats import rosabeats
|
|
6
|
+
|
|
7
|
+
if __name__ == "__main__":
|
|
8
|
+
if len(sys.argv) < 2:
|
|
9
|
+
print("require one argument that is a file containing music", flush=True)
|
|
10
|
+
sys.exit(1)
|
|
11
|
+
|
|
12
|
+
infile = sys.argv[1]
|
|
13
|
+
outfile = infile[0:-4] + "_shuf.wav"
|
|
14
|
+
|
|
15
|
+
song = rosabeats(infile, debug=True)
|
|
16
|
+
song.divide_bars(8, 2)
|
|
17
|
+
song.track_beats()
|
|
18
|
+
|
|
19
|
+
beatlist = [x for x in range(song.total_beats)]
|
|
20
|
+
random.shuffle(beatlist)
|
|
21
|
+
|
|
22
|
+
song.enable_output_play()
|
|
23
|
+
song.setup_playback()
|
|
24
|
+
|
|
25
|
+
song.enable_output_save(outfile)
|
|
26
|
+
song.reset_remix()
|
|
27
|
+
|
|
28
|
+
song.play_beats(beatlist)
|
|
29
|
+
song.save_remix()
|