forked from teamnwah/openmw-tes3coop
First attempt at OpenAL (thanks to ChrisRobinson)
git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@20 ea6a568a-9f4f-0410-981a-c910a81bb256actorid
parent
fa6f5b81ae
commit
6988814728
@ -1,9 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# See INSTALL-linux.txt for instructions
|
||||
# See COMPILE-linux.txt for instructions
|
||||
|
||||
make || exit 1
|
||||
|
||||
gdc -Wall -Wextra -O2 -g -fversion=Posix -o openmw openmw.d core/*.d ogre/*.d nif/*.d util/*.d bsa/*.d monster/util/*.d input/*.d sound/*.d scene/*.d esm/*.d cpp_*.o -laudiere -lm -lOgreMain -lOIS -lstdc++
|
||||
gdc -Wall -g -fversion=Posix -o openmw openmw.d core/*.d ogre/*.d nif/*.d util/*.d bsa/*.d monster/util/*.d input/*.d sound/*.d scene/*.d esm/*.d cpp_ogre.o -lalut -lopenal -lm -lOgreMain -lOIS -lstdc++
|
||||
|
||||
gdc -Wall -Wextra -O2 -g -fversion=Posix -o esmtool esmtool.d core/*.d ogre/*.d nif/*.d util/*.d bsa/*.d monster/util/*.d input/*.d sound/*.d scene/*.d esm/*.d cpp_*.o -laudiere -lm -lOgreMain -lOIS -lstdc++
|
||||
gdc -Wall -g -fversion=Posix -o esmtool esmtool.d core/*.d ogre/*.d nif/*.d util/*.d bsa/*.d monster/util/*.d input/*.d sound/*.d scene/*.d esm/*.d cpp_ogre.o -lalut -lopenal -lm -lOgreMain -lOIS -lstdc++
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
OpenMW - The completely unofficial reimplementation of Morrowind
|
||||
Copyright (C) 2008 Nicolay Korslund
|
||||
Email: < korslund@gmail.com >
|
||||
WWW: http://openmw.snaptoad.com/
|
||||
|
||||
This file (audiere.d) is part of the OpenMW package.
|
||||
|
||||
OpenMW is distributed as free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
version 3, as published by the Free Software Foundation.
|
||||
|
||||
This program 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
version 3 along with this program. If not, see
|
||||
http://www.gnu.org/licenses/ .
|
||||
|
||||
*/
|
||||
|
||||
// This file exposes the C++ functions that deal directly with the
|
||||
// sound library. The functions are implemented in cpp_audiere.cpp
|
||||
|
||||
module sound.audiere;
|
||||
|
||||
// A sound resource is the handle that represents the resource,
|
||||
// ie. the file.
|
||||
typedef void* AudiereResource;
|
||||
|
||||
// A sound instance is an instance of this resource. We can have
|
||||
// several instances of the same file playing at once. Each instance
|
||||
// has its own volume, file position, pitch, etc.
|
||||
typedef void* AudiereInstance;
|
||||
|
||||
extern(C)
|
||||
{
|
||||
// Open the music device. Returns 0 on success, 1 on failure.
|
||||
int cpp_openDevice();
|
||||
|
||||
// Open a new sound resource. Returns null on failure.
|
||||
AudiereResource cpp_openSound(char* filename);
|
||||
|
||||
// Close a resource.
|
||||
void cpp_closeSound(AudiereResource sound);
|
||||
|
||||
// Create an instance of a sound.
|
||||
AudiereInstance cpp_createInstance(AudiereResource sound);
|
||||
|
||||
// Create an instance by streaming directly from file, and play it.
|
||||
AudiereInstance cpp_playStream(char* filename, float volume);
|
||||
|
||||
// Destroy a previously created instance
|
||||
void cpp_destroyInstance(AudiereInstance instance);
|
||||
|
||||
// Is this instance currently playing?
|
||||
int cpp_isPlaying(AudiereInstance sound);
|
||||
|
||||
// Adjust parameters for this instance.
|
||||
void cpp_setParams(AudiereInstance sound, float volume, float pan);
|
||||
|
||||
// Play a sound.
|
||||
void cpp_playSound(AudiereInstance sound);
|
||||
|
||||
// Set repeat mode on
|
||||
void cpp_setRepeat(AudiereInstance sound);
|
||||
|
||||
// Stop a sound
|
||||
void cpp_stopSound(AudiereInstance sound);
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
OpenMW - The completely unofficial reimplementation of Morrowind
|
||||
Copyright (C) 2008 Nicolay Korslund
|
||||
Email: < korslund@gmail.com >
|
||||
WWW: http://openmw.snaptoad.com/
|
||||
|
||||
This file (cpp_audiere.cpp) is part of the OpenMW package.
|
||||
|
||||
OpenMW is distributed as free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
version 3, as published by the Free Software Foundation.
|
||||
|
||||
This program 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
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
version 3 along with this program. If not, see
|
||||
http://www.gnu.org/licenses/ .
|
||||
|
||||
*/
|
||||
|
||||
#include <audiere.h>
|
||||
#include <iostream>
|
||||
using namespace audiere;
|
||||
using namespace std;
|
||||
|
||||
/*
|
||||
* Sound, using Audiere. Creates a very simple C interface for
|
||||
* opening, closing and manipulating sounds.
|
||||
*/
|
||||
|
||||
AudioDevicePtr device;
|
||||
|
||||
extern "C" int32_t cpp_openDevice()
|
||||
{
|
||||
device = OpenDevice("");
|
||||
if (!device) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Opens a new sample buffer from a file
|
||||
extern "C" SampleBuffer *cpp_openSound(char* filename)
|
||||
{
|
||||
SampleSourcePtr sample = OpenSampleSource(filename);
|
||||
if(!sample) return NULL;
|
||||
SampleBufferPtr buf = CreateSampleBuffer(sample);
|
||||
buf->ref();
|
||||
return buf.get();
|
||||
}
|
||||
|
||||
// Delete a sample buffer
|
||||
extern "C" void cpp_closeSound(SampleBuffer *buf)
|
||||
{
|
||||
buf->unref();
|
||||
}
|
||||
|
||||
// Get an output stream from a sample buffer.
|
||||
extern "C" OutputStream *cpp_createInstance(SampleBuffer *buf)
|
||||
{
|
||||
SampleSourcePtr sample = buf->openStream();
|
||||
if(!sample) return NULL;
|
||||
|
||||
OutputStreamPtr sound = OpenSound(device, sample, false);
|
||||
|
||||
sound->ref();
|
||||
return sound.get();
|
||||
}
|
||||
|
||||
// Stream a file directly. Used for music.
|
||||
extern "C" OutputStream *cpp_playStream(char* filename, float volume)
|
||||
{
|
||||
OutputStreamPtr sound = OpenSound(device, filename, true);
|
||||
if(sound)
|
||||
{
|
||||
sound->ref();
|
||||
sound->setVolume(volume);
|
||||
sound->play();
|
||||
}
|
||||
return sound.get();
|
||||
}
|
||||
|
||||
extern "C" void cpp_destroyInstance(OutputStream *sound)
|
||||
{
|
||||
sound->unref();
|
||||
}
|
||||
|
||||
extern "C" int32_t cpp_isPlaying(OutputStream *sound)
|
||||
{
|
||||
if(sound && sound->isPlaying()) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void cpp_setParams(OutputStream *sound, float vol, float pan)
|
||||
{
|
||||
if(sound)
|
||||
{
|
||||
sound->setVolume(vol);
|
||||
sound->setPan(pan);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void cpp_playSound(OutputStream *sound)
|
||||
{
|
||||
sound->play();
|
||||
}
|
||||
|
||||
extern "C" void cpp_setRepeat(OutputStream *sound)
|
||||
{
|
||||
sound->setRepeat(true);
|
||||
}
|
||||
|
||||
// Stop the sound
|
||||
extern "C" void cpp_stopSound(OutputStream *sound)
|
||||
{
|
||||
if(sound) sound->stop();
|
||||
}
|
Loading…
Reference in New Issue