0

I am trying to record chunks of ultrasonic sound using the m500-384 microphone on a raspberry pi 3. I can record just the audio fine if that is the only process run, but the problem comes in when I try to record the audio in a separate thread while executing a loop in the main thread. The audio thread cannot keep up and misses readings. Is there a more efficient way to record the audio?

Right now I am using PyAudio to record the audio and I am using just regular threading.

David
  • 1

1 Answers1

0

To confirm your recording sample rate is 384Khz please show us the output of issuing this on one of your audio recording files

for example :

ffprobe myaudiofile.wav

... output says

ffprobe version N-86279-gac8dfcbd89 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 6.3.0 (Ubuntu 6.3.0-12ubuntu2) 20170406
  configuration: 
  libavutil      55. 63.100 / 55. 63.100
  libavcodec     57. 96.101 / 57. 96.101
  libavformat    57. 72.101 / 57. 72.101
  libavdevice    57.  7.100 / 57.  7.100
  libavfilter     6. 90.100 /  6. 90.100
  libswscale      4.  7.101 /  4.  7.101
  libswresample   2.  8.100 /  2.  8.100
Input #0, wav, from 'Cesária_Évora_Live_au_Bataclan-jYGcobbQAnQ_mono.wav':
  Metadata:
    encoder         : Lavf57.72.101
  Duration: 00:00:21.51, bitrate: 705 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s

Please tell us what the last line says ? as above shows my file has a sample rate of 44100 Hz ... are you seeing 384000 Hz ?

I would be surprised if a SOC computer like raspberry pi 3 can offer a sample rate of 384000 Hz however I would like to be wrong ... in order to record audio at such an extremely high sample rate the hardware must sample the incoming analog audio curve once every 2.60416 microseconds

issue this to see what your hardware is capable of (issued on ubuntu)

cat /proc/asound/card0/codec#2

in output this is the important section

  PCM:
    rates [0x7f0]: 32000 44100 48000 88200 96000 176400 192000

my ubuntu laptop says above ... are you seeing 384000 ?

Scott Stensland
  • 26,870
  • 12
  • 93
  • 104