def __repr__(self): ident_parts = [type(self).__name__] if isinstance(self.get('object'), str): ident_parts.append(utf8(self.get('object'))) if isinstance(self.get('id'), str): ident_parts.append('id=%s' % utf8(self.get('id'))) return '<%s at %s> JSON: %s' % ( ' '.join(ident_parts), hex(id(self)), str(self))
def __repr__(self): ident_parts = [type(self).__name__] if isinstance(self.get('object'), str): ident_parts.append(utf8(self.get('object'))) if isinstance(self.get('id'), str): ident_parts.append('id=%s' % utf8(self.get('id'))) return '<%s at %s> JSON: %s' % (' '.join(ident_parts), hex( id(self)), str(self))
def play_handle(handle, show_tags = True): if handle == 0: print(('BASS_StreamCreateFile error', get_error_description(BASS_ErrorGetCode()))) else: if show_tags: print('============== Tags Information ==============') try: import pytags print((pytags.TAGS_Read(handle, '%IFV1(%ITRM(%TRCK),%ITRM(%TRCK). )%IFV2(%ITRM(%ARTI),%ICAP(%ITRM(%ARTI)),no artist) - %IFV2(%ITRM(%TITL),%ICAP(%ITRM(%TITL)),no title)%IFV1(%ITRM(%ALBM), - %IUPC(%ITRM(%ALBM)))%IFV1(%YEAR, %(%YEAR%))%IFV1(%ITRM(%GNRE), {%ITRM(%GNRE)})%IFV1(%ITRM(%CMNT), [%ITRM(%CMNT)])'))) except: print('============== tags module not accessible ==============') print('============== BASS_ChannelGetTags return ==============') for tag in get_tags(handle): print(tag) for key, value in get_tags_as_dict(handle).items(): print((key, ':', value)) print('============== Channel Information ==============') channel_info = BASS_CHANNELINFO() if not BASS_ChannelGetInfo(handle, channel_info): print(('BASS_ChannelGetInfo error', get_error_description(BASS_ErrorGetCode()))) else: print(('default playback rate =', channel_info.freq)) print(('channels =', channel_info.chans)) print(('BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags =', channel_info.flags)) print(('type of channel =', hex(channel_info.ctype))) print(('original resolution =', channel_info.origres)) print(('plugin =', channel_info.plugin)) print(('sample =', channel_info.sample)) print(('filename =', channel_info.filename)) print('============== Ext Channel Information ==============') channel_length = BASS_ChannelGetLength(handle, BASS_POS_BYTE) channel_position = BASS_ChannelGetPosition(handle, BASS_POS_BYTE) print(('Channel Length =', channel_length)) print(('Channel Length =', int(BASS_ChannelBytes2Seconds(handle, channel_length)), 'seconds')) import time if not BASS_ChannelPlay(handle, False): print(('BASS_ChannelPlay error', get_error_description(BASS_ErrorGetCode()))) else: print('============== Play Information ==============') while channel_position < channel_length: channel_position = BASS_ChannelGetPosition(handle, BASS_POS_BYTE) print(('Channel Position =', channel_position)) print(('Channel Position =', int(BASS_ChannelBytes2Seconds(handle, channel_position)), 'seconds')) print(('CPU =', BASS_GetCPU())) time.sleep(1) if not BASS_StreamFree(handle): print(('BASS_StreamFree error', get_error_description(BASS_ErrorGetCode())))
if not BASS_ChannelPlay(handle, False): print(('BASS_ChannelPlay error', get_error_description(BASS_ErrorGetCode()))) else: print('============== Play Information ==============') while channel_position < channel_length: channel_position = BASS_ChannelGetPosition(handle, BASS_POS_BYTE) print(('Channel Position =', channel_position)) print(('Channel Position =', int(BASS_ChannelBytes2Seconds(handle, channel_position)), 'seconds')) print(('CPU =', BASS_GetCPU())) time.sleep(1) if not BASS_StreamFree(handle): print(('BASS_StreamFree error', get_error_description(BASS_ErrorGetCode()))) if __name__ == "__main__": print(('BASS implemented Version', BASSVERSIONTEXT)) print(('BASS real Version', hex(BASS_GetVersion()))) if not BASS_Init(-1, 44100, 0, 0, 0): print(('BASS_Init error', get_error_description(BASS_ErrorGetCode()))) else: print('============== BASS Information ==============') bi = BASS_INFO() if not BASS_GetInfo(bi): print(('BASS_GetInfo error', get_error_description(BASS_ErrorGetCode()))) else: print(('device capabilities (DSCAPS_xxx flags) =', bi.flags)) print(('size of total device hardware memory =', bi.hwsize)) print(('size of free device hardware memory =', bi.hwfree)) print(('number of free sample slots in the hardware =', bi.freesam)) print(('number of free 3D sample slots in the hardware =', bi.free3d)) print(('min sample rate supported by the hardware =', bi.minrate)) print(('max sample rate supported by the hardware =', bi.maxrate))
def hexdigest(self): """Like digest(), but returns a string of hexadecimal digits instead. """ return "".join( [hex(ord(x))[2:].zfill(2) for x in tuple(self.digest())])
def hexdigest(self): """Like digest(), but returns a string of hexadecimal digits instead. """ return "".join([hex(ord(x))[2:].zfill(2) for x in tuple(self.digest())])
def play_handle(handle, show_tags=True): if handle == 0: print(('BASS_StreamCreateFile error', get_error_description(BASS_ErrorGetCode()))) else: if show_tags: print('============== Tags Information ==============') try: import pytags print((pytags.TAGS_Read( handle, '%IFV1(%ITRM(%TRCK),%ITRM(%TRCK). )%IFV2(%ITRM(%ARTI),%ICAP(%ITRM(%ARTI)),no artist) - %IFV2(%ITRM(%TITL),%ICAP(%ITRM(%TITL)),no title)%IFV1(%ITRM(%ALBM), - %IUPC(%ITRM(%ALBM)))%IFV1(%YEAR, %(%YEAR%))%IFV1(%ITRM(%GNRE), {%ITRM(%GNRE)})%IFV1(%ITRM(%CMNT), [%ITRM(%CMNT)])' ))) except: print( '============== tags module not accessible ==============') print( '============== BASS_ChannelGetTags return ==============') for tag in get_tags(handle): print(tag) for key, value in get_tags_as_dict(handle).items(): print((key, ':', value)) print('============== Channel Information ==============') channel_info = BASS_CHANNELINFO() if not BASS_ChannelGetInfo(handle, channel_info): print(('BASS_ChannelGetInfo error', get_error_description(BASS_ErrorGetCode()))) else: print(('default playback rate =', channel_info.freq)) print(('channels =', channel_info.chans)) print(('BASS_SAMPLE/STREAM/MUSIC/SPEAKER flags =', channel_info.flags)) print(('type of channel =', hex(channel_info.ctype))) print(('original resolution =', channel_info.origres)) print(('plugin =', channel_info.plugin)) print(('sample =', channel_info.sample)) print(('filename =', channel_info.filename)) print('============== Ext Channel Information ==============') channel_length = BASS_ChannelGetLength(handle, BASS_POS_BYTE) channel_position = BASS_ChannelGetPosition(handle, BASS_POS_BYTE) print(('Channel Length =', channel_length)) print(('Channel Length =', int(BASS_ChannelBytes2Seconds(handle, channel_length)), 'seconds')) import time if not BASS_ChannelPlay(handle, False): print(('BASS_ChannelPlay error', get_error_description(BASS_ErrorGetCode()))) else: print('============== Play Information ==============') while channel_position < channel_length: channel_position = BASS_ChannelGetPosition( handle, BASS_POS_BYTE) print(('Channel Position =', channel_position)) print(('Channel Position =', int(BASS_ChannelBytes2Seconds(handle, channel_position)), 'seconds')) print(('CPU =', BASS_GetCPU())) time.sleep(1) if not BASS_StreamFree(handle): print(('BASS_StreamFree error', get_error_description(BASS_ErrorGetCode())))
handle, BASS_POS_BYTE) print(('Channel Position =', channel_position)) print(('Channel Position =', int(BASS_ChannelBytes2Seconds(handle, channel_position)), 'seconds')) print(('CPU =', BASS_GetCPU())) time.sleep(1) if not BASS_StreamFree(handle): print(('BASS_StreamFree error', get_error_description(BASS_ErrorGetCode()))) if __name__ == "__main__": print(('BASS implemented Version', BASSVERSIONTEXT)) print(('BASS real Version', hex(BASS_GetVersion()))) if not BASS_Init(-1, 44100, 0, 0, 0): print(('BASS_Init error', get_error_description(BASS_ErrorGetCode()))) else: print('============== BASS Information ==============') bi = BASS_INFO() if not BASS_GetInfo(bi): print(('BASS_GetInfo error', get_error_description(BASS_ErrorGetCode()))) else: print(('device capabilities (DSCAPS_xxx flags) =', bi.flags)) print(('size of total device hardware memory =', bi.hwsize)) print(('size of free device hardware memory =', bi.hwfree)) print( ('number of free sample slots in the hardware =', bi.freesam)) print(('number of free 3D sample slots in the hardware =',