Foros - Stratos

Programadores => Programación de audio => Mensaje iniciado por: gazpachu en 05 de Febrero de 2004, 01:32:04 PM

Título: Streaming Con Direct Sound
Publicado por: gazpachu en 05 de Febrero de 2004, 01:32:04 PM
 Problema:

Tengo una aplicación que lanza dos streams de sonido. Por separado se oyen bien y los threads hacen bien su trabajo. El problema es a la hora de mezclar los streams.... Los threads siguen haciendo bien su trabajo, lo que me lleva a pensar que tiene que ser algún problema con el Buffer Primario.

Los streams son buffers secundarios. Actualmente cada vez que creo un stream, lo hago con el siguiente codigo:

// Calculate the Notify Size for the Streaming
nBlockAlign = ( DWORD )m_pWaveFile->m_pwfx->nBlockAlign;
nSamplesPerSec = m_pWaveFile->m_pwfx->nSamplesPerSec;
m_dwNotifySize = nSamplesPerSec * 3 * nBlockAlign / NUM_PLAY_NOTIFICATIONS;
m_dwNotifySize -= m_dwNotifySize % nBlockAlign;

   // Figure out how big the DSound buffer should be
   m_dwDSBufferSize = m_dwNotifySize * NUM_PLAY_NOTIFICATIONS;

   // Set up the direct sound buffer.  Request the NOTIFY flag, so
   // that we are notified as the sound buffer plays.  Note, that using this flag
   // may limit the amount of hardware acceleration that can occur.
   DSBUFFERDESC dsbd;
ZeroMemory( &dsbd, sizeof( DSBUFFERDESC ) );

   dsbd.dwSize          = sizeof( DSBUFFERDESC );
   dsbd.dwFlags         = m_dwCreationFlags;
   dsbd.dwBufferBytes   = m_dwDSBufferSize;
   dsbd.lpwfxFormat     = m_pWaveFile->m_pwfx;

// Check Primary Buffer Capabilities
/*LPDSBCAPS DSBCaps;
ZeroMemory( &DSBCaps, sizeof( LPDSBCAPS ) );
m_pDSPrimary->GetCaps( DSBCaps );

if( DSBCaps->dwBufferBytes < dsbd.dwBufferBytes )
{*/
 //  Since the Primary Buffer is already created by the Plugin definition,
 // we don't need to create it again. Only if is smaller.
 if( FAILED ( hr = m_pDS->CreateSoundBuffer( &dsbd, &m_pDSPrimary, NULL ) ) )
 {
  return hr;
 }
// }

if( FAILED( hr = m_pDSPrimary->QueryInterface( IID_IDirectSoundBuffer8, ( LPVOID* )&m_pDS8Buffer ) ) )
{
 return hr;
}


Osea, que cada vez que creo un buffer secundario, se crea un buffer primario con las especificaciones de tamaño del buffer secundario-.----
Cuando se oyen los streams a la vez, hay problemas para mezclar el sonido, se oyen chasquidos, los streams saltan....

En fin,... sé que tiene que ser problema de como inicializo el buffer primario...

Si alguien tiene alguna idea... se lo agradecería---

Graciass!!!