notting updatee

This commit is contained in:
dharm pimsen 2023-12-21 22:28:51 +07:00
parent 718b918324
commit 4b522fc2e7
5 changed files with 29 additions and 31 deletions

View File

@ -192,6 +192,7 @@ class App:
bytesconunt_frame = 0 bytesconunt_frame = 0
start_time = time.time() start_time = time.time()
evaluation_audio_X = None evaluation_audio_X = None
decodecodec = None
while True: while True:
try: try:
if self.working: if self.working:
@ -245,9 +246,11 @@ class App:
pass pass
if self.firstrun: if self.firstrun:
opus_decoder = OpusDecoder() decodecodec = datadecoded["channel"][self.readchannel]["RDS"]["ContentInfo"]["Codec"]
opus_decoder.set_channels(self.RDS["ContentInfo"]["channel"]) if decodecodec.upper() == "OPUS":
opus_decoder.set_sampling_frequency(self.RDS["ContentInfo"]["samplerates"]) opus_decoder = OpusDecoder()
opus_decoder.set_channels(self.RDS["ContentInfo"]["channel"])
opus_decoder.set_sampling_frequency(self.RDS["ContentInfo"]["samplerates"])
streamoutput = self.paudio.open(format=pyaudio.paInt16, channels=self.RDS["ContentInfo"]["channel"], rate=self.RDS["ContentInfo"]["samplerates"], output=True, output_device_index=self.device_index_output) streamoutput = self.paudio.open(format=pyaudio.paInt16, channels=self.RDS["ContentInfo"]["channel"], rate=self.RDS["ContentInfo"]["samplerates"], output=True, output_device_index=self.device_index_output)
evaluation_audio_X = np.fft.fftfreq(1024, 1.0 / self.RDS["ContentInfo"]["samplerates"])[:1024 // 2] evaluation_audio_X = np.fft.fftfreq(1024, 1.0 / self.RDS["ContentInfo"]["samplerates"])[:1024 // 2]
if len(datadecoded["channel"]) > 1: if len(datadecoded["channel"]) > 1:
@ -269,7 +272,6 @@ class App:
dpg.configure_item("mediachannelselect", show=True, default_value=channel_info[self.readchannel - 1]) dpg.configure_item("mediachannelselect", show=True, default_value=channel_info[self.readchannel - 1])
elif self.firststart: elif self.firststart:
self.readchannel = datadecoded["mainchannel"] self.readchannel = datadecoded["mainchannel"]
# check if channel is encrypted # check if channel is encrypted
if datadecoded["channel"][self.readchannel]["Encrypt"]: if datadecoded["channel"][self.readchannel]["Encrypt"]:
dpg.configure_item("requestpasswordpopup", show=True) dpg.configure_item("requestpasswordpopup", show=True)
@ -302,7 +304,10 @@ class App:
dpg.configure_item("serverstatus", default_value="Decrypt Error", color=(255, 0, 0)) dpg.configure_item("serverstatus", default_value="Decrypt Error", color=(255, 0, 0))
if self.ccisdecrypt or not self.ccisencrypt: if self.ccisdecrypt or not self.ccisencrypt:
decoded_pcm = opus_decoder.decode(memoryview(bytearray(data))) if decodecodec.upper() == "OPUS":
decoded_pcm = opus_decoder.decode(memoryview(bytearray(data)))
else: # pcm
decoded_pcm = data
# Check if the decoded PCM is empty or not # Check if the decoded PCM is empty or not
if len(decoded_pcm) > 0: if len(decoded_pcm) > 0:
@ -486,6 +491,8 @@ class App:
if self.config["debug"]["hideconsole"] == "true": if self.config["debug"]["hideconsole"] == "true":
ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0) ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0)
ctypes.CDLL("opus.dll")
dpg.create_context() dpg.create_context()
dpg.create_viewport(title=f'IDRB Client v1.5 Beta', width=1280, height=720, large_icon="IDRBfavicon.ico") # set viewport window dpg.create_viewport(title=f'IDRB Client v1.5 Beta', width=1280, height=720, large_icon="IDRBfavicon.ico") # set viewport window
dpg.setup_dearpygui() dpg.setup_dearpygui()

View File

@ -12,7 +12,8 @@ a = Analysis(
('config.ini', '.'), # Example source ('config.ini') and destination ('.') paths ('config.ini', '.'), # Example source ('config.ini') and destination ('.') paths
('IDRBfavicon.ico', '.'), ('IDRBfavicon.ico', '.'),
('IDRBfavicon.png', '.'), ('IDRBfavicon.png', '.'),
('IDRBlogo.png', '.') ('IDRBlogo.png', '.'),
('opus.dll', '.')
], ],
hiddenimports=[], hiddenimports=[],
hookspath=[], hookspath=[],

View File

@ -1,5 +1,6 @@
[audio] [audio]
device = device = Speakers (2- USB Audio DAC )
[debug] [debug]
hideconsole = true hideconsole = true

BIN
Client/opus.dll Normal file

Binary file not shown.

View File

@ -48,22 +48,11 @@ s.bind(server_port)
s.listen(1) s.listen(1)
p = pyaudio.PyAudio() p = pyaudio.PyAudio()
sample_rate = 48000 sample_rate = 48000
bytes_per_sample = p.get_sample_size(pyaudio.paInt16) bytes_per_sample = p.get_sample_size(pyaudio.paInt16)
codec = "opus" # opus, pcm, aac
# Create an Opus encoder
bitrates = 64000 #Kbps
channel = 2 # Stereo
framesize = 60
if bitrates >= 500000:
bitrates = 500000
device_name_input = "Line 5 (Virtual Audio Cable)" device_name_input = "Line 5 (Virtual Audio Cable)"
device_index_input = 0 device_index_input = 0
@ -126,9 +115,9 @@ RDS = {
# can add more here # can add more here
], ],
"ContentInfo": { "ContentInfo": {
"Codec": codec, "Codec": "opus",
"bitrate": bitrates, "bitrate": 64000,
"channel": channel, "channel": 2,
"samplerates": sample_rate "samplerates": sample_rate
}, },
"images": { "images": {
@ -168,9 +157,9 @@ RDS2 = {
# can add more server here # can add more server here
], ],
"ContentInfo": { "ContentInfo": {
"Codec": codec, "Codec": "Opus",
"bitrate": 8000, "bitrate": 8000,
"channel": channel, "channel": 2,
"samplerates": sample_rate "samplerates": sample_rate
}, },
"images": { "images": {
@ -226,9 +215,9 @@ def encode_audio():
encoder = OpusBufferedEncoder() encoder = OpusBufferedEncoder()
encoder.set_application("audio") encoder.set_application("audio")
encoder.set_sampling_frequency(sample_rate) encoder.set_sampling_frequency(sample_rate)
encoder.set_channels(channel) encoder.set_channels(2)
encoder.set_bitrates(bitrates) encoder.set_bitrates(64000)
encoder.set_frame_size(framesize) encoder.set_frame_size(60)
while True: while True:
pcm = np.frombuffer(streaminput.read(1024, exception_on_overflow=False), dtype=np.int16) pcm = np.frombuffer(streaminput.read(1024, exception_on_overflow=False), dtype=np.int16)
@ -239,15 +228,13 @@ def encode_audio():
channel1.put(encoded_packet.tobytes()) channel1.put(encoded_packet.tobytes())
def encode_audio2(): def encode_audio2():
encoder2 = OpusBufferedEncoder() encoder2 = OpusBufferedEncoder()
encoder2.set_application("audio") encoder2.set_application("audio")
encoder2.set_sampling_frequency(sample_rate) encoder2.set_sampling_frequency(sample_rate)
encoder2.set_channels(channel) encoder2.set_channels(2)
encoder2.set_bitrates(8000) encoder2.set_bitrates(8000)
encoder2.set_frame_size(framesize) encoder2.set_frame_size(60)
while True: while True:
pcm2 = np.frombuffer(streaminput2.read(1024, exception_on_overflow=False), dtype=np.int16) pcm2 = np.frombuffer(streaminput2.read(1024, exception_on_overflow=False), dtype=np.int16)
@ -257,6 +244,8 @@ def encode_audio2():
# Put the encoded audio into the buffer # Put the encoded audio into the buffer
channel2.put(encoded_packet.tobytes()) channel2.put(encoded_packet.tobytes())
#channel2.put(pcm2.tobytes()) # if you use pcm
audio_thread = threading.Thread(target=encode_audio) audio_thread = threading.Thread(target=encode_audio)
audio_thread.start() audio_thread.start()