title: How to get left output using pyAudio
body: <p>Suppose I have a song, which plays on both of the speakers on my headphones. I want to write a code using pyAudio, so that I get output on only on speaker. Like those <a href="https://www.youtube.com/watch?v=e8ODm-F9-IM" rel="nofollow noreferrer">videos</a> demonstrating left-right check.</p>
  
  <p>I went through <a href="https://stackoverflow.com/questions/30071822/pyaudio-how-to-get-sound-on-only-one-speaker">this</a> question, but I don't think this solves my problem. Also, since I am a new member, I cannot comment on it, for further clarification.</p>
  
  <p>I tried to implement a solution from the above linked question, but it wasn't giving me correct answers. Here is the implementation.</p>
  
  <pre><code>from struct import pack
  from math import sin, pi
  import wave
  import random
  
  RATE=44100
  
  ## GENERATE MONO FILE ##
  wv = wave.open('music.wav', 'w')
  wv.setparams((1, 2, RATE, 0, 'NONE', 'not compressed'))
  maxVol=2**15-1.0 #maximum amplitude
  wvData=bytes()
  
  for i in range(0, RATE*3):
      # print(type(pack('h', int(maxVol*sin(i*500/RATE)))))
      wvData+=pack('h', int(maxVol*sin(i*500.0/RATE))) #500Hz
  
  wv.writeframes(wvData)
  wv.close()
  </code></pre>
  
  <p>I got a 3 second clip containing noise as the output, which is not expected. The actual output should only play the audio on one channel only, either be left or right.</p>