aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Doan <daviddoan@Davids-MacBook-Pro-193.local>2023-12-14 18:19:50 -0500
committerDavid Doan <daviddoan@Davids-MacBook-Pro-193.local>2023-12-14 18:19:50 -0500
commit54d8ff9d8fbcc68e2fe424261b14ed2e1670e446 (patch)
treea6383819e1a76820d5811461285c28496ada1d35
parent7da49af8e3d7910ba6d5caba46c114bdf0418358 (diff)
utils and threading updates
-rw-r--r--Sender.py36
1 files changed, 2 insertions, 34 deletions
diff --git a/Sender.py b/Sender.py
index 8ebe503..0eb97b3 100644
--- a/Sender.py
+++ b/Sender.py
@@ -27,36 +27,8 @@ def play_frequency(freq, amplitude, duration=1.0, samplingRate=44100, p=None):
stream.stop_stream()
stream.close()
- p.terminate()
-
-
-# def play_frequency(freq, amplitude, duration=1.0, samplingRate=44100):
-# p = pyaudio.PyAudio()
-
-# # Generate sample
-# samples = np.sin(2 * np.pi * np.arange(samplingRate * duration) * freq / samplingRate)
-
-# # Normalize
-# max_amplitude = np.max(np.abs(samples))
-# normalized_samples = (amplitude / max_amplitude) * samples
-
-# # clip to [0.0, 1.0]
-# normalized_samples = np.clip(normalized_samples, 0.0, 1.0)
-
-# samples_bytes = normalized_samples.astype(np.float32).tobytes()
-
-# stream = p.open(format=pyaudio.paFloat32,
-# channels=1,
-# rate=samplingRate,
-# output=True)
-
-# stream.write(samples_bytes)
-
-# # Stop and close the stream
-# stream.stop_stream()
-# stream.close()
+ # p.terminate()
-# p.terminate()
"""
Use threads to play multiple frequencies simultaneously.
@@ -191,14 +163,10 @@ class LinkLayer:
if not self.isReceiving:
user_input = input("Enter data to send: ")
if user_input == "exit" or user_input == "q":
- self.exit()
+ break
self.transmit_string(user_input)
else:
print("Currently receiving data, please wait...")
- def exit(self):
- self.stream.stop_stream()
- self.stream.close()
- self.p.terminate()
# take in range width, the number of bytes, and the bytes themselves, and starting freq