Panda3D
Loading...
Searching...
No Matches
movieAudioCursor.I
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 movieAudioCursor.I
10 * @author jyelon
11 * @date 2007-07-02
12 */
13
14/**
15 * Returns the MovieAudio which this cursor references.
16 */
17INLINE PT(MovieAudio) MovieAudioCursor::
18get_source() const {
19 return _source;
20}
21
22/**
23 * Returns the audio sample rate.
24 */
25INLINE int MovieAudioCursor::
26audio_rate() const {
27 return _audio_rate;
28}
29
30/**
31 * Returns the number of audio channels (ie, two for stereo, one for mono).
32 */
33INLINE int MovieAudioCursor::
34audio_channels() const {
35 return _audio_channels;
36}
37
38/**
39 * Returns the length of the movie. Attempting to read audio samples beyond
40 * the specified length will produce silent samples.
41 *
42 * Some kinds of Movie, such as internet TV station, might not have a
43 * predictable length. In that case, the length will be set to a very large
44 * number: 1.0E10.
45 *
46 * Some AVI files have incorrect length values encoded into them - they may be
47 * a second or two long or short. When playing such an AVI using the Movie
48 * class, you may see a slightly truncated video, or a slightly elongated
49 * video (padded with black frames). There are utilities out there to fix the
50 * length values in AVI files.
51 *
52 * An audio consumer needs to check the length, the ready status, and the
53 * aborted flag.
54 */
55INLINE double MovieAudioCursor::
56length() const {
57 return _length;
58}
59
60/**
61 * Returns true if the movie can seek. If this is true, seeking is still not
62 * guaranteed to be fast: for some movies, seeking is implemented by rewinding
63 * to the beginning and then fast-forwarding to the desired location. Even if
64 * the movie cannot seek, the seek method can still advance to an arbitrary
65 * location by reading samples and discarding them. However, to move
66 * backward, can_seek must return true.
67 */
68INLINE bool MovieAudioCursor::
69can_seek() const {
70 return _can_seek;
71}
72
73/**
74 * Returns true if seek operations are constant time.
75 */
76INLINE bool MovieAudioCursor::
77can_seek_fast() const {
78 return _can_seek_fast;
79}
80
81/**
82 * If aborted is true, it means that the "ready" samples are not being
83 * replenished. See the method "ready" for an explanation.
84 */
85INLINE bool MovieAudioCursor::
86aborted() const {
87 return _aborted;
88}
89
90/**
91 * Returns the current offset within the file.
92 */
93INLINE double MovieAudioCursor::
94tell() const {
95 return _last_seek + ((_samples_read * 1.0) / _audio_rate);
96}
97
98/**
99 * Skip audio samples from the stream. This is mostly for debugging purposes.
100 */
101INLINE void MovieAudioCursor::
102skip_samples(int n) {
103 read_samples(n, (int16_t*)0);
104}
void read_samples(int n, Datagram *dg)
Read audio samples from the stream into a Datagram.
A MovieAudio is actually any source that provides a sequence of audio samples.
Definition movieAudio.h:44