title: Bass lib use to decode mono mp3
body: <p>I use the bass lib (Un4seen) to decode audio. Everything works well, but now I have a mp3 with mono channel and the final output bas create is player double time speed. May something have to be wrong.</p>
  <p>I use currently:</p>
  <pre><code>    bool CDecoder::Init(size_t nBlockSize)
      {
          assert(nBlockSize &gt; 0);
          
          m_pEmptySemaphore-&gt;AddWaiter(&amp;m_cWaiter);
          m_pFullSemaphore-&gt;AddWaiter(&amp;m_cWaiter);
          m_pFinishEvent-&gt;AddWaiter(&amp;m_cWaiter);
          m_pStopEvent-&gt;AddWaiter(&amp;m_cWaiter);
          m_pTrackFinishEvent-&gt;AddWaiter(&amp;m_cWaiter);
          
          
          m_bNoBuf = true;
          m_CurBufBytes = 0;
          m_nWrite = 0;
          m_nRead = 0;
          m_nBufSize = nBlockSize;
          m_pBufferPercent = 0;
  
          if (g_BassHandle)
          {
              _BASS_ChannelStop(g_BassHandle);
              _BASS_StreamFree(g_BassHandle);
              g_BassHandle = 0;
          }
          
  
          if (!_BASS_Init(-1, 44100, BASS_DEVICE_STEREO , NULL, NULL)) {
              if (_BASS_ErrorGetCode() != BASS_ERROR_ALREADY) {
                  return false;
              }
          }
  
        
  
  
  #ifdef WIN32
  #ifdef _UNICODE     
          g_BassHandle = _BASS_StreamCreateFile(false, (const WCHAR*)m_strFileName, 0, 0, BASS_STREAM_DECODE | BASS_UNICODE);
  #else
          g_BassHandle = _BASS_StreamCreateFile(false, (const char*)m_strFileName, 0, 0, BASS_STREAM_DECODE);
  #endif
  #else
          g_BassHandle = _BASS_StreamCreateFile(false, m_strFileName.GetAsUtf8(), 0, 0, BASS_STREAM_DECODE);
  #endif
          
  
          
          try
          {
              //m_BuffLens interessiert mich nicht.
              m_nBuffLens = new size_t[BUFNUM];
              memset(m_nBuffLens, 0, sizeof(size_t)*BUFNUM);
              m_pBuffer = new BYTE[BUFNUM*m_nBufSize];
          }
          catch(...)
          {
              Deinit();
              return false;
          }
          
          return true;
      }
      
  #ifdef WIN32
      BOOL PeekAndPump2()
      {
          MSG msg;
          while (::PeekMessage (&amp;msg, NULL, 0, 0, PM_NOREMOVE))
          {
              ::TranslateMessage(&amp;msg);
              ::DispatchMessage(&amp;msg);
          }
          
          return TRUE;
      }
  #endif
  
  //decode:
  bool CDecoder::DecodeFrame(BYTE *pcmdata, size_t nSize, size_t &amp;nRealSize)
      {
          std::vector&lt;KEvent *&gt; vWaitObjects(1);
          //vWaitObjects[0] = m_pFullSemaphore;
          vWaitObjects[0] = m_pFinishEvent;
          
          //Hier hängt er, er wartet auf etwas.
          
  #ifdef WIN32
          PeekAndPump2();
  #endif
          
         
              //get a buffer
              //
              /*
              if (nSize &gt; m_nBuffLens[m_nRead])
                  nSize = m_nBuffLens[m_nRead];
               */
              
              //BYTE* pBuf;
              //RETURN VALUE IST BYTES WRITTEN ZUM BUFFER
              //AM Ende sind die Bytes die gebraucht werden.
          
              //Das Handle ist auf einmal weg
          
              int pos=_BASS_ChannelGetPosition(g_BassHandle,BASS_POS_BYTE);
          
              DWORD result = _BASS_ChannelIsActive(g_BassHandle);
              if(result==BASS_ACTIVE_STOPPED){
                  return false;
              }
              int cSize = _BASS_ChannelGetData(g_BassHandle,m_pBuffer,nSize/*BUFNUM*m_nBufSize   20000*/);
              
              //BYTE* pBuf = m_pBuffer + m_nBufSize * m_nRead;
          
              if(cSize!=-1){
                  memcpy(pcmdata, m_pBuffer, cSize);
                  nRealSize = cSize;
                  return true;
              }
              return false;
              
              //m_pFullSemaphore-&gt;Increase(1);
              
              /*
              if (nSize == m_nBuffLens[m_nRead])
              {
                  m_nRead = (m_nRead + 1) % BUFNUM;
                  m_pEmptySemaphore-&gt;Increase(1);
              }
              else
              {
                  m_nBuffLens[m_nRead] -= nSize;
                  
                  memcpy(pBuf, m_pBuffer + cSize, m_nBuffLens[m_nRead]);
                  m_pFullSemaphore-&gt;Increase(1);
              }
               */
      }
  </code></pre>
  <p>After I added <code>BASS_SAMPLE_FLOAT</code> the final audio is good in speed but the audio has &quot;swoosh&quot; signals inside the stream. If I use a stereo (2 channel) audio it works well, just on mono stream it fails.
  Anything I have missed in case of mono files? I expected that with</p>
  <pre><code>_BASS_Init(-1, 44100, BASS_DEVICE_STEREO , NULL, NULL)
  </code></pre>
  <p>the output is always 44.1 and Stereo.</p>