Comments (5)
As I mentioned in issue #20, I see no benefit to disabling normalization when writing a floating-point array to a PCM file. This would degrade PySoundFile's clean abstraction and add unnecessary complexity. If a Python user wants to PySoundFile to interpret a floating-point in_array as integer values, it can be accomplished by passing in_array.astype(np.int16) instead.
from python-soundfile.
Very interesting, yes.
SFC_SET_SCALE_FLOAT_INT_READ
looks interesting as well.
from python-soundfile.
I just had a closer look ...
There are a few commands that give global information, namely SFC_GET_LIB_VERSION
and SFC_GET*FORMAT*
.
We're already providing the FORMAT
stuff with available_formats()
and similar functions.
We'd only have to add one function, e.g. named get_lib_version()
or libsndfile_version()
(any other suggestions for a function name?).
All the rest give information about an existing SNDFILE
object:
SFC_GET_LOG_INFO
SFC_GET_CURRENT_SF_INFO
SFC_GET_NORM_DOUBLE
SFC_GET_NORM_FLOAT
SFC_SET_NORM_DOUBLE
SFC_SET_NORM_FLOAT
SFC_SET_SCALE_FLOAT_INT_READ
SFC_SET_SCALE_INT_FLOAT_WRITE
SFC_CALC_SIGNAL_MAX
SFC_CALC_NORM_SIGNAL_MAX
SFC_CALC_MAX_ALL_CHANNELS
SFC_CALC_NORM_MAX_ALL_CHANNELS
SFC_GET_SIGNAL_MAX
SFC_GET_MAX_ALL_CHANNELS
SFC_SET_ADD_PEAK_CHUNK
SFC_SET_ADD_HEADER_PAD_CHUNK
SFC_UPDATE_HEADER_NOW
SFC_SET_UPDATE_HEADER_AUTO
SFC_FILE_TRUNCATE
SFC_SET_RAW_START_OFFSET
SFC_SET_DITHER_ON_WRITE
SFC_SET_DITHER_ON_READ
SFC_GET_DITHER_INFO_COUNT
SFC_GET_DITHER_INFO
SFC_GET_EMBED_FILE_INFO
SFC_SET_CLIPPING
SFC_GET_CLIPPING
SFC_GET_INSTRUMENT
SFC_SET_INSTRUMENT
SFC_GET_LOOP_INFO
SFC_GET_BROADCAST_INFO
SFC_SET_BROADCAST_INFO
SFC_GET_CHANNEL_MAP_INFO
SFC_SET_CHANNEL_MAP_INFO
SFC_RAW_DATA_NEEDS_ENDSWAP
SFC_WAVEX_SET_AMBISONIC
SFC_WAVEX_GET_AMBISONIC
SFC_SET_VBR_ENCODING_QUALITY
SFC_TEST_IEEE_FLOAT_REPLACE
SFC_SET_ADD_DITHER_ON_WRITE
SFC_SET_ADD_DITHER_ON_READ
Needless to say, those are a lot.
I don't think it's a good idea to provide each single one of them as a method or property of SoundFile
.
What about having an attribute (e.g. called SoundFile.command
) that itself has all the information as properties?
E.g.:
f = sf.open(...)
f.command.vbr_encoding_quality = 0.8
Any other suggestions for an attribute name?
properties
, settings
, info
, ...?
from python-soundfile.
I do not want to simply copy this stuff from sndfile. PySoundFile should be as useful and pythonic as possible. The fact that it is implemented using sndfile is an implementation detail that we should not expose unless necessary.
Thus, I would like to implement these commands in ways that make sense for PySoundFile, and not as a generic "command interface" that just defers to libsndfile.
Ideas:
SFC_GET_LIB_VERSION
asSoundFile.__sndversion__
.SFC_GET_LOG_INFO
as content of the exception ifsf_open*
fails.SFC_CALC_SIGNAL_MAX
asSoundFile.max()
(similarly for the otherCALC
commands).SFC_SET_NORM_*
,SFC_SET_SCALE_*
,SFC_GET/SET_CLIPPING
are probably more easily dealt with on the Numpy side, so we should skip them.SFC_GET_*_FORMAT_*
are already implemented asSoundFile.format_info
SFC_UPDATE_HEADER_NOW
could be integrated inSoundFile.flush()
SFC_FILE_TRUNCATE
asSoundFile.truncate()
SFC_GET_LOOP_INFO
andSFC_GET_INSTRUMENT
in a specialSoundFile.midi
property.SFC_SET_VBR_ENCODING_QUALITY
as a special keyword argument for ogg files only.
Of course, this will add a lot of complexity to the library, the tests, and the documentation.
But I would rather not support some of these, than doing something like SoundFile.send_command("VBR_ENCODING_QUALITY", 0.9)
. After all, if the user really wants to do this, he can always sf._snd.sf_command(soundfile._file, sf._snd.SFC_SET_VBR_ENCODING_QUALITY, 0.9, 4)
.
from python-soundfile.
Since libsndfile 1.0.27 the the new commands SFC_GET_CUE_COUNT
, SFC_GET_CUE
, SFC_SET_CUE
are available, see libsndfile/libsndfile@9ea30b4 and http://www.mega-nerd.com/libsndfile/command.html.
This might be useful, see also http://stackoverflow.com/q/20011239.
from python-soundfile.
Related Issues (20)
- Feature request: Support interleaved stereo data HOT 4
- buffer_read doesn't work in basic test HOT 2
- Soundfile read/write wav is not symmetric with default arguments HOT 3
- module 'soundfile' has no attribute 'SoundFileRuntimeError' HOT 5
- Value Error: array is too big when loading .flac file
- soundfile crashes when trying to export long .ogg file HOT 1
- soundfile.LibsndfileError: Error opening <_io.BytesIO object at 0x0000022B81C21850>: Format not recognised. HOT 2
- Cannot suppress warnings when decoding mp3
- Cannot open Ogg FLAC file: unknown error in flac decoder HOT 1
- miniforge3/lib/python3.9/site-packages/soundfile.py", line 1229, in _init_virtual_io def vio_get_filelen(user_data): MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks
- Cannot write Ogg files over 96 seconds long at 44.1 kHz HOT 4
- soundfile.info does not work on mp3 HOT 2
- soundfile.LibsndfileError: <exception str() failed> HOT 6
- How to save left and right channel in separate files? HOT 1
- soundfile.LibsndfileError: Error : unknown error in flac decoder. HOT 2
- "Format not recognised." for m4a files HOT 2
- soundfile.LibsndfileError: Error opening <tempfile._TemporaryFileWrapper object at 0x7feadae59070>: Format not recognised. HOT 2
- Part of mp3 is loaded. HOT 2
- unknown error in flac decoder HOT 2
- Capture libmpg123/libsndfile warnings HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-soundfile.