Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SequenceData.cpp « sequence « src « audaspace « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fb920acc1a8b786a3d1d12dcd32533854e59c390 (plain)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*******************************************************************************
 * Copyright 2009-2016 Jörg Müller
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

#include "sequence/SequenceData.h"
#include "sequence/SequenceReader.h"
#include "sequence/SequenceEntry.h"

#include <mutex>

AUD_NAMESPACE_BEGIN

SequenceData::SequenceData(Specs specs, float fps, bool muted) :
	m_specs(specs),
	m_status(0),
	m_entry_status(0),
	m_id(0),
	m_muted(muted),
	m_fps(fps),
	m_speed_of_sound(343.3f),
	m_doppler_factor(1),
	m_distance_model(DISTANCE_MODEL_INVERSE_CLAMPED),
	m_volume(1, 1.0f),
	m_location(3),
	m_orientation(4)
{
	Quaternion q;
	m_orientation.write(q.get());
	float f = 1;
	m_volume.write(&f);
}

SequenceData::~SequenceData()
{
}

void SequenceData::lock()
{
	m_mutex.lock();
}

void SequenceData::unlock()
{
	m_mutex.unlock();
}

Specs SequenceData::getSpecs()
{
	std::lock_guard<std::recursive_mutex> lock(m_mutex);

	return m_specs;
}

void SequenceData::setSpecs(Specs specs)
{
	std::lock_guard<std::recursive_mutex> lock(m_mutex);

	m_specs = specs;
	m_status++;
}

float SequenceData::getFPS() const
{
	return m_fps;
}

void SequenceData::setFPS(float fps)
{
	std::lock_guard<std::recursive_mutex> lock(m_mutex);

	m_fps = fps;
}

void SequenceData::mute(bool muted)
{
	std::lock_guard<std::recursive_mutex> lock(m_mutex);

	m_muted = muted;
}

bool SequenceData::isMuted() const
{
	return m_muted;
}

float SequenceData::getSpeedOfSound() const
{
	return m_speed_of_sound;
}

void SequenceData::setSpeedOfSound(float speed)
{
	std::lock_guard<std::recursive_mutex> lock(m_mutex);

	m_speed_of_sound = speed;
	m_status++;
}

float SequenceData::getDopplerFactor() const
{
	return m_doppler_factor;
}

void SequenceData::setDopplerFactor(float factor)
{
	std::lock_guard<std::recursive_mutex> lock(m_mutex);

	m_doppler_factor = factor;
	m_status++;
}

DistanceModel SequenceData::getDistanceModel() const
{
	return m_distance_model;
}

void SequenceData::setDistanceModel(DistanceModel model)
{
	std::lock_guard<std::recursive_mutex> lock(m_mutex);

	m_distance_model = model;
	m_status++;
}

AnimateableProperty* SequenceData::getAnimProperty(AnimateablePropertyType type)
{
	switch(type)
	{
	case AP_VOLUME:
		return &m_volume;
	case AP_LOCATION:
		return &m_location;
	case AP_ORIENTATION:
		return &m_orientation;
	default:
		return nullptr;
	}
}

std::shared_ptr<SequenceEntry> SequenceData::add(std::shared_ptr<ISound> sound, float begin, float end, float skip)
{
	std::lock_guard<std::recursive_mutex> lock(m_mutex);

	std::shared_ptr<SequenceEntry> entry = std::shared_ptr<SequenceEntry>(new SequenceEntry(sound, begin, end, skip, m_id++));

	m_entries.push_back(entry);
	m_entry_status++;

	return entry;
}

void SequenceData::remove(std::shared_ptr<SequenceEntry> entry)
{
	std::lock_guard<std::recursive_mutex> lock(m_mutex);

	m_entries.remove(entry);
	m_entry_status++;
}

AUD_NAMESPACE_END