2019-03-26 03:23:25

I don't suppose anyone knows of some good examples of bass being used in python. Searching on Google for "bass" or even "pybass" doesn't really return any useful results for me.


I'd kind of like to see if it would be better to use than openAL or not.

***
You can follow me on twitter @s_luttrell and an almost never used Facebook account at skluttrell.

2019-03-26 04:23:06

Hi there,

There is a wrapper around PyBass called sound_lib, which can be obtained from

http://hg.q-continuum.net

I've been going by Bryn, which is now reflected in my profile. Please do your best to respect this :) Mess ups are totally OK though, I don't mind and totally understand!
Follow on twitter! @ItsBrynify
Thanks, enjoy, thumbs up, share, like, hate, exist, do what ya do,
my website: brynify.me

2019-03-26 05:33:05

Oh, thanks. I already had that downloaded. I just thought it was for something else since pybass was already a thing.

***
You can follow me on twitter @s_luttrell and an almost never used Facebook account at skluttrell.

2019-03-26 05:38:24

The reason you probably aren't able to find anything on pybass, it's nothing more than a pythonic version of bass.h with a couple additional functions. Everything provided in the bass examples directory is fairly easy to port, a hell of a lot easier than using C in fact. The following code should play a file, I'd personally wrap this entire procedure into a class with some additional functions for volume, pan, etc etc. That's what I did. Hasn't been tested but I don't see any reason why it wouldn't work. other libraries provide a higher level interface, pybass actually requires use of ctypes in some instances. All depends on your preferences, I personally find it adequate for my game dev needs. We're looking at a rather light wait library so that's certainly a plus. Consult the actual docs for a function listing, reference, etc etc. They're surprisingly good.

import pybass
import platform
import time

#_init should be called whenever you want to use bass.
inited=pybass.BASS_Init(device, 44100, 0, 0, 0)

resource="idiot.wav"

#every os, aside from darwin, needs to be encoded to utf-8.
#stick with me here, weird but it works
unicode=True
if platform.system()=="Darwin":
    unicode=False
    resource=resource.encode(sys.getfilesystemencoding())
handle=pybass.BASS_StreamCreateFile(False, resource, 0, 0, (pybass.BASS_UNICODE if unicode else 0))
if not handle: #something broke. Valid handles are always >0
    print("error: "+pybass.get_error_description(pybass.BASS_ErrorGetCode()))
#now play
pybass.BASS_ChannelPlay(handle, True)
#block until the file is done playing
input("enter to stop playing and exit...")

2019-03-26 06:34:49

Just a note that BASS has some (IMO) very bad licensing conditions that I personally disapprove of. If your making a non-commercial product your good and can use it all you like, but if not...
* You can pay the 125 EUR price for a shareware license so long as your product does not exceed 40 EUR. That translates to $141.44 for the price of the license, and $45.26 for your products price tag, as of the time of writing.
* If your product exceeds 40 eur ($45.26), you can either purchase another license, which will double the amount you can charge for your app, or go for the "Single Commercial license, which is 950 eur, $1,074.92, as of the time of writing. If your deploying for iOS or Android, the price drops down to 475 eur ($537.46). That limits you to only one commercial product, though. If you want unlimited commercials, you'll have to pay a whopping 3,450 eur ($3903.64). That license, of course, only applies to a single location of development.
Talk about ridiculous!

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2019-03-26 15:43:07

Thanks for the example. I agree with putting things in classes too. I tend to write things in away that won't change my main code if I decide to use another method.


Yeah, I already read the license. It's satisfactory for my needs. I don't plan on selling anything anyway, but even if I did I probably wouldn't sell it for more than $10-20. Maybe I'm undervaluing my work.

***
You can follow me on twitter @s_luttrell and an almost never used Facebook account at skluttrell.