Skip to content

Commit b954a2c

Browse files
authored
Merge branch 'master' into add_ffprobe_checks_and_env_variables
2 parents 95a533f + a612e04 commit b954a2c

File tree

8 files changed

+68
-70
lines changed

8 files changed

+68
-70
lines changed

.github/workflows/test_unittests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
ffmpeg-version: ["3.2.4", "3.4.2", "4.4.2", "5.1.2", "6.1.1", "7.0.0"]
13+
ffmpeg-version: ["4.3", "5.0", "6.0", "7.0"]
1414

1515
# Timeout: https://stackoverflow.com/a/59076067/4521646
1616
timeout-minutes: 10
@@ -25,7 +25,7 @@ jobs:
2525
activate-environment: stempeg
2626
auto-update-conda: true
2727
auto-activate-base: false
28-
python-version: 3.7
28+
python-version: 3.11
2929
- name: Install dependencies FFMPEG ${{ matrix.ffmpeg-version }}
3030
env:
3131
FFMPEG_INSTALL: ${{ matrix.pytorch-version }}

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
[![Supported Python versions](https://img.shields.io/pypi/pyversions/stempeg.svg)](https://pypi.python.org/pypi/stempeg)
77

88
Python package to read and write [STEM](https://www.native-instruments.com/en/specials/stems/) audio files.
9-
Technically, stems are audio containers that combine multiple audio streams and metadata in a single audio file. This makes it ideal to playback multitrack audio, where users can select the audio sub-stream during playback (e.g. supported by VLC).
9+
Technically, stems are audio containers that combine multiple audio streams and metadata in a single audio file. This makes it ideal to playback multitrack audio, where users can select the audio sub-stream during playback (e.g. supported by VLC).
1010

1111
Under the hood, _stempeg_ uses [ffmpeg](https://www.ffmpeg.org/) for reading and writing multistream audio, optionally [MP4Box](https://github.com/gpac/gpac) is used to create STEM files that are compatible with Native Instruments hardware and software.
1212

1313
#### Features
1414

1515
- robust and fast interface for ffmpeg to read and write any supported format from/to numpy.
1616
- reading supports seeking and duration.
17-
- control container and codec as well as bitrate when compressed audio is written.
17+
- control container and codec as well as bitrate when compressed audio is written.
1818
- store multi-track audio within audio formats by aggregate streams into channels (concatenation of pairs of
1919
stereo channels).
2020
- support for internal ffmpeg resampling furing read and write.
@@ -70,7 +70,7 @@ conda install -c conda-forge stempeg
7070

7171
Stempeg can read multi-stream and single stream audio files, thus, it can replace your normal audio loaders for 1d or 2d (mono/stereo) arrays.
7272

73-
By default [`read_stems`](https://faroit.com/stempeg/read.html#stempeg.read.read_stems), assumes that multiple substreams can exit (default `reader=stempeg.StreamsReader()`).
73+
By default [`read_stems`](https://faroit.com/stempeg/read.html#stempeg.read.read_stems), assumes that multiple substreams can exit (default `reader=stempeg.StreamsReader()`).
7474
To support multi-stream, even when the audio container doesn't support multiple streams
7575
(e.g. WAV), streams can be mapped to multiple pairs of channels. In that
7676
case, `reader=stempeg.ChannelsReader()`, can be passed. Also see:
@@ -121,7 +121,7 @@ Writing stem files from a numpy tensor can done with.
121121
stempeg.write_stems(path="output.stem.mp4", data=S, sample_rate=44100, writer=stempeg.StreamsWriter())
122122
```
123123

124-
As seen in the flow chart above, stempeg supports multiple ways to write multi-stream audio.
124+
As seen in the flow chart above, stempeg supports multiple ways to write multi-stream audio.
125125
Each of the method has different number of parameters. To select a method one of the following setting and be passed:
126126

127127
* `stempeg.FilesWriter`
@@ -136,8 +136,8 @@ Each of the method has different number of parameters. To select a method one of
136136
Stem will be saved into a single multistream audio.
137137
Additionally Native Instruments Stems compabible
138138
Metadata is added. This requires the installation of
139-
`MP4Box`.
140-
139+
`MP4Box`.
140+
141141
> :warning: __Warning__: Muxing stems using _ffmpeg_ leads to multi-stream files not compatible with Native Instrument Hardware or Software. Please use [MP4Box](https://github.com/gpac/gpac) if you use the `stempeg.NISTemsWriter()`
142142
143143
For more information on writing stems, see [`stempeg.write_stems`](https://faroit.com/stempeg/write.html#stempeg.write.write_stems).

docs/read.html

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ <h1 class="title">Module <code>stempeg.read</code></h1>
101101
duration (float): duration in seconds
102102
dtype (numpy.dtype): Type of audio array to be casted into
103103
stem_idx (int): stream id
104-
ffmpeg_format (str): ffmpeg intermediate format encoding.
104+
ffmpeg_format (str): ffmpeg intermediate format encoding.
105105
Choose &#34;f32le&#34; for best compatibility
106106

107107
Returns:
@@ -123,10 +123,10 @@ <h1 class="title">Module <code>stempeg.read</code></h1>
123123

124124
# decode to raw pcm format
125125
if ffmpeg_format == &#34;f64le&#34;:
126-
# PCM 64 bit float
126+
# PCM 64 bit float
127127
numpy_dtype = &#39;&lt;f8&#39;
128128
elif ffmpeg_format == &#34;f32le&#34;:
129-
# PCM 32 bit float
129+
# PCM 32 bit float
130130
numpy_dtype = &#39;&lt;f4&#39;
131131
elif ffmpeg_format == &#34;s16le&#34;:
132132
# PCM 16 bit signed int
@@ -150,7 +150,7 @@ <h1 class="title">Module <code>stempeg.read</code></h1>
150150
duration=None,
151151
stem_id=None,
152152
always_3d=False,
153-
dtype=np.float_,
153+
dtype=np.float64,
154154
ffmpeg_format=&#34;f32le&#34;,
155155
info=None,
156156
sample_rate=None,
@@ -181,28 +181,28 @@ <h1 class="title">Module <code>stempeg.read</code></h1>
181181
duration (float): Duration to load in seconds.
182182
stem_id (int, optional): substream id,
183183
defauls to `None` (all substreams are loaded).
184-
always_3d (bool, optional): By default, reading a
184+
always_3d (bool, optional): By default, reading a
185185
single-stream audio file will return a
186186
two-dimensional array. With ``always_3d=True``, audio data is
187187
always returned as a three-dimensional array, even if the audio
188188
file has only one stream.
189189
dtype (np.dtype, optional): Numpy data type to use, default to `np.float32`.
190-
info (Info, Optional): Pass ffmpeg `Info` object to reduce number
190+
info (Info, Optional): Pass ffmpeg `Info` object to reduce number
191191
of os calls on file.
192192
This can be used e.g. the sample rate and length of a track is
193193
already known in advance. Useful for ML training where the
194194
info objects can be pre-processed, thus audio loading can
195195
be speed up.
196-
sample_rate (float, optional): Sample rate of returned audio.
196+
sample_rate (float, optional): Sample rate of returned audio.
197197
Defaults to `None` which results in
198198
the sample rate returned from the mixture.
199-
reader (Reader): Holds parameters for the reading method.
199+
reader (Reader): Holds parameters for the reading method.
200200
One of the following:
201201
`StreamsReader(...)`
202202
Read from a single multistream audio (default).
203203
`ChannelsReader(...)`
204204
Read/demultiplexed from multiple channels.
205-
multiprocess (bool): Applys multi-processing for reading
205+
multiprocess (bool): Applys multi-processing for reading
206206
substreams in parallel to speed up reading. Defaults to `True`
207207

208208
Returns:
@@ -280,7 +280,7 @@ <h1 class="title">Module <code>stempeg.read</code></h1>
280280
channels = min(_chans)
281281
else:
282282
raise RuntimeError(&#34;Stems do not have the same number of channels per substream&#34;)
283-
283+
284284
# set channels to minimum channel per stream
285285
stems = []
286286

@@ -511,7 +511,7 @@ <h2 id="shape">Shape</h2>
511511
duration=None,
512512
stem_id=None,
513513
always_3d=False,
514-
dtype=np.float_,
514+
dtype=np.float64,
515515
ffmpeg_format=&#34;f32le&#34;,
516516
info=None,
517517
sample_rate=None,
@@ -542,28 +542,28 @@ <h2 id="shape">Shape</h2>
542542
duration (float): Duration to load in seconds.
543543
stem_id (int, optional): substream id,
544544
defauls to `None` (all substreams are loaded).
545-
always_3d (bool, optional): By default, reading a
545+
always_3d (bool, optional): By default, reading a
546546
single-stream audio file will return a
547547
two-dimensional array. With ``always_3d=True``, audio data is
548548
always returned as a three-dimensional array, even if the audio
549549
file has only one stream.
550550
dtype (np.dtype, optional): Numpy data type to use, default to `np.float32`.
551-
info (Info, Optional): Pass ffmpeg `Info` object to reduce number
551+
info (Info, Optional): Pass ffmpeg `Info` object to reduce number
552552
of os calls on file.
553553
This can be used e.g. the sample rate and length of a track is
554554
already known in advance. Useful for ML training where the
555555
info objects can be pre-processed, thus audio loading can
556556
be speed up.
557-
sample_rate (float, optional): Sample rate of returned audio.
557+
sample_rate (float, optional): Sample rate of returned audio.
558558
Defaults to `None` which results in
559559
the sample rate returned from the mixture.
560-
reader (Reader): Holds parameters for the reading method.
560+
reader (Reader): Holds parameters for the reading method.
561561
One of the following:
562562
`StreamsReader(...)`
563563
Read from a single multistream audio (default).
564564
`ChannelsReader(...)`
565565
Read/demultiplexed from multiple channels.
566-
multiprocess (bool): Applys multi-processing for reading
566+
multiprocess (bool): Applys multi-processing for reading
567567
substreams in parallel to speed up reading. Defaults to `True`
568568

569569
Returns:
@@ -641,7 +641,7 @@ <h2 id="shape">Shape</h2>
641641
channels = min(_chans)
642642
else:
643643
raise RuntimeError(&#34;Stems do not have the same number of channels per substream&#34;)
644-
644+
645645
# set channels to minimum channel per stream
646646
stems = []
647647

@@ -1130,4 +1130,4 @@ <h4><code><a title="stempeg.read.StreamsReader" href="#stempeg.read.StreamsReade
11301130
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.1</a>.</p>
11311131
</footer>
11321132
</body>
1133-
</html>
1133+
</html>

setup.py

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,43 @@
1414
# Fields marked as "Optional" may be commented out.
1515

1616
setup(
17-
name='stempeg',
18-
version='0.2.3',
19-
description='Read and write stem/multistream audio files',
17+
name="stempeg",
18+
version="0.2.4",
19+
description="Read and write stem/multistream audio files",
2020
long_description=long_description,
21-
long_description_content_type='text/markdown',
22-
url='http://github.com/faroit/stempeg',
23-
author='Fabian-Robert Stoeter',
24-
author_email='[email protected]',
21+
long_description_content_type="text/markdown",
22+
url="http://github.com/faroit/stempeg",
23+
author="Fabian-Robert Stoeter",
24+
author_email="[email protected]",
2525
classifiers=[
26-
'Development Status :: 4 - Beta',
27-
'Environment :: Console',
28-
'Intended Audience :: Telecommunications Industry',
29-
'Intended Audience :: Science/Research',
30-
'Programming Language :: Python :: 3.5',
31-
'Programming Language :: Python :: 3.6',
32-
'Programming Language :: Python :: 3.7',
33-
'Programming Language :: Python :: 3.8',
34-
'Topic :: Multimedia :: Sound/Audio :: Analysis',
35-
'Topic :: Multimedia :: Sound/Audio :: Sound Synthesis'
26+
"Development Status :: 4 - Beta",
27+
"Environment :: Console",
28+
"Intended Audience :: Telecommunications Industry",
29+
"Intended Audience :: Science/Research",
30+
"Programming Language :: Python :: 3.9",
31+
"Programming Language :: Python :: 3.10",
32+
"Programming Language :: Python :: 3.11",
33+
"Topic :: Multimedia :: Sound/Audio :: Analysis",
34+
"Topic :: Multimedia :: Sound/Audio :: Sound Synthesis",
3635
],
3736
zip_safe=True,
38-
keywords='stems audio reader',
39-
packages=find_packages(exclude=['tests']),
37+
keywords="stems audio reader",
38+
packages=find_packages(exclude=["tests"]),
4039
# Dependencies, this installs the entire Python scientific
4140
# computations stack
42-
install_requires=[
43-
'numpy>=1.6',
44-
'ffmpeg-python>=0.2.0'
45-
],
41+
install_requires=["numpy>=1.6", "ffmpeg-python>=0.2.0"],
4642
extras_require={
47-
'tests': [
48-
'pytest',
43+
"tests": [
44+
"pytest",
4945
],
5046
},
51-
entry_points={'console_scripts': [
52-
'stem2files=stempeg.cli:cli',
53-
]},
47+
entry_points={
48+
"console_scripts": [
49+
"stem2files=stempeg.cli:cli",
50+
]
51+
},
5452
project_urls={ # Optional
55-
'Bug Reports': 'https://github.com/faroit/stempeg/issues',
53+
"Bug Reports": "https://github.com/faroit/stempeg/issues",
5654
},
57-
include_package_data=True
55+
include_package_data=True,
5856
)

stempeg/read.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _read_ffmpeg(
7171
duration (float): duration in seconds
7272
dtype (numpy.dtype): Type of audio array to be casted into
7373
stem_idx (int): stream id
74-
ffmpeg_format (str): ffmpeg intermediate format encoding.
74+
ffmpeg_format (str): ffmpeg intermediate format encoding.
7575
Choose "f32le" for best compatibility
7676
7777
Returns:
@@ -93,10 +93,10 @@ def _read_ffmpeg(
9393

9494
# decode to raw pcm format
9595
if ffmpeg_format == "f64le":
96-
# PCM 64 bit float
96+
# PCM 64 bit float
9797
numpy_dtype = '<f8'
9898
elif ffmpeg_format == "f32le":
99-
# PCM 32 bit float
99+
# PCM 32 bit float
100100
numpy_dtype = '<f4'
101101
elif ffmpeg_format == "s16le":
102102
# PCM 16 bit signed int
@@ -120,7 +120,7 @@ def read_stems(
120120
duration=None,
121121
stem_id=None,
122122
always_3d=False,
123-
dtype=np.float_,
123+
dtype=np.float64,
124124
ffmpeg_format="f32le",
125125
info=None,
126126
sample_rate=None,
@@ -151,28 +151,28 @@ def read_stems(
151151
duration (float): Duration to load in seconds.
152152
stem_id (int, optional): substream id,
153153
defauls to `None` (all substreams are loaded).
154-
always_3d (bool, optional): By default, reading a
154+
always_3d (bool, optional): By default, reading a
155155
single-stream audio file will return a
156156
two-dimensional array. With ``always_3d=True``, audio data is
157157
always returned as a three-dimensional array, even if the audio
158158
file has only one stream.
159159
dtype (np.dtype, optional): Numpy data type to use, default to `np.float32`.
160-
info (Info, Optional): Pass ffmpeg `Info` object to reduce number
160+
info (Info, Optional): Pass ffmpeg `Info` object to reduce number
161161
of os calls on file.
162162
This can be used e.g. the sample rate and length of a track is
163163
already known in advance. Useful for ML training where the
164164
info objects can be pre-processed, thus audio loading can
165165
be speed up.
166-
sample_rate (float, optional): Sample rate of returned audio.
166+
sample_rate (float, optional): Sample rate of returned audio.
167167
Defaults to `None` which results in
168168
the sample rate returned from the mixture.
169-
reader (Reader): Holds parameters for the reading method.
169+
reader (Reader): Holds parameters for the reading method.
170170
One of the following:
171171
`StreamsReader(...)`
172172
Read from a single multistream audio (default).
173173
`ChannelsReader(...)`
174174
Read/demultiplexed from multiple channels.
175-
multiprocess (bool): Applys multi-processing for reading
175+
multiprocess (bool): Applys multi-processing for reading
176176
substreams in parallel to speed up reading. Defaults to `True`
177177
178178
Returns:
@@ -250,7 +250,7 @@ def read_stems(
250250
channels = min(_chans)
251251
else:
252252
raise RuntimeError("Stems do not have the same number of channels per substream")
253-
253+
254254
# set channels to minimum channel per stream
255255
stems = []
256256

tests/test_random.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44

55

6-
@pytest.fixture(params=[1024, 2048, 12313, 100000])
6+
@pytest.fixture(params=[1024, 2048, 100000])
77
def nb_samples(request):
88
return request.param
99

tests/test_read.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ def dtype(request):
99
return request.param
1010

1111

12-
@pytest.fixture(params=[None, 0, 0.0000001, 1, 100])
12+
@pytest.fixture(params=[None, 0, 0.0000001, 1])
1313
def start(request):
1414
return request.param
1515

1616

17-
@pytest.fixture(params=[None, 0.00000001, 0.5, 1, 2.00000000000001])
17+
@pytest.fixture(params=[None, 0.00000001, 0.5, 2.00000000000001])
1818
def duration(request):
1919
return request.param
2020

tests/test_write.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def ordered(obj):
160160
else:
161161
return obj
162162

163-
163+
@pytest.mark.optional
164164
def test_nistems():
165165
stems, rate = stempeg.read_stems(stempeg.example_stem_path())
166166
with tmp.NamedTemporaryFile(

0 commit comments

Comments
 (0)