ScummVM API documentation
musicparam.h
1
/* ScummVM - Graphic Adventure Engine
2
*
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
6
*
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*
20
*/
21
22
/*
23
* This code is based on the CRAB engine
24
*
25
* Copyright (c) Arvind Raja Yadav
26
*
27
* Licensed under MIT
28
*
29
*/
30
31
#ifndef CRAB_MUSICPARAM_H
32
#define CRAB_MUSICPARAM_H
33
#include "audio/audiostream.h"
34
#include "
audio/decoders/vorbis.h
"
35
#include "common/file.h"
36
#include "crab/loaders.h"
37
#include "crab/filesystem.h"
38
39
namespace
Crab
{
40
41
namespace
pyrodactyl {
42
namespace
music {
43
// We use this object as key for music tracks
44
// Empty sounds are represented by -1
45
typedef
int
MusicKey;
46
47
// We use this object as key for sound effects
48
// Empty sounds are represented by -1
49
typedef
int
ChunkKey;
50
51
struct
MusicData
{
52
// The id of this track
53
MusicKey _id;
54
Audio::AudioStream
*_track;
55
Common::File
_file;
56
57
// Sound parameters
58
uint32 _fadeInDuration;
59
60
MusicData
() {
61
reset();
62
}
63
64
void
reset() {
65
_id = -1;
66
_track =
nullptr
;
67
_fadeInDuration = 100;
68
69
if
(_file.
isOpen
()) {
70
_file.
close
();
71
}
72
}
73
74
void
load(rapidxml::xml_node<char> *node) {
75
loadNum(_id,
"id"
, node);
76
loadNum(_fadeInDuration,
"fade_in"
, node);
77
78
Common::Path
cleansedPath = cleansePath(
Common::Path
(node->first_attribute(
"path"
)->value(),
'/'
));
79
if
(_file.
open
(cleansedPath)) {
80
Audio::SeekableAudioStream
*stream = Audio::makeVorbisStream(&_file, DisposeAfterUse::NO);
81
// loops=0 means infinite here.
82
_track =
Audio::makeLoopingAudioStream
(stream, 0, 0, 0);
83
}
else
{
84
warning
(
"Could not open file %s"
, cleansedPath.
toString
().c_str());
85
}
86
}
87
};
88
}
// End of namespace music
89
}
// End of namespace pyrodactyl
90
91
}
// End of namespace Crab
92
93
#endif // CRAB_MUSICPARAM_H
warning
void warning(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Common::File::open
virtual bool open(const Path &filename)
Common::Path
Definition:
path.h:52
Audio::SeekableAudioStream
Definition:
audiostream.h:212
Common::File
Definition:
file.h:47
Crab::pyrodactyl::music::MusicData
Definition:
musicparam.h:51
Audio::AudioStream
Definition:
audiostream.h:50
Common::File::close
virtual void close()
Common::Path::toString
String toString(char separator='/') const
Crab
Definition:
moveeffect.h:37
Common::File::isOpen
bool isOpen() const
vorbis.h
Audio::makeLoopingAudioStream
AudioStream * makeLoopingAudioStream(RewindableAudioStream *stream, uint loops)
engines
crab
music
musicparam.h
Generated on Fri Aug 30 2024 09:09:41 for ScummVM API documentation by
1.8.13