@@ -48,6 +48,7 @@ class WAVEHDR(ctypes.Structure):
48
48
charcodeat_key_fix = Infix (lambda s ,y : ord (s [y ]))
49
49
operand_gtgt_key_fix = Infix (lambda x ,y : int (x )>> int (y ))
50
50
operand_ltlt_key_fix = Infix (lambda x , y : int (x )<< int (y ))
51
+ operand_and_key_fix = Infix (lambda x , y : int (x )& int (y ))
51
52
52
53
class ByteBeat :
53
54
def GenerateBuffer (EQUATION , SECONDS_PLAYING , AMOUNT_KILOHERTZ = 8000 ):
@@ -61,7 +62,7 @@ def GenerateBuffer(EQUATION, SECONDS_PLAYING, AMOUNT_KILOHERTZ=8000):
61
62
@ AMOUNT_KILOHERTZ argument: The amount of kilohertz (kHz) the ByteBeat will use.
62
63
@ AMOUNT_KILOHERTZ type: int
63
64
'''
64
- EQUATION = EQUATION .replace ('^' ,'**' ).replace ('random()' ,'__import__("random").random()' ).replace ('|' ,'|operand_key_fix|' ).replace ('/' ,'|division_key_fix|' ).replace ('?' ,' if ' ).replace (':' ,' else ' ).replace ('.charCodeAt' ,' |charcodeat_key_fix| ' ).replace ('>>' ,' |operand_gtgt_key_fix| ' ).replace ('<<' ,' |operand_ltlt_key_fix| ' )
65
+ EQUATION = EQUATION .replace ('^' ,'**' ).replace ('random()' ,'__import__("random").random()' ).replace ('|' ,'|operand_key_fix|' ).replace ('/' ,'|division_key_fix|' ).replace ('?' ,' if ' ).replace (':' ,' else ' ).replace ('.charCodeAt' ,' |charcodeat_key_fix| ' ).replace ('>>' ,' |operand_gtgt_key_fix| ' ).replace ('<<' ,' |operand_ltlt_key_fix| ' ). replace ( '&' , ' |operand_and_key_fix| ' )
65
66
hWaveOut = HWAVEOUT (0 )
66
67
wfx = WAVEFORMATEX (WAVE_FORMAT_PCM , 1 , AMOUNT_KILOHERTZ , AMOUNT_KILOHERTZ , 1 , 8 ,0 )
67
68
waveOutOpen (byref (hWaveOut ), WAVE_MAPPER , LPWAVEFORMATEX (wfx ), 0 , 0 , CALLBACK_NULL )
@@ -82,7 +83,7 @@ def Play(EQUATION, SECONDS_PLAYING, AMOUNT_KILOHERTZ, ASYNC_SLEEP = False):
82
83
@ ASYNC_SLEEP argument: Wait until the sound playing has finished or not.
83
84
@ ASYNC_SLEEP type: bool
84
85
'''
85
- EQUATION = EQUATION .replace ('^' ,'**' ).replace ('random()' ,'__import__("random").random()' ).replace ('|' ,'|operand_key_fix|' ).replace ('/' ,'|division_key_fix|' ).replace ('?' ,' if ' ).replace (':' ,' else ' ).replace ('.charCodeAt' ,' |charcodeat_key_fix| ' ).replace ('>>' ,' |operand_gtgt_key_fix| ' ).replace ('<<' ,' |operand_ltlt_key_fix| ' )
86
+ EQUATION = EQUATION .replace ('^' ,'**' ).replace ('random()' ,'__import__("random").random()' ).replace ('|' ,'|operand_key_fix|' ).replace ('/' ,'|division_key_fix|' ).replace ('?' ,' if ' ).replace (':' ,' else ' ).replace ('.charCodeAt' ,' |charcodeat_key_fix| ' ).replace ('>>' ,' |operand_gtgt_key_fix| ' ).replace ('<<' ,' |operand_ltlt_key_fix| ' ). replace ( '&' , ' |operand_and_key_fix| ' )
86
87
hWaveOut = HWAVEOUT (0 )
87
88
wfx = WAVEFORMATEX (WAVE_FORMAT_PCM , 1 , AMOUNT_KILOHERTZ , AMOUNT_KILOHERTZ , 1 , 8 ,0 )
88
89
winmm .waveOutOpen .argtypes = (LPHWAVEOUT , UINT , LPWAVEFORMATEX , DWORD , DWORD , DWORD )
0 commit comments