Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
99231e55
Commit
99231e55
authored
Jan 12, 2006
by
jpbl
Browse files
added example03.cpp
parent
8176fc49
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/audio/OpenAL/Makefile.am
View file @
99231e55
if
MAINTENER_CODE
noinst_PROGRAMS
=
example01 example02
noinst_PROGRAMS
=
example01 example02
example03
noinst_LTLIBRARIES
=
libsflaudio.la
libsflaudio_la_SOURCES
=
\
...
...
@@ -29,5 +29,6 @@ LDADD = libsflaudio.la $(PORTAUDIO_LIBS) -lopenal -lportaudio
example01_SOURCES
=
example01.cpp
example02_SOURCES
=
example02.cpp
example03_SOURCES
=
example03.cpp
endif
src/audio/OpenAL/NullSource.hpp
View file @
99231e55
...
...
@@ -33,6 +33,7 @@ namespace SFLAudio
virtual
bool
isNull
()
{
return
true
;};
virtual
bool
isPlaying
();
virtual
void
play
(
void
*
data
,
int
size
);
virtual
void
stop
();
};
}
...
...
src/audio/OpenAL/OpenALSource.cpp
View file @
99231e55
...
...
@@ -170,6 +170,8 @@ SFLAudio::OpenALSource::play(void *data, int size)
{
ALboolean
loop
;
alGetError
();
// Copy test.wav data into AL Buffer 0
alBufferData
(
mBuffer
,
getFormat
(),
data
,
size
,
getFrequency
());
ALenum
error
=
alGetError
();
...
...
@@ -179,3 +181,9 @@ SFLAudio::OpenALSource::play(void *data, int size)
alSourcePlay
(
mSource
);
}
void
SFLAudio
::
OpenALSource
::
stop
()
{
alSourceStop
(
mSource
);
}
src/audio/OpenAL/OpenALSource.hpp
View file @
99231e55
...
...
@@ -42,6 +42,7 @@ namespace SFLAudio
// Source functions
virtual
bool
isPlaying
();
virtual
void
play
(
void
*
data
,
int
size
);
virtual
void
stop
();
private:
static
bool
genBuffer
(
ALuint
&
buffer
);
...
...
src/audio/OpenAL/README.txt
View file @
99231e55
example01.cpp: This is an enumeration of device example.
\ No newline at end of file
example01.cpp: This is an enumeration of device example.
example02.cpp: A simple WAV player.
example03.cpp: A simple WAV player, with 2 files playing at the same time.
\ No newline at end of file
src/audio/OpenAL/Source.hpp
View file @
99231e55
...
...
@@ -34,6 +34,7 @@ namespace SFLAudio
virtual
bool
isNull
()
{
return
false
;}
virtual
bool
isPlaying
()
=
0
;
virtual
void
play
(
void
*
data
,
int
size
)
=
0
;
virtual
void
stop
()
=
0
;
int
getFrequency
()
{
return
mFreq
;}
int
getFormat
()
{
return
mFormat
;}
...
...
src/audio/OpenAL/example02.cpp
View file @
99231e55
...
...
@@ -39,12 +39,8 @@ int main(int, char* [])
ALboolean
loop
;
AudioLayer
*
layer
=
SFLAudio
::
AudioManager
::
instance
().
currentLayer
();
std
::
cout
<<
"Layer: "
<<
layer
->
getName
()
<<
std
::
endl
;
Device
*
device
=
layer
->
openDevice
();
std
::
cout
<<
" Device: "
<<
device
->
getName
()
<<
std
::
endl
;
Context
*
context
=
device
->
createContext
();
std
::
cout
<<
" Context is null: "
<<
(
context
->
isNull
()
?
"true"
:
"false"
)
<<
std
::
endl
;
// Load test.wav
alutLoadWAVFile
(
"test.wav"
,
&
format
,
&
data
,
&
size
,
&
freq
,
&
loop
);
...
...
@@ -55,17 +51,16 @@ int main(int, char* [])
}
Source
*
source
=
context
->
createSource
(
format
,
freq
);
std
::
cout
<<
" Source is null: "
<<
(
source
->
isNull
()
?
"true"
:
"false"
)
<<
std
::
endl
;
source
->
play
(
data
,
size
);
std
::
cout
<<
"Unloading test.wav"
<<
std
::
endl
;
// Unload test.wav
alutUnloadWAV
(
format
,
data
,
size
,
freq
);
std
::
cin
.
get
();
error
=
alGetError
();
if
(
error
!=
AL_NO_ERROR
)
{
std
::
cerr
<<
"OpenAL: unloadWAV : "
<<
alGetString
(
error
);
}
std
::
cin
.
get
();
}
src/audio/OpenAL/example03.cpp
0 → 100644
View file @
99231e55
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include
<iostream>
#include
<list>
#include
<string>
#include
<AL/al.h>
#include
<AL/alc.h>
#include
<AL/alut.h>
#include
"SFLAudio.hpp"
using
namespace
SFLAudio
;
int
main
(
int
,
char
*
[])
{
ALenum
format1
;
ALvoid
*
data1
;
ALsizei
size1
;
ALsizei
freq1
;
ALboolean
loop1
;
ALenum
format2
;
ALvoid
*
data2
;
ALsizei
size2
;
ALsizei
freq2
;
ALboolean
loop2
;
AudioLayer
*
layer
=
SFLAudio
::
AudioManager
::
instance
().
currentLayer
();
Device
*
device
=
layer
->
openDevice
();
Context
*
context
=
device
->
createContext
();
// Load test.wav
alutLoadWAVFile
(
"test.wav"
,
&
format1
,
&
data1
,
&
size1
,
&
freq1
,
&
loop1
);
ALenum
error
=
alGetError
();
if
(
error
!=
AL_NO_ERROR
)
{
std
::
cerr
<<
"OpenAL: loadWAVFile : "
<<
alGetString
(
error
);
return
1
;
}
// Load test2.wav
alutLoadWAVFile
(
"test2.wav"
,
&
format2
,
&
data2
,
&
size2
,
&
freq2
,
&
loop2
);
error
=
alGetError
();
if
(
error
!=
AL_NO_ERROR
)
{
std
::
cerr
<<
"OpenAL: loadWAVFile : "
<<
alGetString
(
error
);
return
1
;
}
Source
*
source1
=
context
->
createSource
(
format1
,
freq1
);
source1
->
play
(
data1
,
size1
);
Source
*
source2
=
context
->
createSource
(
format2
,
freq2
);
source2
->
play
(
data2
,
size2
);
// Unload test.wav and test2.wav
alutUnloadWAV
(
format1
,
data1
,
size1
,
freq1
);
alutUnloadWAV
(
format2
,
data2
,
size2
,
freq2
);
std
::
cin
.
get
();
error
=
alGetError
();
if
(
error
!=
AL_NO_ERROR
)
{
std
::
cerr
<<
"OpenAL: unloadWAV : "
<<
alGetString
(
error
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment