Panda3D
wavAudio.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file wavAudio.cxx
10  * @author rdb
11  * @date 2013-08-23
12  */
13 
14 #include "wavAudio.h"
15 #include "wavAudioCursor.h"
16 #include "virtualFileSystem.h"
17 #include "dcast.h"
18 
19 TypeHandle WavAudio::_type_handle;
20 
21 /**
22  * xxx
23  */
25 WavAudio(const Filename &name) :
26  MovieAudio(name)
27 {
28  _filename = name;
29 }
30 
31 /**
32  * xxx
33  */
36 }
37 
38 /**
39  * Open this audio, returning a MovieAudioCursor
40  */
41 PT(MovieAudioCursor) WavAudio::
42 open() {
44  std::istream *stream = vfs->open_read_file(_filename, true);
45 
46  if (stream == nullptr) {
47  return nullptr;
48  } else {
49  PT(WavAudioCursor) cursor = new WavAudioCursor(this, stream);
50  if (cursor == nullptr || !cursor->_is_valid) {
51  return nullptr;
52  } else {
53  return DCAST(MovieAudioCursor, cursor);
54  }
55  }
56 }
57 
58 /**
59  * Obtains a MovieAudio that references a file.
60  */
61 PT(MovieAudio) WavAudio::
62 make(const Filename &name) {
63  return DCAST(MovieAudio, new WavAudio(name));
64 }
WavAudio(const Filename &name)
xxx
Definition: wavAudio.cxx:25
A hierarchy of directories and files that appears to be one continuous file system,...
std::istream * open_read_file(const Filename &filename, bool auto_unwrap) const
Convenience function; returns a newly allocated istream if the file exists and can be read,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Used for reading PCM .wav files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
A MovieAudio is actually any source that provides a sequence of audio samples.
static VirtualFileSystem * get_global_ptr()
Returns the default global VirtualFileSystem.
virtual ~WavAudio()
xxx
Definition: wavAudio.cxx:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PT(MovieAudioCursor) WavAudio
Open this audio, returning a MovieAudioCursor.
Definition: wavAudio.cxx:41
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
A MovieAudio is actually any source that provides a sequence of audio samples.
Definition: movieAudio.h:44