Update audioCircReplayTest.py
This commit is contained in:
@ -14,6 +14,11 @@ Frames = []
|
|||||||
p = pyaudio.PyAudio()
|
p = pyaudio.PyAudio()
|
||||||
info = p.get_host_api_info_by_index(0)
|
info = p.get_host_api_info_by_index(0)
|
||||||
numdevices = info.get('deviceCount')
|
numdevices = info.get('deviceCount')
|
||||||
|
samplesI = 0
|
||||||
|
saves = 0
|
||||||
|
cleanUp = False
|
||||||
|
incomingAudioChan = -1
|
||||||
|
localAudioChan = -1
|
||||||
|
|
||||||
for i in range(0, numdevices):
|
for i in range(0, numdevices):
|
||||||
if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
|
if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
|
||||||
@ -25,65 +30,27 @@ for i in range(0, numdevices):
|
|||||||
AudioChannels.append(p.open(format=pyaudio.paInt16, channels=1, rate=RATE, input=True, frames_per_buffer=CHUNKSIZE, input_device_index=i))
|
AudioChannels.append(p.open(format=pyaudio.paInt16, channels=1, rate=RATE, input=True, frames_per_buffer=CHUNKSIZE, input_device_index=i))
|
||||||
i2+=1
|
i2+=1
|
||||||
|
|
||||||
#streamLocal = p.open(format=pyaudio.paInt16, channels=1, rate=RATE, input=True, frames_per_buffer=CHUNKSIZE, input_device_index=localAudioChan)
|
|
||||||
#if("VoiceMeeter VAIO3 Output" in p.get_device_info_by_host_api_device_index(0, i).get('name')):
|
|
||||||
# localAudioChan = i
|
|
||||||
# print("Using " + p.get_device_info_by_host_api_device_index(0, i).get('name') + " for local stream " + str(i))
|
|
||||||
#if("CABLE" in p.get_device_info_by_host_api_device_index(0, i).get('name')):
|
|
||||||
# incomingAudioChan = i
|
|
||||||
# print("Using " + p.get_device_info_by_host_api_device_index(0, i).get('name') + " for Discord stream " + str(i))
|
|
||||||
|
|
||||||
## Populate frame buffer
|
## Populate frame buffer
|
||||||
i = 0
|
i = 0
|
||||||
while(i <= len(SourcesToRecord)):
|
while(i <= len(SourcesToRecord)):
|
||||||
Frames.append([])
|
Frames.append([])
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
def on_triggered():
|
||||||
samplesI = 0
|
|
||||||
saves = 0
|
|
||||||
|
|
||||||
def on_triggered(): #define your function to be executed on hot-key press
|
|
||||||
global cb, saves
|
global cb, saves
|
||||||
print("Saving replay..", end = "")
|
print("Saving replay..", end = "")
|
||||||
cutUpBuffers = []
|
cutUpBuffers = []
|
||||||
i = 0
|
i = 0
|
||||||
name = time.strftime("%Y-%m-%d_%H-%M-%S-out-")
|
name = time.strftime("%Y-%m-%d_%H-%M-%S-out-")
|
||||||
while(i < len(Frames) - 1):
|
while(i < len(Frames) - 1):
|
||||||
# cutUpBuffers.append(numpy.hstack(Frames[i][-320:]))
|
|
||||||
wav.write(name + str(saves) + str(i) + '.wav',RATE,numpy.hstack(Frames[i][-320:]))
|
wav.write(name + str(saves) + str(i) + '.wav',RATE,numpy.hstack(Frames[i][-320:]))
|
||||||
i += 1
|
i += 1
|
||||||
saves+=1
|
saves+=1
|
||||||
print("[DONE]")
|
print("[DONE]")
|
||||||
# wav.write(name + str(saves) + '-local.wav',RATE,numpydata2)
|
|
||||||
#write_to_textfield(text_to_print) #<-- your function
|
|
||||||
|
|
||||||
shortcut = 'alt+1'
|
shortcut = 'alt+1'
|
||||||
keyboard.add_hotkey(shortcut, on_triggered)
|
keyboard.add_hotkey(shortcut, on_triggered)
|
||||||
|
|
||||||
# initialize portaudio
|
|
||||||
cleanUp = False
|
|
||||||
|
|
||||||
incomingAudioChan = -1
|
|
||||||
localAudioChan = -1
|
|
||||||
deviceWithId = {}
|
|
||||||
#for i in range(0, numdevices):
|
|
||||||
# if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
|
|
||||||
# print("Using " + p.get_device_info_by_host_api_device_index(0, i).get('name') + " for " + str(i))
|
|
||||||
#for i in range(0, numdevices):
|
|
||||||
# if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
|
|
||||||
# deviceWithId[i] = p.get_device_info_by_host_api_device_index(0, i).get('name')
|
|
||||||
# # print("id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name'))
|
|
||||||
# if("VoiceMeeter VAIO3 Output" in p.get_device_info_by_host_api_device_index(0, i).get('name')):
|
|
||||||
# localAudioChan = i
|
|
||||||
# print("Using " + p.get_device_info_by_host_api_device_index(0, i).get('name') + " for local stream " + str(i))
|
|
||||||
# if("CABLE" in p.get_device_info_by_host_api_device_index(0, i).get('name')):
|
|
||||||
# incomingAudioChan = i
|
|
||||||
# print("Using " + p.get_device_info_by_host_api_device_index(0, i).get('name') + " for Discord stream " + str(i))
|
|
||||||
#if(incomingAudioChan == -1 or localAudioChan == -1):
|
|
||||||
# print("FAILURE")
|
|
||||||
# exit
|
|
||||||
|
|
||||||
print(" There are " + str(len(SourcesToRecord)) + " SourcesToRecord. Frames: " + str(len(Frames)))
|
print(" There are " + str(len(SourcesToRecord)) + " SourcesToRecord. Frames: " + str(len(Frames)))
|
||||||
|
|
||||||
print("Running!")
|
print("Running!")
|
||||||
@ -116,4 +83,4 @@ except KeyboardInterrupt:
|
|||||||
i += 1
|
i += 1
|
||||||
p.terminate()
|
p.terminate()
|
||||||
print("Quiting system, saved frame over lifetime: ", end="")
|
print("Quiting system, saved frame over lifetime: ", end="")
|
||||||
print(samplesI)
|
print(samplesI)
|
Reference in New Issue
Block a user