1

I am working on the process in denoise in a NAO robot for a sound localization. I call the "setClientPreferences" module with 48000kHz sample rate in all channels (interleave) for recording:

    channelFlag = 0
    deinterleave = 0  # deinterleave = 1
    sampleRate = 48000
    audio.setClientPreferences(self.getName(),sampleRate,channelFlag,deinterleave)

and obtain the buffer data by this function:

    def processRemote(self,numChannels,samplesPerChannel,timeStamp,buffer):
        print "channels=",numChannels," samples=",samplesPerChannel
        soundDataInterleaved = np.fromstring(str(buffer),dtype=np.int16)
        self.soundData = np.reshape(soundDataInterleaved,(numChannels,samplesPerChannel),'F')

The problem comes when I try to recover the data into wav file in the same sample rate (48000) by python/matlab for testing, the result plays faster than what I have recorded, but sounds more regular when it is set to be half of the sample rate (24000). The same problem exists when I set the rate to 16000kHz at first.

How can I solve this problem? It is really important as I need the accurate sample rate to apply spectrum cubtraction. Also I am confused about the sample numbers for a single channel, which also described in here.

Thankyou!

  • Your code seems ok. What I think is when you write the wav file and more specifically its header. You won't enter the good information, like bytepersec or number of channel. – Alexandre Mazel Jul 20 '18 at 10:03
  • Thanks for your reply, I think my header is matched. I have checked the buffer data agian and found that there are periodic 'blanks' among the buffers therefore they are not continous actually and this is the reason why I cannot write it correct since I consider them as continuous. – Xiangpeng Kong Jul 21 '18 at 11:00
  • two solutions: one microphone is not outputting (disconnected...) but it means also your delinterlacing is not correct. good luck! – Alexandre Mazel Jul 23 '18 at 09:20

0 Answers0