Example #1
0
def main():
    BASS_Init(-1, 44100, 0, 0, 0)
    plugin = BASS_PluginLoad(b'./libbassflac.so', 0)
    print('plugin = %d' % plugin)
    handle = BASS_StreamCreateFile(False, b'test.flac', 0, 0, 0)
    play_handle(handle, show_tags=False)
    BASS_Free()
Example #2
0
def main():
    file_name = u'test_русский.ogg'
    if sys.hexversion >= 0x03000000:
        file_name = 'test_русский.ogg'
    BASS_Init(-1, 44100, 0, 0, 0)
    handle = BASS_StreamCreateFile(False, file_name, 0, 0, BASS_UNICODE)
    play_handle(handle, show_tags=False)
    BASS_Free()
Example #3
0
	bass_ac3_module = ctypes.CDLL('bass_ac3')
	func_type = ctypes.CFUNCTYPE


# BASS_Set/GetConfig options
BASS_CONFIG_AC3_DYNRNG = 0x10001

# Additional BASS_AC3_StreamCreateFile/User/URL flags
BASS_AC3_DYNAMIC_RANGE = 0x800 # enable dynamic range compression

# BASS_CHANNELINFO type
BASS_CTYPE_STREAM_AC3 = 0x11000


#HSTREAM BASSAC3DEF(BASS_AC3_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
BASS_AC3_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_AC3_StreamCreateFile', bass_ac3_module))
#HSTREAM BASSAC3DEF(BASS_AC3_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user);
BASS_AC3_StreamCreateURL = func_type(HSTREAM, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, DOWNLOADPROC, ctypes.c_void_p)(('BASS_AC3_StreamCreateURL', bass_ac3_module))
#HSTREAM BASSAC3DEF(BASS_AC3_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);
BASS_AC3_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_AC3_StreamCreateFileUser', bass_ac3_module))


if __name__ == "__main__":
	if not pybass.BASS_Init(-1, 44100, 0, 0, 0):
		print('BASS_Init error %s' % pybass.get_error_description(pybass.BASS_ErrorGetCode()))
	else:
		handle = BASS_AC3_StreamCreateFile(False, b'test.ac3', 0, 0, 0)
		pybass.play_handle(handle)
		if not pybass.BASS_Free():
			print('BASS_Free error %s' % pybass.get_error_description(pybass.BASS_ErrorGetCode()))
Example #4
0
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);
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);
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);
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);
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);
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);
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);
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);
BASS_WMA_EncodeClose = func_type(ctypes.c_byte, HWMENCODE)(('BASS_WMA_EncodeClose', basswma_module))

#void *BASSWMADEF(BASS_WMA_GetWMObject)(DWORD handle);
BASS_WMA_GetWMObject = func_type(ctypes.c_void_p, ctypes.c_ulong)(('BASS_WMA_GetWMObject', basswma_module))


if __name__ == "__main__":
	if not pybass.BASS_Init(-1, 44100, 0, 0, 0):
		print('BASS_Init error %s' % pybass.get_error_description(pybass.BASS_ErrorGetCode()))
	else:
		handle = BASS_WMA_StreamCreateFile(False, b'test.wma', 0, 0, 0)
		pybass.play_handle(handle)
		if not pybass.BASS_Free():
			print('BASS_Free error %s' % pybass.get_error_description(pybass.BASS_ErrorGetCode()))
Example #5
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright(c) Wasylews 2013 ([email protected])

from pybass import BASS_ChannelSetSync
from pybass import BASS_Free
from pybass import BASS_Init
from pybass import BASS_SYNC_END
from pybass import BASS_StreamCreateFile
from pybass import SYNCPROC
from pybass import play_handle


@SYNCPROC
def onEndPlay(handle, buffer, length, user):
    print("playing finished.")


if __name__ == '__main__':
    BASS_Init(-1, 44100, 0, 0, 0)
    handle = BASS_StreamCreateFile(False, b'test.mp3', 0, 0, 0)
    BASS_ChannelSetSync(handle, BASS_SYNC_END, 0, onEndPlay, 0)
    play_handle(handle, False)
    BASS_Free()
Example #6
0
#BOOL BASSMIDIDEF(BASS_MIDI_FontCompact)(HSOUNDFONT handle);
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);
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);
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);
BASS_MIDI_FontSetVolume = func_type(ctypes.c_byte, HSOUNDFONT, ctypes.c_float)(('BASS_MIDI_FontSetVolume', bassmidi_module))
#float BASSMIDIDEF(BASS_MIDI_FontGetVolume)(HSOUNDFONT handle);
BASS_MIDI_FontGetVolume = func_type(ctypes.c_float, HSOUNDFONT)(('BASS_MIDI_FontGetVolume', bassmidi_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:
		font = BASS_MIDI_FontInit('test.sf2', 0)
		if font == 0:
			print 'BASS_MIDI_FontInit error', pybass.get_error_description(pybass.BASS_ErrorGetCode())
		else:
			font_info = BASS_MIDI_FONTINFO()
			if BASS_MIDI_FontGetInfo(font, font_info):
				print '============== SOUNDFONT Information =============='
				print "name: %s\nloaded: %d / %d" % (font_info.name, font_info.samload, font_info.samsize)
			handle = BASS_MIDI_StreamCreateFile(False, 'test.mid', 0, 0, 0, 44100)
			pybass.play_handle(handle, False)
			if BASS_MIDI_FontFree(font):
				print 'BASS_MIDI_FontFree error', pybass.get_error_description(pybass.BASS_ErrorGetCode())
		if not pybass.BASS_Free():
			print 'BASS_Free error', pybass.get_error_description(pybass.BASS_ErrorGetCode())
Example #7
0
# 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))


# 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))


# 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))


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_FLAC_StreamCreateFile(False, b'test.flac', 0, 0, 0)
        pybass.play_handle(handle, False)
        if not pybass.BASS_Free():
            print('BASS_Free error', pybass.get_error_description(pybass.BASS_ErrorGetCode()))