[Bf-committers] Sound stuff

Brecht Van Lommel brecht at blender.org
Thu Jul 9 14:59:02 CEST 2009


Hi,

Tested on Mac OS X. Only change needed was replacing <malloc.h> by
<stdlib.h>, I think that works on all OSes. For linking I needed to add
libavutil and libz (this was with FFMPEG set to use the one compiled
with Blender in the extern/ directory). Sound playback seems to work.

Brecht.

On Sun, 2009-07-05 at 00:47 +0200, neXyon wrote:
> Hi all,
> 
> idesisNery (IRC nick) is as kind as to test my library under windows 
> with VC++, the problem is that this doesn't support memalign, so I had 
> to rewrite that in SND_Buffer.cpp, which is attached.
> 
> @idesisNery: Please write a mail if everything works now! Thanks a lot 
> for testing!
> 
> Good night!
> 
> > I've done a small, quick update to the file: I added a SConstruct file.
> >
> > I'm quite sure the application won't built under Windows or MacOS 
> > without adjustment in SConstruct or CMakeLists.txt, but I'd really 
> > appreciate it if someone could test it on these plattforms.
> >
> > http://download.blender.org/ftp/incoming/SoundSpace_scons.tar.gz
> >
> > Regards,
> > Jörg
> > _______________________________________________
> > Bf-committers mailing list
> > Bf-committers at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-committers
> >   
> 
> plain text document attachment (SND_Buffer.cpp)
> /*
>  * $Id$
>  *
>  * ***** BEGIN LGPL LICENSE BLOCK *****
>  *
>  * Copyright 2009 Jörg Hermann Müller
>  *
>  * This file is part of SoundSpace.
>  *
>  * SoundSpace is free software: you can redistribute it and/or modify
>  * it under the terms of the GNU Lesser General Public License as published by
>  * the Free Software Foundation, either version 3 of the License, or
>  * (at your option) any later version.
>  *
>  * SoundSpace is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU Lesser General Public License for more details.
>  *
>  * You should have received a copy of the GNU Lesser General Public License
>  * along with SoundSpace.  If not, see <http://www.gnu.org/licenses/>.
>  *
>  * ***** END LGPL LICENSE BLOCK *****
>  */
> 
> #include "SND_Buffer.h"
> #include "SND_Space.h"
> 
> #include <cstring>
> #include <malloc.h>
> 
> #define SND_ALIGN(a) (a + 16 - ((long)a & 15))
> 
> SND_Buffer::SND_Buffer(int size)
> {
> 	m_size = size;
> 	m_buffer = (unsigned char*) malloc(size+15);
> }
> 
> SND_Buffer::~SND_Buffer()
> {
> 	free(m_buffer);
> }
> 
> unsigned char* SND_Buffer::getBuffer()
> {
> 	return SND_ALIGN(m_buffer);
> }
> 
> int SND_Buffer::getSize()
> {
> 	return m_size;
> }
> 
> void SND_Buffer::resize(int size, bool keep)
> {
> 	unsigned char* buffer = (unsigned char*) malloc(size+15);
> 
> 	// copy old data over if wanted
> 	if(keep)
> 		memcpy(SND_ALIGN(buffer), SND_ALIGN(m_buffer), SND_MIN(size, m_size));
> 
> 	free(m_buffer);
> 
> 	m_buffer = buffer;
> 	m_size = size;
> }
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers



More information about the Bf-committers mailing list