Panda3D
Loading...
Searching...
No Matches
userDataAudio.h
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 userDataAudio.h
10 * @author jyelon
11 * @date 2007-07-02
12 */
13
14#ifndef USERDATAAUDIO_H
15#define USERDATAAUDIO_H
16
17#include "movieAudio.h"
18#include "datagramIterator.h"
19#include "pdeque.h"
20
23
24/**
25 * A UserDataAudio is a way for the user to manually supply raw audio samples.
26 * remove_after_read means the data will be removed if read once. Else data
27 * will be stored (enable looping and seeking). Expects data as 16 bit signed
28 * (word); Example for stereo: 1.word = 1.channel,2.word = 2.channel, 3.word =
29 * 1.channel,4.word = 2.channel, etc.
30 */
31class EXPCL_PANDA_MOVIES UserDataAudio : public MovieAudio {
32
33 PUBLISHED:
34 UserDataAudio(int rate, int channels, bool remove_after_read=true);
35 virtual ~UserDataAudio();
36 virtual PT(MovieAudioCursor) open();
37
38 void append(int16_t *data, int n);
39 void append(DatagramIterator *src, int len=0x40000000);
40 void append(const std::string &str);
41 void done(); // A promise not to write any more samples.
42
43 private:
44 void read_samples(int n, int16_t *data);
45 void update_cursor();
46 int _desired_rate;
47 int _desired_channels;
48 UserDataAudioCursor *_cursor;
49 pdeque<int16_t> _data;
50 bool _aborted;
51 bool _remove_after_read;
52 friend class UserDataAudioCursor;
53
54 public:
55 static TypeHandle get_class_type() {
56 return _type_handle;
57 }
58 static void init_type() {
59 MovieAudio::init_type();
60 register_type(_type_handle, "UserDataAudio",
61 MovieAudio::get_class_type());
62 }
63 virtual TypeHandle get_type() const {
64 return get_class_type();
65 }
66 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
67
68 private:
69 static TypeHandle _type_handle;
70};
71
72#include "userDataAudio.I"
73
74#endif
A class to retrieve the individual data elements previously stored in a Datagram.
A MovieAudio is actually any source that provides a sequence of audio samples.
A MovieAudio is actually any source that provides a sequence of audio samples.
Definition movieAudio.h:44
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
A UserDataAudioCursor is a means to manually supply a sequence of raw audio samples.
A UserDataAudio is a way for the user to manually supply raw audio samples.
This is our own Panda specialization on the default STL deque.
Definition pdeque.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.