python - Pyaudio sound has some clicks when I try to balance the stereo -


i trying balance stereo on live stream using pyaudio when hear clicks! here's code:

channels = 2 rate = 44100 class sound(object):     def __init__(self,balloon):         self.t = time()         self.freq  = self.get_freq()         self.phase = 0         self.p = pyaudio.pyaudio()              self.stream = self.p.open(format=pyaudio.pafloat32,                 channels=channels,                 rate=rate,                 output=true,                 stream_callback=self.callback)         self.stream.start_stream()      def callback(self,in_data, frame_count, time_info, status):         bal = self.get_balance() #number between 1 , 0         right = (np.sin(self.phase+2*np.pi*self.freq*(self.t+np.arange(frame_count)/float(rate))))         data = np.zeros((right.shape[0]*2,),np.float32)         data[::2] = bal*right #right speaker         data[1::2] = (1-bal)*right #left speaker         self.t+=frame_count/float(rate)         return (data, pyaudio.pacontinue) 

in callback function if remove balance:

data[::2] = right #right speaker data[1::2] = right #left speaker 

the clicks disappear!


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -