Merge pull request #140 from codeofdusk/i140

update sound_lib
This commit is contained in:
Manuel Cortez 2017-06-17 21:15:58 -05:00 committed by GitHub
commit d4b410cafd
72 changed files with 3741 additions and 3520 deletions

View File

@ -136,7 +136,7 @@ class Session(object):
def init_sound(self): def init_sound(self):
try: self.sound = sound.soundSystem(self.settings["sound"]) try: self.sound = sound.soundSystem(self.settings["sound"])
except: pass except: log.exception("Exception thrown during sound system initialization")
@_require_configuration @_require_configuration
def login(self, verify_credentials=True): def login(self, verify_credentials=True):

View File

@ -6,7 +6,11 @@ import os
import logging as original_logger import logging as original_logger
log = original_logger.getLogger("sound") log = original_logger.getLogger("sound")
import paths import paths
import sound_lib from sound_lib.output import Output
from sound_lib.input import Input
from sound_lib.recording import WaveRecording
from sound_lib.stream import FileStream
from sound_lib.stream import URLStream as SoundlibURLStream
import subprocess import subprocess
import platform import platform
import output import output
@ -30,7 +34,7 @@ def recode_audio(filename, quality=4.5):
def recording(filename): def recording(filename):
# try: # try:
val = sound_lib.recording.WaveRecording(filename=filename) val = WaveRecording(filename=filename)
# except sound_lib.main.BassError: # except sound_lib.main.BassError:
# sound_lib.input.Input() # sound_lib.input.Input()
# val = sound_lib.recording.WaveRecording(filename=filename) # val = sound_lib.recording.WaveRecording(filename=filename)
@ -57,17 +61,17 @@ class soundSystem(object):
self.config = soundConfig self.config = soundConfig
# Set the output and input default devices. # Set the output and input default devices.
try: try:
self.output = sound_lib.output.Output() self.output = Output()
self.input = sound_lib.input.Input() self.input = Input()
except: except IOError:
pass pass
# Try to use the selected device from the configuration. It can fail if the machine does not has a mic. # Try to use the selected device from the configuration. It can fail if the machine does not has a mic.
try: try:
log.debug("Setting input and output devices...") log.debug("Setting input and output devices...")
self.output.set_device(self.output.find_device_by_name(self.config["output_device"])) self.output.set_device(self.output.find_device_by_name(self.config["output_device"]))
self.input.set_device(self.input.find_device_by_name(self.config["input_device"])) self.input.set_device(self.input.find_device_by_name(self.config["input_device"]))
except: except:
log.error("Error in input or output devices, using defaults...") log.exception("Error in input or output devices, using defaults...")
self.config["output_device"] = "Default" self.config["output_device"] = "Default"
self.config["input_device"] = "Default" self.config["input_device"] = "Default"
@ -89,7 +93,7 @@ class soundSystem(object):
def play(self, sound, argument=False): def play(self, sound, argument=False):
if self.soundpack_OK == False: return if self.soundpack_OK == False: return
if self.config["session_mute"] == True: return if self.config["session_mute"] == True: return
sound_object = sound_lib.stream.FileStream(file="%s/%s" % (self.path, sound)) sound_object = FileStream(file="%s/%s" % (self.path, sound))
sound_object.volume = float(self.config["volume"]) sound_object.volume = float(self.config["volume"])
self.files.append(sound_object) self.files.append(sound_object)
sound_object.play() sound_object.play()
@ -140,7 +144,7 @@ class URLStream(object):
elif stream != None: elif stream != None:
self.stream=stream self.stream=stream
if self.prepared == True: if self.prepared == True:
self.stream = sound_lib.stream.URLStream(url=self.url) self.stream = SoundlibURLStream(url=self.url)
if hasattr(self,'stream'): if hasattr(self,'stream'):
self.stream.volume = float(volume) self.stream.volume = float(volume)
self.stream.play() self.stream.play()

View File

@ -1,25 +1,24 @@
import output, input, recording, stream
__author__ = 'Christopher Toth'
__author__ = 'Christopher Toth' __version__ = 0.8
__version__ = 0.73
def find_datafiles():
def find_datafiles(): from glob import glob
from glob import glob import os
import os import platform
import platform import sound_lib
import sound_lib path = os.path.join(sound_lib.__path__[0], 'lib')
path = os.path.join(sound_lib.__path__[0], 'lib') system = platform.system()
system = platform.system() if system == 'Windows':
if system == 'Windows': file_ext = '*.dll'
file_ext = '*.dll' elif system == 'Darwin':
elif system == 'Darwin': file_ext = '*.dylib'
file_ext = '*.dylib' else:
else: file_ext = '*.so'
file_ext = '*.so' if platform.architecture()[0] == '32bit' or platform.system() == 'Darwin':
if platform.architecture()[0] == '32bit' or platform.system() == 'Darwin': arch = 'x86'
arch = 'x86' else:
else: arch = 'x64'
arch = 'x64' dest_dir = os.path.join('sound_lib', 'lib', arch)
dest_dir = os.path.join('sound_lib', 'lib', arch) source = glob(os.path.join(path, arch, file_ext))
source = glob(os.path.join(path, arch, file_ext)) return [(dest_dir, source)]
return [(dest_dir, source)]

View File

@ -1,285 +1,285 @@
from __future__ import absolute_import from __future__ import absolute_import
from .external.pybass import * from .external.pybass import *
from .main import bass_call, bass_call_0, BassError, update_3d_system, FlagObject from .main import bass_call, bass_call_0, BassError, update_3d_system, FlagObject
from ctypes import pointer, c_float, c_long, c_ulong, c_buffer from ctypes import pointer, c_float, c_long, c_ulong, c_buffer
class Channel (FlagObject): class Channel (FlagObject):
"""A "channel" can be a sample playback channel (HCHANNEL), a sample stream (HSTREAM), a MOD music (HMUSIC), or a recording (HRECORD). Each "Channel" function can be used with one or more of these channel types.""" """A "channel" can be a sample playback channel (HCHANNEL), a sample stream (HSTREAM), a MOD music (HMUSIC), or a recording (HRECORD). Each "Channel" function can be used with one or more of these channel types."""
def __init__ (self, handle): def __init__ (self, handle):
self.handle = handle self.handle = handle
self.attribute_mapping = { self.attribute_mapping = {
'eaxmix': BASS_ATTRIB_EAXMIX, 'eaxmix': BASS_ATTRIB_EAXMIX,
'frequency': BASS_ATTRIB_FREQ, 'frequency': BASS_ATTRIB_FREQ,
'pan': BASS_ATTRIB_PAN, 'pan': BASS_ATTRIB_PAN,
'volume': BASS_ATTRIB_VOL 'volume': BASS_ATTRIB_VOL
} }
def add_attributes_to_mapping(self, **attrs): def add_attributes_to_mapping(self, **attrs):
self.attribute_mapping.update(**attrs) self.attribute_mapping.update(**attrs)
def play (self, restart=False): def play (self, restart=False):
"""Starts (or resumes) playback of a sample, stream, MOD music, or recording.""" """Starts (or resumes) playback of a sample, stream, MOD music, or recording."""
return bass_call(BASS_ChannelPlay, self.handle, restart) return bass_call(BASS_ChannelPlay, self.handle, restart)
def play_blocking(self, restart=False): def play_blocking(self, restart=False):
self.play(restart=restart) self.play(restart=restart)
while self.is_playing: while self.is_playing:
pass pass
def pause (self): def pause (self):
return bass_call(BASS_ChannelPause, self.handle) return bass_call(BASS_ChannelPause, self.handle)
def is_active (self): def is_active (self):
"Checks if a sample, stream, or MOD music is active (playing) or stalled. Can also check if a recording is in progress.""" "Checks if a sample, stream, or MOD music is active (playing) or stalled. Can also check if a recording is in progress."""
return bass_call_0(BASS_ChannelIsActive, self.handle) return bass_call_0(BASS_ChannelIsActive, self.handle)
@property @property
def is_playing(self): def is_playing(self):
return self.is_active() == BASS_ACTIVE_PLAYING return self.is_active() == BASS_ACTIVE_PLAYING
@property @property
def is_paused(self): def is_paused(self):
return self.is_active() == BASS_ACTIVE_PAUSED return self.is_active() == BASS_ACTIVE_PAUSED
@property @property
def is_stopped(self): def is_stopped(self):
return self.is_active() == BASS_ACTIVE_STOPPED return self.is_active() == BASS_ACTIVE_STOPPED
@property @property
def is_stalled(self): def is_stalled(self):
return self.is_active() == BASS_ACTIVE_STALLED return self.is_active() == BASS_ACTIVE_STALLED
def get_position (self, mode=BASS_POS_BYTE): def get_position (self, mode=BASS_POS_BYTE):
"""Retrieves the playback position of a sample, stream, or MOD music. Can also be used with a recording channel.""" """Retrieves the playback position of a sample, stream, or MOD music. Can also be used with a recording channel."""
return bass_call_0(BASS_ChannelGetPosition, self.handle, mode) return bass_call_0(BASS_ChannelGetPosition, self.handle, mode)
def set_position (self, pos, mode=BASS_POS_BYTE): def set_position (self, pos, mode=BASS_POS_BYTE):
"""Sets the playback position of a sample, MOD music, or stream.""" """Sets the playback position of a sample, MOD music, or stream."""
return bass_call(BASS_ChannelSetPosition, self.handle, pos, mode) return bass_call(BASS_ChannelSetPosition, self.handle, pos, mode)
position = property(get_position, set_position) position = property(get_position, set_position)
def stop (self): def stop (self):
"""Stops a sample, stream, MOD music, or recording.""" """Stops a sample, stream, MOD music, or recording."""
return bass_call(BASS_ChannelStop, self.handle) return bass_call(BASS_ChannelStop, self.handle)
def update (self, length=0): def update (self, length=0):
"""Updates the playback buffer of a stream or MOD music.""" """Updates the playback buffer of a stream or MOD music."""
return bass_call(BASS_ChannelUpdate, self.handle, length) return bass_call(BASS_ChannelUpdate, self.handle, length)
def get_length (self, mode=BASS_POS_BYTE): def get_length (self, mode=BASS_POS_BYTE):
return bass_call_0(BASS_ChannelGetLength, self.handle, mode) return bass_call_0(BASS_ChannelGetLength, self.handle, mode)
__len__ = get_length __len__ = get_length
def __bool__(self): def __nonzero__(self):
return True return True
def get_device(self): def get_device(self):
"""Retrieves the device that a channel is using.""" """Retrieves the device that a channel is using."""
return bass_call_0( BASS_ChannelGetDevice, self.handle) return bass_call_0( BASS_ChannelGetDevice, self.handle)
def set_device (self, device): def set_device (self, device):
"""Changes the device that a stream, MOD music or sample is using.""" """Changes the device that a stream, MOD music or sample is using."""
bass_call(BASS_ChannelSetDevice, self.handle, device) bass_call(BASS_ChannelSetDevice, self.handle, device)
device = property(get_device, set_device) device = property(get_device, set_device)
def set_fx(self, type, priority=0): def set_fx(self, type, priority=0):
"""Sets an effect on a stream, MOD music, or recording channel.""" """Sets an effect on a stream, MOD music, or recording channel."""
return SoundEffect(bass_call(BASS_ChannelSetFX, type, priority)) return SoundEffect(bass_call(BASS_ChannelSetFX, type, priority))
def bytes_to_seconds(self, position=None): def bytes_to_seconds(self, position=None):
"""Translates a byte position into time (seconds), based on a channel's format.""" """Translates a byte position into time (seconds), based on a channel's format."""
position = position or self.position position = position or self.position
return bass_call_0(BASS_ChannelBytes2Seconds, self.handle, position) return bass_call_0(BASS_ChannelBytes2Seconds, self.handle, position)
def length_in_seconds(self): def length_in_seconds(self):
return self.bytes_to_seconds(self.get_length()) return self.bytes_to_seconds(self.get_length())
def seconds_to_bytes(self, position): def seconds_to_bytes(self, position):
"""Translates a time (seconds) position into bytes, based on a channel's format.""" """Translates a time (seconds) position into bytes, based on a channel's format."""
return bass_call_0(BASS_ChannelSeconds2Bytes, self.handle, position) return bass_call_0(BASS_ChannelSeconds2Bytes, self.handle, position)
def get_attribute(self, attribute): def get_attribute(self, attribute):
"""Retrieves the value of a channel's attribute.""" """Retrieves the value of a channel's attribute."""
value = pointer(c_float()) value = pointer(c_float())
if attribute in self.attribute_mapping: if attribute in self.attribute_mapping:
attribute = self.attribute_mapping[attribute] attribute = self.attribute_mapping[attribute]
bass_call(BASS_ChannelGetAttribute, self.handle, attribute, value) bass_call(BASS_ChannelGetAttribute, self.handle, attribute, value)
return value.contents.value return value.contents.value
def set_attribute(self, attribute, value): def set_attribute(self, attribute, value):
"""Sets the value of a channel's attribute.""" """Sets the value of a channel's attribute."""
if attribute in self.attribute_mapping: if attribute in self.attribute_mapping:
attribute = self.attribute_mapping[attribute] attribute = self.attribute_mapping[attribute]
return bass_call(BASS_ChannelSetAttribute, self.handle, attribute, value) return bass_call(BASS_ChannelSetAttribute, self.handle, attribute, value)
def slide_attribute(self, attribute, value, time): def slide_attribute(self, attribute, value, time):
"""Slides a channel's attribute from its current value to a new value.""" """Slides a channel's attribute from its current value to a new value."""
if attribute in self.attribute_mapping: if attribute in self.attribute_mapping:
attribute = self.attribute_mapping[attribute] attribute = self.attribute_mapping[attribute]
return bass_call(BASS_ChannelSlideAttribute, self.handle, attribute, value, time*1000) return bass_call(BASS_ChannelSlideAttribute, self.handle, attribute, value, time*1000)
def is_sliding (self, attribute=None): def is_sliding (self, attribute=None):
"""Checks if an attribute (or any attribute) of a sample, stream, or MOD music is sliding.""" """Checks if an attribute (or any attribute) of a sample, stream, or MOD music is sliding."""
return bass_call_0(BASS_ChannelIsSliding, self.handle, attribute) return bass_call_0(BASS_ChannelIsSliding, self.handle, attribute)
def get_info(self): def get_info(self):
"""Retrieves information on a channel.""" """Retrieves information on a channel."""
value = pointer(BASS_CHANNELINFO()) value = pointer(BASS_CHANNELINFO())
bass_call(BASS_ChannelGetInfo, self.handle, value) bass_call(BASS_ChannelGetInfo, self.handle, value)
return value[0] return value[0]
def get_level(self): def get_level(self):
"""Retrieves the level (peak amplitude) of a stream, MOD music or recording channel.""" """Retrieves the level (peak amplitude) of a stream, MOD music or recording channel."""
return bass_call_0(BASS_ChannelGetLevel, self.handle) return bass_call_0(BASS_ChannelGetLevel, self.handle)
def lock(self): def lock(self):
"""Locks a stream, MOD music or recording channel to the current thread.""" """Locks a stream, MOD music or recording channel to the current thread."""
return bass_call(BASS_ChannelLock, self.handle, True) return bass_call(BASS_ChannelLock, self.handle, True)
def unlock(self): def unlock(self):
"""Unlocks a stream, MOD music or recording channel from the current thread.""" """Unlocks a stream, MOD music or recording channel from the current thread."""
return bass_call(BASS_ChannelLock, self.handle, False) return bass_call(BASS_ChannelLock, self.handle, False)
def get_3d_attributes(self): def get_3d_attributes(self):
"""Retrieves the 3D attributes of a sample, stream, or MOD music channel with 3D functionality.""" """Retrieves the 3D attributes of a sample, stream, or MOD music channel with 3D functionality."""
answer = dict(mode=c_ulong(), min=c_float(), max=c_float(), iangle=c_ulong(), oangle=c_ulong(), outvol=c_float()) answer = dict(mode=c_ulong(), min=c_float(), max=c_float(), iangle=c_ulong(), oangle=c_ulong(), outvol=c_float())
bass_call(BASS_ChannelGet3DAttributes, self.handle, pointer(answer['mode']), pointer(answer['min']), pointer(answer['max']), pointer(answer['iangle']), pointer(answer['oangle']), pointer(answer['outvol'])) bass_call(BASS_ChannelGet3DAttributes, self.handle, pointer(answer['mode']), pointer(answer['min']), pointer(answer['max']), pointer(answer['iangle']), pointer(answer['oangle']), pointer(answer['outvol']))
for k in answer: for k in answer:
answer[k] = answer[k].value() answer[k] = answer[k].value()
return answer return answer
@update_3d_system @update_3d_system
def set_3d_attributes(self, mode=-1, min=0.0, max=0.0, iangle=-1, oangle=-1, outvol=-1): def set_3d_attributes(self, mode=-1, min=0.0, max=0.0, iangle=-1, oangle=-1, outvol=-1):
"""Sets the 3D attributes of a sample, stream, or MOD music channel with 3D functionality.""" """Sets the 3D attributes of a sample, stream, or MOD music channel with 3D functionality."""
return bass_call(BASS_ChannelSet3DAttributes, self.handle, mode, min, max, iangle, oangle, outvol) return bass_call(BASS_ChannelSet3DAttributes, self.handle, mode, min, max, iangle, oangle, outvol)
def get_3d_position(self): def get_3d_position(self):
"""Retrieves the 3D position of a sample, stream, or MOD music channel with 3D functionality.""" """Retrieves the 3D position of a sample, stream, or MOD music channel with 3D functionality."""
answer = dict(position=BASS_3DVECTOR(), orientation=BASS_3DVECTOR(), velocity=BASS_3DVECTOR()) answer = dict(position=BASS_3DVECTOR(), orientation=BASS_3DVECTOR(), velocity=BASS_3DVECTOR())
bass_call(BASS_ChannelGet3DPosition, self.handle, pointer(answer['position']), pointer(answer['orientation']), pointer(answer['velocity'])) bass_call(BASS_ChannelGet3DPosition, self.handle, pointer(answer['position']), pointer(answer['orientation']), pointer(answer['velocity']))
return answer return answer
@update_3d_system @update_3d_system
def set_3d_position(self, position=None, orientation=None, velocity=None): def set_3d_position(self, position=None, orientation=None, velocity=None):
"""Sets the 3D position of a sample, stream, or MOD music channel with 3D functionality.""" """Sets the 3D position of a sample, stream, or MOD music channel with 3D functionality."""
if position: if position:
position = pointer(position) position = pointer(position)
if orientation: if orientation:
orientation = pointer(orientation) orientation = pointer(orientation)
if velocity: if velocity:
velocity = pointer(velocity) velocity = pointer(velocity)
return bass_call(BASS_ChannelSet3DPosition, self.handle, position, orientation, velocity) return bass_call(BASS_ChannelSet3DPosition, self.handle, position, orientation, velocity)
def set_link(self, handle): def set_link(self, handle):
"""Links two MOD music or stream channels together.""" """Links two MOD music or stream channels together."""
bass_call(BASS_ChannelSetLink, self.handle, handle) bass_call(BASS_ChannelSetLink, self.handle, handle)
def remove_link(self, handle): def remove_link(self, handle):
"""Removes a link between two MOD music or stream channels.""" """Removes a link between two MOD music or stream channels."""
return bass_call(BASS_ChannelRemoveLink, self.handle, handle) return bass_call(BASS_ChannelRemoveLink, self.handle, handle)
def __iadd__(self, other): def __iadd__(self, other):
"""Convenience method to link this channel to another. Calls set_link on the passed in item's handle""" """Convenience method to link this channel to another. Calls set_link on the passed in item's handle"""
self.set_link(other.handle) self.set_link(other.handle)
return self return self
def __isub__(self, other): def __isub__(self, other):
"""Convenience method to unlink this channel from another. Calls remove_link on the passed in item's handle""" """Convenience method to unlink this channel from another. Calls remove_link on the passed in item's handle"""
self.remove_link(other.handle) self.remove_link(other.handle)
return self return self
def get_frequency(self): def get_frequency(self):
return self.get_attribute(BASS_ATTRIB_FREQ ) return self.get_attribute(BASS_ATTRIB_FREQ )
def set_frequency(self, frequency): def set_frequency(self, frequency):
self.set_attribute(BASS_ATTRIB_FREQ, frequency) self.set_attribute(BASS_ATTRIB_FREQ, frequency)
frequency = property(fget=get_frequency, fset=set_frequency) frequency = property(fget=get_frequency, fset=set_frequency)
def get_pan(self): def get_pan(self):
return self.get_attribute(BASS_ATTRIB_PAN) return self.get_attribute(BASS_ATTRIB_PAN)
def set_pan(self, pan): def set_pan(self, pan):
return self.set_attribute(BASS_ATTRIB_PAN, pan) return self.set_attribute(BASS_ATTRIB_PAN, pan)
pan = property(fget=get_pan, fset=set_pan) pan = property(fget=get_pan, fset=set_pan)
def get_volume(self): def get_volume(self):
return self.get_attribute(BASS_ATTRIB_VOL) return self.get_attribute(BASS_ATTRIB_VOL)
def set_volume(self, volume): def set_volume(self, volume):
self.set_attribute(BASS_ATTRIB_VOL, volume) self.set_attribute(BASS_ATTRIB_VOL, volume)
volume = property(fget=get_volume, fset=set_volume) volume = property(fget=get_volume, fset=set_volume)
def get_data(self, length=16384): def get_data(self, length=16384):
buf = c_buffer(length) buf = c_buffer(length)
bass_call_0(BASS_ChannelGetData, self.handle, pointer(buf), length) bass_call_0(BASS_ChannelGetData, self.handle, pointer(buf), length)
return buf return buf
#This is less and less of a one-to-one mapping, #This is less and less of a one-to-one mapping,
#But I feel that it's better to be consistent with ourselves #But I feel that it's better to be consistent with ourselves
#Than with the library. We won't punish ourselves #Than with the library. We won't punish ourselves
#For their bad decisions #For their bad decisions
def get_looping(self): def get_looping(self):
return bass_call_0(BASS_ChannelFlags, self.handle, BASS_SAMPLE_LOOP, 0) == 20 return bass_call_0(BASS_ChannelFlags, self.handle, BASS_SAMPLE_LOOP, 0) == 20
def set_looping(self, looping): def set_looping(self, looping):
if looping: if looping:
return bass_call_0(BASS_ChannelFlags, self.handle, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP) return bass_call_0(BASS_ChannelFlags, self.handle, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP)
return bass_call_0(BASS_ChannelFlags, self.handle, 0, BASS_SAMPLE_LOOP) return bass_call_0(BASS_ChannelFlags, self.handle, 0, BASS_SAMPLE_LOOP)
looping = property(fget=get_looping, fset=set_looping) looping = property(fget=get_looping, fset=set_looping)
def __del__(self): def __del__(self):
try: try:
self.free() self.free()
except: except:
pass pass
def get_x(self): def get_x(self):
return self.get_3d_position()['position'].x return self.get_3d_position()['position'].x
def set_x(self, val): def set_x(self, val):
pos = self.get_3d_position() pos = self.get_3d_position()
pos['position'].x = val pos['position'].x = val
self.set_3d_position(**pos) self.set_3d_position(**pos)
x = property(fget=get_x, fset=set_x) x = property(fget=get_x, fset=set_x)
def get_y(self): def get_y(self):
return self.get_3d_position()['position'].y return self.get_3d_position()['position'].y
def set_y(self, val): def set_y(self, val):
pos = self.get_3d_position() pos = self.get_3d_position()
pos['position'].y = val pos['position'].y = val
self.set_3d_position(**pos) self.set_3d_position(**pos)
y = property(fget=get_y, fset=set_y) y = property(fget=get_y, fset=set_y)
def get_z(self): def get_z(self):
return self.get_3d_position()['position'].z return self.get_3d_position()['position'].z
def set_z(self, val): def set_z(self, val):
pos = self.get_3d_position() pos = self.get_3d_position()
pos['position'].z = val pos['position'].z = val
self.set_3d_position(**pos) self.set_3d_position(**pos)
z = property(fget=get_z, fset=set_z) z = property(fget=get_z, fset=set_z)
def get_attributes(self): def get_attributes(self):
"""Retrieves all values of all attributes from this object and displays them in a dictionary whose keys are determined by this object's attribute_mapping""" """Retrieves all values of all attributes from this object and displays them in a dictionary whose keys are determined by this object's attribute_mapping"""
res = {} res = {}
for k in self.attribute_mapping: for k in self.attribute_mapping:
try: try:
res[k] = self.get_attribute(k) res[k] = self.get_attribute(k)
except BassError: except BassError:
pass pass
return res return res

View File

@ -1,57 +1,57 @@
import collections import collections
import ctypes import ctypes
from sound_lib.external import pybass from sound_lib.external import pybass
from sound_lib.main import bass_call, bass_call_0 from sound_lib.main import bass_call, bass_call_0
class BassConfig(collections.Mapping): class BassConfig(collections.Mapping):
config_map = { config_map = {
'3d_algorithm': pybass.BASS_CONFIG_3DALGORITHM, '3d_algorithm': pybass.BASS_CONFIG_3DALGORITHM,
'buffer': pybass.BASS_CONFIG_BUFFER , 'buffer': pybass.BASS_CONFIG_BUFFER ,
'curve_vol': pybass.BASS_CONFIG_CURVE_VOL, 'curve_vol': pybass.BASS_CONFIG_CURVE_VOL,
'curve_pan': pybass.BASS_CONFIG_CURVE_PAN, 'curve_pan': pybass.BASS_CONFIG_CURVE_PAN,
'dev_buffer': pybass.BASS_CONFIG_DEV_BUFFER, 'dev_buffer': pybass.BASS_CONFIG_DEV_BUFFER,
'dev_default': pybass.BASS_CONFIG_DEV_DEFAULT, 'dev_default': pybass.BASS_CONFIG_DEV_DEFAULT,
'float_dsp': pybass.BASS_CONFIG_FLOATDSP, 'float_dsp': pybass.BASS_CONFIG_FLOATDSP,
'gvol_music': pybass.BASS_CONFIG_GVOL_MUSIC, 'gvol_music': pybass.BASS_CONFIG_GVOL_MUSIC,
'gvol_sample': pybass.BASS_CONFIG_GVOL_SAMPLE, 'gvol_sample': pybass.BASS_CONFIG_GVOL_SAMPLE,
'gvol_stream': pybass.BASS_CONFIG_GVOL_STREAM, 'gvol_stream': pybass.BASS_CONFIG_GVOL_STREAM,
'music_virtual': pybass.BASS_CONFIG_MUSIC_VIRTUAL, 'music_virtual': pybass.BASS_CONFIG_MUSIC_VIRTUAL,
'net_agent': pybass.BASS_CONFIG_NET_AGENT, 'net_agent': pybass.BASS_CONFIG_NET_AGENT,
'net_buffer': pybass.BASS_CONFIG_NET_BUFFER, 'net_buffer': pybass.BASS_CONFIG_NET_BUFFER,
'net_passive': pybass.BASS_CONFIG_NET_PASSIVE, 'net_passive': pybass.BASS_CONFIG_NET_PASSIVE,
'net_playlist': pybass.BASS_CONFIG_NET_PLAYLIST, 'net_playlist': pybass.BASS_CONFIG_NET_PLAYLIST,
'net_prebuf': pybass.BASS_CONFIG_NET_PREBUF, 'net_prebuf': pybass.BASS_CONFIG_NET_PREBUF,
'net_proxy': pybass.BASS_CONFIG_NET_PROXY, 'net_proxy': pybass.BASS_CONFIG_NET_PROXY,
'net_read_timeout': pybass.BASS_CONFIG_NET_READTIMEOUT, 'net_read_timeout': pybass.BASS_CONFIG_NET_READTIMEOUT,
'net_timeout': pybass.BASS_CONFIG_NET_TIMEOUT, 'net_timeout': pybass.BASS_CONFIG_NET_TIMEOUT,
'pause_no_play': pybass.BASS_CONFIG_PAUSE_NOPLAY, 'pause_no_play': pybass.BASS_CONFIG_PAUSE_NOPLAY,
'rec_buffer': pybass.BASS_CONFIG_REC_BUFFER, 'rec_buffer': pybass.BASS_CONFIG_REC_BUFFER,
'src': pybass.BASS_CONFIG_SRC, 'src': pybass.BASS_CONFIG_SRC,
'src_sample': pybass.BASS_CONFIG_SRC_SAMPLE, 'src_sample': pybass.BASS_CONFIG_SRC_SAMPLE,
'unicode': pybass.BASS_CONFIG_UNICODE, 'unicode': pybass.BASS_CONFIG_UNICODE,
'update_period': pybass.BASS_CONFIG_UPDATEPERIOD, 'update_period': pybass.BASS_CONFIG_UPDATEPERIOD,
'update_threads': pybass.BASS_CONFIG_UPDATETHREADS, 'update_threads': pybass.BASS_CONFIG_UPDATETHREADS,
'verify': pybass.BASS_CONFIG_VERIFY, 'verify': pybass.BASS_CONFIG_VERIFY,
'vista_speakers': pybass.BASS_CONFIG_VISTA_SPEAKERS, 'vista_speakers': pybass.BASS_CONFIG_VISTA_SPEAKERS,
} }
ptr_config = (pybass.BASS_CONFIG_NET_AGENT, pybass.BASS_CONFIG_NET_PROXY) ptr_config = (pybass.BASS_CONFIG_NET_AGENT, pybass.BASS_CONFIG_NET_PROXY)
def __getitem__(self, key): def __getitem__(self, key):
key = self.config_map.get(key, key) key = self.config_map.get(key, key)
if key in self.ptr_config: if key in self.ptr_config:
return ctypes.string_at(bass_call(pybass.BASS_GetConfigPtr, key)) return ctypes.string_at(bass_call(pybass.BASS_GetConfigPtr, key))
return bass_call_0(pybass.BASS_GetConfig, key) return bass_call_0(pybass.BASS_GetConfig, key)
def __setitem__(self, key, val): def __setitem__(self, key, val):
key = self.config_map.get(key, key) key = self.config_map.get(key, key)
if key in self.ptr_config: if key in self.ptr_config:
return bass_call(pybass.BASS_SetConfigPtr, key, ctypes.create_string_buffer(val)) return bass_call(pybass.BASS_SetConfigPtr, key, ctypes.create_string_buffer(val))
return bass_call(pybass.BASS_SetConfig, key, val) return bass_call(pybass.BASS_SetConfig, key, val)
def __iter__(self): def __iter__(self):
for key in self.config_map.keys(): for key in self.config_map.iterkeys():
yield key yield key
def __len__(self): def __len__(self):
return len(self.config_map) return len(self.config_map)

View File

@ -1 +1,2 @@
from .tempo import Tempo from __future__ import absolute_import
from .tempo import Tempo

View File

@ -1,39 +1,39 @@
from __future__ import absolute_import from __future__ import absolute_import
from sound_lib.external import pybass from sound_lib.external import pybass
from .effect import SoundEffect from .effect import SoundEffect
class Chorus(SoundEffect): class Chorus(SoundEffect):
effect_type = pybass.BASS_FX_DX8_CHORUS effect_type = pybass.BASS_FX_DX8_CHORUS
struct = pybass.BASS_DX8_CHORUS struct = pybass.BASS_DX8_CHORUS
class Echo(SoundEffect): class Echo(SoundEffect):
effect_type = pybass.BASS_FX_DX8_ECHO effect_type = pybass.BASS_FX_DX8_ECHO
struct = pybass.BASS_DX8_ECHO struct = pybass.BASS_DX8_ECHO
class Compressor(SoundEffect): class Compressor(SoundEffect):
effect_type = pybass.BASS_FX_DX8_COMPRESSOR effect_type = pybass.BASS_FX_DX8_COMPRESSOR
struct = pybass.BASS_DX8_COMPRESSOR struct = pybass.BASS_DX8_COMPRESSOR
class Reverb(SoundEffect): class Reverb(SoundEffect):
effect_type = pybass.BASS_FX_DX8_REVERB effect_type = pybass.BASS_FX_DX8_REVERB
struct = pybass.BASS_DX8_REVERB struct = pybass.BASS_DX8_REVERB
class Distortion(SoundEffect): class Distortion(SoundEffect):
effect_type = pybass.BASS_FX_DX8_DISTORTION effect_type = pybass.BASS_FX_DX8_DISTORTION
struct = pybass.BASS_DX8_DISTORTION struct = pybass.BASS_DX8_DISTORTION
class Flanger(SoundEffect): class Flanger(SoundEffect):
effect_type = pybass.BASS_FX_DX8_FLANGER effect_type = pybass.BASS_FX_DX8_FLANGER
struct = pybass.BASS_DX8_FLANGER struct = pybass.BASS_DX8_FLANGER
class Gargle(SoundEffect): class Gargle(SoundEffect):
effect_type = pybass.BASS_FX_DX8_GARGLE effect_type = pybass.BASS_FX_DX8_GARGLE
struct = pybass.BASS_DX8_GARGLE struct = pybass.BASS_DX8_GARGLE
class I3DL2Reverb(SoundEffect): class I3DL2Reverb(SoundEffect):
effect_type = pybass.BASS_FX_DX8_I3DL2REVERB effect_type = pybass.BASS_FX_DX8_I3DL2REVERB
struct = pybass.BASS_DX8_I3DL2REVERB struct = pybass.BASS_DX8_I3DL2REVERB
class ParamEq(SoundEffect): class ParamEq(SoundEffect):
effect_type = pybass.BASS_FX_DX8_PARAMEQ effect_type = pybass.BASS_FX_DX8_PARAMEQ
struct = pybass.BASS_DX8_PARAMEQ struct = pybass.BASS_DX8_PARAMEQ

View File

@ -1,14 +1,13 @@
from __future__ import absolute_import from sound_lib.external import pybass_fx
from sound_lib.external import pybass_fx from effect import SoundEffect
from .effect import SoundEffect
class Volume(SoundEffect):
class Volume(SoundEffect): effect_type = pybass_fx.BASS_FX_BFX_VOLUME
effect_type = pybass_fx.BASS_FX_BFX_VOLUME struct = pybass_fx.BASS_BFX_VOLUME
struct = pybass_fx.BASS_BFX_VOLUME
class PeakEq(SoundEffect):
class PeakEq(SoundEffect): effect_type = pybass_fx.BASS_FX_BFX_PEAKEQ
effect_type = pybass_fx.BASS_FX_BFX_PEAKEQ struct = pybass_fx.BASS_BFX_PEAKEQ
struct = pybass_fx.BASS_BFX_PEAKEQ class DAmp(SoundEffect):
class DAmp(SoundEffect): effect_type = pybass_fx.BASS_FX_BFX_DAMP
effect_type = pybass_fx.BASS_FX_BFX_DAMP struct = pybass_fx.BASS_BFX_DAMP
struct = pybass_fx.BASS_BFX_DAMP

View File

@ -1,71 +1,70 @@
from future.builtins import object from sound_lib.main import bass_call
from sound_lib.main import bass_call import ctypes
import ctypes from sound_lib.external import pybass
from sound_lib.external import pybass import string #for the alphabet!
import string #for the alphabet!
class SoundEffect(object):
class SoundEffect(object):
def __init__(self, channel, type=None, priority=0):
def __init__(self, channel, type=None, priority=0): self.original_channel = channel
self.original_channel = channel if hasattr(channel, 'handle'):
if hasattr(channel, 'handle'): channel = channel.handle
channel = channel.handle if type is None:
if type is None: type = self.effect_type
type = self.effect_type self.effect_type = type
self.effect_type = type self.priority = priority
self.priority = priority self.handle = bass_call(pybass.BASS_ChannelSetFX, channel, type, priority)
self.handle = bass_call(pybass.BASS_ChannelSetFX, channel, type, priority)
def get_parameters(self):
def get_parameters(self): """Retrieves the parameters of an effect."""
"""Retrieves the parameters of an effect.""" res = {}
res = {} params = self.struct()
params = self.struct() bass_call(pybass.BASS_FXGetParameters, self.handle, ctypes.pointer(params))
bass_call(pybass.BASS_FXGetParameters, self.handle, ctypes.pointer(params)) for f in params._fields_:
for f in params._fields_: res[f[0]] = getattr(params, f[0])
res[f[0]] = getattr(params, f[0]) return res
return res
def set_parameters(self, parameters):
def set_parameters(self, parameters): params = self.struct()
params = self.struct() for p, v in parameters.items():
for p, v in parameters.items(): setattr(params, p, v)
setattr(params, p, v) bass_call(pybass.BASS_FXSetParameters, self.handle, ctypes.pointer(params))
bass_call(pybass.BASS_FXSetParameters, self.handle, ctypes.pointer(params))
def __dir__(self):
def __dir__(self): res = dir(self.__class__)
res = dir(self.__class__) return res + self._get_pythonic_effect_fields()
return res + self._get_pythonic_effect_fields()
def _get_effect_fields(self):
def _get_effect_fields(self): return [i[0] for i in self.struct._fields_]
return [i[0] for i in self.struct._fields_]
def _get_pythonic_effect_fields(self):
def _get_pythonic_effect_fields(self): return [self._bass_to_python(i) for i in self._get_effect_fields() if not i.startswith('_') ]
return [self._bass_to_python(i) for i in self._get_effect_fields() if not i.startswith('_') ]
def _bass_to_python(self, func):
def _bass_to_python(self, func): for c in string.ascii_lowercase:
for c in string.ascii_lowercase: func = func.replace(c.upper(), '_%s' % c)
func = func.replace(c.upper(), '_%s' % c) if func.startswith('_'):
if func.startswith('_'): func = func[1:]
func = func[1:] return func[2:]
return func[2:]
def _python_to_bass(self, func):
def _python_to_bass(self, func): for c in string.ascii_lowercase:
for c in string.ascii_lowercase: func = func.replace('_%s' % c, c.upper())
func = func.replace('_%s' % c, c.upper()) func = '%s%s' % (func[0].upper(), func[1:])
func = '%s%s' % (func[0].upper(), func[1:]) for f in self._get_effect_fields():
for f in self._get_effect_fields(): if f.endswith(func):
if f.endswith(func): func = f
func = f return func
return func
def __getattr__(self, attr):
def __getattr__(self, attr): return self.get_parameters()[self._python_to_bass(attr)]
return self.get_parameters()[self._python_to_bass(attr)]
def __setattr__(self, attr, val):
def __setattr__(self, attr, val): if attr not in self._get_pythonic_effect_fields():
if attr not in self._get_pythonic_effect_fields(): return super(SoundEffect, self).__setattr__(attr, val)
return super(SoundEffect, self).__setattr__(attr, val) params = self.get_parameters()
params = self.get_parameters() key = self._python_to_bass(attr)
key = self._python_to_bass(attr) if key not in params:
if key not in params: raise AttributeError('Unable to set attribute, suspect issue with base name-munging code')
raise AttributeError('Unable to set attribute, suspect issue with base name-munging code') params[key] = val
params[key] = val self.set_parameters(params)
self.set_parameters(params)

View File

@ -1,65 +1,66 @@
import ctypes from __future__ import absolute_import
from sound_lib.external import pybass, pybass_fx import ctypes
from sound_lib.stream import BaseStream from ..external import pybass, pybass_fx
from sound_lib.channel import Channel from ..stream import BaseStream
from sound_lib.main import bass_call, bass_call_0 from ..channel import Channel
from ..main import bass_call, bass_call_0
class Tempo(BaseStream):
class Tempo(BaseStream):
def __init__(self, channel, flags=0, loop=False, software=False, three_d=False, sample_fx=False, autofree=False, decode=False, free_source=False):
flags = flags | self.flags_for(loop=False, software=False, three_d=False, sample_fx=False, autofree=False, decode=False, free_source=False) def __init__(self, channel, flags=0, loop=False, software=False, three_d=False, sample_fx=False, autofree=False, decode=False, free_source=False):
self.channel = channel flags = flags | self.flags_for(loop=False, software=False, three_d=False, sample_fx=False, autofree=False, decode=False, free_source=False)
if isinstance(channel, Channel): self.channel = channel
channel = channel.handle if isinstance(channel, Channel):
handle = bass_call(pybass_fx.BASS_FX_TempoCreate, channel, flags) channel = channel.handle
super(Tempo, self).__init__(handle) handle = bass_call(pybass_fx.BASS_FX_TempoCreate, channel, flags)
self.add_attributes_to_mapping( super(Tempo, self).__init__(handle)
tempo=pybass_fx.BASS_ATTRIB_TEMPO, self.add_attributes_to_mapping(
tempo_pitch=pybass_fx.BASS_ATTRIB_TEMPO_PITCH, tempo=pybass_fx.BASS_ATTRIB_TEMPO,
tempo_freq=pybass_fx.BASS_ATTRIB_TEMPO_FREQ, tempo_pitch=pybass_fx.BASS_ATTRIB_TEMPO_PITCH,
) tempo_freq=pybass_fx.BASS_ATTRIB_TEMPO_FREQ,
)
@property
def tempo(self): @property
"""The tempo of a channel.""" def tempo(self):
return self.get_attribute(pybass_fx.BASS_ATTRIB_TEMPO) """The tempo of a channel."""
return self.get_attribute(pybass_fx.BASS_ATTRIB_TEMPO)
@tempo.setter
def tempo(self, val): @tempo.setter
self.set_attribute('tempo', val) def tempo(self, val):
self.set_attribute('tempo', val)
@property
def tempo_pitch(self): @property
return self.get_attribute('tempo_pitch') def tempo_pitch(self):
return self.get_attribute('tempo_pitch')
@tempo_pitch.setter
def tempo_pitch(self, val): @tempo_pitch.setter
self.set_attribute('tempo_pitch', val) def tempo_pitch(self, val):
self.set_attribute('tempo_pitch', val)
@property
def tempo_freq(self): @property
return self.get_attribute('tempo_freq') def tempo_freq(self):
return self.get_attribute('tempo_freq')
@tempo_freq.setter
def tempo_freq(self, val): @tempo_freq.setter
self.set_attribute('tempo_freq', val) def tempo_freq(self, val):
self.set_attribute('tempo_freq', val)
def setup_flag_mapping(self):
super(Tempo, self).setup_flag_mapping() def setup_flag_mapping(self):
self.flag_mapping.update({ super(Tempo, self).setup_flag_mapping()
'free_source': pybass_fx.BASS_FX_FREESOURCE, self.flag_mapping.update({
}) 'free_source': pybass_fx.BASS_FX_FREESOURCE,
})
def get_source(self):
source = pybass_fx.BASS_FX_TempoGetSource(self.handle) def get_source(self):
if source == self.channel.handle: source = pybass_fx.BASS_FX_TempoGetSource(self.handle)
source = self.channel if source == self.channel.handle:
return source source = self.channel
return source
source = property(fget=get_source)
source = property(fget=get_source)
def get_rate_ratio(self):
return bass_call(pybass_fx.BASS_FX_TempoGetRateRatio, self.handle) def get_rate_ratio(self):
return bass_call(pybass_fx.BASS_FX_TempoGetRateRatio, self.handle)
rate_ratio = property(fget=get_rate_ratio)
rate_ratio = property(fget=get_rate_ratio)

View File

@ -1,81 +1,80 @@
from __future__ import absolute_import from external import pybass, pybassenc
from .external import pybass, pybassenc from main import bass_call, bass_call_0, FlagObject
from .main import bass_call, bass_call_0, FlagObject
class Encoder(FlagObject):
class Encoder(FlagObject):
def setup_flag_mapping(self):
def setup_flag_mapping(self): #super(Encoder, self).setup_flag_mapping()
#super(Encoder, self).setup_flag_mapping() self.flag_mapping = {
self.flag_mapping = { 'pcm': pybassenc.BASS_ENCODE_PCM,
'pcm': pybassenc.BASS_ENCODE_PCM, 'no_header': pybassenc.BASS_ENCODE_NOHEAD,
'no_header': pybassenc.BASS_ENCODE_NOHEAD, 'rf64': pybassenc.BASS_ENCODE_RF64,
'rf64': pybassenc.BASS_ENCODE_RF64, 'big_endian': pybassenc.BASS_ENCODE_BIGEND,
'big_endian': pybassenc.BASS_ENCODE_BIGEND, 'fp_8bit': pybassenc.BASS_ENCODE_FP_8BIT,
'fp_8bit': pybassenc.BASS_ENCODE_FP_8BIT, 'fp_16bit': pybassenc.BASS_ENCODE_FP_16BIT,
'fp_16bit': pybassenc.BASS_ENCODE_FP_16BIT, 'fp_24bit': pybassenc.BASS_ENCODE_FP_24BIT,
'fp_24bit': pybassenc.BASS_ENCODE_FP_24BIT, 'fp_32bit': pybassenc.BASS_ENCODE_FP_32BIT,
'fp_32bit': pybassenc.BASS_ENCODE_FP_32BIT, 'queue': pybassenc.BASS_ENCODE_QUEUE,
'queue': pybassenc.BASS_ENCODE_QUEUE, 'limit': pybassenc.BASS_ENCODE_LIMIT,
'limit': pybassenc.BASS_ENCODE_LIMIT, 'no_limit': pybassenc.BASS_ENCODE_CAST_NOLIMIT,
'no_limit': pybassenc.BASS_ENCODE_CAST_NOLIMIT, 'pause': pybassenc.BASS_ENCODE_PAUSE,
'pause': pybassenc.BASS_ENCODE_PAUSE, 'autofree': pybassenc.BASS_ENCODE_AUTOFREE,
'autofree': pybassenc.BASS_ENCODE_AUTOFREE, 'unicode': pybass.BASS_UNICODE,
'unicode': pybass.BASS_UNICODE, }
}
def __init__(self, source, command_line, pcm=False, no_header=False, rf64=False, big_endian=False, fp_8bit=False, fp_16bit=False, fp_24bit=False, fp_32bit=False, queue=False, limit=False, no_limit=False, pause=True, autofree=False, callback=None, user=None):
def __init__(self, source, command_line, pcm=False, no_header=False, rf64=False, big_endian=False, fp_8bit=False, fp_16bit=False, fp_24bit=False, fp_32bit=False, queue=False, limit=False, no_limit=False, pause=True, autofree=False, callback=None, user=None): self.setup_flag_mapping()
self.setup_flag_mapping() flags = self.flags_for(pcm=pcm, no_header=no_header, rf64=rf64, big_endian=big_endian, fp_8bit=fp_8bit, fp_16bit=fp_16bit, fp_24bit=fp_24bit, fp_32bit=fp_32bit, queue=queue, limit=limit, no_limit=no_limit, pause=pause, autofree=autofree) #fwiw!
flags = self.flags_for(pcm=pcm, no_header=no_header, rf64=rf64, big_endian=big_endian, fp_8bit=fp_8bit, fp_16bit=fp_16bit, fp_24bit=fp_24bit, fp_32bit=fp_32bit, queue=queue, limit=limit, no_limit=no_limit, pause=pause, autofree=autofree) #fwiw! self.source = source
self.source = source source_handle = source.handle
source_handle = source.handle if callback is None:
if callback is None: callback = lambda *a: None
callback = lambda *a: None callback = pybassenc.ENCODEPROC(callback)
callback = pybassenc.ENCODEPROC(callback) self.callback = callback
self.callback = callback self.handle = bass_call(pybassenc.BASS_Encode_Start, source_handle, command_line, flags, callback, user)
self.handle = bass_call(pybassenc.BASS_Encode_Start, source_handle, command_line, flags, callback, user)
@property
@property def paused(self):
def paused(self): return bass_call_0(pybassenc.BASS_Encode_IsActive, self.handle) == pybass.BASS_ACTIVE_PAUSED
return bass_call_0(pybassenc.BASS_Encode_IsActive, self.handle) == pybass.BASS_ACTIVE_PAUSED
@paused.setter
@paused.setter def paused(self, paused):
def paused(self, paused): return bass_call(pybassenc.BASS_Encode_SetPaused, self.handle, paused)
return bass_call(pybassenc.BASS_Encode_SetPaused, self.handle, paused)
def is_stopped(self):
def is_stopped(self): return bass_call_0(pybassenc.BASS_Encode_IsActive, self.handle) == pybass.BASS_ACTIVE_STOPPED
return bass_call_0(pybassenc.BASS_Encode_IsActive, self.handle) == pybass.BASS_ACTIVE_STOPPED
def stop(self):
def stop(self): return bass_call(pybassenc.BASS_Encode_Stop, self.handle)
return bass_call(pybassenc.BASS_Encode_Stop, self.handle)
class BroadcastEncoder(Encoder):
class BroadcastEncoder(Encoder):
def __init__(self, source_encoder, server, password, content, name=None, url=None, genre=None, description=None, headers=None, bitrate=0, public=False):
def __init__(self, source_encoder, server, password, content, name=None, url=None, genre=None, description=None, headers=None, bitrate=0, public=False): contents = {
contents = { 'mp3': pybassenc.BASS_ENCODE_TYPE_MP3,
'mp3': pybassenc.BASS_ENCODE_TYPE_MP3, 'ogg': pybassenc.BASS_ENCODE_TYPE_OGG,
'ogg': pybassenc.BASS_ENCODE_TYPE_OGG, 'aac': pybassenc.BASS_ENCODE_TYPE_AAC
'aac': pybassenc.BASS_ENCODE_TYPE_AAC }
} if content in contents:
if content in contents: content = contents[content]
content = contents[content] self.source_encoder = source_encoder
self.source_encoder = source_encoder handle = source_encoder.handle
handle = source_encoder.handle self.server = server
self.server = server self.password = password
self.password = password self.status = bass_call(pybassenc.BASS_Encode_CastInit, handle, server, password, content, name, url, genre, description, headers, bitrate, public)
self.status = bass_call(pybassenc.BASS_Encode_CastInit, handle, server, password, content, name, url, genre, description, headers, bitrate, public)
def set_title(self, title=None, url=None):
def set_title(self, title=None, url=None): return bass_call(pybassenc.BASS_Encode_CastSetTitle, self.source_encoder.handle, title, url)
return bass_call(pybassenc.BASS_Encode_CastSetTitle, self.source_encoder.handle, title, url)
def get_stats(self, type, password=None):
def get_stats(self, type, password=None): types = {
types = { 'shoutcast': pybassenc.BASS_ENCODE_STATS_SHOUT,
'shoutcast': pybassenc.BASS_ENCODE_STATS_SHOUT, 'icecast': pybassenc.BASS_ENCODE_STATS_ICE,
'icecast': pybassenc.BASS_ENCODE_STATS_ICE, 'icecast_server': pybassenc.BASS_ENCODE_STATS_ICESERV,
'icecast_server': pybassenc.BASS_ENCODE_STATS_ICESERV, }
} if type in types:
if type in types: type = types[type]
type = types[type] if password is None:
if password is None: password = self.password
password = self.password return bass_call(pybassenc.BASS_Encode_CastGetStats, self.handle, type, password)
return bass_call(pybassenc.BASS_Encode_CastGetStats, self.handle, type, password)

View File

@ -1,9 +1,10 @@
import platform from __future__ import absolute_import
#if platform.system() == 'Windows': import platform
# import sound_lib.external.pybasswma from . import pybassopus
if platform.system() != 'Darwin': if platform.system() == 'Windows':
import sound_lib.external.pybass_aac from . import pybasswma
import sound_lib.external.pybass_alac if platform.system() != 'Darwin':
import sound_lib.external.pybassopus from . import pybass_aac
import sound_lib.external.pybassflac from . import pybass_alac
import sound_lib.external.pybassmidi from . import pybassflac
from . import pybassmidi

View File

@ -1,9 +1,9 @@
import os import os
from platform_utils.paths import module_path, is_frozen, embedded_data_path from platform_utils.paths import module_path, is_frozen, embedded_data_path
if is_frozen(): if is_frozen():
x86_path = os.path.join(embedded_data_path(), 'sound_lib', 'lib', 'x86') x86_path = os.path.join(embedded_data_path(), 'sound_lib', 'lib', 'x86')
x64_path = os.path.join(embedded_data_path(), 'sound_lib', 'lib', 'x64') x64_path = os.path.join(embedded_data_path(), 'sound_lib', 'lib', 'x64')
else: else:
x86_path = os.path.join(module_path(), '..', 'lib', 'x86') x86_path = os.path.join(module_path(), '..', 'lib', 'x86')
x64_path = os.path.join(module_path(), '..', 'lib', 'x64') x64_path = os.path.join(module_path(), '..', 'lib', 'x64')

File diff suppressed because it is too large Load Diff

View File

@ -1,54 +1,53 @@
from __future__ import absolute_import from __future__ import absolute_import
# Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru # Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru
# http://vosolok2008.narod.ru # http://vosolok2008.narod.ru
# BSD license # BSD license
__version__ = '0.1' __version__ = '0.1'
__versionTime__ = '2009-11-15' __versionTime__ = '2009-11-15'
__author__ = 'Max Kolosov <maxkolosov@inbox.ru>' __author__ = 'Max Kolosov <maxkolosov@inbox.ru>'
__doc__ = ''' __doc__ = '''
pybass_aac.py - is ctypes python module for pybass_aac.py - is ctypes python module for
BASS_AAC - extension to the BASS audio library that enables the playback BASS_AAC - extension to the BASS audio library that enables the playback
of Advanced Audio Coding and MPEG-4 streams (http://www.maresweb.de). of Advanced Audio Coding and MPEG-4 streams (http://www.maresweb.de).
''' '''
import os, sys, ctypes import os, sys, ctypes
from . import pybass from . import pybass
from .paths import x86_path, x64_path from .paths import x86_path, x64_path
import libloader import libloader
bass_aac_module = libloader.load_library('bass_aac', x86_path=x86_path, x64_path=x64_path) bass_aac_module = libloader.load_library('bass_aac', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype() func_type = libloader.get_functype()
#Register the plugin with the Bass plugin system. #Register the plugin with the Bass plugin system.
pybass.BASS_PluginLoad(libloader.find_library_path('bass_aac', x86_path=x86_path, x64_path=x64_path), 0) pybass.BASS_PluginLoad(libloader.find_library_path('bass_aac', x86_path=x86_path, x64_path=x64_path), 0)
QWORD = pybass.QWORD QWORD = pybass.QWORD
HSTREAM = pybass.HSTREAM HSTREAM = pybass.HSTREAM
DOWNLOADPROC = pybass.DOWNLOADPROC DOWNLOADPROC = pybass.DOWNLOADPROC
BASS_FILEPROCS = pybass.BASS_FILEPROCS BASS_FILEPROCS = pybass.BASS_FILEPROCS
# Additional BASS_SetConfig options # Additional BASS_SetConfig options
BASS_CONFIG_MP4_VIDEO = 0x10700 # play the audio from MP4 videos BASS_CONFIG_MP4_VIDEO = 0x10700 # play the audio from MP4 videos
# Additional tags available from BASS_StreamGetTags (for MP4 files) # Additional tags available from BASS_StreamGetTags (for MP4 files)
BASS_TAG_MP4 = 7 # MP4/iTunes metadata BASS_TAG_MP4 = 7 # MP4/iTunes metadata
BASS_AAC_STEREO = 0x400000 # downmatrix to stereo BASS_AAC_STEREO = 0x400000 # downmatrix to stereo
# BASS_CHANNELINFO type # BASS_CHANNELINFO type
BASS_CTYPE_STREAM_AAC = 0x10b00 # AAC BASS_CTYPE_STREAM_AAC = 0x10b00 # AAC
BASS_CTYPE_STREAM_MP4 = 0x10b01 # MP4 BASS_CTYPE_STREAM_MP4 = 0x10b01 # MP4
#HSTREAM BASSAACDEF(BASS_AAC_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags); #HSTREAM BASSAACDEF(BASS_AAC_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
BASS_AAC_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_AAC_StreamCreateFile', bass_aac_module)) BASS_AAC_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_AAC_StreamCreateFile', bass_aac_module))
#HSTREAM BASSAACDEF(BASS_AAC_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user); #HSTREAM BASSAACDEF(BASS_AAC_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user);
BASS_AAC_StreamCreateURL = func_type(HSTREAM, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, DOWNLOADPROC, ctypes.c_void_p)(('BASS_AAC_StreamCreateURL', bass_aac_module)) BASS_AAC_StreamCreateURL = func_type(HSTREAM, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, DOWNLOADPROC, ctypes.c_void_p)(('BASS_AAC_StreamCreateURL', bass_aac_module))
#HSTREAM BASSAACDEF(BASS_AAC_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user); #HSTREAM BASSAACDEF(BASS_AAC_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);
BASS_AAC_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_AAC_StreamCreateFileUser', bass_aac_module)) BASS_AAC_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_AAC_StreamCreateFileUser', bass_aac_module))
#HSTREAM BASSAACDEF(BASS_MP4_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags); #HSTREAM BASSAACDEF(BASS_MP4_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
BASS_MP4_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_MP4_StreamCreateFile', bass_aac_module)) BASS_MP4_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_MP4_StreamCreateFile', bass_aac_module))
#HSTREAM BASSAACDEF(BASS_MP4_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user); #HSTREAM BASSAACDEF(BASS_MP4_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);
BASS_MP4_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_MP4_StreamCreateFileUser', bass_aac_module)) BASS_MP4_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_MP4_StreamCreateFileUser', bass_aac_module))

View File

@ -1,24 +1,24 @@
from __future__ import absolute_import from __future__ import absolute_import
"BASS_ALAC wrapper by Christopher Toth""" "BASS_ALAC wrapper by Christopher Toth"""
import ctypes import ctypes
import os import os
from . import pybass from . import pybass
from .paths import x86_path, x64_path from .paths import x86_path, x64_path
import libloader import libloader
bass_fx_module = libloader.load_library('bass_alac', x86_path=x86_path, x64_path=x64_path) bass_fx_module = libloader.load_library('bass_alac', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype() func_type = libloader.get_functype()
pybass.BASS_PluginLoad(libloader.find_library_path('bass_alac', x86_path=x86_path, x64_path=x64_path), 0) pybass.BASS_PluginLoad(libloader.find_library_path('bass_alac', x86_path=x86_path, x64_path=x64_path), 0)
BASS_TAG_MP4 = 7 BASS_TAG_MP4 = 7
BASS_CTYPE_STREAM_ALAC = 0x10e00 BASS_CTYPE_STREAM_ALAC = 0x10e00
#HSTREAM BASSALACDEF(BASS_ALAC_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags); #HSTREAM BASSALACDEF(BASS_ALAC_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
BASS_ALAC_StreamCreateFile = func_type(pybass.HSTREAM, ctypes.c_byte, ctypes.c_void_p, pybass.QWORD, pybass.QWORD, ctypes.c_ulong) BASS_ALAC_StreamCreateFile = func_type(pybass.HSTREAM, ctypes.c_byte, ctypes.c_void_p, pybass.QWORD, pybass.QWORD, ctypes.c_ulong)
#HSTREAM BASSALACDEF(BASS_ALAC_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user); #HSTREAM BASSALACDEF(BASS_ALAC_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);
BASS_ALAC_StreamCreateFileUser = func_type(pybass.HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_void_p) BASS_ALAC_StreamCreateFileUser = func_type(pybass.HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_void_p)

View File

@ -1,384 +1,383 @@
from __future__ import absolute_import from __future__ import absolute_import
from future.builtins import range "BASS_FX wrapper by Christopher Toth"""
"BASS_FX wrapper by Christopher Toth"""
import ctypes
import ctypes import os
import os from . import pybass
from . import pybass from .paths import x86_path, x64_path
from .paths import x86_path, x64_path import libloader
import libloader
bass_fx_module = libloader.load_library('bass_fx', x86_path=x86_path, x64_path=x64_path)
bass_fx_module = libloader.load_library('bass_fx', x86_path=x86_path, x64_path=x64_path) func_type = libloader.get_functype()
func_type = libloader.get_functype()
#Error codes returned by BASS_ErrorGetCode
#Error codes returned by BASS_ErrorGetCode BASS_ERROR_FX_NODECODE = 4000
BASS_ERROR_FX_NODECODE = 4000 BASS_ERROR_FX_BPMINUSE = 4001
BASS_ERROR_FX_BPMINUSE = 4001
#Tempo / Reverse / BPM / Beat flag
#Tempo / Reverse / BPM / Beat flag BASS_FX_FREESOURCE = 0x10000
BASS_FX_FREESOURCE = 0x10000
#BASS_FX Version
#BASS_FX Version BASS_FX_GetVersion = func_type(ctypes.c_ulong)(('BASS_FX_GetVersion', bass_fx_module))
BASS_FX_GetVersion = func_type(ctypes.c_ulong)(('BASS_FX_GetVersion', bass_fx_module))
"""D S P (Digital Signal Processing)"""
"""D S P (Digital Signal Processing)"""
"""
""" Multi-channel order of each channel is as follows:
Multi-channel order of each channel is as follows: 3 channels left-front, right-front, center.
3 channels left-front, right-front, center. 4 channels left-front, right-front, left-rear/side, right-rear/side.
4 channels left-front, right-front, left-rear/side, right-rear/side. 6 channels (5.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side.
6 channels (5.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side. 8 channels (7.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side, left-rear center, right-rear center.
8 channels (7.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side, left-rear center, right-rear center. """
"""
#DSP channels flags
#DSP channels flags BASS_BFX_CHANALL = -1 #all channels at once (as by default)
BASS_BFX_CHANALL = -1 #all channels at once (as by default) BASS_BFX_CHANNONE = 0 #disable an effect for all channels
BASS_BFX_CHANNONE = 0 #disable an effect for all channels BASS_BFX_CHAN1 = 1 #left-front channel
BASS_BFX_CHAN1 = 1 #left-front channel BASS_BFX_CHAN2 = 2 #right-front channel
BASS_BFX_CHAN2 = 2 #right-front channel BASS_BFX_CHAN3 = 4 #see above info
BASS_BFX_CHAN3 = 4 #see above info BASS_BFX_CHAN4 = 8 #see above info
BASS_BFX_CHAN4 = 8 #see above info BASS_BFX_CHAN5 = 16
BASS_BFX_CHAN5 = 16 BASS_BFX_CHAN6 = 32
BASS_BFX_CHAN6 = 32 BASS_BFX_CHAN7 = 64
BASS_BFX_CHAN7 = 64 BASS_BFX_CHAN8 = 128
BASS_BFX_CHAN8 = 128
#DSP effects
#DSP effects (
( BASS_FX_BFX_ROTATE,
BASS_FX_BFX_ROTATE, BASS_FX_BFX_ECHO,
BASS_FX_BFX_ECHO, BASS_FX_BFX_FLANGER,
BASS_FX_BFX_FLANGER, BASS_FX_BFX_VOLUME,
BASS_FX_BFX_VOLUME, BASS_FX_BFX_PEAKEQ,
BASS_FX_BFX_PEAKEQ, BASS_FX_BFX_REVERB,
BASS_FX_BFX_REVERB, BASS_FX_BFX_LPF,
BASS_FX_BFX_LPF, BASS_FX_BFX_MIX,
BASS_FX_BFX_MIX, BASS_FX_BFX_DAMP,
BASS_FX_BFX_DAMP, BASS_FX_BFX_AUTOWAH,
BASS_FX_BFX_AUTOWAH, BASS_FX_BFX_ECHO2,
BASS_FX_BFX_ECHO2, BASS_FX_BFX_PHASER,
BASS_FX_BFX_PHASER, BASS_FX_BFX_ECHO3,
BASS_FX_BFX_ECHO3, BASS_FX_BFX_CHORUS,
BASS_FX_BFX_CHORUS, BASS_FX_BFX_APF,
BASS_FX_BFX_APF, BASS_FX_BFX_COMPRESSOR,
BASS_FX_BFX_COMPRESSOR, BASS_FX_BFX_DISTORTION,
BASS_FX_BFX_DISTORTION, BASS_FX_BFX_COMPRESSOR2,
BASS_FX_BFX_COMPRESSOR2, BASS_FX_BFX_VOLUME_ENV,
BASS_FX_BFX_VOLUME_ENV, BASS_FX_BFX_BQF,
BASS_FX_BFX_BQF, ) = range(0x10000, 0x10000+20)
) = range(0x10000, 0x10000+20)
#BiQuad filters
#BiQuad filters (
( BASS_BFX_BQF_LOWPASS,
BASS_BFX_BQF_LOWPASS, BASS_BFX_BQF_HIGHPASS,
BASS_BFX_BQF_HIGHPASS, BASS_BFX_BQF_BANDPASS, #constant 0 dB peak gain
BASS_BFX_BQF_BANDPASS, #constant 0 dB peak gain BASS_BFX_BQF_BANDPASS_Q, #constant skirt gain, peak gain = Q
BASS_BFX_BQF_BANDPASS_Q, #constant skirt gain, peak gain = Q BASS_BFX_BQF_NOTCH,
BASS_BFX_BQF_NOTCH, BASS_BFX_BQF_ALLPASS,
BASS_BFX_BQF_ALLPASS, BASS_BFX_BQF_PEAKINGEQ,
BASS_BFX_BQF_PEAKINGEQ, BASS_BFX_BQF_LOWSHELF,
BASS_BFX_BQF_LOWSHELF, BASS_BFX_BQF_HIGHSHELF,
BASS_BFX_BQF_HIGHSHELF, ) = range(9)
) = range(9)
#Echo
#Echo class BASS_BFX_ECHO(ctypes.Structure):
class BASS_BFX_ECHO(ctypes.Structure): _fields_ = [
_fields_ = [ ('fLevel', ctypes.c_float), #[0....1....n] linear
('fLevel', ctypes.c_float), #[0....1....n] linear ('lDelay', ctypes.c_int), #[1200..30000]
('lDelay', ctypes.c_int), #[1200..30000] ]
]
#Flanger
#Flanger class BASS_BFX_FLANGER(ctypes.Structure):
class BASS_BFX_FLANGER(ctypes.Structure): _fields_ = [
_fields_ = [ ('fWetDry', ctypes.c_float), #[0....1....n] linear
('fWetDry', ctypes.c_float), #[0....1....n] linear ('fSpeed', ctypes.c_float), #[0......0.09]
('fSpeed', ctypes.c_float), #[0......0.09] ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#volume
#volume class BASS_BFX_VOLUME(ctypes.Structure):
class BASS_BFX_VOLUME(ctypes.Structure): _fields_ = [
_fields_ = [ ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s or 0 for global volume control
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s or 0 for global volume control ('fVolume', ctypes.c_float), #[0....1....n] linear
('fVolume', ctypes.c_float), #[0....1....n] linear ]
]
#Peaking Equalizer
#Peaking Equalizer class BASS_BFX_PEAKEQ(ctypes.Structure):
class BASS_BFX_PEAKEQ(ctypes.Structure): _fields_ = [
_fields_ = [ ('lBand', ctypes.c_int), #[0...............n] more bands means more memory & cpu usage
('lBand', ctypes.c_int), #[0...............n] more bands means more memory & cpu usage ('fBandwidth', ctypes.c_float), #[0.1...........<10] in octaves - fQ is not in use (Bandwidth has a priority over fQ)
('fBandwidth', ctypes.c_float), #[0.1...........<10] in octaves - fQ is not in use (Bandwidth has a priority over fQ) ('fQ', ctypes.c_float), #[0...............1] the EE kinda definition (linear) (if Bandwidth is not in use)
('fQ', ctypes.c_float), #[0...............1] the EE kinda definition (linear) (if Bandwidth is not in use) ('fCenter', ctypes.c_float), #[1Hz..<info.freq/2] in Hz
('fCenter', ctypes.c_float), #[1Hz..<info.freq/2] in Hz ('fGain', ctypes.c_float), #[-15dB...0...+15dB] in dB
('fGain', ctypes.c_float), #[-15dB...0...+15dB] in dB ('lChannel', ctypes.c_float), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_float), #BASS_BFX_CHANxxx flag/s ]
]
#Reverb
#Reverb class BASS_BFX_REVERB(ctypes.Structure):
class BASS_BFX_REVERB(ctypes.Structure): _fields_ = [
_fields_ = [ ('fLevel', ctypes.c_float), #[0....1....n] linear
('fLevel', ctypes.c_float), #[0....1....n] linear ('lDelay', ctypes.c_int), #[1200..10000]
('lDelay', ctypes.c_int), #[1200..10000] ]
]
#Low Pass Filter
#Low Pass Filter class BASS_BFX_LPF(ctypes.Structure):
class BASS_BFX_LPF(ctypes.Structure): _fields_ = [
_fields_ = [ ('fResonance', ctypes.c_float), #[0.01...........10]
('fResonance', ctypes.c_float), #[0.01...........10] ('fCutOffFreq', ctypes.c_float), #[1Hz...info.freq/2] cutoff frequency
('fCutOffFreq', ctypes.c_float), #[1Hz...info.freq/2] cutoff frequency ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#Swap, remap and mix
#Swap, remap and mix class BASS_BFX_MIX(ctypes.Structure):
class BASS_BFX_MIX(ctypes.Structure): _fields_ = [
_fields_ = [ ('lChannel', ctypes.c_int), #an array of channels to mix using BASS_BFX_CHANxxx flag/s (lChannel[0] is left channel...)
('lChannel', ctypes.c_int), #an array of channels to mix using BASS_BFX_CHANxxx flag/s (lChannel[0] is left channel...) ]
]
#Dynamic Amplification
#Dynamic Amplification class BASS_BFX_DAMP(ctypes.Structure):
class BASS_BFX_DAMP(ctypes.Structure): _fields_ = [
_fields_ = [ ('fTarget', ctypes.c_float), #target volume level [0<......1] linear
('fTarget', ctypes.c_float), #target volume level [0<......1] linear ('fQuiet', ctypes.c_float), #quiet volume level [0.......1] linear
('fQuiet', ctypes.c_float), #quiet volume level [0.......1] linear ('fRate', ctypes.c_float), #amp adjustment rate [0.......1] linear
('fRate', ctypes.c_float), #amp adjustment rate [0.......1] linear ('fGain', ctypes.c_float), #amplification level [0...1...n] linear
('fGain', ctypes.c_float), #amplification level [0...1...n] linear ('fDelay', ctypes.c_float), #delay in seconds before increasing level [0.......n] linear
('fDelay', ctypes.c_float), #delay in seconds before increasing level [0.......n] linear ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#Auto WAH
#Auto WAH class BASS_BFX_AUTOWAH(ctypes.Structure):
class BASS_BFX_AUTOWAH(ctypes.Structure): _fields_ = [
_fields_ = [ ('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-2......2]
('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-2......2] ('fWetMix', ctypes.c_float), #wet (affected) signal mix [-2......2]
('fWetMix', ctypes.c_float), #wet (affected) signal mix [-2......2] ('fFeedback', ctypes.c_float), #feedback [-1......1]
('fFeedback', ctypes.c_float), #feedback [-1......1] ('fRate', ctypes.c_float), #rate of sweep in cycles per second [0<....<10]
('fRate', ctypes.c_float), #rate of sweep in cycles per second [0<....<10] ('fRange', ctypes.c_float), #sweep range in octaves [0<....<10]
('fRange', ctypes.c_float), #sweep range in octaves [0<....<10] ('fFreq', ctypes.c_float), #base frequency of sweep Hz [0<...1000]
('fFreq', ctypes.c_float), #base frequency of sweep Hz [0<...1000] ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#Echo 2
#Echo 2 class BASS_BFX_ECHO2(ctypes.Structure):
class BASS_BFX_ECHO2(ctypes.Structure): _fields_ = [
_fields_ = [ ('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-2......2]
('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-2......2] ('fWetMix', ctypes.c_float), #wet (affected) signal mix [-2......2]
('fWetMix', ctypes.c_float), #wet (affected) signal mix [-2......2] ('fFeedback', ctypes.c_float), #feedback [-1......1]
('fFeedback', ctypes.c_float), #feedback [-1......1] ('fDelay', ctypes.c_float), #delay sec [0<......n]
('fDelay', ctypes.c_float), #delay sec [0<......n] ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#Phaser
#Phaser class BASS_BFX_PHASER(ctypes.Structure):
class BASS_BFX_PHASER(ctypes.Structure): _fields_ = [
_fields_ = [ ('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-2......2]
('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-2......2] ('fWetMix', ctypes.c_float), #wet (affected) signal mix [-2......2]
('fWetMix', ctypes.c_float), #wet (affected) signal mix [-2......2] ('fFeedback', ctypes.c_float), #feedback [-1......1]
('fFeedback', ctypes.c_float), #feedback [-1......1] ('fRate', ctypes.c_float), #rate of sweep in cycles per second [0<....<10]
('fRate', ctypes.c_float), #rate of sweep in cycles per second [0<....<10] ('fRange', ctypes.c_float), #sweep range in octaves [0<....<10]
('fRange', ctypes.c_float), #sweep range in octaves [0<....<10] ('fFreq', ctypes.c_float), #base frequency of sweep [0<...1000]
('fFreq', ctypes.c_float), #base frequency of sweep [0<...1000] ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#Echo 3
#Echo 3 class BASS_BFX_ECHO3(ctypes.Structure):
class BASS_BFX_ECHO3(ctypes.Structure): _fields_ = [
_fields_ = [ ('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-2......2]
('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-2......2] ('fWetMix', ctypes.c_float), #wet (affected) signal mix [-2......2]
('fWetMix', ctypes.c_float), #wet (affected) signal mix [-2......2] ('fDelay', ctypes.c_float), #delay sec [0<......n]
('fDelay', ctypes.c_float), #delay sec [0<......n] ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#Chorus
#Chorus class BASS_BFX_CHORUS(ctypes.Structure):
class BASS_BFX_CHORUS(ctypes.Structure): _fields_ = [
_fields_ = [ ('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-2......2]
('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-2......2] ('fWetMix', ctypes.c_float), #wet (affected) signal mix [-2......2]
('fWetMix', ctypes.c_float), #wet (affected) signal mix [-2......2] ('fFeedback', ctypes.c_float), #feedback [-1......1]
('fFeedback', ctypes.c_float), #feedback [-1......1] ('fMinSweep', ctypes.c_float), #minimal delay ms [0<...6000]
('fMinSweep', ctypes.c_float), #minimal delay ms [0<...6000] ('fMaxSweep', ctypes.c_float), #maximum delay ms [0<...6000]
('fMaxSweep', ctypes.c_float), #maximum delay ms [0<...6000] ('fRate', ctypes.c_float), #rate ms/s [0<...1000]
('fRate', ctypes.c_float), #rate ms/s [0<...1000] ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#All Pass Filter
#All Pass Filter class BASS_BFX_APF(ctypes.Structure):
class BASS_BFX_APF(ctypes.Structure): _fields_ = [
_fields_ = [ ('fGain', ctypes.c_float), #reverberation time [-1=<..<=1]
('fGain', ctypes.c_float), #reverberation time [-1=<..<=1] ('fDelay', ctypes.c_float), #delay sec [0<....<=n]
('fDelay', ctypes.c_float), #delay sec [0<....<=n] ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#Compressor
#Compressor class BASS_BFX_COMPRESSOR(ctypes.Structure):
class BASS_BFX_COMPRESSOR(ctypes.Structure): _fields_ = [
_fields_ = [ ('fThreshold', ctypes.c_float), #compressor threshold [0<=...<=1]
('fThreshold', ctypes.c_float), #compressor threshold [0<=...<=1] ('fAttacktime', ctypes.c_float), #attack time ms [0<.<=1000]
('fAttacktime', ctypes.c_float), #attack time ms [0<.<=1000] ('fReleasetime', ctypes.c_float), #release time ms [0<.<=5000]
('fReleasetime', ctypes.c_float), #release time ms [0<.<=5000] ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#Distortion
#Distortion class BASS_BFX_DISTORTION(ctypes.Structure):
class BASS_BFX_DISTORTION(ctypes.Structure): _fields_ = [
_fields_ = [ ('fDrive', ctypes.c_float), #distortion drive [0<=...<=5]
('fDrive', ctypes.c_float), #distortion drive [0<=...<=5] ('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-5<=..<=5]
('fDryMix', ctypes.c_float), #dry (unaffected) signal mix [-5<=..<=5] ('fWetMix', ctypes.c_float), #wet (affected) signal mix [-5<=..<=5]
('fWetMix', ctypes.c_float), #wet (affected) signal mix [-5<=..<=5] ('fFeedback', ctypes.c_float), #feedback [-1<=..<=1]
('fFeedback', ctypes.c_float), #feedback [-1<=..<=1] ('fVolume', ctypes.c_float), #distortion volume [0=<...<=2]
('fVolume', ctypes.c_float), #distortion volume [0=<...<=2] ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
#Compressor 2
#Compressor 2 class BASS_BFX_COMPRESSOR2(ctypes.Structure):
class BASS_BFX_COMPRESSOR2(ctypes.Structure): _fields_ = [
_fields_ = [ ('fGain', ctypes.c_float), #output gain of signal after compression [-60....60] in dB
('fGain', ctypes.c_float), #output gain of signal after compression [-60....60] in dB ('fThreshold', ctypes.c_float), #point at which compression begins [-60.....0] in dB
('fThreshold', ctypes.c_float), #point at which compression begins [-60.....0] in dB ('fRatio', ctypes.c_float), #compression ratio [1.......n]
('fRatio', ctypes.c_float), #compression ratio [1.......n] ('fAttack', ctypes.c_float), #attack time in ms [0.01.1000]
('fAttack', ctypes.c_float), #attack time in ms [0.01.1000] ('fRelease', ctypes.c_float), #release time in ms [0.01.5000]
('fRelease', ctypes.c_float), #release time in ms [0.01.5000] ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
class BASS_BFX_ENV_NODE(ctypes.Structure):
class BASS_BFX_ENV_NODE(ctypes.Structure): _fields_ = [
_fields_ = [ ('pos', ctypes.c_long), #node position in seconds (1st envelope node must be at position 0)
('pos', ctypes.c_long), #node position in seconds (1st envelope node must be at position 0) ('val', ctypes.c_float), #node value
('val', ctypes.c_float), #node value ]
]
#Volume envelope
#Volume envelope class BASS_BFX_VOLUME_ENV(ctypes.Structure):
class BASS_BFX_VOLUME_ENV(ctypes.Structure): _fields_ = [
_fields_ = [ ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ('lNodeCount', ctypes.c_int), #number of nodes
('lNodeCount', ctypes.c_int), #number of nodes ('pNodes', BASS_BFX_ENV_NODE), #the nodes
('pNodes', BASS_BFX_ENV_NODE), #the nodes ('bFollow', ctypes.c_bool), #follow source position
('bFollow', ctypes.c_bool), #follow source position ]
]
#BiQuad Filters
#BiQuad Filters
class BASS_BFX_BQF(ctypes.Structure):
class BASS_BFX_BQF(ctypes.Structure): _fields_ = [
_fields_ = [ ('lFilter', ctypes.c_int), #BASS_BFX_BQF_xxx filter types
('lFilter', ctypes.c_int), #BASS_BFX_BQF_xxx filter types ('fCenter', ctypes.c_float), #[1Hz..<info.freq/2] Cutoff (central) frequency in Hz
('fCenter', ctypes.c_float), #[1Hz..<info.freq/2] Cutoff (central) frequency in Hz ('fGain', ctypes.c_float), #[-15dB...0...+15dB] Used only for PEAKINGEQ and Shelving filters in dB
('fGain', ctypes.c_float), #[-15dB...0...+15dB] Used only for PEAKINGEQ and Shelving filters in dB ('fBandwidth', ctypes.c_float), #[0.1...........<10] Bandwidth in octaves (fQ is not in use (fBandwidth has a priority over fQ))
('fBandwidth', ctypes.c_float), #[0.1...........<10] Bandwidth in octaves (fQ is not in use (fBandwidth has a priority over fQ)) #(between -3 dB frequencies for BANDPASS and NOTCH or between midpoint
#(between -3 dB frequencies for BANDPASS and NOTCH or between midpoint #(fGgain/2) gain frequencies for PEAKINGEQ)
#(fGgain/2) gain frequencies for PEAKINGEQ) ('fQ', ctypes.c_float), #[0.1.............1] The EE kinda definition (linear) (if fBandwidth is not in use)
('fQ', ctypes.c_float), #[0.1.............1] The EE kinda definition (linear) (if fBandwidth is not in use) ('fS', ctypes.c_float), #[0.1.............1] A "shelf slope" parameter (linear) (used only with Shelving filters)
('fS', ctypes.c_float), #[0.1.............1] A "shelf slope" parameter (linear) (used only with Shelving filters) #when fS = 1, the shelf slope is as steep as you can get it and remain monotonically
#when fS = 1, the shelf slope is as steep as you can get it and remain monotonically #increasing or decreasing gain with frequency.
#increasing or decreasing gain with frequency. ('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s
('lChannel', ctypes.c_int), #BASS_BFX_CHANxxx flag/s ]
]
"""TEMPO / PITCH SCALING / SAMPLERATE"""
"""TEMPO / PITCH SCALING / SAMPLERATE"""
"""NOTES: 1. Supported only - mono / stereo - channels
"""NOTES: 1. Supported only - mono / stereo - channels 2. Enable Tempo supported flags in BASS_FX_TempoCreate and the others to source handle.
2. Enable Tempo supported flags in BASS_FX_TempoCreate and the others to source handle. tempo attributes (BASS_ChannelSet/GetAttribute)"""
tempo attributes (BASS_ChannelSet/GetAttribute)"""
(
( BASS_ATTRIB_TEMPO,
BASS_ATTRIB_TEMPO, BASS_ATTRIB_TEMPO_PITCH,
BASS_ATTRIB_TEMPO_PITCH, BASS_ATTRIB_TEMPO_FREQ,
BASS_ATTRIB_TEMPO_FREQ, ) = range(0x10000, 0x10000+3)
) = range(0x10000, 0x10000+3)
#tempo attributes options
#tempo attributes options #[option] [value]
#[option] [value]
(
( BASS_ATTRIB_TEMPO_OPTION_USE_AA_FILTER, #TRUE (default) / FALSE
BASS_ATTRIB_TEMPO_OPTION_USE_AA_FILTER, #TRUE (default) / FALSE BASS_ATTRIB_TEMPO_OPTION_AA_FILTER_LENGTH, #32 default (8 .. 128 taps)
BASS_ATTRIB_TEMPO_OPTION_AA_FILTER_LENGTH, #32 default (8 .. 128 taps) BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO, #TRUE / FALSE (default)
BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO, #TRUE / FALSE (default) BASS_ATTRIB_TEMPO_OPTION_SEQUENCE_MS, #82 default, 0 = automatic
BASS_ATTRIB_TEMPO_OPTION_SEQUENCE_MS, #82 default, 0 = automatic BASS_ATTRIB_TEMPO_OPTION_SEEKWINDOW_MS, #28 default, 0 = automatic
BASS_ATTRIB_TEMPO_OPTION_SEEKWINDOW_MS, #28 default, 0 = automatic BASS_ATTRIB_TEMPO_OPTION_OVERLAP_MS, #8 default
BASS_ATTRIB_TEMPO_OPTION_OVERLAP_MS, #8 default BASS_ATTRIB_TEMPO_OPTION_PREVENT_CLICK, #TRUE / FALSE (default)
BASS_ATTRIB_TEMPO_OPTION_PREVENT_CLICK, #TRUE / FALSE (default) ) = range(0x10000, 0x10000+7)
) = range(0x10000, 0x10000+7)
#HSTREAM BASS_FXDEF(BASS_FX_TempoCreate)(DWORD chan, DWORD flags);
#HSTREAM BASS_FXDEF(BASS_FX_TempoCreate)(DWORD chan, DWORD flags); BASS_FX_TempoCreate = func_type(pybass.HSTREAM, ctypes.c_ulong, ctypes.c_ulong)(('BASS_FX_TempoCreate', bass_fx_module))
BASS_FX_TempoCreate = func_type(pybass.HSTREAM, ctypes.c_ulong, ctypes.c_ulong)(('BASS_FX_TempoCreate', bass_fx_module))
#DWORD BASS_FXDEF(BASS_FX_TempoGetSource)(HSTREAM chan);
#DWORD BASS_FXDEF(BASS_FX_TempoGetSource)(HSTREAM chan); BASS_FX_TempoGetSource = func_type(ctypes.c_ulong, pybass.HSTREAM)(('BASS_FX_TempoGetSource', bass_fx_module))
BASS_FX_TempoGetSource = func_type(ctypes.c_ulong, pybass.HSTREAM)(('BASS_FX_TempoGetSource', bass_fx_module))
#float BASS_FXDEF(BASS_FX_TempoGetRateRatio)(HSTREAM chan);
#float BASS_FXDEF(BASS_FX_TempoGetRateRatio)(HSTREAM chan); BASS_FX_TempoGetRateRatio = func_type(ctypes.c_float, pybass.HSTREAM)(('BASS_FX_TempoGetRateRatio', bass_fx_module))
BASS_FX_TempoGetRateRatio = func_type(ctypes.c_float, pybass.HSTREAM)(('BASS_FX_TempoGetRateRatio', bass_fx_module))
"""R E V E R S E"""
"""R E V E R S E""" """NOTES: 1. MODs won't load without BASS_MUSIC_PRESCAN flag.
"""NOTES: 1. MODs won't load without BASS_MUSIC_PRESCAN flag. 2. Enable Reverse supported flags in BASS_FX_ReverseCreate and the others to source handle."""
2. Enable Reverse supported flags in BASS_FX_ReverseCreate and the others to source handle."""
#reverse attribute (BASS_ChannelSet/GetAttribute)
#reverse attribute (BASS_ChannelSet/GetAttribute) BASS_ATTRIB_REVERSE_DIR = 0x11000
BASS_ATTRIB_REVERSE_DIR = 0x11000
#playback directions
#playback directions BASS_FX_RVS_REVERSE = -1
BASS_FX_RVS_REVERSE = -1 BASS_FX_RVS_FORWARD = 1
BASS_FX_RVS_FORWARD = 1
#HSTREAM BASS_FXDEF(BASS_FX_ReverseCreate)(DWORD chan, float dec_block, DWORD flags);
#HSTREAM BASS_FXDEF(BASS_FX_ReverseCreate)(DWORD chan, float dec_block, DWORD flags); BASS_FX_ReverseCreate = func_type(pybass.HSTREAM, ctypes.c_ulong, ctypes.c_float, ctypes.c_ulong)(('BASS_FX_ReverseCreate', bass_fx_module))
BASS_FX_ReverseCreate = func_type(pybass.HSTREAM, ctypes.c_ulong, ctypes.c_float, ctypes.c_ulong)(('BASS_FX_ReverseCreate', bass_fx_module))
#DWORD BASS_FXDEF(BASS_FX_ReverseGetSource)(HSTREAM chan);
#DWORD BASS_FXDEF(BASS_FX_ReverseGetSource)(HSTREAM chan); BASS_FX_ReverseGetSource = func_type(ctypes.c_ulong, pybass.HSTREAM)(('BASS_FX_ReverseGetSource', bass_fx_module))
BASS_FX_ReverseGetSource = func_type(ctypes.c_ulong, pybass.HSTREAM)(('BASS_FX_ReverseGetSource', bass_fx_module))
"""B P M (Beats Per Minute)"""
"""B P M (Beats Per Minute)"""
#bpm flags
#bpm flags BASS_FX_BPM_BKGRND = 1 #if in use, then you can do other processing while detection's in progress. Not available in MacOSX yet. (BPM/Beat)
BASS_FX_BPM_BKGRND = 1 #if in use, then you can do other processing while detection's in progress. Not available in MacOSX yet. (BPM/Beat) BASS_FX_BPM_MULT2 = 2 #if in use, then will auto multiply bpm by 2 (if BPM < minBPM*2)
BASS_FX_BPM_MULT2 = 2 #if in use, then will auto multiply bpm by 2 (if BPM < minBPM*2)
#translation options
#translation options (
( BASS_FX_BPM_TRAN_X2, #multiply the original BPM value by 2 (may be called only once & will change the original BPM as well!)
BASS_FX_BPM_TRAN_X2, #multiply the original BPM value by 2 (may be called only once & will change the original BPM as well!) BASS_FX_BPM_TRAN_2FREQ, #BPM value to Frequency
BASS_FX_BPM_TRAN_2FREQ, #BPM value to Frequency BASS_FX_BPM_TRAN_FREQ2, #Frequency to BPM value
BASS_FX_BPM_TRAN_FREQ2, #Frequency to BPM value BASS_FX_BPM_TRAN_2PERCENT, #BPM value to Percents
BASS_FX_BPM_TRAN_2PERCENT, #BPM value to Percents BASS_FX_BPM_TRAN_PERCENT2 , #Percents to BPM value
BASS_FX_BPM_TRAN_PERCENT2 , #Percents to BPM value ) = range(5)
) = range(5)
#typedef void (CALLBACK BPMPROCESSPROC)(DWORD chan, float percent);
#typedef void (CALLBACK BPMPROCESSPROC)(DWORD chan, float percent); BPMPROCESSPROC = func_type(None, ctypes.c_float)
BPMPROCESSPROC = func_type(None, ctypes.c_float)
#typedef void (CALLBACK BPMPROC)(DWORD chan, float bpm, void *user);
#typedef void (CALLBACK BPMPROC)(DWORD chan, float bpm, void *user); BPMPROC = func_type(None, ctypes.c_long, ctypes.c_float, ctypes.c_void_p)
BPMPROC = func_type(None, ctypes.c_long, ctypes.c_float, ctypes.c_void_p)
#float BASS_FXDEF(BASS_FX_BPM_DecodeGet)(DWORD chan, double startSec, double endSec, DWORD minMaxBPM, DWORD flags, BPMPROCESSPROC *proc);
#float BASS_FXDEF(BASS_FX_BPM_DecodeGet)(DWORD chan, double startSec, double endSec, DWORD minMaxBPM, DWORD flags, BPMPROCESSPROC *proc); BASS_FX_BPM_DecodeGet = func_type(ctypes.c_float, ctypes.c_ulong, ctypes.c_double, ctypes.c_double, ctypes.c_ulong, ctypes.c_ulong, BPMPROCESSPROC)(('BASS_FX_BPM_DecodeGet', bass_fx_module))
BASS_FX_BPM_DecodeGet = func_type(ctypes.c_float, ctypes.c_ulong, ctypes.c_double, ctypes.c_double, ctypes.c_ulong, ctypes.c_ulong, BPMPROCESSPROC)(('BASS_FX_BPM_DecodeGet', bass_fx_module))
#BOOL BASS_FXDEF(BASS_FX_BPM_CallbackSet)(DWORD handle, BPMPROC *proc, double period, DWORD minMaxBPM, DWORD flags, void *user);
#BOOL BASS_FXDEF(BASS_FX_BPM_CallbackSet)(DWORD handle, BPMPROC *proc, double period, DWORD minMaxBPM, DWORD flags, void *user); BASS_FX_BPM_CallbackSet = func_type(ctypes.c_bool, ctypes.c_ulong, BPMPROC, ctypes.c_double, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_void_p)(('BASS_FX_BPM_CallbackSet', bass_fx_module))
BASS_FX_BPM_CallbackSet = func_type(ctypes.c_bool, ctypes.c_ulong, BPMPROC, ctypes.c_double, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_void_p)(('BASS_FX_BPM_CallbackSet', bass_fx_module))
#BOOL BASS_FXDEF(BASS_FX_BPM_CallbackReset)(DWORD handle);
#BOOL BASS_FXDEF(BASS_FX_BPM_CallbackReset)(DWORD handle); BASS_FX_BPM_CallbackReset = func_type(ctypes.c_bool, ctypes.c_ulong)(('BASS_FX_BPM_CallbackReset', bass_fx_module))
BASS_FX_BPM_CallbackReset = func_type(ctypes.c_bool, ctypes.c_ulong)(('BASS_FX_BPM_CallbackReset', bass_fx_module))
#float BASS_FXDEF(BASS_FX_BPM_Translate)(DWORD handle, float val2tran, DWORD trans);
#float BASS_FXDEF(BASS_FX_BPM_Translate)(DWORD handle, float val2tran, DWORD trans); BASS_FX_BPM_Translate = func_type(ctypes.c_float, ctypes.c_ulong, ctypes.c_float, ctypes.c_ulong)(('BASS_FX_BPM_Translate', bass_fx_module))
BASS_FX_BPM_Translate = func_type(ctypes.c_float, ctypes.c_ulong, ctypes.c_float, ctypes.c_ulong)(('BASS_FX_BPM_Translate', bass_fx_module))
#BOOL BASS_FXDEF(BASS_FX_BPM_Free)(DWORD handle);
#BOOL BASS_FXDEF(BASS_FX_BPM_Free)(DWORD handle); BASS_FX_BPM_Free = func_type(ctypes.c_bool, ctypes.c_ulong)(('BASS_FX_BPM_Free', bass_fx_module))
BASS_FX_BPM_Free = func_type(ctypes.c_bool, ctypes.c_ulong)(('BASS_FX_BPM_Free', bass_fx_module))
""" Beat """
""" Beat """
#typedef void (CALLBACK BPMBEATPROC)(DWORD chan, double beatpos, void *user);
#typedef void (CALLBACK BPMBEATPROC)(DWORD chan, double beatpos, void *user); BPMBEATPROC = func_type(None, ctypes.c_ulong, ctypes.c_double, ctypes.c_void_p)
BPMBEATPROC = func_type(None, ctypes.c_ulong, ctypes.c_double, ctypes.c_void_p)
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatCallbackSet)(DWORD handle, BPMBEATPROC *proc, void *user);
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatCallbackSet)(DWORD handle, BPMBEATPROC *proc, void *user); BASS_FX_BPM_BeatCallbackSet = func_type(ctypes.c_bool, ctypes.c_ulong, ctypes.c_void_p)(('BASS_FX_BPM_BeatCallbackSet', bass_fx_module))
BASS_FX_BPM_BeatCallbackSet = func_type(ctypes.c_bool, ctypes.c_ulong, ctypes.c_void_p)(('BASS_FX_BPM_BeatCallbackSet', bass_fx_module))
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatCallbackReset)(DWORD handle);
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatCallbackReset)(DWORD handle); BASS_FX_BPM_BeatCallbackReset = func_type(ctypes.c_bool, ctypes.c_ulong)(('BASS_FX_BPM_BeatCallbackReset', bass_fx_module))
BASS_FX_BPM_BeatCallbackReset = func_type(ctypes.c_bool, ctypes.c_ulong)(('BASS_FX_BPM_BeatCallbackReset', bass_fx_module))
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatDecodeGet)(DWORD chan, double startSec, double endSec, DWORD flags, BPMBEATPROC *proc, void *user);
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatDecodeGet)(DWORD chan, double startSec, double endSec, DWORD flags, BPMBEATPROC *proc, void *user); BASS_FX_BPM_BeatDecodeGet = func_type(ctypes.c_bool, ctypes.c_ulong, ctypes.c_double, ctypes.c_double, ctypes.c_ulong, BPMBEATPROC, ctypes.c_void_p)(('BASS_FX_BPM_BeatDecodeGet', bass_fx_module))
BASS_FX_BPM_BeatDecodeGet = func_type(ctypes.c_bool, ctypes.c_ulong, ctypes.c_double, ctypes.c_double, ctypes.c_ulong, BPMBEATPROC, ctypes.c_void_p)(('BASS_FX_BPM_BeatDecodeGet', bass_fx_module))
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatSetParameters)(DWORD handle, float bandwidth, float centerfreq, float beat_rtime);
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatSetParameters)(DWORD handle, float bandwidth, float centerfreq, float beat_rtime); BASS_FX_BPM_BeatSetParameters = func_type(ctypes.c_bool, ctypes.c_ulong, ctypes.c_float, ctypes.c_float, ctypes.c_float)(('BASS_FX_BPM_BeatSetParameters', bass_fx_module))
BASS_FX_BPM_BeatSetParameters = func_type(ctypes.c_bool, ctypes.c_ulong, ctypes.c_float, ctypes.c_float, ctypes.c_float)(('BASS_FX_BPM_BeatSetParameters', bass_fx_module))
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatGetParameters)(DWORD handle, float *bandwidth, float *centerfreq, float *beat_rtime);
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatGetParameters)(DWORD handle, float *bandwidth, float *centerfreq, float *beat_rtime); BASS_FX_BPM_BeatGetParameters = func_type(ctypes.c_bool, ctypes.c_ulong, ctypes.c_float, ctypes.c_float, ctypes.c_float)(('BASS_FX_BPM_BeatGetParameters', bass_fx_module))
BASS_FX_BPM_BeatGetParameters = func_type(ctypes.c_bool, ctypes.c_ulong, ctypes.c_float, ctypes.c_float, ctypes.c_float)(('BASS_FX_BPM_BeatGetParameters', bass_fx_module))
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatFree)(DWORD handle);
#BOOL BASS_FXDEF(BASS_FX_BPM_BeatFree)(DWORD handle); BASS_FX_BPM_BeatFree = func_type(ctypes.c_bool, ctypes.c_ulong)(('BASS_FX_BPM_BeatFree', bass_fx_module))
BASS_FX_BPM_BeatFree = func_type(ctypes.c_bool, ctypes.c_ulong)(('BASS_FX_BPM_BeatFree', bass_fx_module))

View File

@ -1,170 +1,168 @@
from __future__ import absolute_import "BASSENC wrapper by Christopher Toth"""
from future.builtins import range
"BASSENC wrapper by Christopher Toth""" import ctypes
import os
import ctypes import platform
import os import pybass
import platform from paths import x86_path, x64_path
from . import pybass import libloader
from .paths import x86_path, x64_path
import libloader bassenc_module = libloader.load_library('bassenc', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype()
bassenc_module = libloader.load_library('bassenc', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype() HENCODE = ctypes.c_ulong #encoder handle
HENCODE = ctypes.c_ulong #encoder handle #Additional error codes returned by BASS_ErrorGetCode
BASS_ERROR_ACM_CANCEL = 2000 #ACM codec selection cancelled
#Additional error codes returned by BASS_ErrorGetCode pybass.error_descriptions[BASS_ERROR_ACM_CANCEL] = "ACM codec selection cancelled"
BASS_ERROR_ACM_CANCEL = 2000 #ACM codec selection cancelled BASS_ERROR_CAST_DENIED = 2100 #access denied (invalid password)
pybass.error_descriptions[BASS_ERROR_ACM_CANCEL] = "ACM codec selection cancelled" pybass.error_descriptions[BASS_ERROR_CAST_DENIED] = "access denied (invalid password)"
BASS_ERROR_CAST_DENIED = 2100 #access denied (invalid password)
pybass.error_descriptions[BASS_ERROR_CAST_DENIED] = "access denied (invalid password)" #Additional BASS_SetConfig options
BASS_CONFIG_ENCODE_PRIORITY = 0x10300
#Additional BASS_SetConfig options BASS_CONFIG_ENCODE_QUEUE = 0x10301
BASS_CONFIG_ENCODE_PRIORITY = 0x10300 BASS_CONFIG_ENCODE_CAST_TIMEOUT = 0x10310
BASS_CONFIG_ENCODE_QUEUE = 0x10301
BASS_CONFIG_ENCODE_CAST_TIMEOUT = 0x10310 #Additional BASS_SetConfigPtr options
BASS_CONFIG_ENCODE_CAST_PROXY = 0x10311
#Additional BASS_SetConfigPtr options
BASS_CONFIG_ENCODE_CAST_PROXY = 0x10311 #BASS_Encode_Start flags
BASS_ENCODE_NOHEAD = 1 #don't send a WAV header to the encoder
#BASS_Encode_Start flags BASS_ENCODE_FP_8BIT = 2 #convert floating-point sample data to 8-bit integer
BASS_ENCODE_NOHEAD = 1 #don't send a WAV header to the encoder BASS_ENCODE_FP_16BIT = 4 #convert floating-point sample data to 16-bit integer
BASS_ENCODE_FP_8BIT = 2 #convert floating-point sample data to 8-bit integer BASS_ENCODE_FP_24BIT = 6#convert floating-point sample data to 24-bit integer
BASS_ENCODE_FP_16BIT = 4 #convert floating-point sample data to 16-bit integer BASS_ENCODE_FP_32BIT = 8 #convert floating-point sample data to 32-bit integer
BASS_ENCODE_FP_24BIT = 6#convert floating-point sample data to 24-bit integer BASS_ENCODE_BIGEND = 16 #big-endian sample data
BASS_ENCODE_FP_32BIT = 8 #convert floating-point sample data to 32-bit integer BASS_ENCODE_PAUSE = 32 #start encoding paused
BASS_ENCODE_BIGEND = 16 #big-endian sample data BASS_ENCODE_PCM = 64 #write PCM sample data (no encoder)
BASS_ENCODE_PAUSE = 32 #start encoding paused BASS_ENCODE_RF64 = 128 #send an RF64 header
BASS_ENCODE_PCM = 64 #write PCM sample data (no encoder) BASS_ENCODE_MONO = 256 #convert to mono (if not already)
BASS_ENCODE_RF64 = 128 #send an RF64 header BASS_ENCODE_QUEUE = 512 #queue data to feed encoder asynchronously
BASS_ENCODE_MONO = 256 #convert to mono (if not already) BASS_ENCODE_CAST_NOLIMIT = 0x1000 #don't limit casting data rate
BASS_ENCODE_QUEUE = 512 #queue data to feed encoder asynchronously BASS_ENCODE_LIMIT = 0x2000 #limit data rate to real-time
BASS_ENCODE_CAST_NOLIMIT = 0x1000 #don't limit casting data rate BASS_ENCODE_AUTOFREE = 0x40000 #free the encoder when the channel is freed
BASS_ENCODE_LIMIT = 0x2000 #limit data rate to real-time
BASS_ENCODE_AUTOFREE = 0x40000 #free the encoder when the channel is freed #BASS_Encode_GetACMFormat flags
BASS_ACM_DEFAULT = 1 #use the format as default selection
#BASS_Encode_GetACMFormat flags BASS_ACM_RATE = 2 #only list formats with same sample rate as the source channel
BASS_ACM_DEFAULT = 1 #use the format as default selection BASS_ACM_CHANS = 4 #only list formats with same number of channels (eg. mono/stereo)
BASS_ACM_RATE = 2 #only list formats with same sample rate as the source channel BASS_ACM_SUGGEST = 8 #suggest a format (HIWORD=format tag)
BASS_ACM_CHANS = 4 #only list formats with same number of channels (eg. mono/stereo)
BASS_ACM_SUGGEST = 8 #suggest a format (HIWORD=format tag) #BASS_Encode_GetCount counts
#BASS_Encode_GetCount counts (
BASS_ENCODE_COUNT_IN, #sent to encoder
( BASS_ENCODE_COUNT_OUT, #received from encoder
BASS_ENCODE_COUNT_IN, #sent to encoder BASS_ENCODE_COUNT_CAST, #sent to cast server
BASS_ENCODE_COUNT_OUT, #received from encoder BASS_ENCODE_COUNT_QUEUE, #queued
BASS_ENCODE_COUNT_CAST, #sent to cast server BASS_ENCODE_COUNT_QUEUE_LIMIT, #queue limit
BASS_ENCODE_COUNT_QUEUE, #queued BASS_ENCODE_COUNT_QUEUE_FAIL, #failed to queue
BASS_ENCODE_COUNT_QUEUE_LIMIT, #queue limit ) = range(6)
BASS_ENCODE_COUNT_QUEUE_FAIL, #failed to queue
) = range(6) #BASS_Encode_CastInit content MIME types
#BASS_Encode_CastInit content MIME types BASS_ENCODE_TYPE_MP3 = "audio/mpeg"
BASS_ENCODE_TYPE_OGG = "application/ogg"
BASS_ENCODE_TYPE_MP3 = "audio/mpeg" BASS_ENCODE_TYPE_AAC = "audio/aacp"
BASS_ENCODE_TYPE_OGG = "application/ogg"
BASS_ENCODE_TYPE_AAC = "audio/aacp" #BASS_Encode_CastGetStats types
#BASS_Encode_CastGetStats types BASS_ENCODE_STATS_SHOUT = 0 #Shoutcast stats
BASS_ENCODE_STATS_ICE = 1 #Icecast mount-point stats
BASS_ENCODE_STATS_SHOUT = 0 #Shoutcast stats BASS_ENCODE_STATS_ICESERV = 2 #Icecast server stats
BASS_ENCODE_STATS_ICE = 1 #Icecast mount-point stats
BASS_ENCODE_STATS_ICESERV = 2 #Icecast server stats #typedef void (CALLBACK ENCODEPROC)(HENCODE handle, DWORD channel, const void *buffer, DWORD length, void *user);
ENCODEPROC = func_type(None, HENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p)
#typedef void (CALLBACK ENCODEPROC)(HENCODE handle, DWORD channel, const void *buffer, DWORD length, void *user);
ENCODEPROC = func_type(None, HENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p) #typedef void (CALLBACK ENCODEPROCEX)(HENCODE handle, DWORD channel, const void *buffer, DWORD length, QWORD offset, void *user);
ENCODEPROCEX = func_type(None, HENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, pybass.QWORD, ctypes.c_void_p)
#typedef void (CALLBACK ENCODEPROCEX)(HENCODE handle, DWORD channel, const void *buffer, DWORD length, QWORD offset, void *user);
ENCODEPROCEX = func_type(None, HENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, pybass.QWORD, ctypes.c_void_p) #typedef BOOL (CALLBACK ENCODECLIENTPROC)(HENCODE handle, BOOL connect, const char *client, char *headers, void *user);
ENCODECLIENTPROC = func_type(ctypes.c_byte, HENCODE, ctypes.c_byte, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p)
#typedef BOOL (CALLBACK ENCODECLIENTPROC)(HENCODE handle, BOOL connect, const char *client, char *headers, void *user);
ENCODECLIENTPROC = func_type(ctypes.c_byte, HENCODE, ctypes.c_byte, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p) #typedef void (CALLBACK ENCODENOTIFYPROC)(HENCODE handle, DWORD status, void *user);
ENCODENOTIFYPROC = func_type(None, HENCODE, ctypes.c_ulong, ctypes.c_void_p)
#typedef void (CALLBACK ENCODENOTIFYPROC)(HENCODE handle, DWORD status, void *user);
ENCODENOTIFYPROC = func_type(None, HENCODE, ctypes.c_ulong, ctypes.c_void_p) #Encoder notifications
BASS_ENCODE_NOTIFY_ENCODER = 1 #encoder died
#Encoder notifications BASS_ENCODE_NOTIFY_CAST = 2 #cast server connection died
BASS_ENCODE_NOTIFY_ENCODER = 1 #encoder died BASS_ENCODE_NOTIFY_CAST_TIMEOUT = 0x10000 #cast timeout
BASS_ENCODE_NOTIFY_CAST = 2 #cast server connection died BASS_ENCODE_NOTIFY_QUEUE_FULL = 0x10001 #queue is out of space
BASS_ENCODE_NOTIFY_CAST_TIMEOUT = 0x10000 #cast timeout
BASS_ENCODE_NOTIFY_QUEUE_FULL = 0x10001 #queue is out of space #BASS_Encode_ServerInit flags
BASS_ENCODE_SERVER_NOHTTP = 1 #no HTTP headers
#BASS_Encode_ServerInit flags
BASS_ENCODE_SERVER_NOHTTP = 1 #no HTTP headers #DWORD BASSENCDEF(BASS_Encode_GetVersion)();
BASS_Encode_GetVersion = func_type(ctypes.c_ulong)(('BASS_Encode_GetVersion', bassenc_module))
#DWORD BASSENCDEF(BASS_Encode_GetVersion)();
BASS_Encode_GetVersion = func_type(ctypes.c_ulong)(('BASS_Encode_GetVersion', bassenc_module)) #HENCODE BASSENCDEF(BASS_Encode_Start)(DWORD handle, const char *cmdline, DWORD flags, ENCODEPROC *proc, void *user);
BASS_Encode_Start = func_type(HENCODE, ctypes.c_ulong, ctypes.c_char_p, ctypes.c_ulong, ENCODEPROC, ctypes.c_void_p)(('BASS_Encode_Start', bassenc_module))
#HENCODE BASSENCDEF(BASS_Encode_Start)(DWORD handle, const char *cmdline, DWORD flags, ENCODEPROC *proc, void *user);
BASS_Encode_Start = func_type(HENCODE, ctypes.c_ulong, ctypes.c_char_p, ctypes.c_ulong, ENCODEPROC, ctypes.c_void_p)(('BASS_Encode_Start', bassenc_module)) #HENCODE BASSENCDEF(BASS_Encode_StartLimit)(DWORD handle, const char *cmdline, DWORD flags, ENCODEPROC *proc, void *user, DWORD limit);
BASS_Encode_StartLimit = func_type(HENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ENCODEPROC, ctypes.c_void_p, ctypes.c_ulong)(('BASS_Encode_StartLimit', bassenc_module))
#HENCODE BASSENCDEF(BASS_Encode_StartLimit)(DWORD handle, const char *cmdline, DWORD flags, ENCODEPROC *proc, void *user, DWORD limit);
BASS_Encode_StartLimit = func_type(HENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ENCODEPROC, ctypes.c_void_p, ctypes.c_ulong)(('BASS_Encode_StartLimit', bassenc_module)) #BOOL BASSENCDEF(BASS_Encode_AddChunk)(HENCODE handle, const char *id, const void *buffer, DWORD length);
BASS_Encode_AddChunk = func_type(ctypes.c_byte, HENCODE, ctypes.c_char_p, ctypes.c_void_p, ctypes.c_ulong)(('BASS_Encode_AddChunk', bassenc_module))
#BOOL BASSENCDEF(BASS_Encode_AddChunk)(HENCODE handle, const char *id, const void *buffer, DWORD length);
BASS_Encode_AddChunk = func_type(ctypes.c_byte, HENCODE, ctypes.c_char_p, ctypes.c_void_p, ctypes.c_ulong)(('BASS_Encode_AddChunk', bassenc_module)) #DWORD BASSENCDEF(BASS_Encode_IsActive)(DWORD handle);
BASS_Encode_IsActive = func_type(ctypes.c_ulong, ctypes.c_ulong)(('BASS_Encode_IsActive', bassenc_module))
#DWORD BASSENCDEF(BASS_Encode_IsActive)(DWORD handle);
BASS_Encode_IsActive = func_type(ctypes.c_ulong, ctypes.c_ulong)(('BASS_Encode_IsActive', bassenc_module)) #BOOL BASSENCDEF(BASS_Encode_Stop)(DWORD handle);
BASS_Encode_Stop = func_type(ctypes.c_byte, ctypes.c_ulong)(('BASS_Encode_Stop', bassenc_module))
#BOOL BASSENCDEF(BASS_Encode_Stop)(DWORD handle);
BASS_Encode_Stop = func_type(ctypes.c_byte, ctypes.c_ulong)(('BASS_Encode_Stop', bassenc_module)) #BOOL BASSENCDEF(BASS_Encode_StopEx)(DWORD handle, BOOL queue);
BASS_Encode_StopEx = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_byte)
#BOOL BASSENCDEF(BASS_Encode_StopEx)(DWORD handle, BOOL queue);
BASS_Encode_StopEx = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_byte) #BOOL BASSENCDEF(BASS_Encode_SetPaused)(DWORD handle, BOOL paused);
BASS_Encode_SetPaused = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_byte)(('BASS_Encode_SetPaused', bassenc_module))
#BOOL BASSENCDEF(BASS_Encode_SetPaused)(DWORD handle, BOOL paused);
BASS_Encode_SetPaused = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_byte)(('BASS_Encode_SetPaused', bassenc_module)) #BOOL BASSENCDEF(BASS_Encode_Write)(DWORD handle, const void *buffer, DWORD length);
BASS_Encode_Write = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong)(('BASS_Encode_Write', bassenc_module))
#BOOL BASSENCDEF(BASS_Encode_Write)(DWORD handle, const void *buffer, DWORD length);
BASS_Encode_Write = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong)(('BASS_Encode_Write', bassenc_module)) #BOOL BASSENCDEF(BASS_Encode_SetNotify)(DWORD handle, ENCODENOTIFYPROC *proc, void *user);
BASS_Encode_SetNotify = func_type(ctypes.c_byte, ctypes.c_ulong, ENCODENOTIFYPROC, ctypes.c_void_p)(('BASS_Encode_SetNotify', bassenc_module))
#BOOL BASSENCDEF(BASS_Encode_SetNotify)(DWORD handle, ENCODENOTIFYPROC *proc, void *user);
BASS_Encode_SetNotify = func_type(ctypes.c_byte, ctypes.c_ulong, ENCODENOTIFYPROC, ctypes.c_void_p)(('BASS_Encode_SetNotify', bassenc_module)) #QWORD BASSENCDEF(BASS_Encode_GetCount)(DWORD handle, DWORD count);
BASS_Encode_GetCount = func_type(pybass.QWORD, ctypes.c_ulong, ctypes.c_ulong)(('BASS_Encode_GetCount', bassenc_module))
#QWORD BASSENCDEF(BASS_Encode_GetCount)(DWORD handle, DWORD count);
BASS_Encode_GetCount = func_type(pybass.QWORD, ctypes.c_ulong, ctypes.c_ulong)(('BASS_Encode_GetCount', bassenc_module)) #BOOL BASSENCDEF(BASS_Encode_SetChannel)(DWORD handle, DWORD channel);
BASS_Encode_SetChannel = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_ulong)
#BOOL BASSENCDEF(BASS_Encode_SetChannel)(DWORD handle, DWORD channel);
BASS_Encode_SetChannel = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_ulong) #DWORD BASSENCDEF(BASS_Encode_GetChannel)(HENCODE handle);
BASS_Encode_GetChannel = func_type(ctypes.c_ulong, HENCODE)(('BASS_Encode_GetChannel', bassenc_module))
#DWORD BASSENCDEF(BASS_Encode_GetChannel)(HENCODE handle);
BASS_Encode_GetChannel = func_type(ctypes.c_ulong, HENCODE)(('BASS_Encode_GetChannel', bassenc_module)) if platform.system() == 'Windows':
#DWORD BASSENCDEF(BASS_Encode_GetACMFormat)(DWORD handle, void *form, DWORD formlen, const char *title, DWORD flags);
if platform.system() == 'Windows': BASS_Encode_GetACMFormat = func_type(ctypes.c_ulong, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_char_p, ctypes.c_ulong)(('BASS_Encode_GetACMFormat', bassenc_module))
#DWORD BASSENCDEF(BASS_Encode_GetACMFormat)(DWORD handle, void *form, DWORD formlen, const char *title, DWORD flags);
BASS_Encode_GetACMFormat = func_type(ctypes.c_ulong, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_char_p, ctypes.c_ulong)(('BASS_Encode_GetACMFormat', bassenc_module)) #HENCODE BASSENCDEF(BASS_Encode_StartACM)(DWORD handle, const void *form, DWORD flags, ENCODEPROC *proc, void *user);
BASS_Encode_StartACM = func_type(HENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ENCODEPROC, ctypes.c_void_p)(('BASS_Encode_StartACM', bassenc_module))
#HENCODE BASSENCDEF(BASS_Encode_StartACM)(DWORD handle, const void *form, DWORD flags, ENCODEPROC *proc, void *user);
BASS_Encode_StartACM = func_type(HENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ENCODEPROC, ctypes.c_void_p)(('BASS_Encode_StartACM', bassenc_module)) #HENCODE BASSENCDEF(BASS_Encode_StartACMFile)(DWORD handle, const void *form, DWORD flags, const char *file);
BASS_Encode_StartACMFile = func_type(HENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_char_p)(('BASS_Encode_StartACMFile', bassenc_module))
#HENCODE BASSENCDEF(BASS_Encode_StartACMFile)(DWORD handle, const void *form, DWORD flags, const char *file);
BASS_Encode_StartACMFile = func_type(HENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_char_p)(('BASS_Encode_StartACMFile', bassenc_module))
if platform.system() == 'Darwin':
#HENCODE BASSENCDEF(BASS_Encode_StartCA)(DWORD handle, DWORD ftype, DWORD atype, DWORD flags, DWORD bitrate, ENCODEPROCEX *proc, void *user);
if platform.system() == 'Darwin': BASS_Encode_StartCA = func_type(HENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ENCODEPROCEX, ctypes.c_void_p)(('ENCODEPROCEX ', bassenc_module))
#HENCODE BASSENCDEF(BASS_Encode_StartCA)(DWORD handle, DWORD ftype, DWORD atype, DWORD flags, DWORD bitrate, ENCODEPROCEX *proc, void *user); #HENCODE BASSENCDEF(BASS_Encode_StartCAFile)(DWORD handle, DWORD ftype, DWORD atype, DWORD flags, DWORD bitrate, const char *file);
BASS_Encode_StartCA = func_type(HENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ENCODEPROCEX, ctypes.c_void_p)(('ENCODEPROCEX ', bassenc_module)) BASS_Encode_StartCAFile = func_type(HENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_char_p)(('BASS_Encode_StartCAFile', bassenc_module))
#HENCODE BASSENCDEF(BASS_Encode_StartCAFile)(DWORD handle, DWORD ftype, DWORD atype, DWORD flags, DWORD bitrate, const char *file); #Broadcasting
BASS_Encode_StartCAFile = func_type(HENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_char_p)(('BASS_Encode_StartCAFile', bassenc_module))
#Broadcasting #BOOL BASSENCDEF(BASS_Encode_CastInit)(HENCODE handle, const char *server, const char *pass, const char *content, const char *name, const char *url, const char *genre, const char *desc, const char *headers, DWORD bitrate, BOOL pub);
BASS_Encode_CastInit = func_type(ctypes.c_byte, HENCODE, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_byte)(('BASS_Encode_CastInit', bassenc_module))
#BOOL BASSENCDEF(BASS_Encode_CastInit)(HENCODE handle, const char *server, const char *pass, const char *content, const char *name, const char *url, const char *genre, const char *desc, const char *headers, DWORD bitrate, BOOL pub);
BASS_Encode_CastInit = func_type(ctypes.c_byte, HENCODE, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_byte)(('BASS_Encode_CastInit', bassenc_module)) #BOOL BASSENCDEF(BASS_Encode_CastSetTitle)(HENCODE handle, const char *title, const char *url);
BASS_Encode_CastSetTitle = func_type(ctypes.c_byte, HENCODE, ctypes.c_char_p, ctypes.c_char_p)(('BASS_Encode_CastSetTitle', bassenc_module))
#BOOL BASSENCDEF(BASS_Encode_CastSetTitle)(HENCODE handle, const char *title, const char *url);
BASS_Encode_CastSetTitle = func_type(ctypes.c_byte, HENCODE, ctypes.c_char_p, ctypes.c_char_p)(('BASS_Encode_CastSetTitle', bassenc_module)) #const char *BASSENCDEF(BASS_Encode_CastGetStats)(HENCODE handle, DWORD type, const char *pass);
BASS_Encode_CastGetStats = func_type(ctypes.c_char_p, HENCODE, ctypes.c_ulong, ctypes.c_char_p)(('BASS_Encode_CastGetStats', bassenc_module))
#const char *BASSENCDEF(BASS_Encode_CastGetStats)(HENCODE handle, DWORD type, const char *pass);
BASS_Encode_CastGetStats = func_type(ctypes.c_char_p, HENCODE, ctypes.c_ulong, ctypes.c_char_p)(('BASS_Encode_CastGetStats', bassenc_module)) #Local audio server
#Local audio server #DWORD BASSENCDEF(BASS_Encode_ServerInit)(HENCODE handle, const char *port, DWORD buffer, DWORD burst, DWORD flags, ENCODECLIENTPROC *proc, void *user);
BASS_Encode_ServerInit = func_type(ctypes.c_ulong, HENCODE, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ENCODECLIENTPROC, ctypes.c_void_p)(('BASS_Encode_ServerInit', bassenc_module))
#DWORD BASSENCDEF(BASS_Encode_ServerInit)(HENCODE handle, const char *port, DWORD buffer, DWORD burst, DWORD flags, ENCODECLIENTPROC *proc, void *user);
BASS_Encode_ServerInit = func_type(ctypes.c_ulong, HENCODE, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ENCODECLIENTPROC, ctypes.c_void_p)(('BASS_Encode_ServerInit', bassenc_module)) #BOOL BASSENCDEF(BASS_Encode_ServerKick)(HENCODE handle, const char *client);
BASS_Encode_ServerKick = func_type(ctypes.c_byte, HENCODE, ctypes.c_char_p)(('BASS_Encode_ServerKick', bassenc_module))
#BOOL BASSENCDEF(BASS_Encode_ServerKick)(HENCODE handle, const char *client);
BASS_Encode_ServerKick = func_type(ctypes.c_byte, HENCODE, ctypes.c_char_p)(('BASS_Encode_ServerKick', bassenc_module))

View File

@ -1,41 +1,41 @@
from __future__ import absolute_import from __future__ import absolute_import
# Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru # Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru
# http://vosolok2008.narod.ru # http://vosolok2008.narod.ru
# BSD license # BSD license
__version__ = '0.1' __version__ = '0.1'
__versionTime__ = '2009-11-15' __versionTime__ = '2009-11-15'
__author__ = 'Max Kolosov <maxkolosov@inbox.ru>' __author__ = 'Max Kolosov <maxkolosov@inbox.ru>'
__doc__ = ''' __doc__ = '''
pybassflac.py - is ctypes python module for pybassflac.py - is ctypes python module for
BASSFLAC - extension to the BASS audio library, BASSFLAC - extension to the BASS audio library,
enabling the playing of FLAC (Free Lossless Audio Codec) encoded files. enabling the playing of FLAC (Free Lossless Audio Codec) encoded files.
''' '''
import os, sys, ctypes import os, sys, ctypes
from . import pybass from . import pybass
from .paths import x86_path, x64_path from . paths import x86_path, x64_path
import libloader import libloader
bassflac_module = libloader.load_library('bassflac', x86_path=x86_path, x64_path=x64_path) bassflac_module = libloader.load_library('bassflac', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype() func_type = libloader.get_functype()
#Register the plugin with the Bass plugin system. #Register the plugin with the Bass plugin system.
pybass.BASS_PluginLoad(libloader.find_library_path('bassflac', x86_path=x86_path, x64_path=x64_path), 0) pybass.BASS_PluginLoad(libloader.find_library_path('bassflac', x86_path=x86_path, x64_path=x64_path), 0)
QWORD = pybass.QWORD QWORD = pybass.QWORD
HSTREAM = pybass.HSTREAM HSTREAM = pybass.HSTREAM
DOWNLOADPROC = pybass.DOWNLOADPROC DOWNLOADPROC = pybass.DOWNLOADPROC
BASS_FILEPROCS = pybass.BASS_FILEPROCS BASS_FILEPROCS = pybass.BASS_FILEPROCS
# BASS_CHANNELINFO type # BASS_CHANNELINFO type
BASS_CTYPE_STREAM_FLAC = 0x10900 BASS_CTYPE_STREAM_FLAC = 0x10900
BASS_CTYPE_STREAM_FLAC_OGG = 0x10901 BASS_CTYPE_STREAM_FLAC_OGG = 0x10901
#HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags); #HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
BASS_FLAC_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_FLAC_StreamCreateFile', bassflac_module)) BASS_FLAC_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_FLAC_StreamCreateFile', bassflac_module))
#HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user); #HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user);
BASS_FLAC_StreamCreateURL = func_type(HSTREAM, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, DOWNLOADPROC, ctypes.c_void_p)(('BASS_FLAC_StreamCreateURL', bassflac_module)) BASS_FLAC_StreamCreateURL = func_type(HSTREAM, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, DOWNLOADPROC, ctypes.c_void_p)(('BASS_FLAC_StreamCreateURL', bassflac_module))
#HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user); #HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);
BASS_FLAC_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_FLAC_StreamCreateFileUser', bassflac_module)) BASS_FLAC_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_FLAC_StreamCreateFileUser', bassflac_module))

View File

@ -1,204 +1,205 @@
from __future__ import absolute_import from __future__ import absolute_import
# Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru # Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru
# http://vosolok2008.narod.ru # http://vosolok2008.narod.ru
# BSD license # BSD license
__version__ = '0.1' __version__ = '0.1'
__versionTime__ = '2009-11-15' __versionTime__ = '2009-11-15'
__author__ = 'Max Kolosov <maxkolosov@inbox.ru>' __author__ = 'Max Kolosov <maxkolosov@inbox.ru>'
__doc__ = ''' __doc__ = '''
pybassmidi.py - is ctypes python module for pybassmidi.py - is ctypes python module for
BASSMIDI - extension to the BASS audio library, BASSMIDI - extension to the BASS audio library,
enabling the playing of MIDI files and real-time events, enabling the playing of MIDI files and real-time events,
using SF2 soundfonts to provide the sounds. using SF2 soundfonts to provide the sounds.
''' '''
import sys, ctypes, platform, os import sys, ctypes, platform, os
from . import pybass from . import pybass
from .paths import x86_path, x64_path from .paths import x86_path, x64_path
import libloader import libloader
bassmidi_module = libloader.load_library('bassmidi', x86_path=x86_path, x64_path=x64_path) bassmidi_module = libloader.load_library('bassmidi', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype() func_type = libloader.get_functype()
#Register the plugin with the Bass plugin system. #Register the plugin with the Bass plugin system.
pybass.BASS_PluginLoad(libloader.find_library_path('bassmidi', x86_path=x86_path, x64_path=x64_path), 0) pybass.BASS_PluginLoad(libloader.find_library_path('bassmidi', x86_path=x86_path, x64_path=x64_path), 0)
HSOUNDFONT = ctypes.c_ulong HSOUNDFONT = ctypes.c_ulong
QWORD = pybass.QWORD QWORD = pybass.QWORD
HSTREAM = pybass.HSTREAM HSTREAM = pybass.HSTREAM
DOWNLOADPROC = pybass.DOWNLOADPROC DOWNLOADPROC = pybass.DOWNLOADPROC
BASS_FILEPROCS = pybass.BASS_FILEPROCS BASS_FILEPROCS = pybass.BASS_FILEPROCS
# Additional BASS_SetConfig options # Additional BASS_SetConfig options
BASS_CONFIG_MIDI_COMPACT = 0x10400 BASS_CONFIG_MIDI_COMPACT = 0x10400
BASS_CONFIG_MIDI_VOICES = 0x10401 BASS_CONFIG_MIDI_VOICES = 0x10401
BASS_CONFIG_MIDI_AUTOFONT = 0x10402 BASS_CONFIG_MIDI_AUTOFONT = 0x10402
# Additional BASS_SetConfigPtr options # Additional BASS_SetConfigPtr options
BASS_CONFIG_MIDI_DEFFONT = 0x10403 BASS_CONFIG_MIDI_DEFFONT = 0x10403
# Additional sync types # Additional sync types
BASS_SYNC_MIDI_MARKER = 0x10000 BASS_SYNC_MIDI_MARKER = 0x10000
BASS_SYNC_MIDI_CUE = 0x10001 BASS_SYNC_MIDI_CUE = 0x10001
BASS_SYNC_MIDI_LYRIC = 0x10002 BASS_SYNC_MIDI_LYRIC = 0x10002
BASS_SYNC_MIDI_TEXT = 0x10003 BASS_SYNC_MIDI_TEXT = 0x10003
BASS_SYNC_MIDI_EVENT = 0x10004 BASS_SYNC_MIDI_EVENT = 0x10004
BASS_SYNC_MIDI_TICK = 0x10005 BASS_SYNC_MIDI_TICK = 0x10005
BASS_SYNC_MIDI_TIMESIG = 0x10006 BASS_SYNC_MIDI_TIMESIG = 0x10006
# Additional BASS_MIDI_StreamCreateFile/etc flags # Additional BASS_MIDI_StreamCreateFile/etc flags
BASS_MIDI_DECAYEND = 0x1000 BASS_MIDI_DECAYEND = 0x1000
BASS_MIDI_NOFX = 0x2000 BASS_MIDI_NOFX = 0x2000
BASS_MIDI_DECAYSEEK = 0x4000 BASS_MIDI_DECAYSEEK = 0x4000
class BASS_MIDI_FONT(ctypes.Structure): class BASS_MIDI_FONT(ctypes.Structure):
_fields_ = [('font', HSOUNDFONT),#HSOUNDFONT font; // soundfont _fields_ = [('font', HSOUNDFONT),#HSOUNDFONT font; // soundfont
('preset', ctypes.c_int),#int preset; // preset number (-1=all) ('preset', ctypes.c_int),#int preset; // preset number (-1=all)
('bank', ctypes.c_int)#int bank; ('bank', ctypes.c_int)#int bank;
] ]
class BASS_MIDI_FONTINFO(ctypes.Structure): class BASS_MIDI_FONTINFO(ctypes.Structure):
_fields_ = [('name', ctypes.c_char_p),#const char *name; _fields_ = [('name', ctypes.c_char_p),#const char *name;
('copyright', ctypes.c_char_p),#const char *copyright; ('copyright', ctypes.c_char_p),#const char *copyright;
('comment', ctypes.c_char_p),#const char *comment; ('comment', ctypes.c_char_p),#const char *comment;
('presets', ctypes.c_ulong),#DWORD presets; // number of presets/instruments ('presets', ctypes.c_ulong),#DWORD presets; // number of presets/instruments
('samsize', ctypes.c_ulong),#DWORD samsize; // total size (in bytes) of the sample data ('samsize', ctypes.c_ulong),#DWORD samsize; // total size (in bytes) of the sample data
('samload', ctypes.c_ulong),#DWORD samload; // amount of sample data currently loaded ('samload', ctypes.c_ulong),#DWORD samload; // amount of sample data currently loaded
('samtype', ctypes.c_ulong)#DWORD samtype; // sample format (CTYPE) if packed ('samtype', ctypes.c_ulong)#DWORD samtype; // sample format (CTYPE) if packed
] ]
class BASS_MIDI_MARK(ctypes.Structure): class BASS_MIDI_MARK(ctypes.Structure):
_fields_ = [('track', ctypes.c_ulong),#DWORD track; // track containing marker _fields_ = [('track', ctypes.c_ulong),#DWORD track; // track containing marker
('pos', ctypes.c_ulong),#DWORD pos; // marker position (bytes) ('pos', ctypes.c_ulong),#DWORD pos; // marker position (bytes)
('text', ctypes.c_char_p)#const char *text; // marker text ('text', ctypes.c_char_p)#const char *text; // marker text
] ]
# Marker types # Marker types
BASS_MIDI_MARK_MARKER = 0 # marker events BASS_MIDI_MARK_MARKER = 0 # marker events
BASS_MIDI_MARK_CUE = 1 # cue events BASS_MIDI_MARK_CUE = 1 # cue events
BASS_MIDI_MARK_LYRIC = 2 # lyric events BASS_MIDI_MARK_LYRIC = 2 # lyric events
BASS_MIDI_MARK_TEXT = 3 # text events BASS_MIDI_MARK_TEXT = 3 # text events
BASS_MIDI_MARK_TIMESIG = 4 # time signature BASS_MIDI_MARK_TIMESIG = 4 # time signature
# MIDI events # MIDI events
MIDI_EVENT_NOTE = 1 MIDI_EVENT_NOTE = 1
MIDI_EVENT_PROGRAM = 2 MIDI_EVENT_PROGRAM = 2
MIDI_EVENT_CHANPRES = 3 MIDI_EVENT_CHANPRES = 3
MIDI_EVENT_PITCH = 4 MIDI_EVENT_PITCH = 4
MIDI_EVENT_PITCHRANGE = 5 MIDI_EVENT_PITCHRANGE = 5
MIDI_EVENT_DRUMS = 6 MIDI_EVENT_DRUMS = 6
MIDI_EVENT_FINETUNE = 7 MIDI_EVENT_FINETUNE = 7
MIDI_EVENT_COARSETUNE = 8 MIDI_EVENT_COARSETUNE = 8
MIDI_EVENT_MASTERVOL = 9 MIDI_EVENT_MASTERVOL = 9
MIDI_EVENT_BANK = 10 MIDI_EVENT_BANK = 10
MIDI_EVENT_MODULATION = 11 MIDI_EVENT_MODULATION = 11
MIDI_EVENT_VOLUME = 12 MIDI_EVENT_VOLUME = 12
MIDI_EVENT_PAN = 13 MIDI_EVENT_PAN = 13
MIDI_EVENT_EXPRESSION = 14 MIDI_EVENT_EXPRESSION = 14
MIDI_EVENT_SUSTAIN = 15 MIDI_EVENT_SUSTAIN = 15
MIDI_EVENT_SOUNDOFF = 16 MIDI_EVENT_SOUNDOFF = 16
MIDI_EVENT_RESET = 17 MIDI_EVENT_RESET = 17
MIDI_EVENT_NOTESOFF = 18 MIDI_EVENT_NOTESOFF = 18
MIDI_EVENT_PORTAMENTO = 19 MIDI_EVENT_PORTAMENTO = 19
MIDI_EVENT_PORTATIME = 20 MIDI_EVENT_PORTATIME = 20
MIDI_EVENT_PORTANOTE = 21 MIDI_EVENT_PORTANOTE = 21
MIDI_EVENT_MODE = 22 MIDI_EVENT_MODE = 22
MIDI_EVENT_REVERB = 23 MIDI_EVENT_REVERB = 23
MIDI_EVENT_CHORUS = 24 MIDI_EVENT_CHORUS = 24
MIDI_EVENT_CUTOFF = 25 MIDI_EVENT_CUTOFF = 25
MIDI_EVENT_RESONANCE = 26 MIDI_EVENT_RESONANCE = 26
MIDI_EVENT_RELEASE = 27 MIDI_EVENT_RELEASE = 27
MIDI_EVENT_ATTACK = 28 MIDI_EVENT_ATTACK = 28
MIDI_EVENT_REVERB_MACRO = 30 MIDI_EVENT_REVERB_MACRO = 30
MIDI_EVENT_CHORUS_MACRO = 31 MIDI_EVENT_CHORUS_MACRO = 31
MIDI_EVENT_REVERB_TIME = 32 MIDI_EVENT_REVERB_TIME = 32
MIDI_EVENT_REVERB_DELAY = 33 MIDI_EVENT_REVERB_DELAY = 33
MIDI_EVENT_REVERB_LOCUTOFF = 34 MIDI_EVENT_REVERB_LOCUTOFF = 34
MIDI_EVENT_REVERB_HICUTOFF = 35 MIDI_EVENT_REVERB_HICUTOFF = 35
MIDI_EVENT_REVERB_LEVEL = 36 MIDI_EVENT_REVERB_LEVEL = 36
MIDI_EVENT_CHORUS_DELAY = 37 MIDI_EVENT_CHORUS_DELAY = 37
MIDI_EVENT_CHORUS_DEPTH = 38 MIDI_EVENT_CHORUS_DEPTH = 38
MIDI_EVENT_CHORUS_RATE = 39 MIDI_EVENT_CHORUS_RATE = 39
MIDI_EVENT_CHORUS_FEEDBACK = 40 MIDI_EVENT_CHORUS_FEEDBACK = 40
MIDI_EVENT_CHORUS_LEVEL = 41 MIDI_EVENT_CHORUS_LEVEL = 41
MIDI_EVENT_CHORUS_REVERB = 42 MIDI_EVENT_CHORUS_REVERB = 42
MIDI_EVENT_DRUM_FINETUNE = 50 MIDI_EVENT_DRUM_FINETUNE = 50
MIDI_EVENT_DRUM_COARSETUNE = 51 MIDI_EVENT_DRUM_COARSETUNE = 51
MIDI_EVENT_DRUM_PAN = 52 MIDI_EVENT_DRUM_PAN = 52
MIDI_EVENT_DRUM_REVERB = 53 MIDI_EVENT_DRUM_REVERB = 53
MIDI_EVENT_DRUM_CHORUS = 54 MIDI_EVENT_DRUM_CHORUS = 54
MIDI_EVENT_DRUM_CUTOFF = 55 MIDI_EVENT_DRUM_CUTOFF = 55
MIDI_EVENT_DRUM_RESONANCE = 56 MIDI_EVENT_DRUM_RESONANCE = 56
MIDI_EVENT_DRUM_LEVEL = 57 MIDI_EVENT_DRUM_LEVEL = 57
MIDI_EVENT_TEMPO = 62 MIDI_EVENT_TEMPO = 62
MIDI_EVENT_MIXLEVEL = 0x10000 MIDI_EVENT_MIXLEVEL = 0x10000
MIDI_EVENT_TRANSPOSE = 0x10001 MIDI_EVENT_TRANSPOSE = 0x10001
class BASS_MIDI_EVENT(ctypes.Structure): class BASS_MIDI_EVENT(ctypes.Structure):
_fields_ = [('event', ctypes.c_ulong),#DWORD event; // MIDI_EVENT_xxx _fields_ = [('event', ctypes.c_ulong),#DWORD event; // MIDI_EVENT_xxx
('param', ctypes.c_ulong),#DWORD param; ('param', ctypes.c_ulong),#DWORD param;
('chan', ctypes.c_ulong),#DWORD chan; ('chan', ctypes.c_ulong),#DWORD chan;
('tick', ctypes.c_ulong),#DWORD tick; // event position (ticks) ('tick', ctypes.c_ulong),#DWORD tick; // event position (ticks)
('pos', ctypes.c_ulong)#DWORD pos; // event position (bytes) ('pos', ctypes.c_ulong)#DWORD pos; // event position (bytes)
] ]
# BASS_CHANNELINFO type # BASS_CHANNELINFO type
BASS_CTYPE_STREAM_MIDI = 0x10d00 BASS_CTYPE_STREAM_MIDI = 0x10d00
# Additional attributes # Additional attributes
BASS_ATTRIB_MIDI_PPQN = 0x12000 BASS_ATTRIB_MIDI_PPQN = 0x12000
BASS_ATTRIB_MIDI_TRACK_VOL = 0x12100 # + track # BASS_ATTRIB_MIDI_TRACK_VOL = 0x12100 # + track #
# Additional tag type # Additional tag type
BASS_TAG_MIDI_TRACK = 0x11000 # + track #, track text : array of null-terminated ANSI strings BASS_TAG_MIDI_TRACK = 0x11000 # + track #, track text : array of null-terminated ANSI strings
# BASS_ChannelGetLength/GetPosition/SetPosition mode # BASS_ChannelGetLength/GetPosition/SetPosition mode
BASS_POS_MIDI_TICK = 2 # tick position BASS_POS_MIDI_TICK = 2 # tick position
#HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreate)(DWORD channels, DWORD flags, DWORD freq); #HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreate)(DWORD channels, DWORD flags, DWORD freq);
BASS_MIDI_StreamCreate = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_MIDI_StreamCreate', bassmidi_module)) BASS_MIDI_StreamCreate = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_MIDI_StreamCreate', bassmidi_module))
#HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags, DWORD freq); #HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags, DWORD freq);
BASS_MIDI_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong, ctypes.c_ulong)(('BASS_MIDI_StreamCreateFile', bassmidi_module)) BASS_MIDI_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong, ctypes.c_ulong)(('BASS_MIDI_StreamCreateFile', bassmidi_module))
#HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user, DWORD freq); #HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user, DWORD freq);
BASS_MIDI_StreamCreateURL = func_type(HSTREAM, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, DOWNLOADPROC, ctypes.c_void_p, ctypes.c_ulong)(('BASS_MIDI_StreamCreateURL', bassmidi_module)) BASS_MIDI_StreamCreateURL = func_type(HSTREAM, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, DOWNLOADPROC, ctypes.c_void_p, ctypes.c_ulong)(('BASS_MIDI_StreamCreateURL', bassmidi_module))
#HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user, DWORD freq); #HSTREAM BASSMIDIDEF(BASS_MIDI_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user, DWORD freq);
BASS_MIDI_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p, ctypes.c_ulong)(('BASS_MIDI_StreamCreateFileUser', bassmidi_module)) BASS_MIDI_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p, ctypes.c_ulong)(('BASS_MIDI_StreamCreateFileUser', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_StreamGetMark)(HSTREAM handle, DWORD type, DWORD index, BASS_MIDI_MARK *mark); #BOOL BASSMIDIDEF(BASS_MIDI_StreamGetMark)(HSTREAM handle, DWORD type, DWORD index, BASS_MIDI_MARK *mark);
BASS_MIDI_StreamGetMark = func_type(ctypes.c_byte, HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_MIDI_MARK))(('BASS_MIDI_StreamGetMark', bassmidi_module)) BASS_MIDI_StreamGetMark = func_type(ctypes.c_byte, HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_MIDI_MARK))(('BASS_MIDI_StreamGetMark', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_StreamSetFonts)(HSTREAM handle, const BASS_MIDI_FONT *fonts, DWORD count); #BOOL BASSMIDIDEF(BASS_MIDI_StreamSetFonts)(HSTREAM handle, const BASS_MIDI_FONT *fonts, DWORD count);
BASS_MIDI_StreamSetFonts = func_type(ctypes.c_byte, HSTREAM, ctypes.POINTER(BASS_MIDI_FONT), ctypes.c_ulong)(('BASS_MIDI_StreamSetFonts', bassmidi_module)) BASS_MIDI_StreamSetFonts = func_type(ctypes.c_byte, HSTREAM, ctypes.POINTER(BASS_MIDI_FONT), ctypes.c_ulong)(('BASS_MIDI_StreamSetFonts', bassmidi_module))
#DWORD BASSMIDIDEF(BASS_MIDI_StreamGetFonts)(HSTREAM handle, BASS_MIDI_FONT *fonts, DWORD count); #DWORD BASSMIDIDEF(BASS_MIDI_StreamGetFonts)(HSTREAM handle, BASS_MIDI_FONT *fonts, DWORD count);
BASS_MIDI_StreamGetFonts = func_type(ctypes.c_ulong, HSTREAM, ctypes.POINTER(BASS_MIDI_FONT), ctypes.c_ulong)(('BASS_MIDI_StreamGetFonts', bassmidi_module)) BASS_MIDI_StreamGetFonts = func_type(ctypes.c_ulong, HSTREAM, ctypes.POINTER(BASS_MIDI_FONT), ctypes.c_ulong)(('BASS_MIDI_StreamGetFonts', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_StreamLoadSamples)(HSTREAM handle); #BOOL BASSMIDIDEF(BASS_MIDI_StreamLoadSamples)(HSTREAM handle);
BASS_MIDI_StreamLoadSamples = func_type(ctypes.c_byte, HSTREAM)(('BASS_MIDI_StreamLoadSamples', bassmidi_module)) BASS_MIDI_StreamLoadSamples = func_type(ctypes.c_byte, HSTREAM)(('BASS_MIDI_StreamLoadSamples', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_StreamEvent)(HSTREAM handle, DWORD chan, DWORD event, DWORD param); #BOOL BASSMIDIDEF(BASS_MIDI_StreamEvent)(HSTREAM handle, DWORD chan, DWORD event, DWORD param);
BASS_MIDI_StreamEvent = func_type(ctypes.c_byte, HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_MIDI_StreamEvent', bassmidi_module)) BASS_MIDI_StreamEvent = func_type(ctypes.c_byte, HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_MIDI_StreamEvent', bassmidi_module))
#DWORD BASSMIDIDEF(BASS_MIDI_StreamGetEvent)(HSTREAM handle, DWORD chan, DWORD event); #DWORD BASSMIDIDEF(BASS_MIDI_StreamGetEvent)(HSTREAM handle, DWORD chan, DWORD event);
BASS_MIDI_StreamGetEvent = func_type(ctypes.c_ulong, HSTREAM, ctypes.c_ulong, ctypes.c_ulong)(('BASS_MIDI_StreamGetEvent', bassmidi_module)) BASS_MIDI_StreamGetEvent = func_type(ctypes.c_ulong, HSTREAM, ctypes.c_ulong, ctypes.c_ulong)(('BASS_MIDI_StreamGetEvent', bassmidi_module))
#DWORD BASSMIDIDEF(BASS_MIDI_StreamGetEvents)(HSTREAM handle, DWORD track, DWORD filter, BASS_MIDI_EVENT *events); #DWORD BASSMIDIDEF(BASS_MIDI_StreamGetEvents)(HSTREAM handle, DWORD track, DWORD filter, BASS_MIDI_EVENT *events);
BASS_MIDI_StreamGetEvents = func_type(ctypes.c_ulong, HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_MIDI_EVENT))(('BASS_MIDI_StreamGetEvents', bassmidi_module)) BASS_MIDI_StreamGetEvents = func_type(ctypes.c_ulong, HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_MIDI_EVENT))(('BASS_MIDI_StreamGetEvents', bassmidi_module))
#HSTREAM BASSMIDIDEF(BASS_MIDI_StreamGetChannel)(HSTREAM handle, DWORD chan); #HSTREAM BASSMIDIDEF(BASS_MIDI_StreamGetChannel)(HSTREAM handle, DWORD chan);
BASS_MIDI_StreamGetChannel = func_type(HSTREAM, HSTREAM, ctypes.c_ulong)(('BASS_MIDI_StreamGetChannel', bassmidi_module)) BASS_MIDI_StreamGetChannel = func_type(HSTREAM, HSTREAM, ctypes.c_ulong)(('BASS_MIDI_StreamGetChannel', bassmidi_module))
#HSOUNDFONT BASSMIDIDEF(BASS_MIDI_FontInit)(const void *file, DWORD flags); #HSOUNDFONT BASSMIDIDEF(BASS_MIDI_FontInit)(const void *file, DWORD flags);
BASS_MIDI_FontInit = func_type(HSOUNDFONT, ctypes.c_void_p, ctypes.c_ulong)(('BASS_MIDI_FontInit', bassmidi_module)) BASS_MIDI_FontInit = func_type(HSOUNDFONT, ctypes.c_void_p, ctypes.c_ulong)(('BASS_MIDI_FontInit', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_FontFree)(HSOUNDFONT handle); #BOOL BASSMIDIDEF(BASS_MIDI_FontFree)(HSOUNDFONT handle);
BASS_MIDI_FontFree = func_type(ctypes.c_byte, HSOUNDFONT)(('BASS_MIDI_FontFree', bassmidi_module)) BASS_MIDI_FontFree = func_type(ctypes.c_byte, HSOUNDFONT)(('BASS_MIDI_FontFree', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_FontGetInfo)(HSOUNDFONT handle, BASS_MIDI_FONTINFO *info); #BOOL BASSMIDIDEF(BASS_MIDI_FontGetInfo)(HSOUNDFONT handle, BASS_MIDI_FONTINFO *info);
BASS_MIDI_FontGetInfo = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.POINTER(BASS_MIDI_FONTINFO))(('BASS_MIDI_FontGetInfo', bassmidi_module)) BASS_MIDI_FontGetInfo = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.POINTER(BASS_MIDI_FONTINFO))(('BASS_MIDI_FontGetInfo', bassmidi_module))
#const char *BASSMIDIDEF(BASS_MIDI_FontGetPreset)(HSOUNDFONT handle, int preset, int bank); #const char *BASSMIDIDEF(BASS_MIDI_FontGetPreset)(HSOUNDFONT handle, int preset, int bank);
BASS_MIDI_FontGetPreset = func_type(ctypes.c_char_p, HSOUNDFONT, ctypes.c_int, ctypes.c_int)(('BASS_MIDI_FontGetPreset', bassmidi_module)) BASS_MIDI_FontGetPreset = func_type(ctypes.c_char_p, HSOUNDFONT, ctypes.c_int, ctypes.c_int)(('BASS_MIDI_FontGetPreset', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_FontLoad)(HSOUNDFONT handle, int preset, int bank); #BOOL BASSMIDIDEF(BASS_MIDI_FontLoad)(HSOUNDFONT handle, int preset, int bank);
BASS_MIDI_FontLoad = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.c_int, ctypes.c_int)(('BASS_MIDI_FontLoad', bassmidi_module)) BASS_MIDI_FontLoad = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.c_int, ctypes.c_int)(('BASS_MIDI_FontLoad', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_FontCompact)(HSOUNDFONT handle); #BOOL BASSMIDIDEF(BASS_MIDI_FontCompact)(HSOUNDFONT handle);
BASS_MIDI_FontCompact = func_type(ctypes.c_byte, HSOUNDFONT)(('BASS_MIDI_FontCompact', bassmidi_module)) BASS_MIDI_FontCompact = func_type(ctypes.c_byte, HSOUNDFONT)(('BASS_MIDI_FontCompact', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_FontPack)(HSOUNDFONT handle, const void *outfile, const void *encoder, DWORD flags); #BOOL BASSMIDIDEF(BASS_MIDI_FontPack)(HSOUNDFONT handle, const void *outfile, const void *encoder, DWORD flags);
BASS_MIDI_FontPack = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_ulong)(('BASS_MIDI_FontPack', bassmidi_module)) BASS_MIDI_FontPack = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_ulong)(('BASS_MIDI_FontPack', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_FontUnpack)(HSOUNDFONT handle, const void *outfile, DWORD flags); #BOOL BASSMIDIDEF(BASS_MIDI_FontUnpack)(HSOUNDFONT handle, const void *outfile, DWORD flags);
BASS_MIDI_FontUnpack = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.c_void_p, ctypes.c_ulong)(('BASS_MIDI_FontUnpack', bassmidi_module)) BASS_MIDI_FontUnpack = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.c_void_p, ctypes.c_ulong)(('BASS_MIDI_FontUnpack', bassmidi_module))
#BOOL BASSMIDIDEF(BASS_MIDI_FontSetVolume)(HSOUNDFONT handle, float volume); #BOOL BASSMIDIDEF(BASS_MIDI_FontSetVolume)(HSOUNDFONT handle, float volume);
BASS_MIDI_FontSetVolume = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.c_float)(('BASS_MIDI_FontSetVolume', bassmidi_module)) BASS_MIDI_FontSetVolume = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.c_float)(('BASS_MIDI_FontSetVolume', bassmidi_module))
#float BASSMIDIDEF(BASS_MIDI_FontGetVolume)(HSOUNDFONT handle); #float BASSMIDIDEF(BASS_MIDI_FontGetVolume)(HSOUNDFONT handle);
BASS_MIDI_FontGetVolume = func_type(ctypes.c_float, HSOUNDFONT)(('BASS_MIDI_FontGetVolume', bassmidi_module)) BASS_MIDI_FontGetVolume = func_type(ctypes.c_float, HSOUNDFONT)(('BASS_MIDI_FontGetVolume', bassmidi_module))

View File

@ -1,117 +1,115 @@
from __future__ import absolute_import # Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru
# Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru # http://vosolok2008.narod.ru
# http://vosolok2008.narod.ru # BSD license
# BSD license
__version__ = '0.1'
__version__ = '0.1' __versionTime__ = '2009-11-15'
__versionTime__ = '2009-11-15' __author__ = 'Max Kolosov <maxkolosov@inbox.ru>'
__author__ = 'Max Kolosov <maxkolosov@inbox.ru>' __doc__ = '''
__doc__ = ''' pybassmix.py - is ctypes python module for
pybassmix.py - is ctypes python module for BASSmix - extension to the BASS audio library, providing the ability
BASSmix - extension to the BASS audio library, providing the ability to mix together multiple BASS channels, with resampling and matrix mixing
to mix together multiple BASS channels, with resampling and matrix mixing features. It also provides the ability to go the other way and split a
features. It also provides the ability to go the other way and split a BASS channel into multiple channels.
BASS channel into multiple channels. '''
'''
import os, sys, ctypes, platform, pybass
import os, sys, ctypes, platform
from . import pybass QWORD = pybass.QWORD
HSYNC = pybass.HSYNC
QWORD = pybass.QWORD HSTREAM = pybass.HSTREAM
HSYNC = pybass.HSYNC DOWNLOADPROC = pybass.DOWNLOADPROC
HSTREAM = pybass.HSTREAM SYNCPROC = pybass.SYNCPROC
DOWNLOADPROC = pybass.DOWNLOADPROC BASS_FILEPROCS = pybass.BASS_FILEPROCS
SYNCPROC = pybass.SYNCPROC
BASS_FILEPROCS = pybass.BASS_FILEPROCS from paths import x86_path, x64_path
import libloader
from .paths import x86_path, x64_path
import libloader bassmix_module = libloader.load_library('bassmix', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype()
bassmix_module = libloader.load_library('bassmix', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype() # additional BASS_SetConfig option
BASS_CONFIG_MIXER_FILTER = 0x10600
# additional BASS_SetConfig option BASS_CONFIG_MIXER_BUFFER = 0x10601
BASS_CONFIG_MIXER_FILTER = 0x10600 BASS_CONFIG_SPLIT_BUFFER = 0x10610
BASS_CONFIG_MIXER_BUFFER = 0x10601
BASS_CONFIG_SPLIT_BUFFER = 0x10610 # BASS_Mixer_StreamCreate flags
BASS_MIXER_END = 0x10000# end the stream when there are no sources
# BASS_Mixer_StreamCreate flags BASS_MIXER_NONSTOP = 0x20000# don't stall when there are no sources
BASS_MIXER_END = 0x10000# end the stream when there are no sources BASS_MIXER_RESUME = 0x1000# resume stalled immediately upon new/unpaused source
BASS_MIXER_NONSTOP = 0x20000# don't stall when there are no sources
BASS_MIXER_RESUME = 0x1000# resume stalled immediately upon new/unpaused source # source flags
BASS_MIXER_FILTER = 0x1000# resampling filter
# source flags BASS_MIXER_BUFFER = 0x2000# buffer data for BASS_Mixer_ChannelGetData/Level
BASS_MIXER_FILTER = 0x1000# resampling filter BASS_MIXER_LIMIT = 0x4000# limit mixer processing to the amount available from this source
BASS_MIXER_BUFFER = 0x2000# buffer data for BASS_Mixer_ChannelGetData/Level BASS_MIXER_MATRIX = 0x10000# matrix mixing
BASS_MIXER_LIMIT = 0x4000# limit mixer processing to the amount available from this source BASS_MIXER_PAUSE = 0x20000# don't process the source
BASS_MIXER_MATRIX = 0x10000# matrix mixing BASS_MIXER_DOWNMIX = 0x400000# downmix to stereo/mono
BASS_MIXER_PAUSE = 0x20000# don't process the source BASS_MIXER_NORAMPIN = 0x800000# don't ramp-in the start
BASS_MIXER_DOWNMIX = 0x400000# downmix to stereo/mono
BASS_MIXER_NORAMPIN = 0x800000# don't ramp-in the start # envelope node
class BASS_MIXER_NODE(ctypes.Structure):
# envelope node _fields_ = [('pos', ctypes.c_ulong),#QWORD pos;
class BASS_MIXER_NODE(ctypes.Structure): ('value', ctypes.c_float)#float value;
_fields_ = [('pos', ctypes.c_ulong),#QWORD pos; ]
('value', ctypes.c_float)#float value;
] # envelope types
BASS_MIXER_ENV_FREQ = 1
# envelope types BASS_MIXER_ENV_VOL = 2
BASS_MIXER_ENV_FREQ = 1 BASS_MIXER_ENV_PAN = 3
BASS_MIXER_ENV_VOL = 2 BASS_MIXER_ENV_LOOP = 0x10000# FLAG: loop
BASS_MIXER_ENV_PAN = 3
BASS_MIXER_ENV_LOOP = 0x10000# FLAG: loop # additional sync type
BASS_SYNC_MIXER_ENVELOPE = 0x10200
# additional sync type
BASS_SYNC_MIXER_ENVELOPE = 0x10200 # BASS_CHANNELINFO type
BASS_CTYPE_STREAM_MIXER = 0x10800
# BASS_CHANNELINFO type BASS_CTYPE_STREAM_SPLIT = 0x10801
BASS_CTYPE_STREAM_MIXER = 0x10800
BASS_CTYPE_STREAM_SPLIT = 0x10801
#DWORD BASSMIXDEF(BASS_Mixer_GetVersion)();
BASS_Mixer_GetVersion = func_type(ctypes.c_ulong)(('BASS_Mixer_GetVersion', bassmix_module))
#DWORD BASSMIXDEF(BASS_Mixer_GetVersion)();
BASS_Mixer_GetVersion = func_type(ctypes.c_ulong)(('BASS_Mixer_GetVersion', bassmix_module)) #HSTREAM BASSMIXDEF(BASS_Mixer_StreamCreate)(DWORD freq, DWORD chans, DWORD flags);
BASS_Mixer_StreamCreate = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_Mixer_StreamCreate', bassmix_module))
#HSTREAM BASSMIXDEF(BASS_Mixer_StreamCreate)(DWORD freq, DWORD chans, DWORD flags); #BOOL BASSMIXDEF(BASS_Mixer_StreamAddChannel)(HSTREAM handle, DWORD channel, DWORD flags);
BASS_Mixer_StreamCreate = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_Mixer_StreamCreate', bassmix_module)) BASS_Mixer_StreamAddChannel = func_type(ctypes.c_byte, HSTREAM, ctypes.c_ulong, ctypes.c_ulong)(('BASS_Mixer_StreamAddChannel', bassmix_module))
#BOOL BASSMIXDEF(BASS_Mixer_StreamAddChannel)(HSTREAM handle, DWORD channel, DWORD flags); #BOOL BASSMIXDEF(BASS_Mixer_StreamAddChannelEx)(HSTREAM handle, DWORD channel, DWORD flags, QWORD start, QWORD length);
BASS_Mixer_StreamAddChannel = func_type(ctypes.c_byte, HSTREAM, ctypes.c_ulong, ctypes.c_ulong)(('BASS_Mixer_StreamAddChannel', bassmix_module)) BASS_Mixer_StreamAddChannelEx = func_type(ctypes.c_byte, HSTREAM, ctypes.c_ulong, ctypes.c_ulong, QWORD, QWORD)(('BASS_Mixer_StreamAddChannelEx', bassmix_module))
#BOOL BASSMIXDEF(BASS_Mixer_StreamAddChannelEx)(HSTREAM handle, DWORD channel, DWORD flags, QWORD start, QWORD length);
BASS_Mixer_StreamAddChannelEx = func_type(ctypes.c_byte, HSTREAM, ctypes.c_ulong, ctypes.c_ulong, QWORD, QWORD)(('BASS_Mixer_StreamAddChannelEx', bassmix_module)) #HSTREAM BASSMIXDEF(BASS_Mixer_ChannelGetMixer)(DWORD handle);
BASS_Mixer_ChannelGetMixer = func_type(HSTREAM, ctypes.c_ulong)(('BASS_Mixer_ChannelGetMixer', bassmix_module))
#HSTREAM BASSMIXDEF(BASS_Mixer_ChannelGetMixer)(DWORD handle); #DWORD BASSMIXDEF(BASS_Mixer_ChannelFlags)(DWORD handle, DWORD flags, DWORD mask);
BASS_Mixer_ChannelGetMixer = func_type(HSTREAM, ctypes.c_ulong)(('BASS_Mixer_ChannelGetMixer', bassmix_module)) BASS_Mixer_ChannelFlags = func_type(ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_Mixer_ChannelFlags', bassmix_module))
#DWORD BASSMIXDEF(BASS_Mixer_ChannelFlags)(DWORD handle, DWORD flags, DWORD mask); #BOOL BASSMIXDEF(BASS_Mixer_ChannelRemove)(DWORD handle);
BASS_Mixer_ChannelFlags = func_type(ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_Mixer_ChannelFlags', bassmix_module)) BASS_Mixer_ChannelRemove = func_type(ctypes.c_byte, ctypes.c_ulong)(('BASS_Mixer_ChannelRemove', bassmix_module))
#BOOL BASSMIXDEF(BASS_Mixer_ChannelRemove)(DWORD handle); #BOOL BASSMIXDEF(BASS_Mixer_ChannelSetPosition)(DWORD handle, QWORD pos, DWORD mode);
BASS_Mixer_ChannelRemove = func_type(ctypes.c_byte, ctypes.c_ulong)(('BASS_Mixer_ChannelRemove', bassmix_module)) BASS_Mixer_ChannelSetPosition = func_type(ctypes.c_byte, ctypes.c_ulong, QWORD, ctypes.c_ulong)(('BASS_Mixer_ChannelSetPosition', bassmix_module))
#BOOL BASSMIXDEF(BASS_Mixer_ChannelSetPosition)(DWORD handle, QWORD pos, DWORD mode); #QWORD BASSMIXDEF(BASS_Mixer_ChannelGetPosition)(DWORD handle, DWORD mode);
BASS_Mixer_ChannelSetPosition = func_type(ctypes.c_byte, ctypes.c_ulong, QWORD, ctypes.c_ulong)(('BASS_Mixer_ChannelSetPosition', bassmix_module)) BASS_Mixer_ChannelGetPosition = func_type(QWORD, ctypes.c_ulong, ctypes.c_ulong)(('BASS_Mixer_ChannelGetPosition', bassmix_module))
#QWORD BASSMIXDEF(BASS_Mixer_ChannelGetPosition)(DWORD handle, DWORD mode); #DWORD BASSMIXDEF(BASS_Mixer_ChannelGetLevel)(DWORD handle);
BASS_Mixer_ChannelGetPosition = func_type(QWORD, ctypes.c_ulong, ctypes.c_ulong)(('BASS_Mixer_ChannelGetPosition', bassmix_module)) BASS_Mixer_ChannelGetLevel = func_type(ctypes.c_ulong, ctypes.c_ulong)(('BASS_Mixer_ChannelGetLevel', bassmix_module))
#DWORD BASSMIXDEF(BASS_Mixer_ChannelGetLevel)(DWORD handle); #DWORD BASSMIXDEF(BASS_Mixer_ChannelGetData)(DWORD handle, void *buffer, DWORD length);
BASS_Mixer_ChannelGetLevel = func_type(ctypes.c_ulong, ctypes.c_ulong)(('BASS_Mixer_ChannelGetLevel', bassmix_module)) BASS_Mixer_ChannelGetData = func_type(ctypes.c_ulong, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong)(('BASS_Mixer_ChannelGetData', bassmix_module))
#DWORD BASSMIXDEF(BASS_Mixer_ChannelGetData)(DWORD handle, void *buffer, DWORD length); #HSYNC BASSMIXDEF(BASS_Mixer_ChannelSetSync)(DWORD handle, DWORD type, QWORD param, SYNCPROC *proc, void *user);
BASS_Mixer_ChannelGetData = func_type(ctypes.c_ulong, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong)(('BASS_Mixer_ChannelGetData', bassmix_module)) BASS_Mixer_ChannelSetSync = func_type(HSYNC, ctypes.c_ulong, ctypes.c_ulong, QWORD, SYNCPROC, ctypes.c_void_p)(('BASS_Mixer_ChannelSetSync', bassmix_module))
#HSYNC BASSMIXDEF(BASS_Mixer_ChannelSetSync)(DWORD handle, DWORD type, QWORD param, SYNCPROC *proc, void *user); #BOOL BASSMIXDEF(BASS_Mixer_ChannelRemoveSync)(DWORD channel, HSYNC sync);
BASS_Mixer_ChannelSetSync = func_type(HSYNC, ctypes.c_ulong, ctypes.c_ulong, QWORD, SYNCPROC, ctypes.c_void_p)(('BASS_Mixer_ChannelSetSync', bassmix_module)) BASS_Mixer_ChannelRemoveSync = func_type(ctypes.c_byte, ctypes.c_ulong, HSYNC)(('BASS_Mixer_ChannelRemoveSync', bassmix_module))
#BOOL BASSMIXDEF(BASS_Mixer_ChannelRemoveSync)(DWORD channel, HSYNC sync); #BOOL BASSMIXDEF(BASS_Mixer_ChannelSetMatrix)(DWORD handle, const float *matrix);
BASS_Mixer_ChannelRemoveSync = func_type(ctypes.c_byte, ctypes.c_ulong, HSYNC)(('BASS_Mixer_ChannelRemoveSync', bassmix_module)) BASS_Mixer_ChannelSetMatrix = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.POINTER(ctypes.c_float))(('BASS_Mixer_ChannelSetMatrix', bassmix_module))
#BOOL BASSMIXDEF(BASS_Mixer_ChannelSetMatrix)(DWORD handle, const float *matrix); #BOOL BASSMIXDEF(BASS_Mixer_ChannelGetMatrix)(DWORD handle, float *matrix);
BASS_Mixer_ChannelSetMatrix = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.POINTER(ctypes.c_float))(('BASS_Mixer_ChannelSetMatrix', bassmix_module)) BASS_Mixer_ChannelGetMatrix = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.POINTER(ctypes.c_float))(('BASS_Mixer_ChannelGetMatrix', bassmix_module))
#BOOL BASSMIXDEF(BASS_Mixer_ChannelGetMatrix)(DWORD handle, float *matrix); #BOOL BASSMIXDEF(BASS_Mixer_ChannelSetEnvelope)(DWORD handle, DWORD type, const BASS_MIXER_NODE *nodes, DWORD count);
BASS_Mixer_ChannelGetMatrix = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.POINTER(ctypes.c_float))(('BASS_Mixer_ChannelGetMatrix', bassmix_module)) BASS_Mixer_ChannelSetEnvelope = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_MIXER_NODE), ctypes.c_ulong)(('BASS_Mixer_ChannelSetEnvelope', bassmix_module))
#BOOL BASSMIXDEF(BASS_Mixer_ChannelSetEnvelope)(DWORD handle, DWORD type, const BASS_MIXER_NODE *nodes, DWORD count); #BOOL BASSMIXDEF(BASS_Mixer_ChannelSetEnvelopePos)(DWORD handle, DWORD type, QWORD pos);
BASS_Mixer_ChannelSetEnvelope = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_MIXER_NODE), ctypes.c_ulong)(('BASS_Mixer_ChannelSetEnvelope', bassmix_module)) BASS_Mixer_ChannelSetEnvelopePos = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_ulong, QWORD)(('BASS_Mixer_ChannelSetEnvelopePos', bassmix_module))
#BOOL BASSMIXDEF(BASS_Mixer_ChannelSetEnvelopePos)(DWORD handle, DWORD type, QWORD pos); #QWORD BASSMIXDEF(BASS_Mixer_ChannelGetEnvelopePos)(DWORD handle, DWORD type, float *value);
BASS_Mixer_ChannelSetEnvelopePos = func_type(ctypes.c_byte, ctypes.c_ulong, ctypes.c_ulong, QWORD)(('BASS_Mixer_ChannelSetEnvelopePos', bassmix_module)) BASS_Mixer_ChannelGetEnvelopePos = func_type(QWORD, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_float)(('BASS_Mixer_ChannelGetEnvelopePos', bassmix_module))
#QWORD BASSMIXDEF(BASS_Mixer_ChannelGetEnvelopePos)(DWORD handle, DWORD type, float *value);
BASS_Mixer_ChannelGetEnvelopePos = func_type(QWORD, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_float)(('BASS_Mixer_ChannelGetEnvelopePos', bassmix_module)) #HSTREAM BASSMIXDEF(BASS_Split_StreamCreate)(DWORD channel, DWORD flags, int *chanmap);
BASS_Split_StreamCreate = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_int)(('BASS_Split_StreamCreate', bassmix_module))
#HSTREAM BASSMIXDEF(BASS_Split_StreamCreate)(DWORD channel, DWORD flags, int *chanmap); #DWORD BASSMIXDEF(BASS_Split_StreamGetSource)(HSTREAM handle);
BASS_Split_StreamCreate = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_int)(('BASS_Split_StreamCreate', bassmix_module)) BASS_Split_StreamGetSource = func_type(ctypes.c_ulong, HSTREAM)(('BASS_Split_StreamGetSource', bassmix_module))
#DWORD BASSMIXDEF(BASS_Split_StreamGetSource)(HSTREAM handle); #BOOL BASSMIXDEF(BASS_Split_StreamReset)(DWORD handle);
BASS_Split_StreamGetSource = func_type(ctypes.c_ulong, HSTREAM)(('BASS_Split_StreamGetSource', bassmix_module)) BASS_Split_StreamReset = func_type(ctypes.c_byte, ctypes.c_ulong)(('BASS_Split_StreamReset', bassmix_module))
#BOOL BASSMIXDEF(BASS_Split_StreamReset)(DWORD handle);
BASS_Split_StreamReset = func_type(ctypes.c_byte, ctypes.c_ulong)(('BASS_Split_StreamReset', bassmix_module))

View File

@ -1,18 +1,11 @@
# Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru
# http://vosolok2008.narod.ru
# BSD license
__version__ = '0.1' __version__ = '0.1'
__versionTime__ = '2009-11-15' __versionTime__ = '2009-11-15'
__author__ = 'Max Kolosov <maxkolosov@inbox.ru>' __author__ = 'Max Kolosov <maxkolosov@inbox.ru>'
__doc__ = '''
pybassflac.py - is ctypes python module for
BASSFLAC - extension to the BASS audio library,
enabling the playing of FLAC (Free Lossless Audio Codec) encoded files.
'''
import os, sys, ctypes, pybass import os, sys, ctypes
from paths import x86_path, x64_path from . import pybass
from .paths import x86_path, x64_path
import libloader import libloader
bassopus_module = libloader.load_library('bassopus', x86_path=x86_path, x64_path=x64_path) bassopus_module = libloader.load_library('bassopus', x86_path=x86_path, x64_path=x64_path)
@ -36,12 +29,3 @@ BASS_OPUS_StreamCreateURL = func_type(HSTREAM, ctypes.c_char_p, ctypes.c_ulong,
#HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user); #HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);
BASS_OPUS_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_OPUS_StreamCreateFileUser', bassopus_module)) BASS_OPUS_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_OPUS_StreamCreateFileUser', bassopus_module))
if __name__ == "__main__":
if not pybass.BASS_Init(-1, 44100, 0, 0, 0):
print 'BASS_Init error', pybass.get_error_description(pybass.BASS_ErrorGetCode())
else:
handle = BASS_OPUS_StreamCreateFile(False, 'test.opus', 0, 0, 0)
pybass.play_handle(handle)
if not pybass.BASS_Free():
print 'BASS_Free error', pybass.get_error_description(pybass.BASS_ErrorGetCode())

154
src/sound_lib/external/pybasswasapi.py vendored Normal file
View File

@ -0,0 +1,154 @@
# Copyright(c) Andrew Evans 2013
# BSD license
__version__ = '0.1'
__versionTime__ = '2013-03-28'
__author__ = 'Andrew Evans <themindflows@gmail.com>'
__doc__ = '''
pybasswasapi.py - is ctypes python module for WASAPI (http://www.un4seen.com).
BASSWASAPI is basically a wrapper for WASAPI drivers
BASSWASAPI requires a soundcard with WASAPI drivers.
'''
import sys, ctypes, platform
from . import pybass
from .paths import x86_path, x64_path
import libloader
HSTREAM = pybass.HSTREAM
BASS_FILEPROCS = pybass.BASS_FILEPROCS
basswasapi_module = libloader.load_library('basswasapi', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype()
# Additional error codes returned by BASS_ErrorGetCode
BASS_ERROR_WASAPI = 5000
# Device info structure
class BASS_WASAPI_DEVICEINFO(ctypes.Structure):
_fields_ = [
('name', ctypes.c_char_p),
('id', ctypes.c_char_p),
('type', ctypes.c_ulong),
('flags', ctypes.c_ulong),
('minperiod', ctypes.c_float),
('defperiod', ctypes.c_float),
('mixfreq', ctypes.c_ulong),
('mixchans', ctypes.c_ulong)
]
class BASS_WASAPI_INFO(ctypes.Structure):
_fields_ = [
('initflag', ctypes.c_ulong),
('freq', ctypes.c_ulong),
('chans', ctypes.c_ulong),
('format', ctypes.c_ulong),
('buflen', ctypes.c_ulong),
('volmax', ctypes.c_float),
('volmin', ctypes.c_float),
('volstep', ctypes.c_float)
]
# BASS_WASAPI_DEVICEINFO "type"
BASS_WASAPI_TYPE_NETWORKDEVICE = 0
BASS_WASAPI_TYPE_SPEAKERS = 1
BASS_WASAPI_TYPE_LINELEVEL = 2
BASS_WASAPI_TYPE_HEADPHONES = 3
BASS_WASAPI_TYPE_MICROPHONE = 4
BASS_WASAPI_TYPE_HEADSET = 5
BASS_WASAPI_TYPE_HANDSET = 6
BASS_WASAPI_TYPE_DIGITAL = 7
BASS_WASAPI_TYPE_SPDIF = 8
BASS_WASAPI_TYPE_HDMI = 9
BASS_WASAPI_TYPE_UNKNOWN = 10
# BASS_WASAPI_DEVICEINFO flags
BASS_DEVICE_ENABLED = 1
BASS_DEVICE_DEFAULT = 2
BASS_DEVICE_INIT = 4
BASS_DEVICE_LOOPBACK = 8
BASS_DEVICE_INPUT = 16
BASS_DEVICE_UNPLUGGED = 32
BASS_DEVICE_DISABLED = 64
# BASS_WASAPI_Init flags
BASS_WASAPI_EXCLUSIVE = 1
BASS_WASAPI_AUTOFORMAT = 2
BASS_WASAPI_BUFFER = 4
BASS_WASAPI_SESSIONVOL = 8
BASS_WASAPI_EVENT = 16
# BASS_WASAPI_INFO "format"
BASS_WASAPI_FORMAT_FLOAT = 0
BASS_WASAPI_FORMAT_8BIT = 1
BASS_WASAPI_FORMAT_16BIT = 2
BASS_WASAPI_FORMAT_24BIT = 3
BASS_WASAPI_FORMAT_32BIT = 4
# BASS_WASAPI_Set/GetVolume "curve"
BASS_WASAPI_CURVE_DB = 0
BASS_WASAPI_CURVE_LINEAR = 1
BASS_WASAPI_CURVE_WINDOWS = 2
#typedef DWORD (CALLBACK WASAPIPROC)(void *buffer, DWORD length, void *user);
WASAPIPROC = func_type(ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p)
#typedef void (CALLBACK WASAPINOTIFYPROC)(DWORD notify, DWORD device, void *user);
WASAPINOTIFYPROC = func_type(ctypes.c_ulong, ctypes.c_ulong, ctypes.c_void_p)
# Device notifications
BASS_WASAPI_NOTIFY_ENABLED = 0
BASS_WASAPI_NOTIFY_DISABLED = 1
BASS_WASAPI_NOTIFY_DEFOUTPUT = 2
BASS_WASAPI_NOTIFY_DEFINPUT = 3
# DWORD BASSWASAPIDEF(BASS_WASAPI_GetVersion)();
BASS_WASAPI_GetVersion = func_type(HSTREAM)(('BASS_WASAPI_GetVersion', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_SetNotify)(WASAPINOTIFYPROC *proc, void *user);
BASS_WASAPI_SetNotify = func_type(HSTREAM, ctypes.POINTER(WASAPINOTIFYPROC), ctypes.c_void_p)(('BASS_WASAPI_SetNotify', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_GetDeviceInfo)(DWORD device, BASS_WASAPI_DEVICEINFO *info);
BASS_WASAPI_GetDeviceInfo = func_type(HSTREAM, ctypes.c_ulong, ctypes.POINTER(BASS_WASAPI_DEVICEINFO))(('BASS_WASAPI_GetDeviceInfo', basswasapi_module))
# float BASSDEF(BASS_WASAPI_GetDeviceLevel)(DWORD device, int chan);
BASS_WASAPI_GetDeviceLevel = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_int)(('BASS_WASAPI_GetDeviceLevel', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_SetDevice)(DWORD device);
BASS_WASAPI_SetDevice = func_type(HSTREAM, ctypes.c_ulong)(('BASS_WASAPI_SetDevice', basswasapi_module))
# DWORD BASSWASAPIDEF(BASS_WASAPI_GetDevice)();
BASS_WASAPI_GetDevice = func_type(HSTREAM)(('BASS_WASAPI_GetDevice', basswasapi_module))
# DWORD BASSWASAPIDEF(BASS_WASAPI_CheckFormat)(DWORD device, DWORD freq, DWORD chans, DWORD flags);
BASS_WASAPI_CheckFormat = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_WASAPI_CheckFormat', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_Init)(int device, DWORD freq, DWORD chans, DWORD flags, float buffer, float period, WASAPIPROC *proc, void *user);
BASS_WASAPI_Init = func_type(HSTREAM, ctypes.c_int, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_float, ctypes.c_float, WASAPIPROC, ctypes.c_void_p)(('BASS_WASAPI_Init', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_Free)();
BASS_WASAPI_Free = func_type(HSTREAM)(('BASS_WASAPI_Free', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_GetInfo)(BASS_WASAPI_INFO *info);
BASS_WASAPI_GetInfo = func_type(HSTREAM, ctypes.POINTER(BASS_WASAPI_INFO))(('BASS_WASAPI_GetInfo', basswasapi_module))
# float BASSWASAPIDEF(BASS_WASAPI_GetCPU)();
BASS_WASAPI_GetCPU = func_type(HSTREAM)(('BASS_WASAPI_GetCPU', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_Lock)(BOOL lock);
BASS_WASAPI_Lock = func_type(HSTREAM, ctypes.c_bool)(('BASS_WASAPI_Lock', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_Start)();
BASS_WASAPI_Start = func_type(HSTREAM)(('BASS_WASAPI_Start', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_Stop)(BOOL reset);
BASS_WASAPI_Stop = func_type(ctypes.c_bool, ctypes.c_bool)(('BASS_WASAPI_Stop', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_IsStarted)();
BASS_WASAPI_IsStarted = func_type(HSTREAM)(('BASS_WASAPI_IsStarted', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_SetVolume)(DWORD curve, float volume);
BASS_WASAPI_SetVolume = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_float)(('BASS_WASAPI_SetVolume', basswasapi_module))
# float BASSWASAPIDEF(BASS_WASAPI_GetVolume)(DWORD curve);
BASS_WASAPI_GetVolume = func_type(HSTREAM, ctypes.c_ulong)(('BASS_WASAPI_GetVolume', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_SetMute)(BOOL mute);
BASS_WASAPI_SetMute = func_type(HSTREAM, ctypes.c_bool)(('BASS_WASAPI_SetMute', basswasapi_module))
# BOOL BASSWASAPIDEF(BASS_WASAPI_GetMute)();
BASS_WASAPI_GetMute = func_type(HSTREAM)(('BASS_WASAPI_GetMute', basswasapi_module))
# DWORD BASSWASAPIDEF(BASS_WASAPI_PutData)(void *buffer, DWORD length);
BASS_WASAPI_PutData = func_type(HSTREAM, ctypes.c_void_p, ctypes.c_ulong)(('BASS_WASAPI_PutData', basswasapi_module))
# DWORD BASSDEF(BASS_WASAPI_GetData)(void *buffer, DWORD length);
BASS_WASAPI_GetData = func_type(HSTREAM, ctypes.c_void_p, ctypes.c_ulong)(('BASS_WASAPI_GetData', basswasapi_module))
# DWORD BASSDEF(BASS_WASAPI_GetLevel)();
BASS_WASAPI_GetLevel = func_type(HSTREAM)(('BASS_WASAPI_GetLevel', basswasapi_module))

View File

@ -1,148 +1,149 @@
from __future__ import absolute_import from __future__ import absolute_import
# Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru # Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru
# http://vosolok2008.narod.ru # http://vosolok2008.narod.ru
# BSD license # BSD license
__version__ = '0.1' __version__ = '0.1'
__versionTime__ = '2009-11-15' __versionTime__ = '2009-11-15'
__author__ = 'Max Kolosov <maxkolosov@inbox.ru>' __author__ = 'Max Kolosov <maxkolosov@inbox.ru>'
__doc__ = ''' __doc__ = '''
pybasswma.py - is ctypes python module for pybasswma.py - is ctypes python module for
BASSWMA - extension to the BASS audio library, BASSWMA - extension to the BASS audio library,
enabling the playback of WMA files and network streams. enabling the playback of WMA files and network streams.
The audio tracks of WMV files can also be played. The audio tracks of WMV files can also be played.
WMA file encoding and network broadcasting functions are also provided. WMA file encoding and network broadcasting functions are also provided.
Requirements Requirements
============ ============
BASS 2.4 is required. The Windows Media Format modules (v9 or above) are BASS 2.4 is required. The Windows Media Format modules (v9 or above) are
also required to be installed on the user's system. They are installed with also required to be installed on the user's system. They are installed with
Windows Media player, so will already be on most users' systems, but they Windows Media player, so will already be on most users' systems, but they
can also be installed separately (WMFDIST.EXE is available from the BASS website). can also be installed separately (WMFDIST.EXE is available from the BASS website).
''' '''
import os, sys, ctypes
from sound_lib.external import pybass import os, sys, ctypes
from . import pybass
from .paths import x86_path, x64_path from .paths import x86_path, x64_path
import libloader import libloader
QWORD = pybass.QWORD QWORD = pybass.QWORD
HSTREAM = pybass.HSTREAM HSTREAM = pybass.HSTREAM
BASS_FILEPROCS = pybass.BASS_FILEPROCS BASS_FILEPROCS = pybass.BASS_FILEPROCS
HWMENCODE = ctypes.c_ulong# WMA encoding handle HWMENCODE = ctypes.c_ulong# WMA encoding handle
basswma_module = libloader.load_library('basswma', x86_path=x86_path, x64_path=x64_path) basswma_module = libloader.load_library('basswma', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype() func_type = libloader.get_functype()
#Register the plugin with the Bass plugin system. #Register the plugin with the Bass plugin system.
pybass.BASS_PluginLoad(libloader.find_library_path('basswma', x86_path=x86_path, x64_path=x64_path), 0) pybass.BASS_PluginLoad(libloader.find_library_path('basswma', x86_path=x86_path, x64_path=x64_path), 0)
# Additional error codes returned by BASS_ErrorGetCode # Additional error codes returned by BASS_ErrorGetCode
BASS_ERROR_WMA_LICENSE = 1000# the file is protected BASS_ERROR_WMA_LICENSE = 1000# the file is protected
BASS_ERROR_WMA = 1001# Windows Media (9 or above) is not installed BASS_ERROR_WMA = 1001# Windows Media (9 or above) is not installed
BASS_ERROR_WMA_WM9 = BASS_ERROR_WMA BASS_ERROR_WMA_WM9 = BASS_ERROR_WMA
BASS_ERROR_WMA_DENIED = 1002# access denied (user/pass is invalid) BASS_ERROR_WMA_DENIED = 1002# access denied (user/pass is invalid)
BASS_ERROR_WMA_INDIVIDUAL = 1004# individualization is needed BASS_ERROR_WMA_INDIVIDUAL = 1004# individualization is needed
BASS_ERROR_WMA_PUBINIT = 1005# publishing point initialization problem BASS_ERROR_WMA_PUBINIT = 1005# publishing point initialization problem
# Additional BASS_SetConfig options # Additional BASS_SetConfig options
BASS_CONFIG_WMA_PRECHECK = 0x10100 BASS_CONFIG_WMA_PRECHECK = 0x10100
BASS_CONFIG_WMA_PREBUF = 0x10101 BASS_CONFIG_WMA_PREBUF = 0x10101
BASS_CONFIG_WMA_BASSFILE = 0x10103 BASS_CONFIG_WMA_BASSFILE = 0x10103
BASS_CONFIG_WMA_NETSEEK = 0x10104 BASS_CONFIG_WMA_NETSEEK = 0x10104
BASS_CONFIG_WMA_VIDEO = 0x10105 BASS_CONFIG_WMA_VIDEO = 0x10105
# additional WMA sync types # additional WMA sync types
BASS_SYNC_WMA_CHANGE = 0x10100 BASS_SYNC_WMA_CHANGE = 0x10100
BASS_SYNC_WMA_META = 0x10101 BASS_SYNC_WMA_META = 0x10101
# additional BASS_StreamGetFilePosition WMA mode # additional BASS_StreamGetFilePosition WMA mode
BASS_FILEPOS_WMA_BUFFER = 1000# internet buffering progress (0-100%) BASS_FILEPOS_WMA_BUFFER = 1000# internet buffering progress (0-100%)
# Additional flags for use with BASS_WMA_EncodeOpen/File/Network/Publish # Additional flags for use with BASS_WMA_EncodeOpen/File/Network/Publish
BASS_WMA_ENCODE_STANDARD = 0x2000# standard WMA BASS_WMA_ENCODE_STANDARD = 0x2000# standard WMA
BASS_WMA_ENCODE_PRO = 0x4000# WMA Pro BASS_WMA_ENCODE_PRO = 0x4000# WMA Pro
BASS_WMA_ENCODE_24BIT = 0x8000# 24-bit BASS_WMA_ENCODE_24BIT = 0x8000# 24-bit
BASS_WMA_ENCODE_SCRIPT = 0x20000# set script (mid-stream tags) in the WMA encoding BASS_WMA_ENCODE_SCRIPT = 0x20000# set script (mid-stream tags) in the WMA encoding
# Additional flag for use with BASS_WMA_EncodeGetRates # Additional flag for use with BASS_WMA_EncodeGetRates
BASS_WMA_ENCODE_RATES_VBR = 0x10000# get available VBR quality settings BASS_WMA_ENCODE_RATES_VBR = 0x10000# get available VBR quality settings
#typedef void (CALLBACK CLIENTCONNECTPROC)(HWMENCODE handle, BOOL connect, const char *ip, void *user); #typedef void (CALLBACK CLIENTCONNECTPROC)(HWMENCODE handle, BOOL connect, const char *ip, void *user);
CLIENTCONNECTPROC = func_type(None, HWMENCODE, ctypes.c_byte, ctypes.c_char_p, ctypes.c_void_p) CLIENTCONNECTPROC = func_type(None, HWMENCODE, ctypes.c_byte, ctypes.c_char_p, ctypes.c_void_p)
# Client connection notification callback function. # Client connection notification callback function.
#handle : The encoder #handle : The encoder
#connect: TRUE=client is connecting, FALSE=disconnecting #connect: TRUE=client is connecting, FALSE=disconnecting
#ip : The client's IP (xxx.xxx.xxx.xxx:port) #ip : The client's IP (xxx.xxx.xxx.xxx:port)
#user : The 'user' parameter value given when calling BASS_WMA_EncodeSetNotify #user : The 'user' parameter value given when calling BASS_WMA_EncodeSetNotify
#typedef void (CALLBACK WMENCODEPROC)(HWMENCODE handle, DWORD type, const void *buffer, DWORD length, void *user); #typedef void (CALLBACK WMENCODEPROC)(HWMENCODE handle, DWORD type, const void *buffer, DWORD length, void *user);
WMENCODEPROC = func_type(None, HWMENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p) WMENCODEPROC = func_type(None, HWMENCODE, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p)
# Encoder callback function. # Encoder callback function.
#handle : The encoder handle #handle : The encoder handle
#type : The type of data, one of BASS_WMA_ENCODE_xxx values #type : The type of data, one of BASS_WMA_ENCODE_xxx values
#buffer : The encoded data #buffer : The encoded data
#length : Length of the data #length : Length of the data
#user : The 'user' parameter value given when calling BASS_WMA_EncodeOpen #user : The 'user' parameter value given when calling BASS_WMA_EncodeOpen
# WMENCODEPROC "type" values # WMENCODEPROC "type" values
BASS_WMA_ENCODE_HEAD = 0 BASS_WMA_ENCODE_HEAD = 0
BASS_WMA_ENCODE_DATA = 1 BASS_WMA_ENCODE_DATA = 1
BASS_WMA_ENCODE_DONE = 2 BASS_WMA_ENCODE_DONE = 2
# BASS_WMA_EncodeSetTag "form" values # BASS_WMA_EncodeSetTag "form" values
BASS_WMA_TAG_ANSI = 0 BASS_WMA_TAG_ANSI = 0
BASS_WMA_TAG_UNICODE = 1 BASS_WMA_TAG_UNICODE = 1
BASS_WMA_TAG_UTF8 = 2 BASS_WMA_TAG_UTF8 = 2
BASS_WMA_TAG_BINARY = 0x100# FLAG: binary tag (HIWORD=length) BASS_WMA_TAG_BINARY = 0x100# FLAG: binary tag (HIWORD=length)
# BASS_CHANNELINFO type # BASS_CHANNELINFO type
BASS_CTYPE_STREAM_WMA = 0x10300 BASS_CTYPE_STREAM_WMA = 0x10300
BASS_CTYPE_STREAM_WMA_MP3 = 0x10301 BASS_CTYPE_STREAM_WMA_MP3 = 0x10301
# Additional BASS_ChannelGetTags types # Additional BASS_ChannelGetTags types
BASS_TAG_WMA = 8# WMA header tags : series of null-terminated UTF-8 strings BASS_TAG_WMA = 8# WMA header tags : series of null-terminated UTF-8 strings
BASS_TAG_WMA_META = 11# WMA mid-stream tag : UTF-8 string BASS_TAG_WMA_META = 11# WMA mid-stream tag : UTF-8 string
#HSTREAM BASSWMADEF(BASS_WMA_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags); #HSTREAM BASSWMADEF(BASS_WMA_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
BASS_WMA_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_WMA_StreamCreateFile', basswma_module)) BASS_WMA_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_WMA_StreamCreateFile', basswma_module))
#HSTREAM BASSWMADEF(BASS_WMA_StreamCreateFileAuth)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags, const char *user, const char *pass); #HSTREAM BASSWMADEF(BASS_WMA_StreamCreateFileAuth)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags, const char *user, const char *pass);
BASS_WMA_StreamCreateFileAuth = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong, ctypes.c_char_p, ctypes.c_char_p)(('BASS_WMA_StreamCreateFileAuth', basswma_module)) BASS_WMA_StreamCreateFileAuth = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong, ctypes.c_char_p, ctypes.c_char_p)(('BASS_WMA_StreamCreateFileAuth', basswma_module))
#HSTREAM BASSWMADEF(BASS_WMA_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user); #HSTREAM BASSWMADEF(BASS_WMA_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);
BASS_WMA_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_WMA_StreamCreateFileUser', basswma_module)) BASS_WMA_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_WMA_StreamCreateFileUser', basswma_module))
#const char *BASSWMADEF(BASS_WMA_GetTags)(const void *file, DWORD flags); #const char *BASSWMADEF(BASS_WMA_GetTags)(const void *file, DWORD flags);
BASS_WMA_GetTags = func_type(ctypes.c_char_p, ctypes.c_void_p, ctypes.c_ulong)(('BASS_WMA_GetTags', basswma_module)) BASS_WMA_GetTags = func_type(ctypes.c_char_p, ctypes.c_void_p, ctypes.c_ulong)(('BASS_WMA_GetTags', basswma_module))
#const DWORD *BASSWMADEF(BASS_WMA_EncodeGetRates)(DWORD freq, DWORD chans, DWORD flags); #const DWORD *BASSWMADEF(BASS_WMA_EncodeGetRates)(DWORD freq, DWORD chans, DWORD flags);
BASS_WMA_EncodeGetRates = func_type(ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_WMA_EncodeGetRates', basswma_module)) BASS_WMA_EncodeGetRates = func_type(ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_WMA_EncodeGetRates', basswma_module))
#HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpen)(DWORD freq, DWORD chans, DWORD flags, DWORD bitrate, WMENCODEPROC *proc, void *user); #HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpen)(DWORD freq, DWORD chans, DWORD flags, DWORD bitrate, WMENCODEPROC *proc, void *user);
BASS_WMA_EncodeOpen = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, WMENCODEPROC, ctypes.c_void_p)(('BASS_WMA_EncodeOpen', basswma_module)) BASS_WMA_EncodeOpen = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, WMENCODEPROC, ctypes.c_void_p)(('BASS_WMA_EncodeOpen', basswma_module))
#HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpenFile)(DWORD freq, DWORD chans, DWORD flags, DWORD bitrate, const char *file); #HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpenFile)(DWORD freq, DWORD chans, DWORD flags, DWORD bitrate, const char *file);
BASS_WMA_EncodeOpenFile = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_char_p)(('BASS_WMA_EncodeOpenFile', basswma_module)) BASS_WMA_EncodeOpenFile = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_char_p)(('BASS_WMA_EncodeOpenFile', basswma_module))
#HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpenNetwork)(DWORD freq, DWORD chans, DWORD flags, DWORD bitrate, DWORD port, DWORD clients); #HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpenNetwork)(DWORD freq, DWORD chans, DWORD flags, DWORD bitrate, DWORD port, DWORD clients);
BASS_WMA_EncodeOpenNetwork = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_WMA_EncodeOpenNetwork', basswma_module)) BASS_WMA_EncodeOpenNetwork = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong)(('BASS_WMA_EncodeOpenNetwork', basswma_module))
#HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpenNetworkMulti)(DWORD freq, DWORD chans, DWORD flags, const DWORD *bitrates, DWORD port, DWORD clients); #HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpenNetworkMulti)(DWORD freq, DWORD chans, DWORD flags, const DWORD *bitrates, DWORD port, DWORD clients);
BASS_WMA_EncodeOpenNetworkMulti = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulong), ctypes.c_ulong, ctypes.c_ulong)(('BASS_WMA_EncodeOpenNetworkMulti', basswma_module)) BASS_WMA_EncodeOpenNetworkMulti = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulong), ctypes.c_ulong, ctypes.c_ulong)(('BASS_WMA_EncodeOpenNetworkMulti', basswma_module))
#HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpenPublish)(DWORD freq, DWORD chans, DWORD flags, DWORD bitrate, const char *url, const char *user, const char *pass); #HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpenPublish)(DWORD freq, DWORD chans, DWORD flags, DWORD bitrate, const char *url, const char *user, const char *pass);
BASS_WMA_EncodeOpenPublish = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p)(('BASS_WMA_EncodeOpenPublish', basswma_module)) BASS_WMA_EncodeOpenPublish = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p)(('BASS_WMA_EncodeOpenPublish', basswma_module))
#HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpenPublishMulti)(DWORD freq, DWORD chans, DWORD flags, const DWORD *bitrates, const char *url, const char *user, const char *pass); #HWMENCODE BASSWMADEF(BASS_WMA_EncodeOpenPublishMulti)(DWORD freq, DWORD chans, DWORD flags, const DWORD *bitrates, const char *url, const char *user, const char *pass);
BASS_WMA_EncodeOpenPublishMulti = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulong), ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p)(('BASS_WMA_EncodeOpenPublishMulti', basswma_module)) BASS_WMA_EncodeOpenPublishMulti = func_type(HWMENCODE, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulong), ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p)(('BASS_WMA_EncodeOpenPublishMulti', basswma_module))
#DWORD BASSWMADEF(BASS_WMA_EncodeGetPort)(HWMENCODE handle); #DWORD BASSWMADEF(BASS_WMA_EncodeGetPort)(HWMENCODE handle);
BASS_WMA_EncodeGetPort = func_type(ctypes.c_ulong, HWMENCODE)(('BASS_WMA_EncodeGetPort', basswma_module)) BASS_WMA_EncodeGetPort = func_type(ctypes.c_ulong, HWMENCODE)(('BASS_WMA_EncodeGetPort', basswma_module))
#BOOL BASSWMADEF(BASS_WMA_EncodeSetNotify)(HWMENCODE handle, CLIENTCONNECTPROC *proc, void *user); #BOOL BASSWMADEF(BASS_WMA_EncodeSetNotify)(HWMENCODE handle, CLIENTCONNECTPROC *proc, void *user);
BASS_WMA_EncodeSetNotify = func_type(ctypes.c_byte, HWMENCODE, CLIENTCONNECTPROC, ctypes.c_void_p)(('BASS_WMA_EncodeSetNotify', basswma_module)) BASS_WMA_EncodeSetNotify = func_type(ctypes.c_byte, HWMENCODE, CLIENTCONNECTPROC, ctypes.c_void_p)(('BASS_WMA_EncodeSetNotify', basswma_module))
#DWORD BASSWMADEF(BASS_WMA_EncodeGetClients)(HWMENCODE handle); #DWORD BASSWMADEF(BASS_WMA_EncodeGetClients)(HWMENCODE handle);
BASS_WMA_EncodeGetClients = func_type(ctypes.c_ulong, HWMENCODE)(('BASS_WMA_EncodeGetClients', basswma_module)) BASS_WMA_EncodeGetClients = func_type(ctypes.c_ulong, HWMENCODE)(('BASS_WMA_EncodeGetClients', basswma_module))
#BOOL BASSWMADEF(BASS_WMA_EncodeSetTag)(HWMENCODE handle, const char *tag, const char *text, DWORD form); #BOOL BASSWMADEF(BASS_WMA_EncodeSetTag)(HWMENCODE handle, const char *tag, const char *text, DWORD form);
BASS_WMA_EncodeSetTag = func_type(ctypes.c_byte, HWMENCODE, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong)(('BASS_WMA_EncodeSetTag', basswma_module)) BASS_WMA_EncodeSetTag = func_type(ctypes.c_byte, HWMENCODE, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_ulong)(('BASS_WMA_EncodeSetTag', basswma_module))
#BOOL BASSWMADEF(BASS_WMA_EncodeWrite)(HWMENCODE handle, const void *buffer, DWORD length); #BOOL BASSWMADEF(BASS_WMA_EncodeWrite)(HWMENCODE handle, const void *buffer, DWORD length);
BASS_WMA_EncodeWrite = func_type(ctypes.c_byte, HWMENCODE, ctypes.c_void_p, ctypes.c_ulong)(('BASS_WMA_EncodeWrite', basswma_module)) BASS_WMA_EncodeWrite = func_type(ctypes.c_byte, HWMENCODE, ctypes.c_void_p, ctypes.c_ulong)(('BASS_WMA_EncodeWrite', basswma_module))
#BOOL BASSWMADEF(BASS_WMA_EncodeClose)(HWMENCODE handle); #BOOL BASSWMADEF(BASS_WMA_EncodeClose)(HWMENCODE handle);
BASS_WMA_EncodeClose = func_type(ctypes.c_byte, HWMENCODE)(('BASS_WMA_EncodeClose', basswma_module)) BASS_WMA_EncodeClose = func_type(ctypes.c_byte, HWMENCODE)(('BASS_WMA_EncodeClose', basswma_module))
#void *BASSWMADEF(BASS_WMA_GetWMObject)(DWORD handle); #void *BASSWMADEF(BASS_WMA_GetWMObject)(DWORD handle);
BASS_WMA_GetWMObject = func_type(ctypes.c_void_p, ctypes.c_ulong)(('BASS_WMA_GetWMObject', basswma_module)) BASS_WMA_GetWMObject = func_type(ctypes.c_void_p, ctypes.c_ulong)(('BASS_WMA_GetWMObject', basswma_module))

47
src/sound_lib/external/pytags.py vendored Normal file
View File

@ -0,0 +1,47 @@
# Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru
# http://vosolok2008.narod.ru
# BSD license
__version__ = '0.1'
__versionTime__ = '2009-11-10'
__author__ = 'Max Kolosov <maxkolosov@inbox.ru>'
__doc__ = '''
pytags.py - is ctypes python module for
TAGS (Another Tags Reading Library written by Wraith).
BASS audio library has limited support for reading tags, associated with a
stream. This library extends that functionality, allowing developer/user to
extract specific song information from the stream handle used with BASS. The
extracted tag values are formatted into text ouput according to given format
string (including conditional processing).
Supported tags:
---------------
MP3 ID3v1 and ID3v2.2/3/4
OGG/FLAC comments
WMA
APE, OFR, MPC, AAC - all use APE tags
MP4
MOD/etc titles
'''
import sys, ctypes, platform
from paths import x86_path, x64_path
import libloader
tags_module = libloader.load_library('tags', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype()# Current version. Just increments each release.
TAGS_VERSION = 17
# returns description of the last error.
#const char* _stdcall TAGS_GetLastErrorDesc();
TAGS_GetLastErrorDesc = func_type(ctypes.c_char_p)(('TAGS_GetLastErrorDesc', tags_module))
# main purpose of this library
#const char* _stdcall TAGS_Read( DWORD dwHandle, const char* fmt );
TAGS_Read = func_type(ctypes.c_char_p, ctypes.c_ulong, ctypes.c_char_p)(('TAGS_Read', tags_module))
# retrieves the current version
#DWORD _stdcall TAGS_GetVersion();
TAGS_GetVersion = func_type(ctypes.c_ulong)(('TAGS_GetVersion', tags_module))

View File

@ -1,66 +1,94 @@
from __future__ import absolute_import from ctypes import string_at
from future.builtins import object import platform
from ctypes import string_at import wave
import wave
from .external.pybass import *
from .external.pybass import * if platform.system() == 'Windows':
from . import config from .external.pybasswasapi import *
from .main import bass_call, bass_call_0, BassError from . import config
from .main import bass_call, bass_call_0
class Input (object):
class Input (object):
def __init__ (self, device=-1):
try: def __init__ (self, device=-1):
bass_call(BASS_RecordInit, device) bass_call(BASS_RecordInit, device)
except BassError: self._device = device
pass self.config = config.BassConfig()
self._device = device
self.config = config.BassConfig() def free(self):
"""Frees all resources used by the recording device."""
def free(self): return bass_call(BASS_RecordFree)
"""Frees all resources used by the recording device."""
return bass_call(BASS_RecordFree) def get_device(self):
return bass_call_0(BASS_RecordGetDevice)
def get_device(self):
return bass_call_0(BASS_RecordGetDevice) def set_device(self, device):
if device == self._device:
def set_device(self, device): return
if device == self._device: self.free()
return self.__init__(device=device)
self.free()
self.__init__(device=device) device = property(fget=get_device, fset=set_device)
device = property(fget=get_device, fset=set_device) @staticmethod
def get_device_names():
@staticmethod """Convenience method that returns a list of device names that are considered
def get_device_names(): valid by bass.
"""Convenience method that returns a list of device names that are considered
valid by bass. Parameters: none.
returns: list of devices, 0-indexed.
Parameters: none. """
returns: list of devices, 0-indexed. result = ['Default']
""" info = BASS_DEVICEINFO()
result = ['Default'] count = 0
info = BASS_DEVICEINFO() while BASS_RecordGetDeviceInfo(count, ctypes.byref(info)):
count = 0 if info.flags & BASS_DEVICE_ENABLED:
while BASS_RecordGetDeviceInfo(count, ctypes.byref(info)): retrieved = info.name
if info.flags & BASS_DEVICE_ENABLED: if platform.system() == 'Windows':
retrieved = info.name retrieved = retrieved.decode('mbcs')
if platform.system() == 'Windows': elif platform.system() == 'Darwin':
retrieved = retrieved.decode('mbcs') retrieved = retrieved.decode('utf-8')
retrieved = retrieved.replace('(', '').replace(')', '').strip() retrieved = retrieved.replace('(', '').replace(')', '').strip()
result.append(retrieved) result.append(retrieved)
count += 1 count += 1
return result return result
def find_device_by_name(self, name): def find_device_by_name(self, name):
return self.get_device_names().index(name) - 1 return self.get_device_names().index(name) - 1
def find_default_device(self): def find_default_device(self):
return -1 return -1
def find_user_provided_device(self, device_name): def find_user_provided_device(self, device_name):
try: try:
return self.find_device_by_name(device_name) return self.find_device_by_name(device_name)
except ValueError: except ValueError:
return self.find_default_device() return self.find_default_device()
class WASAPIInput(object):
def __init__(self, device=-2, frequency=0, channels=0, flags=0, buffer=0.0, period=0.0, callback=None):
if callback is None:
callback = lambda buffer, length, user: True
self.proc = WASAPIPROC(callback)
bass_call(BASS_WASAPI_Init, device, frequency, channels, flags, buffer, period, self.proc, None)
def free(self):
bass_call(BASS_WASAPI_Free)
def set_device(self, device):
bass_call(BASS_WASAPI_SetDevice, device)
def get_device(self):
return bass_call_0(BASS_WASAPI_GetDevice)
device = property(fget=get_device, fset=set_device)
def start(self):
return bass_call(BASS_WASAPI_Start)
def stop(self, reset=False):
return bass_call(BASS_WASAPI_Stop, reset)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,100 +1,98 @@
from __future__ import absolute_import from ctypes import pointer
from future.builtins import object from functools import partial
from ctypes import pointer from main import bass_call, update_3d_system
from functools import partial from external.pybass import *
from .main import bass_call, update_3d_system
from .external.pybass import * def _getter(base_prop, attr, obj):
return getattr(getattr(obj, base_prop), attr)
def _getter(base_prop, attr, obj):
return getattr(getattr(obj, base_prop), attr) def _setter(base_prop, subattr, obj, val):
old = getattr(obj, base_prop)
def _setter(base_prop, subattr, obj, val): setattr(old, subattr, val)
old = getattr(obj, base_prop) setattr(obj, base_prop, old)
setattr(old, subattr, val)
setattr(obj, base_prop, old) class Listener(object):
class Listener(object): def get_3d_position(self):
res = {
def get_3d_position(self): 'position': BASS_3DVECTOR(),
res = { 'velocity': BASS_3DVECTOR(),
'position': BASS_3DVECTOR(), 'front': BASS_3DVECTOR(),
'velocity': BASS_3DVECTOR(), 'top': BASS_3DVECTOR()
'front': BASS_3DVECTOR(), }
'top': BASS_3DVECTOR() bass_call(BASS_Get3DPosition, pointer(res['position']), pointer(res['velocity']), pointer(res['front']), pointer(res['top']))
} return res
bass_call(BASS_Get3DPosition, pointer(res['position']), pointer(res['velocity']), pointer(res['front']), pointer(res['top']))
return res @update_3d_system
def set_3d_position(self, position=None, velocity=None, front=None, top=None):
@update_3d_system """Sets the position, velocity, and orientation of the listener (ie. the player)."""
def set_3d_position(self, position=None, velocity=None, front=None, top=None): old = self.get_3d_position()
"""Sets the position, velocity, and orientation of the listener (ie. the player).""" if position is None:
old = self.get_3d_position() position = old['position']
if position is None: if velocity is None:
position = old['position'] velocity = old['velocity']
if velocity is None: if front is None:
velocity = old['velocity'] front = old['front']
if front is None: if top is None:
front = old['front'] top = old['top']
if top is None: position = pointer(position)
top = old['top'] velocity = pointer(velocity)
position = pointer(position) front = pointer(front)
velocity = pointer(velocity) top = pointer(top)
front = pointer(front) bass_call(BASS_Set3DPosition, position, velocity, front, top)
top = pointer(top)
bass_call(BASS_Set3DPosition, position, velocity, front, top) def get_position(self):
return self.get_3d_position()['position']
def get_position(self):
return self.get_3d_position()['position'] def set_position(self, position):
self.set_3d_position(position=position)
def set_position(self, position):
self.set_3d_position(position=position) position = property(fget=get_position, fset=set_position)
position = property(fget=get_position, fset=set_position) x = property(fget=partial(_getter, 'position', 'x'), fset=partial(_setter, 'position', 'x'))
x = property(fget=partial(_getter, 'position', 'x'), fset=partial(_setter, 'position', 'x')) y = property(fget=partial(_getter, 'position', 'y'), fset=partial(_setter, 'position', 'y'))
y = property(fget=partial(_getter, 'position', 'y'), fset=partial(_setter, 'position', 'y')) z = property(fget=partial(_getter, 'position', 'z'), fset=partial(_setter, 'position', 'z'))
z = property(fget=partial(_getter, 'position', 'z'), fset=partial(_setter, 'position', 'z')) def get_velocity(self):
return self.get_3d_position()['velocity']
def get_velocity(self):
return self.get_3d_position()['velocity'] def set_velocity(self, velocity):
self.set_3d_position(velocity=velocity)
def set_velocity(self, velocity):
self.set_3d_position(velocity=velocity) velocity = property(fget=get_velocity, fset=set_velocity)
velocity = property(fget=get_velocity, fset=set_velocity) x_velocity = property(fget=partial(_getter, 'velocity', 'x'), fset=partial(_setter, 'velocity', 'x'))
x_velocity = property(fget=partial(_getter, 'velocity', 'x'), fset=partial(_setter, 'velocity', 'x')) y_velocity = property(fget=partial(_getter, 'velocity', 'y'), fset=partial(_setter, 'velocity', 'y'))
y_velocity = property(fget=partial(_getter, 'velocity', 'y'), fset=partial(_setter, 'velocity', 'y')) z_velocity = property(fget=partial(_getter, 'velocity', 'z'), fset=partial(_setter, 'velocity', 'z'))
z_velocity = property(fget=partial(_getter, 'velocity', 'z'), fset=partial(_setter, 'velocity', 'z')) def get_front(self):
return self.get_3d_position()['front']
def get_front(self):
return self.get_3d_position()['front'] def set_front(self, front):
self.set_3d_position(front=front)
def set_front(self, front):
self.set_3d_position(front=front) front = property(fget=get_front, fset=set_front)
front = property(fget=get_front, fset=set_front) front_x = property(fget=partial(_getter, 'front', 'x'), fset=partial(_setter, 'front', 'x'))
front_x = property(fget=partial(_getter, 'front', 'x'), fset=partial(_setter, 'front', 'x')) front_y = property(fget=partial(_getter, 'front', 'y'), fset=partial(_setter, 'front', 'y'))
front_y = property(fget=partial(_getter, 'front', 'y'), fset=partial(_setter, 'front', 'y')) front_z = property(fget=partial(_getter, 'front', 'z'), fset=partial(_setter, 'front', 'z'))
front_z = property(fget=partial(_getter, 'front', 'z'), fset=partial(_setter, 'front', 'z')) def get_top(self):
return self.get_3d_position()['top']
def get_top(self):
return self.get_3d_position()['top'] def set_top(self, top):
self.set_3d_position(top=top)
def set_top(self, top):
self.set_3d_position(top=top) top = property(fget=get_top, fset=set_top)
top = property(fget=get_top, fset=set_top) top_x = property(fget=partial(_getter, 'front', 'x'), fset=partial(_setter, 'front', 'x'))
top_x = property(fget=partial(_getter, 'front', 'x'), fset=partial(_setter, 'front', 'x')) top_y = property(fget=partial(_getter, 'front', 'y'), fset=partial(_setter, 'front', 'y'))
top_y = property(fget=partial(_getter, 'front', 'y'), fset=partial(_setter, 'front', 'y')) top_z = property(fget=partial(_getter, 'front', 'z'), fset=partial(_setter, 'front', 'z'))
top_z = property(fget=partial(_getter, 'front', 'z'), fset=partial(_setter, 'front', 'z'))

View File

@ -1,89 +1,88 @@
from __future__ import absolute_import from __future__ import absolute_import
from future.builtins import object from .external.pybass import *
from .external.pybass import * from functools import update_wrapper
from functools import update_wrapper
EAX_ENVIRONMENTS = {
EAX_ENVIRONMENTS = { 'generic': EAX_ENVIRONMENT_GENERIC,
'generic': EAX_ENVIRONMENT_GENERIC, 'padded_cell': EAX_ENVIRONMENT_PADDEDCELL,
'padded_cell': EAX_ENVIRONMENT_PADDEDCELL, 'room': EAX_ENVIRONMENT_ROOM,
'room': EAX_ENVIRONMENT_ROOM, 'bathroom': EAX_ENVIRONMENT_BATHROOM,
'bathroom': EAX_ENVIRONMENT_BATHROOM, 'living_room': EAX_ENVIRONMENT_LIVINGROOM,
'living_room': EAX_ENVIRONMENT_LIVINGROOM, 'stone_room': EAX_ENVIRONMENT_STONEROOM,
'stone_room': EAX_ENVIRONMENT_STONEROOM, 'auditorium': EAX_ENVIRONMENT_AUDITORIUM,
'auditorium': EAX_ENVIRONMENT_AUDITORIUM, 'concert_hall': EAX_ENVIRONMENT_CONCERTHALL,
'concert_hall': EAX_ENVIRONMENT_CONCERTHALL, 'cave': EAX_ENVIRONMENT_CAVE,
'cave': EAX_ENVIRONMENT_CAVE, 'arena': EAX_ENVIRONMENT_ARENA,
'arena': EAX_ENVIRONMENT_ARENA, 'hanger': EAX_ENVIRONMENT_HANGAR,
'hanger': EAX_ENVIRONMENT_HANGAR, 'carpeted_hallway': EAX_ENVIRONMENT_CARPETEDHALLWAY,
'carpeted_hallway': EAX_ENVIRONMENT_CARPETEDHALLWAY, 'hallway': EAX_ENVIRONMENT_HALLWAY,
'hallway': EAX_ENVIRONMENT_HALLWAY, 'stone_corridor': EAX_ENVIRONMENT_STONECORRIDOR,
'stone_corridor': EAX_ENVIRONMENT_STONECORRIDOR, 'alley': EAX_ENVIRONMENT_ALLEY,
'alley': EAX_ENVIRONMENT_ALLEY, 'forest': EAX_ENVIRONMENT_FOREST,
'forest': EAX_ENVIRONMENT_FOREST, 'city': EAX_ENVIRONMENT_CITY,
'city': EAX_ENVIRONMENT_CITY, 'mountains': EAX_ENVIRONMENT_MOUNTAINS,
'mountains': EAX_ENVIRONMENT_MOUNTAINS, 'quarry': EAX_ENVIRONMENT_QUARRY,
'quarry': EAX_ENVIRONMENT_QUARRY, 'plain': EAX_ENVIRONMENT_PLAIN,
'plain': EAX_ENVIRONMENT_PLAIN, 'parking_lot': EAX_ENVIRONMENT_PARKINGLOT,
'parking_lot': EAX_ENVIRONMENT_PARKINGLOT, 'sewer_pipe': EAX_ENVIRONMENT_SEWERPIPE,
'sewer_pipe': EAX_ENVIRONMENT_SEWERPIPE, 'underwater': EAX_ENVIRONMENT_UNDERWATER,
'underwater': EAX_ENVIRONMENT_UNDERWATER, 'drugged': EAX_ENVIRONMENT_DRUGGED,
'drugged': EAX_ENVIRONMENT_DRUGGED, 'dizzy': EAX_ENVIRONMENT_DIZZY,
'dizzy': EAX_ENVIRONMENT_DIZZY, 'psychotic': EAX_ENVIRONMENT_PSYCHOTIC
'psychotic': EAX_ENVIRONMENT_PSYCHOTIC }
}
class BassError (Exception):
class BassError (Exception): """Error that is raised when there is a problem with a Bass call."""
"""Error that is raised when there is a problem with a Bass call."""
def __init__(self, code, description):
def __init__(self, code, description): self.code = code
self.code = code self.description = description
self.description = description
def __str__(self):
def __str__(self): return '%d, %s' % (self.code, self.description)
return '%d, %s' % (self.code, self.description)
def bass_call(function, *args):
def bass_call(function, *args): """Makes a call to bass and raises an exception if it fails."""
"""Makes a call to bass and raises an exception if it fails.""" res = function(*args)
res = function(*args) if res == 0 or res == -1:
if res == 0 or res == -1: code = BASS_ErrorGetCode()
code = BASS_ErrorGetCode() raise BassError(code, get_error_description(code))
raise BassError(code, get_error_description(code)) return res
return res
def bass_call_0(function, *args):
def bass_call_0(function, *args): """Makes a call to bass and raises an exception if it fails. Does not consider 0 an error."""
"""Makes a call to bass and raises an exception if it fails. Does not consider 0 an error.""" res = function(*args)
res = function(*args) if res == -1:
if res == -1: code = BASS_ErrorGetCode()
code = BASS_ErrorGetCode() raise BassError(code, get_error_description(code))
raise BassError(code, get_error_description(code)) return res
return res
def update_3d_system(func):
def update_3d_system(func): """Decorator to automatically update the 3d system after a function call."""
"""Decorator to automatically update the 3d system after a function call.""" def update_3d_system_wrapper(*args, **kwargs):
def update_3d_system_wrapper(*args, **kwargs): val = func(*args, **kwargs)
val = func(*args, **kwargs) bass_call( BASS_Apply3D)
bass_call( BASS_Apply3D) return val
return val update_wrapper(update_3d_system_wrapper, func)
update_wrapper(update_3d_system_wrapper, func) return update_3d_system_wrapper
return update_3d_system_wrapper
class FlagObject(object):
class FlagObject(object): """An object which translates bass flags into human-readable/usable items"""
"""An object which translates bass flags into human-readable/usable items"""
def flags_for(self, **flags):
def flags_for(self, **flags): res = 0
res = 0 for k, v in flags.items():
for k, v in flags.items(): if v:
if v: res |= self.flag_mapping[k]
res |= self.flag_mapping[k] return res
return res
def setup_flag_mapping(self):
def setup_flag_mapping(self): self.flag_mapping = {
self.flag_mapping = { 'loop': BASS_SAMPLE_LOOP,
'loop': BASS_SAMPLE_LOOP, 'autofree': BASS_STREAM_AUTOFREE,
'autofree': BASS_STREAM_AUTOFREE, 'mono': BASS_SAMPLE_MONO,
'mono': BASS_SAMPLE_MONO, 'software': BASS_SAMPLE_SOFTWARE,
'software': BASS_SAMPLE_SOFTWARE, 'three_d': BASS_SAMPLE_3D,
'three_d': BASS_SAMPLE_3D, 'fx': BASS_SAMPLE_FX,
'fx': BASS_SAMPLE_FX, 'decode': BASS_STREAM_DECODE,
'decode': BASS_STREAM_DECODE, }
}

View File

@ -1,18 +1,17 @@
from __future__ import absolute_import from external import pybass
from .external import pybass from channel import Channel
from .channel import Channel
class Music(Channel):
class Music(Channel):
def __init__(self, mem=False, file=None, offset=0, length=0, flags=0, freq=0):
def __init__(self, mem=False, file=None, offset=0, length=0, flags=0, freq=0): handle = BASS_MusicLoad(mem, file, offset, length, flags, freq)
handle = pybass.BASS_MusicLoad(mem, file, offset, length, flags, freq) super(Music, self).__init__(handle)
super(Music, self).__init__(handle) self.add_attributes_to_mapping(
self.add_attributes_to_mapping( music_amplify=pybass.BASS_ATTRIB_MUSIC_AMPLIFY,
music_amplify=pybass.BASS_ATTRIB_MUSIC_AMPLIFY, music_bpm = BASS_ATTRIB_MUSIC_BPM,
music_bpm = pybass.BASS_ATTRIB_MUSIC_BPM, music_pansep=BASS_ATTRIB_MUSIC_PANSEP,
music_pansep=pybass.BASS_ATTRIB_MUSIC_PANSEP, music_speed=BASS_ATTRIB_MUSIC_SPEED,
music_speed=pybass.BASS_ATTRIB_MUSIC_SPEED, music_vol_chan=BASS_ATTRIB_MUSIC_VOL_CHAN,
music_vol_chan=pybass.BASS_ATTRIB_MUSIC_VOL_CHAN, music_vol_global=BASS_ATTRIB_MUSIC_VOL_GLOBAL,
music_vol_global=pybass.BASS_ATTRIB_MUSIC_VOL_GLOBAL, music_vol_inst=BASS_ATTRIB_MUSIC_VOL_INST,
music_vol_inst=pybass.BASS_ATTRIB_MUSIC_VOL_INST, )
)

View File

@ -1,190 +1,190 @@
from __future__ import division from __future__ import absolute_import
from __future__ import absolute_import from functools import partial
from future.builtins import object import platform
from functools import partial from ctypes import c_char_p, c_float, pointer, string_at
import platform from .external.pybass import *
from ctypes import c_char_p, c_float, pointer, string_at from . import config
from sound_lib.external.pybass import * from .main import bass_call, bass_call_0, EAX_ENVIRONMENTS, update_3d_system
from . import config
from .main import bass_call, bass_call_0, EAX_ENVIRONMENTS, update_3d_system _getter = lambda func, key, obj: func(obj)[key]
_setter = lambda func, kwarg, obj, val: func(obj, **{kwarg: val})
_getter = lambda func, key, obj: func(obj)[key]
_setter = lambda func, kwarg, obj, val: func(obj, **{kwarg: val}) class Output (object):
class Output (object): def __init__(self, device=-1, frequency=44100, flags=0, window=0, clsid=None):
try:
def __init__(self, device=-1, frequency=44100, flags=0, window=0, clsid=None): self.use_default_device()
try: except:
self.use_default_device() pass
except: self._device = device
pass self.frequency = frequency
self._device = device self.flags = flags
self.frequency = frequency self.window = window
self.flags = flags self.clsid = clsid
self.window = window self.init_device(device=device, frequency=frequency, flags=flags, window=window, clsid=clsid)
self.clsid = clsid self.config = config.BassConfig()
self.init_device(device=device, frequency=frequency, flags=flags, window=window, clsid=clsid) self.proxy = None
self.config = config.BassConfig()
self.proxy = None def init_device(self, device=None, frequency=None, flags=None, window=None, clsid=None):
if device is None:
def init_device(self, device=None, frequency=None, flags=None, window=None, clsid=None): device = self._device
if device is None: self._device = device
device = self._device if frequency is None:
self._device = device frequency = self.frequency
if frequency is None: self.frequency = frequency
frequency = self.frequency if flags is None:
self.frequency = frequency flags = self.flags
if flags is None: self.flags = flags
flags = self.flags if window is None:
self.flags = flags window = self.window
if window is None: self.window = window
window = self.window if clsid is None:
self.window = window clsid = self.clsid
if clsid is None: self.clsid = clsid
clsid = self.clsid if platform.system() == 'Linux' and device == -1: #Bass wants default device set to 1 on linux
self.clsid = clsid device = 1
if platform.system() == 'Linux' and device == -1: #Bass wants default device set to 1 on linux bass_call(BASS_Init, device, frequency, flags, window, clsid)
device = 1
bass_call(BASS_Init, device, frequency, flags, window, clsid) def start(self):
return bass_call(BASS_Start)
def start(self):
return bass_call(BASS_Start) def pause(self):
return bass_call(BASS_Pause)
def pause(self):
return bass_call(BASS_Pause) def stop(self):
return bass_call(BASS_Stop)
def stop(self):
return bass_call(BASS_Stop) def get_device(self):
return bass_call_0(BASS_GetDevice)
def get_device(self):
return bass_call_0(BASS_GetDevice) def set_device(self, device):
if device == self._device:
def set_device(self, device): return
if device == self._device: self.free()
return self.init_device(device=device)
self.free() return bass_call(BASS_SetDevice, device)
self.init_device(device=device)
return bass_call(BASS_SetDevice, device) device = property(fget=get_device, fset=set_device)
device = property(fget=get_device, fset=set_device) def get_volume (self):
volume = BASS_GetConfig(BASS_CONFIG_GVOL_STREAM)
def get_volume (self): if volume:
volume = BASS_GetConfig(BASS_CONFIG_GVOL_STREAM) volume = volume / 100.0
if volume: return volume
volume = volume / 100.0
return volume def set_volume (self, volume):
#Pass in a float 0.0 to 100.0 and watch the volume magically change
def set_volume (self, volume): return bass_call(BASS_SetConfig, BASS_CONFIG_GVOL_STREAM, int(round(volume*100, 2)))
#Pass in a float 0.0 to 100.0 and watch the volume magically change
return bass_call(BASS_SetConfig, BASS_CONFIG_GVOL_STREAM, int(round(volume*100, 2))) volume = property(get_volume, set_volume)
volume = property(get_volume, set_volume) @staticmethod
def free():
@staticmethod return bass_call(BASS_Free)
def free():
return bass_call(BASS_Free) def get_proxy(self):
ptr = bass_call(BASS_GetConfigPtr, BASS_CONFIG_NET_PROXY)
def get_proxy(self): return string_at(ptr)
ptr = bass_call(BASS_GetConfigPtr, BASS_CONFIG_NET_PROXY)
return string_at(ptr) def set_proxy(self, proxy):
self.proxy = c_char_p(proxy)
def set_proxy(self, proxy): return bass_call(BASS_SetConfigPtr, BASS_CONFIG_NET_PROXY, self.proxy)
self.proxy = c_char_p(proxy)
return bass_call(BASS_SetConfigPtr, BASS_CONFIG_NET_PROXY, self.proxy) def use_default_device(self, use=True):
return bass_call(BASS_SetConfig, BASS_CONFIG_DEV_DEFAULT, use)
def use_default_device(self, use=True):
return bass_call(BASS_SetConfig, BASS_CONFIG_DEV_DEFAULT, use) @staticmethod
def get_device_names():
@staticmethod """Convenience method that returns a list of device names that are considered
def get_device_names(): valid by bass.
"""Convenience method that returns a list of device names that are considered
valid by bass. Parameters: none.
returns: list of devices, 0-indexed.
Parameters: none. """
returns: list of devices, 0-indexed. result = [] # empty list to start.
""" info = BASS_DEVICEINFO()
result = [] # empty list to start. count = 1
info = BASS_DEVICEINFO() while BASS_GetDeviceInfo(count, ctypes.byref(info)):
count = 1 if info.flags & BASS_DEVICE_ENABLED:
while BASS_GetDeviceInfo(count, ctypes.byref(info)): retrieved = info.name
if info.flags & BASS_DEVICE_ENABLED: if platform.system() == 'Windows':
retrieved = info.name retrieved = retrieved.decode('mbcs')
if platform.system() == 'Windows': elif platform.system() == 'Darwin':
retrieved = retrieved.decode('mbcs') retrieved = retrieved.decode('utf-8')
retrieved = retrieved.replace('(', '').replace(')', '').strip() retrieved = retrieved.replace('(', '').replace(')', '').strip()
result.append(retrieved) result.append(retrieved)
count += 1 count += 1
return result return result
def find_device_by_name(self, name): def find_device_by_name(self, name):
return self.get_device_names().index(name) + 1 return self.get_device_names().index(name) + 1
def find_default_device(self): def find_default_device(self):
try: try:
return self.get_device_names().index('Default')+1 return self.get_device_names().index('Default')+1
except: except:
return -1 return -1
def find_user_provided_device(self, device_name): def find_user_provided_device(self, device_name):
try: try:
return self.find_device_by_name(device_name) return self.find_device_by_name(device_name)
except ValueError: except ValueError:
return self.find_default_device() return self.find_default_device()
class ThreeDOutput(Output): class ThreeDOutput(Output):
def __init__(self, flags=BASS_DEVICE_3D, *args, **kwargs): def __init__(self, flags=BASS_DEVICE_3D, *args, **kwargs):
super(ThreeDOutput, self).__init__(flags=flags, *args, **kwargs) super(ThreeDOutput, self).__init__(flags=flags, *args, **kwargs)
def get_3d_factors(self): def get_3d_factors(self):
res = { res = {
'distance_factor': c_float(), 'distance_factor': c_float(),
'rolloff': c_float(), 'rolloff': c_float(),
'doppler_factor': c_float() 'doppler_factor': c_float()
} }
bass_call(BASS_Get3DFactors, pointer(res['distance_factor']), pointer(res['rolloff']), pointer(res['doppler_factor'])) bass_call(BASS_Get3DFactors, pointer(res['distance_factor']), pointer(res['rolloff']), pointer(res['doppler_factor']))
return {k: res[k].value for k in res} return {k: res[k].value for k in res}
@update_3d_system @update_3d_system
def set_3d_factors(self, distance_factor=-1, rolloff=-1, doppler_factor=-1): def set_3d_factors(self, distance_factor=-1, rolloff=-1, doppler_factor=-1):
conversions = { conversions = {
'meters': 1.0, 'meters': 1.0,
'yards': 0.9144, 'yards': 0.9144,
'feet': 0.3048 'feet': 0.3048
} }
if distance_factor in conversions: if distance_factor in conversions:
distance_factor = conversions[distance_factor] distance_factor = conversions[distance_factor]
return bass_call(BASS_Set3DFactors, distance_factor, rolloff, doppler_factor) return bass_call(BASS_Set3DFactors, distance_factor, rolloff, doppler_factor)
distance_factor = property(fget=partial(_getter, get_3d_factors, 'distance_factor'), fset=partial(_setter, set_3d_factors, 'distance_factor')) distance_factor = property(fget=partial(_getter, get_3d_factors, 'distance_factor'), fset=partial(_setter, set_3d_factors, 'distance_factor'))
rolloff = property(fget=partial(_getter, get_3d_factors, 'rolloff'), fset=partial(_setter, set_3d_factors, 'rolloff')) rolloff = property(fget=partial(_getter, get_3d_factors, 'rolloff'), fset=partial(_setter, set_3d_factors, 'rolloff'))
doppler_factor = property(fget=partial(_getter, get_3d_factors, 'doppler_factor'), fset=partial(_setter, set_3d_factors, 'doppler_factor')) doppler_factor = property(fget=partial(_getter, get_3d_factors, 'doppler_factor'), fset=partial(_setter, set_3d_factors, 'doppler_factor'))
def set_eax_parameters(self, environment=None, volume=None, decay=None, damp=None): def set_eax_parameters(self, environment=None, volume=None, decay=None, damp=None):
def convert_arg(arg): def convert_arg(arg):
if arg is None: if arg is None:
arg = -1 arg = -1
return arg return arg
environment = convert_arg(environment) environment = convert_arg(environment)
if isinstance(environment, str) and environment in EAX_ENVIRONMENTS: if isinstance(environment, basestring) and environment in EAX_ENVIRONMENTS:
environment = EAX_ENVIRONMENTS[environment] environment = EAX_ENVIRONMENTS[environment]
volume = convert_arg(volume) volume = convert_arg(volume)
decay = convert_arg(decay) decay = convert_arg(decay)
damp = convert_arg(damp) damp = convert_arg(damp)
bass_call(BASS_SetEAXParameters, environment, volume, decay, damp) bass_call(BASS_SetEAXParameters, environment, volume, decay, damp)
def get_3d_algorithm(self): def get_3d_algorithm(self):
return BASS_GetConfig(BASS_CONFIG_3DALGORITHM) return BASS_GetConfig(BASS_CONFIG_3DALGORITHM)
def set_3d_algorithm(self, algo): def set_3d_algorithm(self, algo):
replacements = { replacements = {
'default': BASS_3DALG_DEFAULT, 'default': BASS_3DALG_DEFAULT,
'off': BASS_3DALG_OFF, 'off': BASS_3DALG_OFF,
'full': BASS_3DALG_FULL, 'full': BASS_3DALG_FULL,
'light': BASS_3DALG_LIGHT, 'light': BASS_3DALG_LIGHT,
} }
if algo in replacements: if algo in replacements:
algo = replacements[algo] algo = replacements[algo]
return BASS_SetConfig(BASS_CONFIG_3DALGORITHM, algo) return BASS_SetConfig(BASS_CONFIG_3DALGORITHM, algo)

View File

@ -1,49 +1,49 @@
from __future__ import absolute_import from __future__ import absolute_import
from .channel import Channel from .channel import Channel
from .external.pybass import * from .external.pybass import *
from ctypes import string_at from ctypes import string_at
import wave import wave
from .main import bass_call, bass_call_0 from .main import bass_call, bass_call_0
class Recording(Channel): class Recording(Channel):
def __init__(self, frequency=44100, channels=2, flags=BASS_RECORD_PAUSE, proc=None, user=None): def __init__(self, frequency=44100, channels=2, flags=BASS_RECORD_PAUSE, proc=None, user=None):
if not proc: if not proc:
proc = lambda: True proc = lambda: True
self.callback = RECORDPROC(proc) self.callback = RECORDPROC(proc)
self._frequency = frequency self._frequency = frequency
self._channels = channels self._channels = channels
self._flags = flags self._flags = flags
handle = bass_call(BASS_RecordStart, frequency, channels, flags, self.callback, user) handle = bass_call(BASS_RecordStart, frequency, channels, flags, self.callback, user)
super(Recording, self).__init__(handle) super(Recording, self).__init__(handle)
def free(self): def free(self):
pass pass
class WaveRecording(Recording): class WaveRecording(Recording):
def __init__(self, filename=None, proc=None, *args, **kwargs): def __init__(self, filename=None, proc=None, *args, **kwargs):
callback = proc or self.recording_callback callback = proc or self.recording_callback
super(WaveRecording, self).__init__(proc=callback, *args, **kwargs) super(WaveRecording, self).__init__(proc=callback, *args, **kwargs)
self.filename = filename self.filename = filename
def recording_callback(self, handle, buffer, length, user): def recording_callback(self, handle, buffer, length, user):
buf = string_at(buffer, length) buf = string_at(buffer, length)
self.file.writeframes(buf) self.file.writeframes(buf)
return True return True
def setup_file(self): def setup_file(self):
self.file = wave.open(self.filename, 'w') self.file = wave.open(self.filename, 'w')
self.file.setnchannels(self._channels) self.file.setnchannels(self._channels)
self.file.setsampwidth(2) self.file.setsampwidth(2)
self.file.setframerate(self._frequency) self.file.setframerate(self._frequency)
def play(self, *args, **kwargs): def play(self, *args, **kwargs):
if not self.is_playing: if not self.is_playing:
self.setup_file() self.setup_file()
super(WaveRecording, self).play(*args, **kwargs) super(WaveRecording, self).play(*args, **kwargs)
def stop(self, *args, **kwargs): def stop(self, *args, **kwargs):
super(WaveRecording, self).stop(*args, **kwargs) super(WaveRecording, self).stop(*args, **kwargs)
self.file.close() self.file.close()

View File

@ -1,61 +1,74 @@
from __future__ import absolute_import from __future__ import absolute_import
import platform import platform
import sys import sys
from .channel import Channel from .channel import Channel
from .main import bass_call, bass_call_0 from .main import bass_call, bass_call_0
from .external.pybass import * from .external.pybass import *
try:
convert_to_unicode = str convert_to_unicode = unicode
except NameError:
class BaseStream(Channel): convert_to_unicode = str
def _callback(*args): class BaseStream(Channel):
#Stub it out as otherwise it'll crash, hard. Used for stubbing download procs
return 0 def _callback(*args):
#Stub it out as otherwise it'll crash, hard. Used for stubbing download procs
def free(self): return 0
return bass_call(BASS_StreamFree, self.handle)
def free(self):
def get_file_position(self, mode): return bass_call(BASS_StreamFree, self.handle)
return bass_call_0(BASS_StreamGetFilePosition, self.handle, mode)
def get_file_position(self, mode):
class Stream(BaseStream): return bass_call_0(BASS_StreamGetFilePosition, self.handle, mode)
def __init__(self, freq=44100, chans=2, flags=0, proc=None, user=None, three_d=False, autofree=False, decode=False): class Stream(BaseStream):
self.proc = STREAMPROC(proc)
self.setup_flag_mapping() def __init__(self, freq=44100, chans=2, flags=0, proc=None, user=None, three_d=False, autofree=False, decode=False):
flags = flags | self.flags_for(three_d=three_d, autofree=autofree, decode=decode) self.proc = STREAMPROC(proc)
handle = bass_call(BASS_StreamCreate, freq, chans, flags, self.proc, user) self.setup_flag_mapping()
super(Stream, self).__init__(handle) flags = flags | self.flags_for(three_d=three_d, autofree=autofree, decode=decode)
handle = bass_call(BASS_StreamCreate, freq, chans, flags, self.proc, user)
class FileStream(BaseStream): super(Stream, self).__init__(handle)
def __init__(self, mem=False, file=None, offset=0, length=0, flags=0, three_d=False, mono=False, autofree=False, decode=False, unicode=True): class FileStream(BaseStream):
"""Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plugin supported file."""
if platform.system() == 'Darwin' or platform.system() == "Linux": def __init__(self, mem=False, file=None, offset=0, length=0, flags=0, three_d=False, mono=False, autofree=False, decode=False, unicode=True):
unicode = False """Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plugin supported file."""
file = file.encode(sys.getfilesystemencoding()) if platform.system() == 'Darwin':
self.setup_flag_mapping() unicode = False
flags = flags | self.flags_for(three_d=three_d, autofree=autofree, mono=mono, decode=decode, unicode=unicode) file = file.encode(sys.getfilesystemencoding())
if unicode and isinstance(file, str): self.setup_flag_mapping()
file = convert_to_unicode(file) flags = flags | self.flags_for(three_d=three_d, autofree=autofree, mono=mono, decode=decode, unicode=unicode)
self.file = file if unicode and isinstance(file, str):
handle = bass_call(BASS_StreamCreateFile, mem, file, offset, length, flags) file = convert_to_unicode(file)
super(FileStream, self).__init__(handle) self.file = file
handle = bass_call(BASS_StreamCreateFile, mem, file, offset, length, flags)
def setup_flag_mapping(self): super(FileStream, self).__init__(handle)
super(FileStream, self).setup_flag_mapping()
self.flag_mapping.update({ def setup_flag_mapping(self):
'unicode': BASS_UNICODE super(FileStream, self).setup_flag_mapping()
}) self.flag_mapping.update({
'unicode': BASS_UNICODE
class URLStream(BaseStream): })
def __init__(self, url="", offset=0, flags=0, downloadproc=None, user=None, three_d=False, autofree=False, decode=False): class URLStream(BaseStream):
self._downloadproc = downloadproc or self._callback #we *must hold on to this
self.downloadproc = DOWNLOADPROC(self._downloadproc) def __init__(self, url="", offset=0, flags=0, downloadproc=None, user=None, three_d=False, autofree=False, decode=False):
self.url = url self._downloadproc = downloadproc or self._callback #we *must hold on to this
self.setup_flag_mapping() self.downloadproc = DOWNLOADPROC(self._downloadproc)
flags = flags | self.flags_for(three_d=three_d, autofree=autofree, decode=decode) self.url = url
handle = bass_call(BASS_StreamCreateURL, url, offset, flags, self.downloadproc, user) self.setup_flag_mapping()
super(URLStream, self).__init__(handle) flags = flags | self.flags_for(three_d=three_d, autofree=autofree, decode=decode)
handle = bass_call(BASS_StreamCreateURL, url, offset, flags, self.downloadproc, user)
super(URLStream, self).__init__(handle)
class PushStream(BaseStream):
def __init__(self, freq=44100, chans=2, flags=0, user=None, three_d=False, autofree=False, decode=False):
self.proc = STREAMPROC_PUSH
self.setup_flag_mapping()
flags = flags | self.flags_for(three_d=three_d, autofree=autofree, decode=decode)
handle = bass_call(BASS_StreamCreate, freq, chans, flags, self.proc, user)
super(PushStream, self).__init__(handle)
def push(self, data):
return bass_call_0(BASS_StreamPutData, self.handle, data, len(data))