diff options
| author | Kasper Nyhus Kaae <[email protected]> | 2022-03-07 21:30:33 +0100 |
|---|---|---|
| committer | HiFiPhile <[email protected]> | 2024-04-27 20:29:07 +0200 |
| commit | c917d47e71d9cef3f6cf096cf9606913ef7020fd (patch) | |
| tree | e006289c25b0859f1b5713026e81232b413ede77 /examples/device/audio_test_freertos/src/plot_audio_samples.py | |
| parent | 31b559370d29f5093979fc50de2ae415fa6612ce (diff) | |
audio_test_freertos & audio_4_channel_mic_freertos
Diffstat (limited to 'examples/device/audio_test_freertos/src/plot_audio_samples.py')
| -rw-r--r-- | examples/device/audio_test_freertos/src/plot_audio_samples.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/device/audio_test_freertos/src/plot_audio_samples.py b/examples/device/audio_test_freertos/src/plot_audio_samples.py new file mode 100644 index 000000000..6e3c4978e --- /dev/null +++ b/examples/device/audio_test_freertos/src/plot_audio_samples.py @@ -0,0 +1,34 @@ +import sounddevice as sd +import matplotlib.pyplot as plt +import numpy as np +import platform + +if __name__ == '__main__': + + # If you got "ValueError: No input device matching", that is because your PC name example device + # differently from tested list below. Uncomment the next line to see full list and try to pick correct one + # print(sd.query_devices()) + + fs = 48000 # Sample rate + duration = 100e-3 # Duration of recording + + if platform.system() == 'Windows': + # MME is needed since there are more than one MicNode device APIs (at least in Windows) + device = 'Microphone (MicNode) MME' + elif platform.system() == 'Darwin': + device = 'MicNode' + else: + device ='default' + + myrecording = sd.rec(int(duration * fs), samplerate=fs, channels=1, dtype='int16', device=device) + print('Waiting...') + sd.wait() # Wait until recording is finished + print('Done!') + + time = np.arange(0, duration, 1 / fs) # time vector + plt.plot(time, myrecording) + plt.xlabel('Time [s]') + plt.ylabel('Amplitude') + plt.title('MicNode') + plt.show() +
\ No newline at end of file |
