rosabeats 0.1.3__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.
@@ -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,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,122 @@
1
+ # rosabeats
2
+
3
+ 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.
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ 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.
10
+
11
+ ## Features
12
+
13
+ - **Beat Detection**: Automatically detect beats and tempo in audio files
14
+ - **Bar Analysis**: Group beats into bars with configurable beats-per-bar
15
+ - **Audio Segmentation**: Segment songs into structural parts using:
16
+ - Laplacian segmentation (powered by librosa)
17
+ - Segmentino (using Vamp plugins)
18
+ - **Audio Remixing**: Create remixes by manipulating beats and bars:
19
+ - Play individual beats or ranges of beats
20
+ - Play entire bars or ranges of bars
21
+ - Shuffle beats or bars randomly
22
+ - Reverse the order of beats within bars
23
+ - Create precise rests with beat-accurate timing
24
+ - **Beat Recipe Files**: Save and load beat patterns as reusable recipes
25
+ - **Interactive Shell**: Command-line interface for experimenting with beat patterns
26
+ - **Segment Analysis**: Identify structurally similar sections in songs
27
+ - **Output Options**: Play remixes in real-time, save to files, or generate beat recipes
28
+
29
+ ## Installation
30
+
31
+ ### Prerequisites
32
+
33
+ - Python 3.9+ (Tested most recently with Python 3.11.12 and 3.13.2)
34
+ - ffms2 libraries (On Fedora: `dnf install ffms2`; tested most recently with ffms-5.0)
35
+
36
+ ### Installing from PyPI
37
+
38
+ ```bash
39
+ # Basic install
40
+ pip install rosabeats
41
+
42
+ # With optional dependencies
43
+ pip install rosabeats[all]
44
+ ```
45
+
46
+ Or with [uv](https://docs.astral.sh/uv/):
47
+ ```bash
48
+ uv pip install rosabeats
49
+ uv pip install rosabeats[all]
50
+ ```
51
+
52
+ ### Installing from Source
53
+
54
+ 1. Clone the repository:
55
+ ```bash
56
+ git clone https://github.com/jbff/rosabeats.git
57
+ cd rosabeats
58
+ ```
59
+
60
+ 2. Install the package:
61
+ ```bash
62
+ pip install .
63
+ ```
64
+
65
+ Or for development (editable install):
66
+ ```bash
67
+ pip install -e .
68
+ ```
69
+
70
+ 3. Installing optional dependencies:
71
+
72
+ rosabeats has optional dependencies that can be installed based on your needs:
73
+
74
+ ```bash
75
+ # Install with Vamp plugin support
76
+ pip install .[vamp]
77
+
78
+ # Install with ffms2 support for additional audio formats
79
+ pip install .[ffms2]
80
+
81
+ # Install with all optional dependencies
82
+ pip install .[all]
83
+ ```
84
+
85
+ This will install the package and its dependencies, and make the following command-line tools available:
86
+ - `beatrecipe-processor`: Process beat recipes
87
+ - `segment-song`: Segment songs using librosa's Laplacian segmentation
88
+ - `beatswitch`: Generate beat recipes with alternating patterns
89
+ - `rosabeats-shell`: Interactive shell for beat manipulation
90
+
91
+ ### Optional: Vamp Plugins for Segmentino
92
+
93
+ If you want to use the Segmentino-based segmentation:
94
+
95
+ 1. Download and install the Vamp plugin SDK
96
+ 2. Install the Segmentino plugin
97
+
98
+ ### Using rosabeats
99
+
100
+ The package can be imported in Python as:
101
+ ```python
102
+ import rosabeats
103
+ ```
104
+
105
+ 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.
106
+
107
+ ## License
108
+
109
+ ## ISC License
110
+
111
+ Copyright © 2025 [John Fleming](https://github.com/jbff)
112
+
113
+ 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.
114
+
115
+ 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.
116
+
117
+ ## Acknowledgments
118
+
119
+ - [librosa](https://librosa.org/) for audio analysis
120
+ - [Vamp plugins](https://www.vamp-plugins.org/) for audio segmentation
121
+ - [Amen](https://github.com/algorithmic-music-exploration/amen) was the original inspiration
122
+
@@ -0,0 +1,80 @@
1
+ every beat recipe must contain these two lines, at the top:
2
+ file <filename.wav>
3
+ beats_bar # #
4
+
5
+ the two arguments to beats_bar specify the number of beats pe bar, and the absolute beat
6
+ number in the file that starts the first bar (this is often 0, first beat = first bar,
7
+ but is also often not, depending on track and file characteristics; using control_beats.py
8
+ to experiment is best way to discover if this should be non-zero for a given track)
9
+
10
+ These two lines are necessary to specify source and in order to calculate where bars are
11
+ in the file. After them, everything else is optional and can occur as many or few times as
12
+ you like, in any order
13
+
14
+ beats #
15
+ bars #
16
+ beats #-#
17
+ bars #-#
18
+
19
+ These are the simplest. You can play one or more beats, or one or more bars, by specifying
20
+ the beats or bars you wish to play. All of these are valid syntax:
21
+
22
+ beats 3
23
+ beats 3-3
24
+ beats 3-8
25
+ beats 8-3
26
+ bars 4
27
+ bars 4-4
28
+ bars 4-12
29
+ bars 12-4
30
+
31
+ If the first and last # specified are the same, it will be like specifying a single
32
+ beat/bar. If the first # specified is greater than the last, the beats/bars will be
33
+ played in reverse order, i.e. bars 4-1 will play bar 4, bar 3, bar 2, then bar 1.
34
+
35
+ rest #
36
+
37
+ Will insert silence. The argument specifies number of beats of silence. "rest 1" will
38
+ insert 1 beat of silence. Argument is floating point, so you can add fractional beats
39
+ of silence, e.g. "rest 0.5" will add half a beat of silence.
40
+
41
+ beats_shuf #
42
+ beats_shuf #-#
43
+ bars_shuf #
44
+ bars_shuf #-#
45
+
46
+ These two act much like beats and bars covered previously, except instead of playing
47
+ the specified beats or bars in the sequence specified, they will be randomly shuffled
48
+ before being played. If only a single beat or bar is given after these specifiers,
49
+ it will be the same as using "beats" or "bars" as shuffling a single item will always
50
+ result in the output of that one item (i.e. "bars_shuf 8" is same as "bars 8").
51
+
52
+
53
+ bars_rev #
54
+ bars_rev #-#
55
+
56
+ This is like bars, except it will play the beats in the bar in reverse order. That is,
57
+ if "bars 0" played beats 0, 1, 2, 3, 4, 5, 6, and 7, "bars_rev 0" would play beats
58
+ 7, 6, 5, 4, 3, 2, 1, and 0.
59
+
60
+ beat_div # # #
61
+ This will divide a beat into equal segments and play a certain number of them. The
62
+ first argument is the beat #. The second argument is how many pieces to divide the beat
63
+ into. THe third argument is how many times to play that subdivided beat. For example,
64
+ "beat_div 540 2 2" will play the first half of beat 540 twice; "beat_div 300 3 12"
65
+ will play the first third of beat 300 12 times (this will sound like 4 beats of triplets).
66
+
67
+ def name bars #
68
+ def name bars #-#
69
+ def name beats #
70
+ def name beats #-#
71
+
72
+ This defines a segment that can later be played with the play command (below). Right now
73
+ it can only handle beats and bars specifications (per above) but the plan is to expand it
74
+ to represent any valid command.
75
+
76
+ play name
77
+
78
+ This will play any defined segment defined with "def" (above). If previously you had said
79
+ "def seg1 bars 0-7" later when you say "play seg1" it will actually play bars 0-7.
80
+ 1
@@ -0,0 +1,58 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rosabeats"
7
+ dynamic = ["version"]
8
+ description = "Audio beat detection, segmentation, and remixing library using librosa"
9
+ readme = "README.md"
10
+ license = "ISC"
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ { name = "John Fleming" }
14
+ ]
15
+ keywords = ["audio", "beat", "detection", "segmentation", "remixing", "librosa", "music"]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Operating System :: OS Independent",
24
+ "Topic :: Multimedia :: Sound/Audio :: Analysis",
25
+ "Topic :: Multimedia :: Sound/Audio :: Conversion",
26
+ ]
27
+ dependencies = [
28
+ "librosa>=0.11.0,<1.0",
29
+ "soundfile>=0.13.0,<1.0",
30
+ "sounddevice>=0.5.0,<1.0",
31
+ "numpy>=2.0,<3.0",
32
+ "scipy>=1.15,<2.0",
33
+ "scikit-learn>=1.5,<2.0",
34
+ ]
35
+
36
+ [project.optional-dependencies]
37
+ ffms2 = ["ffms2"]
38
+ vamp = ["vamp"]
39
+ all = ["ffms2", "vamp"]
40
+
41
+ [project.scripts]
42
+ beatrecipe-processor = "rosabeats.beatrecipe_processor:main"
43
+ segment-song = "rosabeats.segment_song:main"
44
+ beatswitch = "rosabeats.beatswitch:main"
45
+ rosabeats-shell = "rosabeats.rosabeats_shell:main"
46
+
47
+ [project.urls]
48
+ Homepage = "https://github.com/jbff/rosabeats"
49
+ Repository = "https://github.com/jbff/rosabeats"
50
+
51
+ [tool.setuptools.dynamic]
52
+ version = {attr = "rosabeats.__version__"}
53
+
54
+ [tool.setuptools.packages.find]
55
+ where = ["."]
56
+
57
+ [tool.setuptools.package-data]
58
+ rosabeats = ["docs/*"]
@@ -0,0 +1,23 @@
1
+ """
2
+ rosabeats: Audio beat detection, segmentation, and remixing library
3
+
4
+ This package provides tools for audio beat detection, segmentation, and remixing.
5
+ It leverages the power of librosa and other audio processing libraries to enable
6
+ precise beat tracking, song segmentation, and creative audio manipulation.
7
+
8
+ Main features:
9
+ - Beat Detection: Automatically detect beats and tempo in audio files
10
+ - Bar Analysis: Group beats into bars with configurable beats-per-bar
11
+ - Audio Segmentation: Segment songs into structural parts
12
+ - Audio Remixing: Create remixes by manipulating beats and bars
13
+ - Beat Recipe Files: Save and load beat patterns as reusable recipes
14
+ """
15
+
16
+ __version__ = "0.1.3"
17
+
18
+ # Import main classes and functions from the module
19
+ from .rosabeats import rosabeats
20
+
21
+ # Expose key functionality at package level
22
+ __all__ = ['rosabeats']
23
+