File: Sound.cpp

package info (click to toggle)
pinball 0.3.20201218-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,452 kB
  • sloc: cpp: 15,230; makefile: 840; sh: 381; xml: 24
file content (59 lines) | stat: -rw-r--r-- 1,343 bytes parent folder | download | duplicates (9)
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
/***************************************************************************
                          Sound.cpp  -  description
                             -------------------
    begin                : Wed Jan 26 2000
    copyright            : (C) 2000 by Henrik Enqvist
    email                : henqvist@excite.com
 ***************************************************************************/

#include <stddef.h>

#include "Private.h"
#include "Sound.h"
#include "Group.h"

Sound::Sound(EmSample* sample, float dist, bool b3D) {
	m_b3D = b3D;
	m_fDistance = dist;
	p_Sample = sample;
	m_vtxSrc.x = 0;
	m_vtxSrc.y = 0;
	m_vtxSrc.z = 0;
	p_Parent = NULL;
}

void Sound::setParent(Group* g) {
	p_Parent = g;
}


void Sound::play(bool loop) {
	m_bLoop = loop;
	if (p_Sample == NULL) return;
}

void Sound::adjust() {
	EM_COUT("Sound::adjust()" << endl, 1);
//	int vol, pan;
//	float r2;

	if (!m_b3D) return;
	if (p_Sample == NULL) return;
	
	// Volume.
/*	r2 = (vtxAlPos.x*vtxAlPos.x + vtxAlPos.y*vtxAlPos.y + vtxAlPos.z*vtxAlPos.z)/100;
	r2 /= fDistance;
	r2 = EM_MAX(1, r2);
	vol = (int)((float)255/r2);
	vol = (int)EM_MIN(vol, 255);

	// Pan
	if ( EM_ZERO(vtxAlPos.z)) {
		if (vtxAlPos.x > 0) pan = 255;
		else pan = 0;
	}	else {
		pan = (int) EMath::emAtan (vtxAlPos.x/ABS(vtxAlPos.z))*2;
		pan += 127;
		pan = EM_MAX(0, pan);
	}*/
}