Skip to content

Commit d84b534

Browse files
authored
Update ByteBeat.py
1 parent ec23b3b commit d84b534

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ByteBeat.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class WAVEHDR(ctypes.Structure):
4848
charcodeat_key_fix=Infix(lambda s,y: ord(s[y]))
4949
operand_gtgt_key_fix=Infix(lambda x,y: int(x)>>int(y))
5050
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))
5152

5253
class ByteBeat:
5354
def GenerateBuffer(EQUATION, SECONDS_PLAYING, AMOUNT_KILOHERTZ=8000):
@@ -61,7 +62,7 @@ def GenerateBuffer(EQUATION, SECONDS_PLAYING, AMOUNT_KILOHERTZ=8000):
6162
@ AMOUNT_KILOHERTZ argument: The amount of kilohertz (kHz) the ByteBeat will use.
6263
@ AMOUNT_KILOHERTZ type: int
6364
'''
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| ')
6566
hWaveOut = HWAVEOUT(0)
6667
wfx = WAVEFORMATEX(WAVE_FORMAT_PCM, 1, AMOUNT_KILOHERTZ, AMOUNT_KILOHERTZ, 1, 8,0)
6768
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):
8283
@ ASYNC_SLEEP argument: Wait until the sound playing has finished or not.
8384
@ ASYNC_SLEEP type: bool
8485
'''
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| ')
8687
hWaveOut = HWAVEOUT(0)
8788
wfx = WAVEFORMATEX(WAVE_FORMAT_PCM, 1, AMOUNT_KILOHERTZ, AMOUNT_KILOHERTZ, 1, 8,0)
8889
winmm.waveOutOpen.argtypes = (LPHWAVEOUT, UINT, LPWAVEFORMATEX, DWORD, DWORD, DWORD)

0 commit comments

Comments
 (0)