Panda3D

userDataAudio.h

00001 // Filename: userDataAudio.h
00002 // Created by: jyelon (02Jul07)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef USERDATAAUDIO_H
00016 #define USERDATAAUDIO_H
00017 
00018 #include "movieAudio.h"
00019 #include "datagramIterator.h"
00020 #include "pdeque.h"
00021 
00022 class MovieAudioCursor;
00023 class UserDataAudioCursor;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : UserDataAudio
00027 // Description : A UserDataAudio is a way for the user to manually
00028 //               supply raw audio samples. 
00029 ////////////////////////////////////////////////////////////////////
00030 class EXPCL_PANDA_MOVIES UserDataAudio : public MovieAudio {
00031 
00032  PUBLISHED:
00033   UserDataAudio(int rate, int channels);
00034   virtual ~UserDataAudio();
00035   virtual PT(MovieAudioCursor) open();
00036 
00037   void append(PN_int16 *data, int n);
00038   void append(DatagramIterator *src, int len=0x40000000);
00039   void append(const string &str);
00040   void done(); // A promise not to write any more samples.  
00041 
00042  private:
00043   void read_samples(int n, PN_int16 *data);
00044   void update_cursor();
00045   int _desired_rate;
00046   int _desired_channels;
00047   UserDataAudioCursor *_cursor;
00048   pdeque<PN_int16> _data;
00049   bool _aborted;
00050   friend class UserDataAudioCursor;
00051   
00052  public:
00053   static TypeHandle get_class_type() {
00054     return _type_handle;
00055   }
00056   static void init_type() {
00057     MovieAudio::init_type();
00058     register_type(_type_handle, "UserDataAudio",
00059                   MovieAudio::get_class_type());
00060   }
00061   virtual TypeHandle get_type() const {
00062     return get_class_type();
00063   }
00064   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00065 
00066  private:
00067   static TypeHandle _type_handle;
00068 };
00069 
00070 #include "userDataAudio.I"
00071 
00072 #endif
 All Classes Functions Variables Enumerations