I guess, if you want interactive spatial sound (3D) osgAL is the
preferred choice as xinelib and quicktime cant do that. That is to have
the sound following the movie node in space.

If you on other hand need codecs to do Dolby Digital etc. then osgAL
(openal) is not the right choice.

/Anders

________________________________________________________________
 Anders Backman               Email:    [EMAIL PROTECTED]
 HPC2N/VRlab                  Phone:    +46 (0)90-786 9936
 Umea university              Cellular: +46 (0)70-392 64 67
 S-901 87 UMEA SWEDEN         Fax:      +46 90-786 6126
                               http://www.cs.umu.se/~andersb
 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Robert Osfield
> Sent: den 14 juli 2006 10:53
> To: osg users
> Subject: Re: [osg-users] Playing sound in movies (win32)
> 
> 
> Hi Marta,
> 
> I'm not yet familiar with osgAL so I'll defer to others on 
> how best to do it.  Also osgAL isn't part of the core OSG so 
> I can't merge anything that is based on it yet, the wiki is a 
> good place to post such code though.
> 
> The xine-lib and quicktime plugin do there own sound support 
> without the need for osgAL, does the AVI library you are 
> using not support this as well?
> 
> Robert.
> 
> On 7/14/06, Marta Pla i Castells <[EMAIL PROTECTED]> wrote:
> >
> > Hi all,
> >
> > I've been playing with the code of Mikkel Gjøl (osgAVI ) 
> and finally 
> > I've been able to play sound in my osgmovie application 
> extracting the 
> > sound buffer to an openalpp sample and the creating a soundState of 
> > osgAL. The only fact is that my code isn't as clean as I wanted. :( 
> > The good new is that it WORKS!!!
> >
> > I insert my new code here. If Robert, or someone who knows the good 
> > way to modify the code, wants to add it to the osg code I 
> will be very 
> > pleased.
> >
> > Thank you very much to Mikkel and Tao for their help
> >
> > /*****************************************************/
> >
> >
> > void AviImageStream::OpenAVI( LPCSTR in_filename ) {
> > // note: opens an avi-file
> > // note: allocates data here, before thread is started!
> > //       (thus in a thread with a gl-context)
> >
> >         AVIFileInit(); // Opens The AVIFile Library
> >
> >         // Opens The AVI Stream
> >         if( AVIStreamOpenFromFile( &m_pavi, in_filename, 
> treamtypeVIDEO,
> >                                  0, OF_READ, NULL)) {
> >                 std::string err( "Failed to open the AVI-file: " +
> >                                         std::string(in_filename));
> >                 MessageBox( HWND_DESKTOP, err.c_str(), 
> "Error", MB_OK |
> >                                 MB_ICONEXCLAMATION );
> >                 exit(-1);
> >         }
> >
> >         AVIStreamInfo( m_pavi, &m_psi, sizeof(m_psi) );
> >
> >         if( AVIStreamOpenFromFile( &m_pavi_sound, in_filename,
> >                                 streamtypeAUDIO, 0, 
> OF_READ, NULL)) {
> >                 std::string err( "Failed to open the AVI-file: " +
> >                                         std::string(in_filename));
> >                 MessageBox( HWND_DESKTOP, err.c_str(), 
> "Error", MB_OK |
> >                                 MB_ICONEXCLAMATION );
> >                 exit(-1);
> >         }
> >
> >         AVIStreamInfo( m_pavi_sound, &m_psi_sound, 
> > sizeof(m_psi_sound));
> >
> >         long lSize;
> >         AVIStreamRead(m_pavi_sound, 0, 
> AVISTREAMREAD_CONVENIENT, NULL,
> >                         0, &lSize, NULL);
> >
> >         LPBYTE pChunk = new BYTE[lSize];
> >
> >         AVIStreamReadFormat(m_pavi_sound, 0, pChunk, &lSize);
> >
> >         LPWAVEFORMATEX pWaveFormat = (LPWAVEFORMATEX)pChunk;
> >         long m_length = AVIStreamLength(m_pavi_sound); //Member int
> >
> >         if(pWaveFormat->wFormatTag!=1)
> >                 puts("Esta comprimido");
> >
> >         LPBYTE m_lpAudioBuffer = new BYTE[m_length*4];
> >
> >         // Get the full stream
> >         for(int i=0; i<m_length; i++)
> >                 AVIStreamRead(m_pavi_sound, i, 
> AVISTREAMREAD_CONVENIENT,
> >                          &m_lpAudioBuffer[i*4], lSize, NULL, NULL);
> >
> >
> >         openalpp::ref_ptr<openalpp::Sample> sample = new
> >                         openalpp::Sample(AL_FORMAT_STEREO16,
> >                         m_lpAudioBuffer, m_length*4,
> >                         pWaveFormat->nSamplesPerSec);
> >
> >         sound_state = new osgAL::SoundState("video");
> >         sound_state->setSample(sample);
> >         sound_state->setGain(1.0f);
> >         sound_state->setPitch(1);
> >
> >         sound_state->setPlay(false);
> >         sound_state->setLooping(true);
> >
> >         sound_state->allocateSource(10, false);
> >
> >      
> > osgAL::SoundManager::instance()->addSoundState(sound_state.get());
> >
> >         sound_state->apply();
> >
> >         m_width  = m_psi.rcFrame.right - 
> m_psi.rcFrame.left;                            // Width Is
> > Right Side Of Frame Minus Left
> >         m_height = m_psi.rcFrame.bottom - 
> m_psi.rcFrame.top;                            // Height Is
> > Bottom Of Frame Minus Top
> >
> >         m_lastframe = AVIStreamLength( m_pavi );            
>                                             // The Last Frame Of The
> > Stream
> >         m_mpf = AVIStreamSampleToTime( m_pavi, m_lastframe ) / 
> > m_lastframe;
> >
> >         m_pgf = AVIStreamGetFrameOpen(m_pavi, NULL);
> >         if( !m_pgf) {
> >                 MessageBox( HWND_DESKTOP, "Failed To Open The AVI
> >                 Frame", "Error", MB_OK | MB_ICONEXCLAMATION );
> >                 exit(-1);
> >         }
> >
> >         osg::ImageStream::setImage( m_width, m_height, 1,
> > internal_format,                                            
>                     pixelformat, type,
> >                                 0,osg::Image::NO_DELETE,
> >                                 packing );
> >
> >         return;
> > }
> >
> >
> > /*****************************************************/
> >
> >
> > _______________________________________________
> > osg-users mailing list
> > osg-users@openscenegraph.net 
> > http://openscenegraph.net/mailman/listinfo/osg-users
> > http://www.openscenegraph.org/
> >
> >
> >
> _______________________________________________
> osg-users mailing list
> osg-users@openscenegraph.net 
> http://openscenegraph.net/mailman/listinfo/osg> -users
> 
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to