-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathListener.cpp
More file actions
100 lines (80 loc) · 2.13 KB
/
Listener.cpp
File metadata and controls
100 lines (80 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
This file is part of the Sound library.
Copyright (C) 2008-2012 Benjamin Eikel <benjamin@eikel.org>
Copyright (C) 2008-2012 Claudius Jähn <claudius@uni-paderborn.de>
Copyright (C) 2008-2012 Ralf Petring <ralf@petring.net>
This library is subject to the terms of the Mozilla Public License, v. 2.0.
You should have received a copy of the MPL along with this library; see the
file LICENSE. If not, you can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "Listener.h"
#include "SoundInternals.h"
namespace Sound {
//! [static] singleton
Listener * Listener::getInstance() {
static auto instance(new Listener);
return instance;
}
//! [ctor]
Listener::Listener(){
//ctor
}
//! [dtor]
Listener::~Listener(){
//dtor
}
void Listener::setGain(float f){
alListenerf(AL_GAIN,f);
}
void Listener::setPosition(float x,float y,float z){
alListener3f( AL_POSITION,x,y,z);
}
void Listener::setVelocity(float x,float y,float z){
alListener3f( AL_VELOCITY,x,y,z);
}
void Listener::setOrientation(float dirX,float dirY,float dirZ,float upX,float upY,float upZ){
float v[]={dirX,dirY,dirZ,upX,upY,upZ};
alListenerfv( AL_ORIENTATION,v );
}
float Listener::getGain(){
float v=0;
alGetListenerf(AL_GAIN,&v);
return v;
}
void Listener::getPosition(float & x,float & y,float & z){
alGetListener3f(AL_POSITION,&x,&y,&z);
}
void Listener::getVelocity(float & x,float & y,float & z){
alGetListener3f(AL_VELOCITY,&x,&y,&z);
}
void Listener::getOrientation(float & dirX,float & dirY,float & dirZ,float & upX,float & upY,float & upZ){
float v[6];
alGetListenerfv( AL_ORIENTATION,v );
dirX=v[0], dirY=v[1], dirZ=v[2];
upX=v[3], upY=v[4], upZ=v[5];
}
void Listener::setDopplerFactor(float f){
alDopplerFactor(f);
}
void Listener::setSpeedOfSound(float f){
alSpeedOfSound(f);
}
void Listener::setDistanceModel(int modelType){
alDistanceModel(modelType);
}
float Listener::getDopplerFactor(){
float v=0;
alGetListenerf(AL_DOPPLER_FACTOR,&v);
return v;
}
float Listener::getSpeedOfSound(){
float v=0;
alGetListenerf(AL_SPEED_OF_SOUND,&v);
return v;
}
int Listener::getDistanceModel(){
int v=0;
alGetListeneri(AL_DISTANCE_MODEL,&v);
return v;
}
}