Giter VIP home page Giter VIP logo

bass4py's People

Contributors

timtam avatar

Watchers

 avatar  avatar  avatar

Forkers

keithcat1

bass4py's Issues

Remove the length parameter for functions like Channel.get_data and Channel.put_data

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.

Support BASSMIX and BASSENC?

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.

Any Python objects that are used by callbacks should have their reference count incremented

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.

The filelike dependency doesn't seem to support Python3

Python 3.9.5, Windows 10 X64,
Bass4Py Cython branch requires filelike, but I got an error when running pip install . in the root of the repository.
Manualy doing:
pip install filelike
Gives this:
Collecting filelike==0.5.0
Using cached filelike-0.5.0.tar.gz (35 kB)
Preparing metadata (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\keith\AppData\Local\Temp\pip-install-w6hga3lu\fileli
ke_3dc3c6efb7fe4b15bc5e3bed6dda846e\setup.py'"'"'; file='"'"'C:\Users\keith\AppData\Local\Temp\pip-install-w6hga3lu\filelike_3dc3c6efb7fe4b15bc5e3bed6dda846
e\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');cod
e = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\keith\AppData\Local\Temp\pip-p
ip-egg-info-hb5rv494'
cwd: C:\Users\keith\AppData\Local\Temp\pip-install-w6hga3lu\filelike_3dc3c6efb7fe4b15bc5e3bed6dda846e
Complete output (1 lines):
error in filelike setup command: use_2to3 is invalid.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.