Panda3D
wavAudio.cxx
1 // Filename: wavAudio.cxx
2 // Created by: rdb (23Aug13)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "wavAudio.h"
16 #include "wavAudioCursor.h"
17 #include "virtualFileSystem.h"
18 #include "dcast.h"
19 
20 TypeHandle WavAudio::_type_handle;
21 
22 ////////////////////////////////////////////////////////////////////
23 // Function: WavAudio::Constructor
24 // Access: Protected
25 // Description: xxx
26 ////////////////////////////////////////////////////////////////////
28 WavAudio(const Filename &name) :
29  MovieAudio(name)
30 {
31  _filename = name;
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: WavAudio::Destructor
36 // Access: Protected, Virtual
37 // Description: xxx
38 ////////////////////////////////////////////////////////////////////
41 }
42 
43 ////////////////////////////////////////////////////////////////////
44 // Function: WavAudio::open
45 // Access: Published, Virtual
46 // Description: Open this audio, returning a MovieAudioCursor
47 ////////////////////////////////////////////////////////////////////
48 PT(MovieAudioCursor) WavAudio::
49 open() {
51  istream *stream = vfs->open_read_file(_filename, true);
52 
53  if (stream == NULL) {
54  return NULL;
55  } else {
56  PT(WavAudioCursor) cursor = new WavAudioCursor(this, stream);
57  if (cursor == NULL || !cursor->_is_valid) {
58  return NULL;
59  } else {
60  return DCAST(MovieAudioCursor, cursor);
61  }
62  }
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: WavAudio::make
67 // Access: Published, Static
68 // Description: Obtains a MovieAudio that references a file.
69 ////////////////////////////////////////////////////////////////////
70 PT(MovieAudio) WavAudio::
71 make(const Filename &name) {
72  return DCAST(MovieAudio, new WavAudio(name));
73 }
WavAudio(const Filename &name)
xxx
Definition: wavAudio.cxx:28
A hierarchy of directories and files that appears to be one continuous file system, even though the files may originate from several different sources that may not be related to the actual OS's file system.
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...
Used for reading PCM .wav files.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
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:40
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A MovieAudio is actually any source that provides a sequence of audio samples.
Definition: movieAudio.h:48