iizukanao / picam

Audio/video recorder for Raspberry Pi with language agnostic API
GNU Lesser General Public License v2.1
485 stars 78 forks source link

i2s Mic buzzing sound #115

Open kpolley opened 5 years ago

kpolley commented 5 years ago

This is the command:

./picam -w 1920 -h 1080 -f 15 --alsadev plug:dmic_sv

Sometimes the resulting video has no issues and great sound quality, sometimes the microphone creates a very loud buzzing sound. This happens anywhere between 10-25 seconds after recording. I'm assuming it's because of this error here:

failed to set buffer size for microphone: buffer_size=2048 multiply=100 
trying smaller buffer size for microphone: buffer_size=2048 multiply=50 
failed to set buffer size for microphone: buffer_size=2048 multiply=50        
trying smaller buffer size for microphone: buffer_size=2048 multiply=25    
microphone: buffer size: 51200 frames (channels=1 buffer_size=2048 multiply=25)

Here are the picam logs where I created 5 videos: The 1st, 2nd and 3rd are great. The 4th and 5th have the buzzing sound.

pi@raspberrypi:~/picam $ ./picam -w 640 -h 480 --alsadev plug:dmic_sv -f 20 --verbose
video_width=640         
video_height=480                                                         
video_fps=20.000000                                                              
fr_q16=1310720                                                               
video_pts_step=4500                                                          
video_gop_size=20                                                            
video_rotation=0                                                               
video_hflip=0                                              
video_vflip=0                                                                         
video_bitrate=2000000                                                        
video_avc_profile=constrained_baseline                                       
video_avc_level=3.1                                                          
video_qp_min=-1                                                               
video_qp_max=-1                                                              
video_qp_initial=-1                                                                         
video_slice_dquant=-1                                                  
alsa_dev=plug:dmic_sv                                                    
audio_channels=1                                                                             
audio_sample_rate=48000                                                        
audio_bitrate=40000                                                      
audio_volume_multiply=1.000000                                                        
is_hlsout_enabled=0                                                          
is_hls_encryption_enabled=0                                                  
hls_encryption_key_uri=stream.key                                            
hls_encryption_key=0x75b0a81de17487c88a47507a7e1fdf73                         
hls_encryption_iv=0x000102030405060708090a0b0c0d0e0f                         
hls_output_dir=/run/shm/video 
rtsp_enabled=0
rtsp_video_control_path=/tmp/node_rtsp_rtmp_videoControl
rtsp_audio_control_path=/tmp/node_rtsp_rtmp_audioControl
rtsp_video_data_path=/tmp/node_rtsp_rtmp_videoData
rtsp_audio_data_path=/tmp/node_rtsp_rtmp_audioData
tcp_enabled=0
tcp_output_dest=
auto_exposure_enabled=0
auto_exposure_threshold=5.000000
is_vfr_enabled=0
white_balance=auto
exposure_control=auto
awb_red_gain=0.000000
awb_blue_gain=0.000000
metering=average
manual_exposure_compensation=0
exposure_compensation=0.000000
manual_exposure_aperture=0
exposure_aperture=0
manual_exposure_shutter_speed=0
exposure_shutter_speed=0
manual_exposure_sensitivity=0
exposure_sensitivity=0
roi_left=0.000000
roi_top=0.000000
roi_width=1.000000
roi_height=1.000000
min_fps=-1.000000
max_fps=-1.000000
is_timestamp_enabled=0
timestamp_format=%a %b %d %l:%M:%S %p
timestamp_layout=15
timestamp_horizontal_margin=10
timestamp_vertical_margin=10
is_timestamp_abs_pos_enabled=0
timestamp_pos_x=0
timestamp_pos_y=0
timestamp_text_align=1
timestamp_font_name=FreeMono:style=Bold
timestamp_font_file=
timestamp_font_face_index=(null)
timestamp_font_points=14.000000
timestamp_font_dpi=96
timestamp_color=ffffff
timestamp_stroke_color=000000
timestamp_stroke_width=1
timestamp_letter_spacing=0
is_preview_enabled=0
is_previewrect_enabled=0
preview_x=0
preview_y=0
preview_width=0                                         
preview_height=0                                        
preview_opacity=255                               
blank_background_color=0x0                        
is_audio_preview_enabled=0
audio_preview_dev=plughw:0,0
record_buffer_keyframes=5
state_dir=state                 
hooks_dir=hooks 
configuring devices
exposure control: auto
setting exposure:    
  eMetering: 0        
  xEVCompensation: 0
  nApertureFNumber: 0         
  bAutoAperture: 0            
  nShutterSpeedMsec: 0    
  bAutoShutterSpeed: 1
  nSensitivity: 0              
  bAutoSensitivity: 1   
Set video_encode state to idle
Enable port buffers for camera 71
Enable port buffers for video_encode 200
Enable port buffers for video_encode 201
Set camera state to executing
Set video_encode state to executing
opening ALSA device for capture: plug:dmic_sv
final audio_channels: 1
sample_rate: 48000    
nb_samples: 1024                     
sample_fmt: 1      
audio_codec_ctx->channel_layout: 4
av_frame->channel_layout: 4 
audio_codec_ctx->channels: 1  
av_frame->channels: 0
allocated 2048 bytes for audio samples
audio_pts_step_base: 1920
actual sample rate=48000 dir=0         
failed to set buffer size for microphone: buffer_size=2048 multiply=100
trying smaller buffer size for microphone: buffer_size=2048 multiply=50
failed to set buffer size for microphone: buffer_size=2048 multiply=50
trying smaller buffer size for microphone: buffer_size=2048 multiply=25
microphone: buffer size: 51200 frames (channels=1 buffer_size=2048 multiply=25)
microphone: setting period size to 1024
actual_period_size=1024 dir=0                                                                                                                                                                               
audio capture device:                                                                                                                                                                                       
Plug PCM: Route conversion PCM (sformat=S32_LE)                                                                                                                                                             
  Transformation table:                                                                                                                                                                                     
    0 <- 0*0.5 + 1*0.5                                                                                                                                                                                      
Its setup is: 
  stream       : CAPTURE                                
  access       : MMAP_INTERLEAVED                       
  format       : S16_LE                           
  subformat    : STD                              
  channels     : 1        
  rate         : 48000      
  exact rate   : 48000 (48000/1)
  msbits       : 16             
  buffer_size  : 51200
  period_size  : 1024
  period_time  : 21333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1  
  avail_min    : 1024         
  period_event : 0            
  start_threshold  : 1    
  stop_threshold   : 51200
  silence_threshold: 0         
  silence_size : 0      
  boundary     : 1677721600   
Slave: Soft volume PCM           
Control: Boost Capture Volume           
min_dB: -3                              
max_dB: 30                   
resolution: 256                    
Its setup is:                                
  stream       : CAPTURE
  access       : MMAP_INTERLEAVED
  format       : S32_LE              
  subformat    : STD
  channels     : 2                
  rate         : 48000      
  exact rate   : 48000 (48000/1)
  msbits       : 32  
  buffer_size  : 51200                
  period_size  : 1024    
  period_time  : 21333                 
  tstamp_mode  : NONE                                                  
  tstamp_type  : MONOTONIC                                             
  period_step  : 1                                                    
  avail_min    : 1024                                                  
  period_event : 0                                                             
  start_threshold  : 1          
 stop_threshold   : 51200                                                                                                                                                                                  
  silence_threshold: 0                                                                                                                                                                                      
  silence_size : 0                                                                                                                                                                                          
  boundary     : 1677721600                                                                                                                                                                                 
Slave: Hardware PCM card 1 'snd_rpi_simple_card' device 0 subdevice 0                                                                                                                                       
Its setup is: 
  stream       : CAPTURE                                
  access       : MMAP_INTERLEAVED                       
  format       : S32_LE                           
  subformat    : STD                              
  channels     : 2        
  rate         : 48000      
  exact rate   : 48000 (48000/1)
  msbits       : 32             
  buffer_size  : 51200
  period_size  : 1024
  period_time  : 21333
  tstamp_mode  : NONE
  tstamp_type  : MONOTONIC
  period_step  : 1  
  avail_min    : 1024         
  period_event : 0            
  start_threshold  : 1    
  stop_threshold   : 51200
  silence_threshold: 0         
  silence_size : 0      
  boundary     : 1677721600   
  appl_ptr     : 0               
  hw_ptr       : 0                      
start capturing video                   
waiting for the first video buffer
start capturing audio              
[microphone started]capturing started        
.e(0x0).e(0x0).[NAL7]..................... 20.93 fps k=1 a-v=5340 c-a=4584 u=0 d=0 pts=94500
.................... 20.18 fps k=2 a-v=3660 c-a=6096 u=0 d=0 pts=184500
.................... 20.18 fps k=3 a-v=-1860 c-a=11583 u=0 d=0 pts=274500
...................vSPEED_DOWN(-14400). 20.16 fps k=4 a-v=-14760 c-a=24708 u=0 d=1 pts=364200
.................... 20.18 fps k=5 a-v=-11520 c-a=24511 u=0 d=1 pts=451200
.................... 20.23 fps k=6 a-v=-8280 c-a=23837 u=0 d=1 pts=538200
.................... 20.13 fps k=7 a-v=-5040 c-a=23601 u=0 d=1 pts=625200
.................... 20.07 fps k=8 a-v=-3720 c-a=25983 u=0 d=1 pts=712200
.................... 20.24 fps k=9 a-v=-8160 c-a=32928 u=0 d=1 pts=799200
.................... 20.24 fps k=10 a-v=-6840 c-a=34336 u=0 d=1 pts=886200
.................... 20.12 fps k=11 a-v=-7440 c-a=37879 u=0 d=1 pts=973200
.................... 20.06 fps k=12 a-v=-8040 c-a=41823 u=0 d=1 pts=1060200
.................... 20.18 fps k=13 a-v=-8640 c-a=45322 u=0 d=1 pts=1147200
.................... 20.17 fps k=14 a-v=-9240 c-a=48911 u=0 d=1 pts=1234200
.................... 20.14 fps k=15 a-v=-6000 c-a=48847 u=0 d=1 pts=1321200
.................... 20.20 fps k=16 a-v=-4680 c-a=50231 u=0 d=1 pts=1408200    
.................... 20.20 fps k=17 a-v=-12960 c-a=61535 u=0 d=1 pts=1495200
.................... 20.16 fps k=18 a-v=-21240 c-a=72810 u=0 d=1 pts=1582200                                                                                                                                
....disk_usage=9% start rec to rec/archive/2018-11-09_20-11-26.ts                                                                                                                                           
.........caught up....... 20.16 fps k=19 a-v=-19920 c-a=74537 u=0 d=1 pts=1669200                                                                                                                           
.................... 20.16 fps k=20 a-v=-24360 c-a=81890 u=0 d=1 pts=1756200                                                                                                                                
.................... 20.16 fps k=21 a-v=-23040 c-a=83591 u=0 d=1 pts=1843200                                                                                                                                
.................... 20.20 fps k=22 a-v=-21720 c-a=85321 u=0 d=1 pts=1930200
.................... 20.19 fps k=23 a-v=-26160 c-a=92676 u=0 d=1 pts=2017200
...................F. 20.15 fps k=24 a-v=-30600 c-a=100452 u=0 d=1 pts=2104200
.........stop rec                                 
copy symlink(archive/2018-11-09_20-11-26.ts, rec/2018-11-09_20-11-26.ts)
unlink........... 20.30 fps k=25 a-v=-31200 c-a=103659 u=0 d=1 pts=2191200
................disk_usage=9% .start rec to rec/archive/2018-11-09_20-11-33.ts
... 20.25 fps k=26 a-v=-33720 c-a=108774 u=0 d=1 pts=2278200
........caught up............ 20.06 fps k=27 a-v=-34320 c-a=112641 u=0 d=1 pts=2365200
.................... 20.17 fps k=28 a-v=-38760 c-a=120068 u=0 d=1 pts=2452200
.................... 20.18 fps k=29 a-v=-48960 c-a=133171 u=0 d=1 pts=2539200
.................... 20.10 fps k=30 a-v=-55320 c-a=142554 u=0 d=1 pts=2626200
...................F. 20.12 fps k=31 a-v=-63600 c-a=154107 u=0 d=1 pts=2713200
.................... 20.26 fps k=32 a-v=-64200 c-a=157461 u=0 d=1 pts=2800200
.stop rec           
.copy symlink(archive/2018-11-09_20-11-33.ts, rec/2018-11-09_20-11-33.ts)
unlink.................. 20.17 fps k=33 a-v=-64800 c-a=160960 u=0 d=1 pts=2887200
.................... 20.18 fps k=34 a-v=-65400 c-a=164579 u=0 d=1 pts=2974200
.................... 20.17 fps k=35 a-v=-64080 c-a=166182 u=0 d=1 pts=3061200
.................... 20.16 fps k=36 a-v=-70440 c-a=175801 u=0 d=1 pts=3148200
.................disk_usage=9% .start rec to rec/archive/2018-11-09_20-11-44.ts
.. 20.24 fps k=37 a-v=-74880 c-a=182722 u=0 d=1 pts=3235200
........caught up............ 20.07 fps k=38 a-v=-73560 c-a=184664 u=0 d=1 pts=3322200
.................... 20.17 fps k=39 a-v=-74160 c-a=188195 u=0 d=1 pts=3409200
.................... 20.14 fps k=40 a-v=-72840 c-a=189897 u=0 d=1 pts=3496200
.................... 20.16 fps k=41 a-v=-69600 c-a=189624 u=0 d=1 pts=3583200
....................F 20.02 fps k=42 a-v=-66360 c-a=189971 u=0 d=1 pts=3670200
.................... 20.31 fps k=43 a-v=-63120 c-a=189335 u=0 d=1 pts=3757200
.................... 20.13 fps k=44 a-v=-59880 c-a=189149 u=0 d=1 pts=3844200               
..........stop rec                                                     
copy .symlink(archive/2018-11-09_20-11-44.ts, rec/2018-11-09_20-11-44.ts)
unlink......... 20.22 fps k=45 a-v=-56640 c-a=188474 u=0 d=1 pts=3931200                                                                                                                                    
.................disk_usage=9% .start rec to rec/archive/2018-11-09_20-11-53.ts                                                                                                                             
.. 20.27 fps k=46 a-v=-53400 c-a=188023 u=0 d=1 pts=4018200                                                                                                                                                 
........caught up............ 20.13 fps k=47 a-v=-52080 c-a=189639 u=0 d=1 pts=4105200                                                                                                                      
.................... 20.06 fps k=48 a-v=-48840 c-a=189637 u=0 d=1 pts=4192200                                                                                                                               
.................... 20.17 fps k=49 a-v=-45600 c-a=189439 u=0 d=1 pts=4279200                                                                                                                               
.................... 20.18 fps k=50 a-v=-42360 c-a=189179 u=0 d=1 pts=4366200                                                                                                                               
....................F 20.01 fps k=51 a-v=-39120 c-a=190101 u=0 d=1 pts=4453200                                                                                                                              
.................... 20.49 fps k=52 a-v=-35880 c-a=188282 u=0 d=1 pts=4540200                                                                                                                               
.................... 20.13 fps k=53 a-v=-32640 c-a=187964 u=0 d=1 pts=4627200                                                                                                                               
..................stop rec                                                                                                                                                                                  
copy .symlink(archive/2018-11-09_20-11-53.ts, rec/2018-11-09_20-11-53.ts)                                                                                                                                   
unlink. 20.10 fps k=54 a-v=-31320 c-a=189638 u=0 d=1 pts=4714200                                                                                                                                            
.................... 20.05 fps k=55 a-v=-28080 c-a=189792 u=0 d=1 pts=4801200                                                                                                                               
.................... 20.23 fps k=56 a-v=-24840 c-a=189072 u=0 d=1 pts=4888200                                                                                                                               
......disk_usage=9% .start rec to rec/archive/2018-11-09_20-12-04.ts                                                                                                                                        
.........caught up.... 20.13 fps k=57 a-v=-21600 c-a=188866 u=0 d=1 pts=4975200                                                                                                                             
.................... 20.13 fps k=58 a-v=-18360 c-a=188555 u=0 d=1 pts=5062200                                                                                                                               
.................... 19.99 fps k=59 a-v=-15120 c-a=189304 u=0 d=1 pts=5149200                                                                                                                               
.................... 20.20 fps k=60 a-v=-11880 c-a=188385 u=0 d=1 pts=5236200
.................... 20.16 fps k=61 a-v=-10560 c-a=190097 u=0 d=1 pts=5323200
....................F 20.07 fps k=62 a-v=-7320 c-a=190179 u=0 d=1 pts=5410200 
.................... 20.35 fps k=63 a-v=-4080 c-a=189163 u=0 d=1 pts=5497200
.......stop rec                                                         
copy .symlink(archive/2018-11-09_20-12-04.ts, rec/2018-11-09_20-12-04.ts) 
unlink..vNORMAL.......... 20.04 fps k=64 a-v=-2490 c-a=189216 u=0 d=1 pts=5585850
.................... 20.17 fps k=65 a-v=-2250 c-a=188995 u=0 d=1 pts=5675850
.................... 20.21 fps k=66 a-v=-2010 c-a=188674 u=0 d=1 pts=5765850          
.................... 20.22 fps k=67 a-v=-1770 c-a=188406 u=0 d=1 pts=5855850 
.................... 20.21 fps k=68 a-v=-3450 c-a=190067 u=0 d=1 pts=5945850 
........^Cstop requested (signal=2)                                          
shutdown sequence start                                                       
waiting for the camera to finish                                             
hit Ctrl-\ to force stop
.stop capturing video                                                    
shutdown_openmax: ilclient_flush_tunnels                                         
shutdown_openmax: disable port buffer for camera 71                          
shutdown_openmax: disable port buffer for video_encode 200                   
shutdown_openmax: disable port buffer for video_encode 201                   
shutdown_openmax: disable tunnel[0]                                            
shutdown_openmax: teardown tunnels                         
shutdown_openmax: state transition to idle                                            
shutdown_openmax: state transition to loaded                                 
shutdown_openmax: ilclient_cleanup_components                                
shutdown_openmax: OMX_Deinit                                                 
shutdown_openmax: ilclient_destroy cam_client                                 
shutdown_openmax: ilclient_destroy ilclient                                  
shutdown_video                                                                              
teardown_audio_encode                                                  
teardown_audio_capture_device            
hls_destroy                                                
pthread_mutex_destroy                                                                 
teardown_socks                                                               
free_encoded_packets                                                         
stop_watching_hooks                                                          
stop requested (signal=15)                                                    
pthread_join hooks_thread                                                    
free keyframe_pointers                                                                      
shutdown successful                        
viveksanagari commented 5 years ago

Hi @kpolley I am facing the same problem. Did you (or anyone) somehow manage to solve the buzzing sound from the mic?

I am using raspberry pi 2 with a D-link USB modem and a microphone. I am hearing a very disturbing buzzing sound from the mic (together with the voice). I thought it could be a disturbance from the air which is causing the buzzing sound. I tried to buy a pop filter for the microphone to avoid the noise from the air. But that didn't solve the problem. It seems there is some other thing which is causing the buzzing sound.

Is it from the picam or the microphone? Because I have tested the Pi with two different microphones and the result buzzing sound is the same.

What can I do to avoid the noise from the mic?

Please help. Thank you in advance.

rajeshkrarora1 commented 5 years ago

sir, if the mic and speakers are in proximity, one will get the buzzing sound, echo and with passing time (withing seconds) the echo increases so much that there is only echo sound and nothing else.

so we need to use mic away from speakers,

https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=be81ceab-3a65-45b8-859a-e92e6a669d47 I’m protected online with Avast Free Antivirus. Get it here — it’s free forever. https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=be81ceab-3a65-45b8-859a-e92e6a669d47 <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Feb 22, 2019 at 3:49 PM vmiovneik notifications@github.com wrote:

Hi @kpolley https://github.com/kpolley I am facing the same problem. Did you (or anyone) somehow manage to solve the buzzing sound from the mic?

I am using raspberry pi 2 with a D-link USB modem and a microphone. I am hearing a very disturbing buzzing sound from the mic (together with the voice). I thought it could be a disturbance from the air which is causing the buzzing sound. I tried to buy a pop filter for the microphone to avoid the noise from the air. But that didn't solve the problem. It seems there is some other thing which is causing the buzzing sound.

Is it from the picam or the microphone? Because I have tested the Pi with two different microphones and the result buzzing sound is the same.

What can I do to avoid the noise from the mic?

Please help. Thank you in advance.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/iizukanao/picam/issues/115#issuecomment-466348080, or mute the thread https://github.com/notifications/unsubscribe-auth/Ako7-iXE4MXSw5gECO8Jvi2565lY1P6dks5vP8RKgaJpZM4YX0W7 .

kpolley commented 5 years ago

@viveksanagari after lots of trial and error I came to the conclusion it was something wrong with picam and it's attempt to sync the audio and video. I actually ditched picam altogether and built something similar myself using python

Some of the code is is specific to my hardware, but give it a try and I hope it works out! Feel free to post any issues you face on the repo.

viveksanagari commented 5 years ago

sir, if the mic and speakers are in proximity, one will get the buzzing sound, echo and with passing time (withing seconds) the echo increases so much that there is only echo sound and nothing else. so we need to use mic away from speakers, https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=be81ceab-3a65-45b8-859a-e92e6a669d47 I’m protected online with Avast Free Antivirus. Get it here — it’s free forever. https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=be81ceab-3a65-45b8-859a-e92e6a669d47 <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Hi @rajeshkrarora1 Thank you for responding, I tried to place the raspberry pi in a closed room and heard the audio from another room, just to make sure the audio and speakers are not near to each other such that it captures each others output. However it didn't made a difference in my case. Can you please suggest what could be the other possibility to solve my problem.

Thank you in advance,

viveksanagari commented 5 years ago

@viveksanagari after lots of trial and error I came to the conclusion it was something wrong with picam and it's attempt to sync the audio and video. I actually ditched picam altogether and built something similar myself using python

Some of the code is is specific to my hardware, but give it a try and I hope it works out! Feel free to post any issues you face on the repo.

Hi @kpolley Thank you for responding and directing to your python solution. I will definitely try it to see how it works for my purpose.

Alongside, I have tried to record some video and audio using 'raspivid' and 'arecord' command line tools by using the below command,

raspivid -t 10000 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 -o video.h264 & arecord --device=hw:1,0 --format S16_LE --duration=10 --rate 44100 -c1 test.wav &

The audio noise/disturbance lived even while recording from the command line tools, as it was while recording the video from 'Picam'. So, do you think in my case could there be any other possible reason for this disturbance in audio? For example, the signals from 4g dongle? the power supply? the raspberry pi? the mic? capture card?

Kindly point out if you (or anyone) have some possible reasons for this, so I can test it for solution. Thanks for your help in advance.

rajeshkrarora1 commented 5 years ago

Dear @viveksanagari https://github.com/viveksanagari, you try adjusting the mic sensitivity by going into alsmixer and after selecting your (f6) mic press (f5) to go into the soft-volume control and reduce the mic input to around 30 and see if that resolves ur problem

On Mon, Feb 25, 2019 at 10:50 PM vmiovneik notifications@github.com wrote:

@viveksanagari https://github.com/viveksanagari after lots of trial and error I came to the conclusion it was something wrong with picam and it's attempt to sync the audio and video. I actually ditched picam altogether and built something similar myself using python https://github.com/kpolley/Python_AVrecorder

Some of the code is is specific to my hardware, but give it a try and I hope it works out! Feel free to post any issues you face on the repo.

Hi @kpolley https://github.com/kpolley Thank you for responding and directing to your python solution. I will definitely try it to see how it works for my purpose.

Alongside, I have tried to record some video and audio using 'raspivid' and 'arecord' command line tools by using the below command,

raspivid -t 10000 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 -o video.h264 & arecord --device=hw:1,0 --format S16_LE --duration=10 --rate 44100 -c1 test.wav &

The audio noise/disturbance lived even while recording from the command line tools, as it was while recording the video from 'Picam'. So, do you think in my case could there be any other possible reason for this disturbance in audio? For example, the signals from 4g dongle? the power supply? the raspberry pi? the mic? capture card?

Kindly point out if you (or anyone) have some possible reasons for this, so I can test it for solution. Thanks for your help in advance.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iizukanao/picam/issues/115#issuecomment-467098270, or mute the thread https://github.com/notifications/unsubscribe-auth/Ako7-oMgK8r3E4mI3wuMot9a2Pv17-p4ks5vRBtFgaJpZM4YX0W7 .

rajeshkrarora1 commented 5 years ago

dear @viveksanagari https://github.com/viveksanagari, A closed room can also make sound bounce back and create a buzzing sound or create an echo, check ur room acoustics

On Mon, Feb 25, 2019 at 11:22 PM rajesh kumar rajeshkrarora1@gmail.com wrote:

Dear @viveksanagari https://github.com/viveksanagari, you try adjusting the mic sensitivity by going into alsmixer and after selecting your (f6) mic press (f5) to go into the soft-volume control and reduce the mic input to around 30 and see if that resolves ur problem

On Mon, Feb 25, 2019 at 10:50 PM vmiovneik notifications@github.com wrote:

@viveksanagari https://github.com/viveksanagari after lots of trial and error I came to the conclusion it was something wrong with picam and it's attempt to sync the audio and video. I actually ditched picam altogether and built something similar myself using python https://github.com/kpolley/Python_AVrecorder

Some of the code is is specific to my hardware, but give it a try and I hope it works out! Feel free to post any issues you face on the repo.

Hi @kpolley https://github.com/kpolley Thank you for responding and directing to your python solution. I will definitely try it to see how it works for my purpose.

Alongside, I have tried to record some video and audio using 'raspivid' and 'arecord' command line tools by using the below command,

raspivid -t 10000 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 -o video.h264 & arecord --device=hw:1,0 --format S16_LE --duration=10 --rate 44100 -c1 test.wav &

The audio noise/disturbance lived even while recording from the command line tools, as it was while recording the video from 'Picam'. So, do you think in my case could there be any other possible reason for this disturbance in audio? For example, the signals from 4g dongle? the power supply? the raspberry pi? the mic? capture card?

Kindly point out if you (or anyone) have some possible reasons for this, so I can test it for solution. Thanks for your help in advance.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iizukanao/picam/issues/115#issuecomment-467098270, or mute the thread https://github.com/notifications/unsubscribe-auth/Ako7-oMgK8r3E4mI3wuMot9a2Pv17-p4ks5vRBtFgaJpZM4YX0W7 .

rajeshkrarora1 commented 5 years ago

it is alsamixer, not alsmixer sorry for the spelling mistake

On Mon, Feb 25, 2019 at 11:27 PM rajesh kumar rajeshkrarora1@gmail.com wrote:

dear @viveksanagari https://github.com/viveksanagari, A closed room can also make sound bounce back and create a buzzing sound or create an echo, check ur room acoustics

On Mon, Feb 25, 2019 at 11:22 PM rajesh kumar rajeshkrarora1@gmail.com wrote:

Dear @viveksanagari https://github.com/viveksanagari, you try adjusting the mic sensitivity by going into alsmixer and after selecting your (f6) mic press (f5) to go into the soft-volume control and reduce the mic input to around 30 and see if that resolves ur problem

On Mon, Feb 25, 2019 at 10:50 PM vmiovneik notifications@github.com wrote:

@viveksanagari https://github.com/viveksanagari after lots of trial and error I came to the conclusion it was something wrong with picam and it's attempt to sync the audio and video. I actually ditched picam altogether and built something similar myself using python https://github.com/kpolley/Python_AVrecorder

Some of the code is is specific to my hardware, but give it a try and I hope it works out! Feel free to post any issues you face on the repo.

Hi @kpolley https://github.com/kpolley Thank you for responding and directing to your python solution. I will definitely try it to see how it works for my purpose.

Alongside, I have tried to record some video and audio using 'raspivid' and 'arecord' command line tools by using the below command,

raspivid -t 10000 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 -o video.h264 & arecord --device=hw:1,0 --format S16_LE --duration=10 --rate 44100 -c1 test.wav &

The audio noise/disturbance lived even while recording from the command line tools, as it was while recording the video from 'Picam'. So, do you think in my case could there be any other possible reason for this disturbance in audio? For example, the signals from 4g dongle? the power supply? the raspberry pi? the mic? capture card?

Kindly point out if you (or anyone) have some possible reasons for this, so I can test it for solution. Thanks for your help in advance.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iizukanao/picam/issues/115#issuecomment-467098270, or mute the thread https://github.com/notifications/unsubscribe-auth/Ako7-oMgK8r3E4mI3wuMot9a2Pv17-p4ks5vRBtFgaJpZM4YX0W7 .

viveksanagari commented 5 years ago

Hi @rajeshkrarora1

I have adjusted the mic volume from alsamixer. Before adjusting the mic it was, screenshot from 2019-02-26 13-24-07

After adjusting the mic it is, screenshot from 2019-02-26 13-33-44

The noise was still there, only the voice signals were heard low.

I have tried to leave a room (not closed) with raspberry and mic with no other voice (except the voice of fan for laptop, however, it is very low). But still, the noise is alive.

I also tried to switch my raspberry pi 2 with a raspberry pi 3 (model B+) unfortunately it also didn't make any difference.

Do we have any other suggestions, please.

samcormack commented 5 years ago

If any one else comes across this issue, I've found a solution that's working for me so far. I'm assuming the i2s microphone is set up as shown here: https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-and-test#adding-volume-control-5-66. That is, there is a ~/.asoundrc (or /etc/asound.conf) file with contents:

#This section makes a reference to your I2S hardware, adjust the card name
# to what is shown in arecord -l after card x: before the name in []
#You may have to adjust channel count also but stick with default first
pcm.dmic_hw {
    type hw
    card sndrpisimplecar
    channels 2
    format S32_LE
}

#This is the software volume control, it links to the hardware above and after
# saving the .asoundrc file you can type alsamixer, press F6 to select
# your I2S mic then F4 to set the recording volume and arrow up and down
# to adjust the volume
# After adjusting the volume - go for 50 percent at first, you can do
# something like 
# arecord -D dmic_sv -c2 -r 48000 -f S32_LE -t wav -V mono -v myfile.wav
pcm.dmic_sv {
    type softvol
    slave.pcm dmic_hw
    control {
        name "Boost Capture Volume"
        card sndrpisimplecar
    }
    min_dB -3.0
    max_dB 30.0
}

The issue seems to be with the software volume control in alsa (or at least the way it interacts with picam). If I run the command picam --alsadev plug:dmic_sv as in the original issue, I get a loud buzzing noise after 10-15 seconds. However, running the command

picam --alsadev plug:dmic_hw

works with no buzzing for as long as I've tried it so far. To increase the volume, I just use the picam volume option: picam --alsadev plug:dmic_hw --volume 4 which also works without issue.

Note that simply using hw:1,0 for the alsa device doesn't work and you will get no sound. The configuration in pcm.dmic_hw is required for picam to use it (see #86).

rajeshkrarora1 commented 4 years ago

Dear @samcormack , Sorry i read your suggestion today, and tried it with my setup, it is working wonderfully well, Thanks for sharing it.