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!