timtam / bass4py Goto Github PK
View Code? Open in Web Editor NEWA simple and object-like interface for the bass audio library from un4seen.com.
A simple and object-like interface for the bass audio library from un4seen.com.
If you don't want to pass the entire buffer to BASS, then pass a slice, no extra work necessary for Cython. If you want to pass the equivalent of NULL to BASS then do:
def get_data(Channel self, unsigned char[:] data):
BASS_ChannelGetData(self.channel, &data[0] if data is not None and data.shape[0] > 0 else NULL, <QWORD>data.shape[0]) # if the memoryview has a length of 0 or is None, pass NULL
You can efficiently retrieve the length of a 1D memoryview with:
data.shape[0]
which is of type Py_ssize_t, which is 32-bits on 32-bit systems and 64-bit on 64-bit systems I believe.
Would be nice if the BASS extensions were all supported, probably in a separate package for each one.
The ones I'm interested in are BASSENC and BASSMIX. With BASSENC, you could probably bundle BASSENC_MP3, BASSENC_FLAC and BASSENC_OGG in the same package as BASSENC because most people will probably just want to use those instead of hooking up a command-line encoder anyway.
On one hand, if I create a BASS channel sync or any object that our C function callback will expect to have access to, set it on a channel and then discard it, it's possible for the Python GC to garbage collect it. Then our callback we passed to BASS comes along, tries to get a reference to that sync object, but oops it's not there anymore. Being able to set syncs on a channel and then just forget them would be nice.
On the other hand, implementing this is kind of a pain. You can use the following Cython-defined macros to increment and decrement the reference count of an object.
from cpython.ref cimport PyObject, Py_DECREF, Py_INCREF
Increment the reference just before converting the PyObject* to void* in order to pass it as a userdata parameter to BASS, then decrement the reference count once we know BASS is done with it or the object will never be freed which causes a memory leak. Unfortunately BASS doesn't provide any way of knowing when a sync's userdata can be freed, so channels have to keep a list of the syncs applied to them or something and Py_DECREF them all along with any other objects owned by the channel when the channel is freed. The best way of knowing when a channel is freed that I know of is setting a BASS_SYNC_FREE on the channel, which can't be used on HSAMPLE channels. BASS_SampleGetChannel supports the BASS_SAMCHAN_STREAM flag which returns a HSTREAM which is the same as normal but it's a stream, supports more BASS features and has slightly lower performance compared to not using BASS_SAMCHAN_STREAM, so we could just make using BASS_SAMCHAN_STREAM the default I guess.
WARNING: Discarding https://files.pythonhosted.org/packages/68/30/912d8be3957f1ed545ca156a3bfa8c65f5137febff08dcd4bf08bc29a1b8/filelike-0.5.0.tar.gz#sha256=b1f4324f9c6e
a630473c3f4e8f86395fd76412e21cc25effc236e2eb6aa2b239 (from https://pypi.org/simple/filelike/). Command errored out with exit status 1: python setup.py egg_info Check th
e logs for full command output.
ERROR: Could not find a version that satisfies the requirement filelike==0.5.0 (from versions: 0.3.5p1, 0.1.0, 0.1.1, 0.2.0, 0.2.1, 0.2.2, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0
.3.4, 0.3.5, 0.3.6, 0.3.7, 0.4.0, 0.4.1, 0.5.0)
ERROR: No matching distribution found for filelike==0.5.0
I was under the impression that & is used to check the presence of a flag while | is used to toggle a flag.
For example bass4py/bass/stream.pyx:line 89
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.