Beispiel #1
0
 def get_3d_attributes(self):
  """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())
  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:
   answer[k] = answer[k].value()
  return answer
Beispiel #2
0
 def get_attribute(self, attribute):
  """Retrieves the value of a channel's attribute."""
  value = pointer(c_float())
  if attribute in self.attribute_mapping:
   attribute = self.attribute_mapping[attribute]
  bass_call(BASS_ChannelGetAttribute, self.handle, attribute, value)
  return value.contents.value
Beispiel #3
0
 def init_device(self,
                 device=None,
                 frequency=None,
                 flags=None,
                 window=None,
                 clsid=None):
     if device is None:
         device = self._device
     self._device = device
     if frequency is None:
         frequency = self.frequency
     self.frequency = frequency
     if flags is None:
         flags = self.flags
     self.flags = flags
     if window is None:
         window = self.window
     self.window = window
     if clsid is None:
         clsid = self.clsid
     self.clsid = clsid
     if platform.system(
     ) == 'Linux' and device == -1:  #Bass wants default device set to 1 on linux
         device = 1
     bass_call(BASS_Init, device, frequency, flags, window, clsid)
Beispiel #4
0
 def get_attribute(self, attribute):
     """Retrieves the value of a channel's attribute."""
     value = pointer(c_float())
     if attribute in self.attribute_mapping:
         attribute = self.attribute_mapping[attribute]
     bass_call(BASS_ChannelGetAttribute, self.handle, attribute, value)
     return value.contents.value
Beispiel #5
0
 def get_3d_factors(self):
  res = {
   'distance_factor': c_float(),
   'rolloff': c_float(),
   'doppler_factor': c_float()
  }
  bass_call(BASS_Get3DFactors, pointer(res['distance_factor']), pointer(res['rolloff']), pointer(res['doppler_factor']))
  return {k: res[k].value for k in res}
Beispiel #6
0
 def get_3d_position(self):
     """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())
     bass_call(BASS_ChannelGet3DPosition, self.handle,
               pointer(answer['position']), pointer(answer['orientation']),
               pointer(answer['velocity']))
     return answer
Beispiel #7
0
 def get_3d_position(self):
  res = {
   'position': BASS_3DVECTOR(),
   'velocity': 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
Beispiel #8
0
 def get_3d_factors(self):
     res = {
         'distance_factor': c_float(),
         'rolloff': c_float(),
         'doppler_factor': c_float()
     }
     bass_call(BASS_Get3DFactors, pointer(res['distance_factor']),
               pointer(res['rolloff']), pointer(res['doppler_factor']))
     return {k: res[k].value for k in res}
Beispiel #9
0
 def get_3d_position(self):
     res = {
         'position': BASS_3DVECTOR(),
         'velocity': 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
Beispiel #10
0
 def set_eax_parameters(self, environment=None, volume=None, decay=None, damp=None):
  def convert_arg(arg):
   if arg is None:
    arg = -1
   return arg
  environment = convert_arg(environment)
  if isinstance(environment, basestring) and environment in EAX_ENVIRONMENTS:
   environment = EAX_ENVIRONMENTS[environment]
  volume = convert_arg(volume)
  decay = convert_arg(decay)
  damp = convert_arg(damp)
  bass_call(BASS_SetEAXParameters, environment, volume, decay, damp)
Beispiel #11
0
 def get_3d_attributes(self):
     """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())
     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:
         answer[k] = answer[k].value()
     return answer
Beispiel #12
0
 def set_3d_position(self, position=None, velocity=None, front=None, top=None):
     """Sets the position, velocity, and orientation of the listener (ie. the player)."""
     old = self.get_3d_position()
     if position is None:
         position = old['position']
     if velocity is None:
         velocity = old['velocity']
     if front is None:
         front = old['front']
     if top is None:
         top = old['top']
     position = pointer(position)
     velocity = pointer(velocity)
     front = pointer(front)
     top = pointer(top)
     bass_call(BASS_Set3DPosition, position, velocity, front, top)
Beispiel #13
0
 def __init__(self,
              source_encoder,
              server,
              password,
              content,
              name=None,
              url=None,
              genre=None,
              description=None,
              headers=None,
              bitrate=0,
              public=False):
     contents = {
         'mp3': pybassenc.BASS_ENCODE_TYPE_MP3,
         'ogg': pybassenc.BASS_ENCODE_TYPE_OGG,
         'aac': pybassenc.BASS_ENCODE_TYPE_AAC
     }
     if content in contents:
         content = contents[content]
     self.source_encoder = source_encoder
     handle = source_encoder.handle
     self.server = server
     self.password = password
     self.status = bass_call(pybassenc.BASS_Encode_CastInit, handle, server,
                             password, content, name, url, genre,
                             description, headers, bitrate, public)
Beispiel #14
0
 def __init__(self,
              mem=False,
              file=None,
              offset=0,
              length=0,
              flags=0,
              three_d=False,
              mono=False,
              autofree=False,
              decode=False,
              unicode=True):
     """Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plugin supported file."""
     if platform.system() == 'Darwin':
         unicode = False
         file = file.encode(sys.getfilesystemencoding())
     self.setup_flag_mapping()
     flags = flags | self.flags_for(three_d=three_d,
                                    autofree=autofree,
                                    mono=mono,
                                    decode=decode,
                                    unicode=unicode)
     if unicode and isinstance(file, str):
         file = convert_to_unicode(file)
     self.file = file
     handle = bass_call(BASS_StreamCreateFile, mem, file, offset, length,
                        flags)
     super(FileStream, self).__init__(handle)
Beispiel #15
0
 def set_3d_position(self, position=None, velocity=None, front=None, top=None):
  """Sets the position, velocity, and orientation of the listener (ie. the player)."""
  old = self.get_3d_position()
  if position is None:
   position = old['position']
  if velocity is None:
   velocity = old['velocity']
  if front is None:
   front = old['front']
  if top is None:
   top = old['top']
  position = pointer(position)
  velocity = pointer(velocity)
  front = pointer(front)
  top = pointer(top)
  bass_call(BASS_Set3DPosition, position, velocity, front, top)
Beispiel #16
0
 def __init__(self, url="", offset=0, flags=0, downloadproc=None, user=None, three_d=False, autofree=False, decode=False):
  self._downloadproc = downloadproc or self._callback #we *must hold on to this
  self.downloadproc = DOWNLOADPROC(self._downloadproc)
  self.url = url
  self.setup_flag_mapping()
  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)
Beispiel #17
0
    def set_eax_parameters(self,
                           environment=None,
                           volume=None,
                           decay=None,
                           damp=None):
        def convert_arg(arg):
            if arg is None:
                arg = -1
            return arg

        environment = convert_arg(environment)
        if isinstance(environment,
                      basestring) and environment in EAX_ENVIRONMENTS:
            environment = EAX_ENVIRONMENTS[environment]
        volume = convert_arg(volume)
        decay = convert_arg(decay)
        damp = convert_arg(damp)
        bass_call(BASS_SetEAXParameters, environment, volume, decay, damp)
Beispiel #18
0
 def __init__(self, mem=False, file=None, offset=0, length=0, flags=0, three_d=False, mono=False, autofree=False, decode=False, unicode=True):
  """Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plugin supported file."""
  self.setup_flag_mapping()
  flags = flags | self.flags_for(three_d=three_d, autofree=autofree, mono=mono, decode=decode, unicode=unicode)
  if unicode and isinstance(file, str):
   file = convert_to_unicode(file)
  self.file = file
  handle = bass_call(BASS_StreamCreateFile, mem, file, offset, length, flags)
  super(FileStream, self).__init__(handle)
Beispiel #19
0
 def set_3d_factors(self, distance_factor=-1, rolloff=-1, doppler_factor=-1):
  conversions = {
   'meters': 1.0,
   'yards': 0.9144,
   'feet': 0.3048
  }
  if distance_factor in conversions:
   distance_factor = conversions[distance_factor]
  return bass_call(BASS_Set3DFactors, distance_factor, rolloff, doppler_factor)
Beispiel #20
0
 def __init__(self, frequency=44100, channels=2, flags=BASS_RECORD_PAUSE, proc=None, user=None):
  if not proc:
   proc = lambda: True
  self.callback = RECORDPROC(proc)
  self._frequency = frequency
  self._channels = channels
  self._flags = flags
  handle = bass_call(BASS_RecordStart, frequency, channels, flags, self.callback, user)
  super(Recording, self).__init__(handle)
Beispiel #21
0
 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."""
  if position:
   position = pointer(position)
  if orientation:
   orientation = pointer(orientation)
  if velocity:
   velocity = pointer(velocity)
  return bass_call(BASS_ChannelSet3DPosition, self.handle, position, orientation, velocity)
Beispiel #22
0
 def set_3d_factors(self,
                    distance_factor=-1,
                    rolloff=-1,
                    doppler_factor=-1):
     conversions = {'meters': 1.0, 'yards': 0.9144, 'feet': 0.3048}
     if distance_factor in conversions:
         distance_factor = conversions[distance_factor]
     return bass_call(BASS_Set3DFactors, distance_factor, rolloff,
                      doppler_factor)
Beispiel #23
0
 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."""
     return bass_call(BASS_ChannelSet3DAttributes, self.handle, mode, min,
                      max, iangle, oangle, outvol)
Beispiel #24
0
 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."""
     if position:
         position = pointer(position)
     if orientation:
         orientation = pointer(orientation)
     if velocity:
         velocity = pointer(velocity)
     return bass_call(BASS_ChannelSet3DPosition, self.handle, position,
                      orientation, velocity)
Beispiel #25
0
 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()
  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
  source_handle = source.handle
  if callback is None:
   callback = lambda *a: None
  callback = pybassenc.ENCODEPROC(callback)
  self.callback = callback
  self.handle = bass_call(pybassenc.BASS_Encode_Start, source_handle, command_line, flags, callback, user)
Beispiel #26
0
 def init_device(self, device=None, frequency=None, flags=None, window=None, clsid=None):
  if device is None:
   device = self._device
  self._device = device
  if frequency is None:
   frequency = self.frequency
  self.frequency = frequency
  if flags is None:
   flags = self.flags
  self.flags = flags
  if window is None:
   window = self.window
  self.window = window
  if clsid is None:
   clsid = self.clsid
  self.clsid = clsid
  if platform.system() == 'Linux' and device == -1: #Bass wants default device set to 1 on linux
   device = 1
  bass_call(BASS_Init, device, frequency, flags, window, clsid)
Beispiel #27
0
 def get_stats(self, type, password=None):
  types = {
   'shoutcast': pybassenc.BASS_ENCODE_STATS_SHOUT,
   'icecast': pybassenc.BASS_ENCODE_STATS_ICE,
   'icecast_server': pybassenc.BASS_ENCODE_STATS_ICESERV,
  }
  if type in types:
   type = types[type]
  if password is None:
   password = self.password  
  return bass_call(pybassenc.BASS_Encode_CastGetStats, self.handle, type, password)
Beispiel #28
0
 def __init__(self, source_encoder, server, password, content, name=None, url=None, genre=None, description=None, headers=None, bitrate=0, public=False):
  contents = {
   'mp3': pybassenc.BASS_ENCODE_TYPE_MP3,
   'ogg': pybassenc.BASS_ENCODE_TYPE_OGG,
   'aac': pybassenc.BASS_ENCODE_TYPE_AAC
  }
  if content in contents:
   content = contents[content]
  self.source_encoder = source_encoder
  handle = source_encoder.handle
  self.server = server
  self.password = password
  self.status = bass_call(pybassenc.BASS_Encode_CastInit, handle, server, password, content, name, url, genre, description, headers, bitrate, public)
Beispiel #29
0
 def __init__(self,
              frequency=44100,
              channels=2,
              flags=BASS_RECORD_PAUSE,
              proc=None,
              user=None):
     if not proc:
         proc = lambda: True
     self.callback = RECORDPROC(proc)
     self._frequency = frequency
     self._channels = channels
     self._flags = flags
     handle = bass_call(BASS_RecordStart, frequency, channels, flags,
                        self.callback, user)
     super(Recording, self).__init__(handle)
Beispiel #30
0
 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)
Beispiel #31
0
 def __init__(self,
              url="",
              offset=0,
              flags=0,
              downloadproc=None,
              user=None,
              three_d=False,
              autofree=False,
              decode=False):
     self._downloadproc = downloadproc or self._callback  #we *must hold on to this
     self.downloadproc = DOWNLOADPROC(self._downloadproc)
     self.url = url
     self.setup_flag_mapping()
     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)
Beispiel #32
0
 def pause(self):
  return bass_call(BASS_Pause)
Beispiel #33
0
 def stop(self):
  return bass_call(BASS_Stop)
Beispiel #34
0
 def free(self):
  return bass_call(BASS_StreamFree, self.handle)
Beispiel #35
0
 def start(self):
     return bass_call(BASS_Start)
Beispiel #36
0
 def set_proxy(self, proxy):
  self.proxy = c_char_p(proxy)
  return bass_call(BASS_SetConfigPtr, BASS_CONFIG_NET_PROXY, self.proxy)
Beispiel #37
0
 def free(self):
  """Frees all resources used by the recording device."""
  return bass_call(BASS_RecordFree)
Beispiel #38
0
 def get_proxy(self):
     ptr = bass_call(BASS_GetConfigPtr, BASS_CONFIG_NET_PROXY)
     return string_at(ptr)
Beispiel #39
0
 def free():
  return bass_call(BASS_Free)
Beispiel #40
0
 def set_volume(self, volume):
     #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)))
Beispiel #41
0
 def free():
     return bass_call(BASS_Free)
Beispiel #42
0
 def set_device(self, device):
     if device == self._device:
         return
     self.free()
     self.init_device(device=device)
     return bass_call(BASS_SetDevice, device)
Beispiel #43
0
 def stop(self):
     return bass_call(BASS_Stop)
Beispiel #44
0
 def pause(self):
     return bass_call(BASS_Pause)
Beispiel #45
0
 def set_device(self, device):
  if device == self._device:
   return
  self.free()
  self.init_device(device=device)
  return bass_call(BASS_SetDevice, device)
Beispiel #46
0
 def set_title(self, title=None, url=None):
     return bass_call(pybassenc.BASS_Encode_CastSetTitle,
                      self.source_encoder.handle, title, url)
Beispiel #47
0
 def set_volume (self, volume):
  #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)))
Beispiel #48
0
 def stop(self):
     return bass_call(pybassenc.BASS_Encode_Stop, self.handle)
Beispiel #49
0
 def get_proxy(self):
  ptr = bass_call(BASS_GetConfigPtr, BASS_CONFIG_NET_PROXY)
  return string_at(ptr)
Beispiel #50
0
 def set_proxy(self, proxy):
     self.proxy = c_char_p(proxy)
     return bass_call(BASS_SetConfigPtr, BASS_CONFIG_NET_PROXY, self.proxy)
Beispiel #51
0
 def use_default_device(self, use=True):
  return bass_call(BASS_SetConfig, BASS_CONFIG_DEV_DEFAULT, use)
Beispiel #52
0
 def use_default_device(self, use=True):
     return bass_call(BASS_SetConfig, BASS_CONFIG_DEV_DEFAULT, use)
Beispiel #53
0
 def __init__ (self, device=-1):
  bass_call(BASS_RecordInit, device)
  self._device = device
  self.config = config.BassConfig()
Beispiel #54
0
 def start(self):
  return bass_call(BASS_Start)
Beispiel #55
0
 def __init__(self, freq=44100, chans=2, flags=0, proc=None, user=None, three_d=False, autofree=False, decode=False):
  self.proc = STREAMPROC(proc)
  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(Stream, self).__init__(handle)
Beispiel #56
0
 def paused(self, paused):
     return bass_call(pybassenc.BASS_Encode_SetPaused, self.handle, paused)
Beispiel #57
0
 def __init__(self, url="", offset=0, flags=0, downloadproc=None, user=None):
  self._downloadproc = downloadproc or self._callback #we *must hold on to this
  self.downloadproc = DOWNLOADPROC(self._downloadproc)
  self.url = url
  handle = bass_call(BASS_StreamCreateURL, url, offset, flags, self.downloadproc, user)
  super(URLStream, self).__init__(handle)
Beispiel #58
0
 def set_fx(self, type, priority=0):
  """Sets an effect on a stream, MOD music, or recording channel."""
  return SoundEffect(bass_call(BASS_ChannelSetFX, type, priority))