Skip to content

Commit fa3837f

Browse files
np.float_ -> np.float64 (#50)
1 parent 0c938ba commit fa3837f

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

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>

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

0 commit comments

Comments
 (0)